1
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
2
|
import { ActivatedRoute, Router } from '@angular/router';
|
3
|
import { JobResultEntry, StoredJob } from '../../domain/typeScriptClasses';
|
4
|
import { MonitorService } from '../../services/monitor.service';
|
5
|
import { loadingJobSummary, loadingJobSummaryError, noContentRulesResults,
|
6
|
noUsageRulesResults } from '../../domain/shared-messages';
|
7
|
import { ConfirmationDialogComponent } from '../../shared/reusablecomponents/confirmation-dialog.component';
|
8
|
import { AuthenticationService } from '../../services/authentication.service';
|
9
|
|
10
|
@Component({
|
11
|
selector: 'app-compatibility-validation-results',
|
12
|
templateUrl: 'compatibility-validation-results.component.html'
|
13
|
})
|
14
|
|
15
|
export class CompatibilityValidationResultsComponent implements OnInit {
|
16
|
errorMessage: string;
|
17
|
loadingMessage: string;
|
18
|
noRulesTested: 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 router: Router,
|
35
|
private monitorService: MonitorService,
|
36
|
private authService: AuthenticationService) {}
|
37
|
|
38
|
ngOnInit () {
|
39
|
if (this.authService.getIsUserLoggedIn()) {
|
40
|
setTimeout(() => {
|
41
|
this.getJobInfo();
|
42
|
}, 500 );
|
43
|
} else {
|
44
|
const id = this.route.snapshot.paramMap.get('id');
|
45
|
this.authService.redirectUrl = '/compatibility/browseHistory/' + id;
|
46
|
this.authService.loginWithState();
|
47
|
}
|
48
|
}
|
49
|
|
50
|
getJobInfo() {
|
51
|
const id = this.route.snapshot.paramMap.get('id');
|
52
|
this.loadingMessage = loadingJobSummary;
|
53
|
this.monitorService.getJobSummary(id, 'all').subscribe(
|
54
|
job => {
|
55
|
this.jobSummary = job;
|
56
|
if (this.jobSummary.resultEntries && this.jobSummary.resultEntries.length) {
|
57
|
this.jobSummary.resultEntries.forEach(
|
58
|
entry => {
|
59
|
if (entry.type === 'content') {
|
60
|
this.contentResults.push(entry);
|
61
|
} else if (entry.type === 'usage') {
|
62
|
this.usageResults.push(entry);
|
63
|
}
|
64
|
}
|
65
|
);
|
66
|
}
|
67
|
},
|
68
|
error => {
|
69
|
console.log(error);
|
70
|
this.errorMessage = loadingJobSummaryError;
|
71
|
this.loadingMessage = '';
|
72
|
},
|
73
|
() => {
|
74
|
this.loadingMessage = '';
|
75
|
if (!this.contentResults.length) {
|
76
|
this.noContent = noContentRulesResults;
|
77
|
}
|
78
|
if (!this.usageResults.length) {
|
79
|
this.noUsage = noUsageRulesResults;
|
80
|
}
|
81
|
/*if ( this.authService.activateFrontAuthorization && (this.authService.getUserEmail() !== this.jobSummary.userEmail.trim()) ) {
|
82
|
this.router.navigateByUrl('/403-forbidden', { skipLocationChange: true });
|
83
|
}*/
|
84
|
}
|
85
|
);
|
86
|
}
|
87
|
|
88
|
viewErrors(rule: JobResultEntry) {
|
89
|
this.modalTitle = `Rule: ${rule.name}`;
|
90
|
this.currentErrors = rule.errors;
|
91
|
this.checkErrors.showModal();
|
92
|
}
|
93
|
|
94
|
linkToError(er: string) {
|
95
|
return encodeURI(`${this.jobSummary.baseUrl}?verb=GetRecord&metadataPrefix=${this.jobSummary.metadataPrefix}&identifier=${er}`);
|
96
|
}
|
97
|
|
98
|
}
|