1
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
2
|
import { TranslateService } from '@ngx-translate/core';
|
3
|
import { LazyLoadEvent } from 'primeng/api';
|
4
|
import { Page } from 'src/app/shared/models/paging/page.interface';
|
5
|
import { SystemException } from 'src/app/shared/models/system-exception.interface';
|
6
|
import { ApplicationLevelExceptionService } from 'src/app/shared/services/administration/application-level-exception.service';
|
7
|
import { ErrorHandlingService } from 'src/app/shared/services/error-handling/error-handling.service';
|
8
|
|
9
|
@Component({
|
10
|
selector: 'app-application-level-table',
|
11
|
templateUrl: './application-level-table.component.html',
|
12
|
styleUrls: ['./application-level-table.component.scss']
|
13
|
})
|
14
|
export class ApplicationLevelTableComponent implements OnInit {
|
15
|
|
16
|
@Output() paginationEvent = new EventEmitter<{ page: number, offset: number }>(); // TODO: Use interface.
|
17
|
@Input() loading: boolean;
|
18
|
@Input() set searchResultsPage(results: Page<SystemException>) {
|
19
|
|
20
|
// This setter may be called on page setup without arguments.
|
21
|
if (!results) {
|
22
|
return;
|
23
|
}
|
24
|
|
25
|
this._searchResultsPage = results;
|
26
|
this.totalRecords = results.totalElements;
|
27
|
// this.loading = false;
|
28
|
}
|
29
|
_searchResultsPage: Page<SystemException>;
|
30
|
totalRecords: number;
|
31
|
rows: number = 10;
|
32
|
header: string;
|
33
|
trace: string;
|
34
|
displayTraceDialog: boolean;
|
35
|
|
36
|
constructor(private errorHandlingService: ErrorHandlingService, private applicationLevelService: ApplicationLevelExceptionService) { }
|
37
|
|
38
|
ngOnInit(): void {
|
39
|
}
|
40
|
|
41
|
onLazyLoad(event: LazyLoadEvent) {
|
42
|
let pageToRequest = Math.floor(event.first / event.rows);
|
43
|
let pageSize = event.rows;
|
44
|
this.paginationEvent.emit({ page: pageToRequest, offset: pageSize });
|
45
|
}
|
46
|
|
47
|
edit(id: number) {
|
48
|
this.header = "Trace";
|
49
|
if(id){
|
50
|
this.applicationLevelService.getById(id).subscribe(result => {
|
51
|
this.trace = result.trace;
|
52
|
this.displayTraceDialog = true;
|
53
|
},
|
54
|
err => {
|
55
|
this.errorHandlingService.showHttpResponseError(err)
|
56
|
});
|
57
|
}
|
58
|
}
|
59
|
|
60
|
cancelEditLevelException() {
|
61
|
this.displayTraceDialog = false;
|
62
|
this.trace = null;
|
63
|
}
|
64
|
}
|