1
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
2
|
import { Router } from '@angular/router';
|
3
|
import { LazyLoadEvent } from 'primeng/api';
|
4
|
import { ProcessesPerClient } from './../../../shared/models/dashboard-section.interface';
|
5
|
import { Page } from './../../../shared/models/paging/page.interface';
|
6
|
import { DocumentClassification } from './../../../shared/models/document-classification.interface';
|
7
|
import { DashboardSection } from './../../../shared/models/dashboard-section.interface';
|
8
|
|
9
|
@Component({
|
10
|
selector: 'app-dashboard-processes-per-client',
|
11
|
templateUrl: './dashboard-processes-per-client.component.html',
|
12
|
styleUrls: ['./dashboard-processes-per-client.component.scss']
|
13
|
})
|
14
|
export class DashboardProcessesPerClientComponent implements OnInit {
|
15
|
numOfClientsPresentedList: number[] = [3, 5, 10];
|
16
|
|
17
|
// Inputs
|
18
|
@Input() section: DashboardSection;
|
19
|
@Input() documentClassifications: DocumentClassification[];
|
20
|
|
21
|
// Outputs
|
22
|
@Output() paginationEvent = new EventEmitter<{ sectionType: string, sectionPage: number, sectionOffset: number }>();
|
23
|
@Output() onTotalElementsChanged = new EventEmitter<number>();
|
24
|
|
25
|
constructor(private router: Router) { }
|
26
|
|
27
|
ngOnInit(): void {
|
28
|
}
|
29
|
|
30
|
totalElementsChanged(val) {
|
31
|
this.onTotalElementsChanged.emit(val);
|
32
|
}
|
33
|
|
34
|
onLazyLoad(event: LazyLoadEvent) {
|
35
|
let pageToRequest = Math.floor(event.first / event.rows);
|
36
|
let pageSize = event.rows;
|
37
|
|
38
|
this.paginationEvent.emit({ sectionType: this.section.type, sectionPage: pageToRequest, sectionOffset: pageSize });
|
39
|
}
|
40
|
|
41
|
preview(client) {
|
42
|
if (this.documentClassifications?.length) {
|
43
|
const classificationId = this.documentClassifications.find(dc => dc.classificationName === this.section.type).classificationId;
|
44
|
this.router.navigate(['/pages/processes', { clientId: client.clientId, type: classificationId }]);
|
45
|
}
|
46
|
}
|
47
|
}
|