diff --git a/src/app/containers/service/container-service.service.ts b/src/app/containers/service/container-service.service.ts index 9a743c0d..ae02f2f9 100644 --- a/src/app/containers/service/container-service.service.ts +++ b/src/app/containers/service/container-service.service.ts @@ -20,8 +20,8 @@ export class ContainerServiceService extends BaseService { loading$ = this.loadingSource.asObservable(); constructor(private http: HttpClient) { - super(); - } + super(); + } private setLoading(loading: boolean) { this.loadingSource.next(loading); @@ -43,8 +43,8 @@ export class ContainerServiceService extends BaseService { getContainersByGroupId(groupId: number): Observable { this.setLoading(true); - return this.http.get(`${this.baseUrl}/group/${groupId}/containers`).pipe( - finalize(() => this.setLoading(false)) + return this.http.get(`${this.baseUrl}/container/${groupId}/containers`).pipe( + finalize(() => this.setLoading(false)) ); } diff --git a/src/app/dashboard/components/bar-chart-containers-by-facility/bar-chart-containers-by-facility.component.ts b/src/app/dashboard/components/bar-chart-containers-by-facility/bar-chart-containers-by-facility.component.ts index 96a1652e..dde62f0f 100644 --- a/src/app/dashboard/components/bar-chart-containers-by-facility/bar-chart-containers-by-facility.component.ts +++ b/src/app/dashboard/components/bar-chart-containers-by-facility/bar-chart-containers-by-facility.component.ts @@ -1,26 +1,26 @@ -import {Component, OnInit} from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { DashboardService } from '../../service/dashboard.service'; -import {ChartType} from "chart.js"; -import {BaseChartDirective} from "ng2-charts"; -import {CommonModule} from "@angular/common"; -import {HttpClientModule} from "@angular/common/http"; +import { ChartType } from "chart.js"; +import { BaseChartDirective } from "ng2-charts"; +import { CommonModule } from "@angular/common"; +import { HttpClientModule } from "@angular/common/http"; @Component({ selector: 'app-bar-chart-containers-by-facility', standalone: true, imports: [ - CommonModule, HttpClientModule,BaseChartDirective + CommonModule, HttpClientModule, BaseChartDirective ], templateUrl: './bar-chart-containers-by-facility.component.html', styleUrl: './bar-chart-containers-by-facility.component.css' }) -export class BarChartContainersByFacilityComponent implements OnInit{ +export class BarChartContainersByFacilityComponent implements OnInit { public groupsChartLabels: string[] = ['Containers']; public groupsChartData: number[] = []; public facilitychartType: ChartType = 'bar'; public barColors: string[] = []; - accountId:number; + accountId: number; users: any[] = []; groups: any[] = []; containers: any[] = []; @@ -40,7 +40,7 @@ export class BarChartContainersByFacilityComponent implements OnInit{ } loadGroups(): void { - this.dashboardService.getGroups(this.accountId).subscribe(data => { + this.dashboardService.getGroupsByAccount(this.accountId).subscribe(data => { this.groups = data; this.groupsChartLabels = this.groups.map(group => group.name); this.groupsChartData = this.groups.map(group => group.containerCount); diff --git a/src/app/dashboard/components/bar-chart-workers-by-facility/bar-chart-workers-by-facility.component.ts b/src/app/dashboard/components/bar-chart-workers-by-facility/bar-chart-workers-by-facility.component.ts index 692ee856..c85d1ea7 100644 --- a/src/app/dashboard/components/bar-chart-workers-by-facility/bar-chart-workers-by-facility.component.ts +++ b/src/app/dashboard/components/bar-chart-workers-by-facility/bar-chart-workers-by-facility.component.ts @@ -1,7 +1,7 @@ -import {Component, OnInit} from '@angular/core'; -import {ChartType} from "chart.js"; -import {DashboardService} from "../../service/dashboard.service"; -import {BaseChartDirective} from "ng2-charts"; +import { Component, OnInit } from '@angular/core'; +import { ChartType } from "chart.js"; +import { DashboardService } from "../../service/dashboard.service"; +import { BaseChartDirective } from "ng2-charts"; @Component({ selector: 'app-bar-chart-workers-by-facility', @@ -18,7 +18,7 @@ export class BarChartWorkersByFacilityComponent implements OnInit { public facilitychartType: ChartType = 'bar'; public barColors: string[] = []; - accountId:number; + accountId: number; users: any[] = []; groups: any[] = []; containers: any[] = []; @@ -38,7 +38,7 @@ export class BarChartWorkersByFacilityComponent implements OnInit { } loadGroups(): void { - this.dashboardService.getGroups(this.accountId).subscribe(data => { + this.dashboardService.getGroupsByAccount(this.accountId).subscribe(data => { this.groups = data; this.groupsChartLabels = this.groups.map(group => group.name); this.groupsChartData = this.groups.map(group => group.profileCount); diff --git a/src/app/dashboard/service/dashboard.service.ts b/src/app/dashboard/service/dashboard.service.ts index 339bcb9f..7938bc48 100644 --- a/src/app/dashboard/service/dashboard.service.ts +++ b/src/app/dashboard/service/dashboard.service.ts @@ -1,16 +1,17 @@ import { Injectable } from '@angular/core'; -import { Observable} from "rxjs"; -import {HttpClient} from "@angular/common/http"; +import { Observable } from "rxjs"; +import { HttpClient } from "@angular/common/http"; import { BaseService } from '../../shared/service/base.service'; +import { Facility } from '../../facilities/model/facility-model/facility.model'; @Injectable({ providedIn: 'root' }) export class DashboardService extends BaseService { - constructor( private http: HttpClient) { - super(); - } + constructor(private http: HttpClient) { + super(); + } @@ -20,10 +21,19 @@ export class DashboardService extends BaseService { getContainers(accountId: number): Observable { - return this.http.get(`${this.baseUrl}/${accountId}/containers`); + return this.http.get(`${this.baseUrl}/container/by-account/${accountId}`); } getUsers(accountId: number): Observable { - return this.http.get(`${this.baseUrl}/${accountId}/users`); + return this.http.get(`${this.baseUrl}/user/workers/${accountId}`); + } + + getGroupsByAccount(accountId: number): Observable { + return this.http.post(`${this.baseUrl}/group/by-account`, + { accountId: accountId }, + { + headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } + } + ); } } diff --git a/src/app/workers/components/worker-items/worker-items.component.ts b/src/app/workers/components/worker-items/worker-items.component.ts index 115fb1d5..e4724673 100644 --- a/src/app/workers/components/worker-items/worker-items.component.ts +++ b/src/app/workers/components/worker-items/worker-items.component.ts @@ -1,11 +1,11 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {MatTab, MatTabGroup} from "@angular/material/tabs"; -import {WorkerServiceService} from "../../service/worker-service.service"; -import {WorkerDetailsComponent} from "../worker-details/worker-details.component"; -import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card"; -import {NgForOf} from "@angular/common"; -import {MatIcon, MatIconModule} from '@angular/material/icon'; -import {MatButton} from "@angular/material/button"; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { MatTab, MatTabGroup } from "@angular/material/tabs"; +import { WorkerServiceService } from "../../service/worker-service.service"; +import { WorkerDetailsComponent } from "../worker-details/worker-details.component"; +import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from "@angular/material/card"; +import { NgForOf } from "@angular/common"; +import { MatIcon, MatIconModule } from '@angular/material/icon'; +import { MatButton } from "@angular/material/button"; import { TranslateModule } from '@ngx-translate/core'; @@ -30,7 +30,7 @@ export class WorkerItemsComponent implements OnInit { @Input() workersItems: any[] = []; @Output() workerSelected = new EventEmitter(); - constructor(private workerServiceService: WorkerServiceService) {} + constructor(private workerServiceService: WorkerServiceService) { } ngOnInit() { const myUserId = localStorage.getItem('userId'); diff --git a/src/app/workers/service/worker-service.service.ts b/src/app/workers/service/worker-service.service.ts index 15fc15a8..6be9f86d 100644 --- a/src/app/workers/service/worker-service.service.ts +++ b/src/app/workers/service/worker-service.service.ts @@ -8,9 +8,9 @@ import { BaseService } from '../../shared/service/base.service'; }) export class WorkerServiceService extends BaseService { - constructor(private http: HttpClient) { - super(); - } + constructor(private http: HttpClient) { + super(); + } getWorkers(): Observable { const accountId = localStorage.getItem('accountId');