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, loadingRepoError,
|
6
|
loadingRepoMessage, noAggregationHistory } from '../../domain/shared-messages';
|
7
|
import {AuthenticationService} from '../../services/authentication.service';
|
8
|
|
9
|
@Component ({
|
10
|
selector: 'app-compatibility-monitor-repo',
|
11
|
templateUrl: 'compatibility-monitor-repo.component.html'
|
12
|
})
|
13
|
|
14
|
export class CompatibilityMonitorRepoComponent implements OnInit {
|
15
|
loadingMessage: string;
|
16
|
errorMessage: string;
|
17
|
noAggregations: string;
|
18
|
|
19
|
repoId = '';
|
20
|
repoName = '';
|
21
|
repo: Repository;
|
22
|
|
23
|
latestAggregations: AggregationDetails[] = [];
|
24
|
|
25
|
constructor(private route: ActivatedRoute,
|
26
|
private router: Router,
|
27
|
private repoService: RepositoryService,
|
28
|
private authService: AuthenticationService) {}
|
29
|
|
30
|
ngOnInit() {
|
31
|
this.readRepoId();
|
32
|
this.getRepo();
|
33
|
let body = document.getElementsByTagName('body')[0];
|
34
|
body.classList.remove("top_bar_active"); //remove the class
|
35
|
body.classList.remove("page_heading_active");
|
36
|
body.classList.remove("landing");
|
37
|
body.classList.add("dashboard");
|
38
|
}
|
39
|
|
40
|
readRepoId() {
|
41
|
this.repoId = this.route.snapshot.paramMap.get('id');
|
42
|
this.repoName = `repository with id \'${this.repoId}\'`;
|
43
|
}
|
44
|
|
45
|
getRepo() {
|
46
|
if (this.repoId) {
|
47
|
this.loadingMessage = loadingRepoMessage;
|
48
|
this.repoService.getRepositoryById(this.repoId).subscribe(
|
49
|
repo => {
|
50
|
this.repo = repo;
|
51
|
},
|
52
|
error => {
|
53
|
console.log(error);
|
54
|
this.loadingMessage = '';
|
55
|
this.errorMessage = loadingRepoError;
|
56
|
},
|
57
|
() => {
|
58
|
this.loadingMessage = '';
|
59
|
if (this.repo) {
|
60
|
this.repoName = this.repo.officialName;
|
61
|
this.getLatestAggregationHistory();
|
62
|
} else {
|
63
|
this.errorMessage = loadingRepoError;
|
64
|
}
|
65
|
}
|
66
|
);
|
67
|
}
|
68
|
}
|
69
|
|
70
|
getLatestAggregationHistory() {
|
71
|
this.loadingMessage = loadingAggregationHistory;
|
72
|
this.repoService.getRepositoryAggregations(this.repo.id).subscribe(
|
73
|
aggr => this.latestAggregations = aggr,
|
74
|
error => {
|
75
|
this.loadingMessage = '';
|
76
|
this.errorMessage = loadingAggregationHistoryError;
|
77
|
},
|
78
|
() => {
|
79
|
this.loadingMessage = '';
|
80
|
if ( !this.latestAggregations || (this.latestAggregations.length === 0) ) {
|
81
|
this.noAggregations = noAggregationHistory;
|
82
|
}
|
83
|
}
|
84
|
);
|
85
|
}
|
86
|
|
87
|
}
|