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
|
import * as Highcharts from 'highcharts';
|
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
|
noRulesTested: string;
|
20
|
noContent: string;
|
21
|
noUsage: string;
|
22
|
|
23
|
jobSummary: StoredJob;
|
24
|
contentResults: JobResultEntry[] = [];
|
25
|
usageResults: JobResultEntry[] = [];
|
26
|
currentErrors: string[] = [];
|
27
|
|
28
|
modalTitle: string;
|
29
|
isModalShown: boolean;
|
30
|
|
31
|
ruleNameForContent: string[] = [];
|
32
|
ruleNameForUsage: string[] = [];
|
33
|
unprocessedDataForContent: string[] = [];
|
34
|
unprocessedDataForUsage: string[] = [];
|
35
|
processedDataForContent: number[] = [];
|
36
|
processedDataForUsage: number[] = [];
|
37
|
|
38
|
HighchartsForContent: typeof Highcharts = Highcharts;
|
39
|
HighchartsForUsage: typeof Highcharts = Highcharts;
|
40
|
chartOptionsForContent: Highcharts.Options;
|
41
|
chartOptionsForUsage: Highcharts.Options;
|
42
|
|
43
|
@ViewChild('checkErrors', { static: true })
|
44
|
public checkErrors: ConfirmationDialogComponent;
|
45
|
|
46
|
constructor (private route: ActivatedRoute,
|
47
|
private router: Router,
|
48
|
private monitorService: MonitorService,
|
49
|
private authService: AuthenticationService) {}
|
50
|
|
51
|
ngOnInit () {
|
52
|
if (this.authService.getIsUserLoggedIn()) {
|
53
|
this.getJobInfo();
|
54
|
} else {
|
55
|
const id = this.route.snapshot.paramMap.get('id');
|
56
|
this.authService.redirectUrl = '/compatibility/browseHistory/' + id;
|
57
|
this.authService.loginWithState();
|
58
|
}
|
59
|
let body = document.getElementsByTagName('body')[0];
|
60
|
body.classList.remove("top_bar_active"); //remove the class
|
61
|
body.classList.remove("page_heading_active");
|
62
|
body.classList.remove("landing");
|
63
|
body.classList.add("dashboard");
|
64
|
}
|
65
|
|
66
|
getJobInfo() {
|
67
|
const id = this.route.snapshot.paramMap.get('id');
|
68
|
this.loadingMessage = loadingJobSummary;
|
69
|
this.monitorService.getJobSummary(id, 'all').subscribe(
|
70
|
job => {
|
71
|
this.jobSummary = job;
|
72
|
if (this.jobSummary.resultEntries && this.jobSummary.resultEntries.length) {
|
73
|
this.jobSummary.resultEntries.forEach(
|
74
|
entry => {
|
75
|
if (entry.type === 'content') {
|
76
|
this.contentResults.push(entry);
|
77
|
this.ruleNameForContent.push(entry.name);
|
78
|
this.unprocessedDataForContent.push(entry.successes.split('/')[0]);
|
79
|
} else if (entry.type === 'usage') {
|
80
|
this.usageResults.push(entry);
|
81
|
this.ruleNameForUsage.push(entry.name);
|
82
|
this.unprocessedDataForUsage.push(entry.successes.split('/')[0]);
|
83
|
}
|
84
|
}
|
85
|
);
|
86
|
}
|
87
|
},
|
88
|
error => {
|
89
|
console.log(error);
|
90
|
this.errorMessage = loadingJobSummaryError;
|
91
|
this.loadingMessage = '';
|
92
|
},
|
93
|
() => {
|
94
|
this.loadingMessage = '';
|
95
|
if (!this.contentResults.length) {
|
96
|
this.noContent = noContentRulesResults;
|
97
|
} else {
|
98
|
this.processedDataForContent = this.unprocessedDataForContent.map(Number);
|
99
|
this.chartOptionsForContent = {
|
100
|
title: { text: ''},
|
101
|
yAxis: { title: { text: 'Number of records' } },
|
102
|
xAxis: { categories: this.ruleNameForContent },
|
103
|
series: [{ name: 'For content', data: this.processedDataForContent, type: 'column' }]
|
104
|
};
|
105
|
}
|
106
|
if (!this.usageResults.length) {
|
107
|
this.noUsage = noUsageRulesResults;
|
108
|
} else {
|
109
|
this.processedDataForUsage = this.unprocessedDataForUsage.map(Number);
|
110
|
this.chartOptionsForUsage = {
|
111
|
title: { text: ''},
|
112
|
yAxis: { title: { text: 'Number of records' } },
|
113
|
xAxis: { categories: this.ruleNameForUsage },
|
114
|
series: [{ name: 'For usage', data: this.processedDataForUsage, type: 'column' }]
|
115
|
};
|
116
|
}
|
117
|
/*if ( this.authService.activateFrontAuthorization && (this.authService.getUserEmail() !== this.jobSummary.userEmail.trim()) ) {
|
118
|
this.router.navigateByUrl('/403-forbidden', { skipLocationChange: true });
|
119
|
}*/
|
120
|
}
|
121
|
);
|
122
|
}
|
123
|
|
124
|
viewErrors(rule: JobResultEntry) {
|
125
|
this.modalTitle = `Rule: ${rule.name}`;
|
126
|
this.currentErrors = rule.errors;
|
127
|
this.checkErrors.showModal();
|
128
|
}
|
129
|
|
130
|
linkToError(er: string) {
|
131
|
return encodeURI(`${this.jobSummary.baseUrl}?verb=GetRecord&metadataPrefix=${this.jobSummary.metadataPrefix}&identifier=${er}`);
|
132
|
}
|
133
|
|
134
|
}
|