1
|
import { StatusPerDocument } from './../../../../shared/models/status-per-document.interface';
|
2
|
import { Component, OnInit } from '@angular/core';
|
3
|
import { LazyLoadEvent } from 'primeng/api';
|
4
|
import { ReceivedFile } from '../../../../shared/models/inbox-document.interface';
|
5
|
import { FILE_TYPE } from '../../../../shared/enums/FILE_TYPE.enum';
|
6
|
import { DialogService } from 'primeng/dynamicdialog';
|
7
|
import { IgnoreFileDialogComponent } from '../inbox-dialogs/ignore-file-dialog/ignore-file-dialog.component';
|
8
|
import { InboxManagementService } from '../../../../shared/services/inbox-management.service';
|
9
|
import { InboxSearchCriteriaInterface } from '../../../../shared/models/inbox-search-criteria.interface';
|
10
|
import { EditFileClassAndQeueToAbbyForRecognitionDialogComponent } from '../inbox-dialogs/edit-file-class-and-qeue-to-abby-for-recognition-dialog/edit-file-class-and-qeue-to-abby-for-recognition-dialog.component';
|
11
|
import { ForwardFileToAbbyForRecognitionDialogComponent } from '../inbox-dialogs/forward-file-to-abby-for-recognition-dialog/forward-file-to-abby-for-recognition-dialog.component';
|
12
|
import { CLASSIFICATION_STATUS } from '../../../../shared/enums/CLASSIFICATION_STATUS.enum';
|
13
|
import { FileViewerPopupComponent } from '../inbox-dialogs/file-viewer-popup/file-viewer-popup.component';
|
14
|
import { InboxBatch } from '../../../../shared/models/inbox-batch.interface';
|
15
|
import { Page } from '../../../../shared/models/paging/page.interface';
|
16
|
import { ReceivedFiles } from 'src/app/shared/models/receivedFiles.interface';
|
17
|
import { AuthService } from 'src/app/shared/services/auth.service';
|
18
|
import { USER_RIGHTS } from 'src/app/shared/enums/USER_RIGHTS.enum';
|
19
|
|
20
|
|
21
|
@Component({
|
22
|
selector: 'app-inbox-documents-table',
|
23
|
templateUrl: './inbox-documents-table.component.html',
|
24
|
styleUrls: ['./inbox-documents-table.component.scss']
|
25
|
})
|
26
|
export class InboxDocumentsTableComponent implements OnInit {
|
27
|
|
28
|
// tslint:disable-next-line:variable-name
|
29
|
loading = true;
|
30
|
documents: ReceivedFiles[];
|
31
|
documentsBatch: InboxBatch[];
|
32
|
totalRecords: any;
|
33
|
|
34
|
// tslint:disable-next-line:variable-name
|
35
|
private _documentRequest: InboxSearchCriteriaInterface; // DocumentsRequest;
|
36
|
|
37
|
constructor(public dialogService: DialogService, private inboxManagementService: InboxManagementService, public auth: AuthService) {
|
38
|
}
|
39
|
|
40
|
|
41
|
get documentRequest(): InboxSearchCriteriaInterface {
|
42
|
|
43
|
return this._documentRequest;
|
44
|
}
|
45
|
|
46
|
set documentRequest(value) {
|
47
|
console.log(value);
|
48
|
this._documentRequest = value;
|
49
|
this.loadDocuments(null);
|
50
|
}
|
51
|
|
52
|
|
53
|
ngOnInit(): void {
|
54
|
|
55
|
// this.loading = false;
|
56
|
}
|
57
|
|
58
|
changeIcon(document:any): string{
|
59
|
if(document?.ignored){
|
60
|
return 'pi pi-eye-slash';
|
61
|
}else{
|
62
|
return 'pi pi-eye';
|
63
|
}
|
64
|
}
|
65
|
|
66
|
loadDocuments(event: LazyLoadEvent): void {
|
67
|
this.loading = true;
|
68
|
this.documentRequest.receivedFrom = new Date(Date.UTC(this.documentRequest.receivedFrom?.getFullYear(), this.documentRequest.receivedFrom?.getMonth(), this.documentRequest.receivedFrom?.getDate()));
|
69
|
this.documentRequest.receivedTo = new Date(Date.UTC(this.documentRequest.receivedTo?.getFullYear(), this.documentRequest.receivedTo?.getMonth(), this.documentRequest.receivedTo?.getDate() + 1));
|
70
|
this.documentRequest.receivedTo?.setMilliseconds(this.documentRequest.receivedTo?.getMilliseconds() - 1);
|
71
|
if (event) {
|
72
|
this.inboxManagementService.searchByCriteriaPaged(
|
73
|
event.first / event.rows,
|
74
|
event.rows, this.documentRequest,
|
75
|
'inboxForm')
|
76
|
.subscribe(x => {
|
77
|
this.dataManagement(x as any);
|
78
|
});
|
79
|
} else {
|
80
|
this.inboxManagementService.searchByCriteriaPaged(
|
81
|
0,
|
82
|
5,
|
83
|
this.documentRequest,
|
84
|
'inboxForm')
|
85
|
.subscribe(x => {
|
86
|
this.dataManagement(x as any);
|
87
|
});
|
88
|
}
|
89
|
}
|
90
|
|
91
|
|
92
|
ignoreDialog(document: any): void {
|
93
|
console.log(document);
|
94
|
const dynamicDialogRef = this.dialogService.open(IgnoreFileDialogComponent, { data: document });
|
95
|
dynamicDialogRef.onClose.subscribe(() => {
|
96
|
this.loadDocuments(null);
|
97
|
});
|
98
|
}
|
99
|
|
100
|
canPreviewByUA(): boolean {
|
101
|
return this.auth.userRights.find(rdc => USER_RIGHTS.C02.isGrantedToUser(rdc.rights)) != null;
|
102
|
}
|
103
|
|
104
|
showOrDownloadFile(document: any): void {
|
105
|
|
106
|
this.dialogService.open(FileViewerPopupComponent, { data: document });
|
107
|
}
|
108
|
|
109
|
forwardDialog(document: any): void {
|
110
|
console.log(document);
|
111
|
this.dialogService.open(ForwardFileToAbbyForRecognitionDialogComponent, { data: document });
|
112
|
}
|
113
|
|
114
|
editClassDialog(document: any, dialogTitle: string): void {
|
115
|
console.log(document);
|
116
|
this.dialogService.open(EditFileClassAndQeueToAbbyForRecognitionDialogComponent, { data: { document, title: dialogTitle } });
|
117
|
}
|
118
|
|
119
|
private dataManagement(x: Page<InboxBatch>): void {
|
120
|
this.documentsBatch = x.data;
|
121
|
this.documents = x?.data?.map(documents => {
|
122
|
return documents?.receivedFile;
|
123
|
});
|
124
|
this.loading = false;
|
125
|
}
|
126
|
}
|