Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/containers/service/container-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -43,8 +43,8 @@ export class ContainerServiceService extends BaseService {

getContainersByGroupId(groupId: number): Observable<any> {
this.setLoading(true);
return this.http.get<any>(`${this.baseUrl}/group/${groupId}/containers`).pipe(
finalize(() => this.setLoading(false))
return this.http.get<any>(`${this.baseUrl}/container/${groupId}/containers`).pipe(
finalize(() => this.setLoading(false))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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[] = [];
Expand All @@ -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);
Expand Down
24 changes: 17 additions & 7 deletions src/app/dashboard/service/dashboard.service.ts
Original file line number Diff line number Diff line change
@@ -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();
}



Expand All @@ -20,10 +21,19 @@ export class DashboardService extends BaseService {


getContainers(accountId: number): Observable<any> {
return this.http.get(`${this.baseUrl}/${accountId}/containers`);
return this.http.get(`${this.baseUrl}/container/by-account/${accountId}`);
}
getUsers(accountId: number): Observable<any> {
return this.http.get(`${this.baseUrl}/${accountId}/users`);
return this.http.get(`${this.baseUrl}/user/workers/${accountId}`);
}

getGroupsByAccount(accountId: number): Observable<Facility[]> {
return this.http.post<Facility[]>(`${this.baseUrl}/group/by-account`,
{ accountId: accountId },
{
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
}
);
}

}
Original file line number Diff line number Diff line change
@@ -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';


Expand All @@ -30,7 +30,7 @@ export class WorkerItemsComponent implements OnInit {
@Input() workersItems: any[] = [];
@Output() workerSelected = new EventEmitter<number>();

constructor(private workerServiceService: WorkerServiceService) {}
constructor(private workerServiceService: WorkerServiceService) { }

ngOnInit() {
const myUserId = localStorage.getItem('userId');
Expand Down
6 changes: 3 additions & 3 deletions src/app/workers/service/worker-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
const accountId = localStorage.getItem('accountId');
Expand Down
Loading