src/app/dashboard/dashboard.component.ts
| selector | app-dashboard |
| styleUrls | ./dashboard.component.css |
| templateUrl | ./dashboard.component.html |
Properties |
Methods |
constructor(router: Router, authenticationService: AuthenticationService, toastr: ToastrService, spinner: NgxSpinnerService, apiService: ApiService)
|
||||||||||||||||||
|
Defined in src/app/dashboard/dashboard.component.ts:38
|
||||||||||||||||||
|
Parameters :
|
| logout |
logout()
|
|
Defined in src/app/dashboard/dashboard.component.ts:86
|
|
Returns :
void
|
| mapStatus | ||||||
mapStatus(status: string)
|
||||||
|
Defined in src/app/dashboard/dashboard.component.ts:91
|
||||||
|
Parameters :
Returns :
string
|
| ngOnInit |
ngOnInit()
|
|
Defined in src/app/dashboard/dashboard.component.ts:48
|
|
Returns :
void
|
| onGridReady | ||||||
onGridReady(params: GridReadyEvent<ManagerTable>)
|
||||||
|
Defined in src/app/dashboard/dashboard.component.ts:77
|
||||||
|
Parameters :
Returns :
void
|
| onSelect | ||||
onSelect(event)
|
||||
|
Defined in src/app/dashboard/dashboard.component.ts:95
|
||||
|
Parameters :
Returns :
void
|
| chartData |
Type : ChartData[]
|
|
Defined in src/app/dashboard/dashboard.component.ts:28
|
| Public columnDefs |
Type : ColDef[]
|
Default value : [
{ field: 'userId' },
{ field: 'firstName' },
{ field: 'lastName' },
{ field: 'role' },
{ field: 'timesheetID' },
{ field: 'month' },
{ field: 'year' },
{ field: 'createdOn' },
{ field: 'timesheetStatus' },
]
|
|
Defined in src/app/dashboard/dashboard.component.ts:56
|
| currentUser |
Type : User
|
|
Defined in src/app/dashboard/dashboard.component.ts:23
|
| Public defaultColDef |
Type : ColDef
|
Default value : {
flex: 1,
minWidth: 100,
sortable: true,
resizable: true,
}
|
|
Defined in src/app/dashboard/dashboard.component.ts:68
|
| defaultProject |
Type : Project
|
|
Defined in src/app/dashboard/dashboard.component.ts:26
|
| gradient |
Default value : false
|
|
Defined in src/app/dashboard/dashboard.component.ts:33
|
| gridApi |
Type : GridApi
|
|
Defined in src/app/dashboard/dashboard.component.ts:27
|
| projectForm |
Type : FormGroup
|
|
Defined in src/app/dashboard/dashboard.component.ts:24
|
| Public rowData |
Type : ManagerTable[]
|
|
Defined in src/app/dashboard/dashboard.component.ts:75
|
| showLegend |
Default value : true
|
|
Defined in src/app/dashboard/dashboard.component.ts:34
|
| showXAxis |
Default value : true
|
|
Defined in src/app/dashboard/dashboard.component.ts:31
|
| showXAxisLabel |
Default value : true
|
|
Defined in src/app/dashboard/dashboard.component.ts:35
|
| showYAxis |
Default value : true
|
|
Defined in src/app/dashboard/dashboard.component.ts:32
|
| showYAxisLabel |
Default value : true
|
|
Defined in src/app/dashboard/dashboard.component.ts:37
|
| title |
Type : string
|
|
Defined in src/app/dashboard/dashboard.component.ts:25
|
| xAxisLabel |
Type : string
|
Default value : 'User'
|
|
Defined in src/app/dashboard/dashboard.component.ts:36
|
| yAxisLabel |
Type : string
|
Default value : 'Registered hours'
|
|
Defined in src/app/dashboard/dashboard.component.ts:38
|
import { Component, OnInit, ViewChild } from '@angular/core';
import { AuthenticationService } from '../services/authentication.service';
import { User } from '../models/user';
import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { NgxSpinnerService } from 'ngx-spinner';
import { ApiService } from '../services/api.service';
import { Project } from '../models/Project';
import { ColDef, GridApi, GridReadyEvent } from 'ag-grid-community';
import { ManagerTable } from '../models/manager-table';
import { mapStatus } from '../timesheets-list/timesheet-list.utils';
import { ChartData } from '../models/chart-data';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
currentUser: User;
projectForm: FormGroup;
title: string;
defaultProject: Project;
gridApi: GridApi;
chartData: ChartData[];
// options
showXAxis = true;
showYAxis = true;
gradient = false;
showLegend = true;
showXAxisLabel = true;
xAxisLabel = 'User';
showYAxisLabel = true;
yAxisLabel = 'Registered hours';
constructor(private router: Router,
private authenticationService: AuthenticationService,
private toastr: ToastrService,
private spinner: NgxSpinnerService,
private apiService: ApiService) {
this.authenticationService.currentUser.subscribe(x => this.currentUser = x);
}
ngOnInit(): void {
this.spinner.show();
this.apiService.getManagerChartData().subscribe(data => {
this.chartData = data;
this.spinner.hide();
})
}
public columnDefs: ColDef[] = [
{ field: 'userId' },
{ field: 'firstName' },
{ field: 'lastName' },
{ field: 'role' },
{ field: 'timesheetID' },
{ field: 'month' },
{ field: 'year' },
{ field: 'createdOn' },
{ field: 'timesheetStatus' },
];
public defaultColDef: ColDef = {
flex: 1,
minWidth: 100,
sortable: true,
resizable: true,
};
public rowData!: ManagerTable[];
onGridReady(params: GridReadyEvent<ManagerTable>) {
this.gridApi = params.api;
this.apiService.getManagerTable().subscribe((data) => {
data.map(x => x.timesheetStatus = mapStatus(x.timesheetStatus));
//data.map(x => Number(x.userId)).sort();
this.gridApi.setRowData(data);
})
}
logout() {
this.authenticationService.logout();
this.router.navigate(['/login']);
}
mapStatus(status: string): string {
return mapStatus(status);
}
onSelect(event) {
console.log(event);
}
}
<div class="page-header pb-10 page-header-dark bg-primary">
<div class="container-fluid">
<div class="page-header-content">
<h1 class="page-header-title">
<div class="page-header-icon"><i class="fas fa-table"></i></div>
<span>Dashboard</span>
</h1>
<div class="page-header-subtitle">Your personal dashboard</div>
</div>
</div>
</div>
<div style="position: relative;">
<ngx-spinner bdOpacity=0.5 bdColor="rgba(51,51,51,0.85)" size="medium" color="#fff" type="line-scale" [fullScreen]="true">
<p style="color: white"> Openning connection to our database... </p>
</ngx-spinner>
</div>
<div class="container-fluid mt-n10">
<div class="card card-header-actions mx-auto">
<div class="card-header">
Users details
</div>
<div class="card-body">
<ag-grid-angular
style="width: 100%; height: 400px;"
class="ag-theme-alpine"
[columnDefs]="columnDefs"
[defaultColDef]="defaultColDef"
(gridReady)="onGridReady($event)"
></ag-grid-angular>
</div>
</div>
<br>
<div class="card card-header-actions mx-auto">
<div class="card-body">
<ngx-charts-bar-vertical
[results]="chartData"
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[legend]="showLegend"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[showGridLines]="false"
[xAxisLabel]="xAxisLabel"
[yAxisLabel]="yAxisLabel"
(select)="onSelect($event)">
</ngx-charts-bar-vertical>
</div>
</div>
</div>
./dashboard.component.css