1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { ActivatedRoute, Router } from '@angular/router';
|
3
|
import { AggregationDetails, Repository } from '../../../domain/typeScriptClasses';
|
4
|
import { RepositoryService } from '../../../services/repository.service';
|
5
|
import { loadingAggregationHistory, loadingAggregationHistoryError, noAggregationHistory } from '../../../domain/shared-messages';
|
6
|
import { SharedService } from "../../../services/shared.service";
|
7
|
|
8
|
@Component ({
|
9
|
selector: 'app-compatibility-fullhistory-monitor-repo',
|
10
|
templateUrl: 'compatibility-monitor-fullHistory-repo.component.html'
|
11
|
})
|
12
|
|
13
|
export class CompatibilityMonitorFullHistoryRepoComponent implements OnInit {
|
14
|
loadingMessage: string;
|
15
|
errorMessage: string;
|
16
|
noAggregations: string;
|
17
|
|
18
|
repoName = '';
|
19
|
repo: Repository;
|
20
|
|
21
|
aggregationsMap: Map<string, AggregationDetails[]> = new Map<string, AggregationDetails[]>();
|
22
|
years: string[] = [];
|
23
|
|
24
|
constructor(private route: ActivatedRoute,
|
25
|
private router: Router,
|
26
|
private repoService: RepositoryService,
|
27
|
private sharedService: SharedService) {}
|
28
|
|
29
|
ngOnInit() {
|
30
|
|
31
|
if(this.sharedService.getRepository()) {
|
32
|
this.repo = this.sharedService.getRepository();
|
33
|
this.repoName = this.repo.officialName;
|
34
|
this.getAllAggregationHistory();
|
35
|
}
|
36
|
|
37
|
this.sharedService.repository$.subscribe(
|
38
|
r => {
|
39
|
this.repo = r;
|
40
|
if (this.repo) {
|
41
|
this.repoName = this.repo.officialName;
|
42
|
this.getAllAggregationHistory();
|
43
|
}
|
44
|
}
|
45
|
);
|
46
|
|
47
|
let body = document.getElementsByTagName('body')[0];
|
48
|
body.classList.remove("top_bar_active"); //remove the class
|
49
|
body.classList.remove("page_heading_active");
|
50
|
body.classList.remove("landing");
|
51
|
body.classList.add("dashboard");
|
52
|
}
|
53
|
|
54
|
getAllAggregationHistory() {
|
55
|
this.loadingMessage = loadingAggregationHistory;
|
56
|
this.repoService.getRepositoryAggregationsByYear(this.repo.id).subscribe(
|
57
|
aggr => this.aggregationsMap = aggr,
|
58
|
error => {
|
59
|
this.loadingMessage = '';
|
60
|
this.errorMessage = loadingAggregationHistoryError;
|
61
|
},
|
62
|
() => {
|
63
|
this.loadingMessage = '';
|
64
|
this.years = Object.keys(this.aggregationsMap);
|
65
|
if ( this.years.length === 0 ) {
|
66
|
this.noAggregations = noAggregationHistory;
|
67
|
} else {
|
68
|
this.years.sort( (a, b) => ( a > b ? -1 : 1 ) );
|
69
|
}
|
70
|
}
|
71
|
);
|
72
|
}
|
73
|
|
74
|
}
|