1
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
2
|
import { ActivatedRoute } from '@angular/router';
|
3
|
import { JobResultEntry, StoredJob } from '../../domain/typeScriptClasses';
|
4
|
import { MonitorService } from '../../services/monitor.service';
|
5
|
import {
|
6
|
loadingJobSummary, loadingJobSummaryError, noContentRulesResults,
|
7
|
noUsageRulesResults
|
8
|
} from '../../domain/shared-messages';
|
9
|
import { ConfirmationDialogComponent } from '../../shared/reusablecomponents/confirmation-dialog.component';
|
10
|
|
11
|
@Component({
|
12
|
selector: 'app-compatibility-validation-results',
|
13
|
templateUrl: 'compatibility-validation-results.component.html'
|
14
|
})
|
15
|
|
16
|
export class CompatibilityValidationResultsComponent implements OnInit {
|
17
|
errorMessage: string;
|
18
|
loadingMessage: string;
|
19
|
noContent: string;
|
20
|
noUsage: string;
|
21
|
|
22
|
jobSummary: StoredJob;
|
23
|
contentResults: JobResultEntry[] = [];
|
24
|
usageResults: JobResultEntry[] = [];
|
25
|
currentErrors: string[] = [];
|
26
|
|
27
|
modalTitle: string;
|
28
|
isModalShown: boolean;
|
29
|
|
30
|
@ViewChild('checkErrors')
|
31
|
public checkErrors: ConfirmationDialogComponent;
|
32
|
|
33
|
constructor (private route: ActivatedRoute,
|
34
|
private monitorService: MonitorService) {}
|
35
|
|
36
|
ngOnInit () {
|
37
|
setTimeout(() => {
|
38
|
this.getJobInfo();
|
39
|
}, 500 );
|
40
|
}
|
41
|
|
42
|
getJobInfo() {
|
43
|
let id = this.route.snapshot.paramMap.get('id');
|
44
|
this.loadingMessage = loadingJobSummary;
|
45
|
this.monitorService.getJobSummary(id,'all').subscribe(
|
46
|
job => {
|
47
|
this.jobSummary = job;
|
48
|
if (this.jobSummary.resultEntries.length) {
|
49
|
this.jobSummary.resultEntries.forEach(
|
50
|
entry => {
|
51
|
if (entry.type == 'content') {
|
52
|
this.contentResults.push(entry);
|
53
|
} else if (entry.type == 'usage') {
|
54
|
this.usageResults.push(entry);
|
55
|
}
|
56
|
}
|
57
|
);
|
58
|
}
|
59
|
},
|
60
|
error => {
|
61
|
console.log(error);
|
62
|
this.errorMessage = loadingJobSummaryError;
|
63
|
},
|
64
|
() => {
|
65
|
this.loadingMessage = '';
|
66
|
if (!this.contentResults.length) {
|
67
|
this.noContent = noContentRulesResults;
|
68
|
}
|
69
|
if (!this.usageResults.length) {
|
70
|
this.noUsage = noUsageRulesResults;
|
71
|
}
|
72
|
}
|
73
|
);
|
74
|
}
|
75
|
|
76
|
viewErrors(rule: JobResultEntry) {
|
77
|
this.modalTitle = `Rule: ${rule.name}`;
|
78
|
this.currentErrors = rule.errors;
|
79
|
this.checkErrors.showModal();
|
80
|
}
|
81
|
|
82
|
linkToError(er: string) {
|
83
|
return encodeURI(`${this.jobSummary.baseUrl}?verb=GetRecord&metadataPrefix=${this.jobSummary.metadataPrefix}&identifier=${er}`);
|
84
|
}
|
85
|
|
86
|
}
|