1
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
2
|
import { PiwikService } from '../../services/piwik.service';
|
3
|
import { PiwikInfo } from '../../domain/typeScriptClasses';
|
4
|
import { loadingReposMessage, reposRetrievalError } from '../../domain/shared-messages';
|
5
|
import { ConfirmationDialogComponent } from '../../shared/reusablecomponents/confirmation-dialog.component';
|
6
|
|
7
|
@Component ({
|
8
|
selector: 'app-admin-metrics',
|
9
|
templateUrl: 'adminPg-metrics.component.html'
|
10
|
})
|
11
|
|
12
|
export class AdminPgMetricsComponent implements OnInit {
|
13
|
piwiks: PiwikInfo[] = [];
|
14
|
showSpinner: boolean;
|
15
|
errorMessage: string;
|
16
|
loadingMessage: string;
|
17
|
|
18
|
modalTitle = "Approval Confirmation";
|
19
|
modalButton = "Yes, validate";
|
20
|
isModalShown: boolean;
|
21
|
|
22
|
@ViewChild('confirmApprovalModal')
|
23
|
public confirmApprovalModal: ConfirmationDialogComponent;
|
24
|
|
25
|
constructor(private piwikService: PiwikService) {}
|
26
|
|
27
|
ngOnInit() {
|
28
|
this.getPiwiks();
|
29
|
this.isModalShown = false;
|
30
|
}
|
31
|
|
32
|
|
33
|
getPiwiks(){
|
34
|
this.showSpinner = true;
|
35
|
this.loadingMessage = loadingReposMessage;
|
36
|
this.piwikService.getPiwikSitesForRepos()
|
37
|
.subscribe(
|
38
|
piwiks => this.piwiks = piwiks.sort( function(a,b){
|
39
|
if(a.repositoryName<b.repositoryName){
|
40
|
return -1;
|
41
|
} else if(a.repositoryName>b.repositoryName){
|
42
|
return 1;
|
43
|
} else {
|
44
|
return 0;
|
45
|
}
|
46
|
} ),
|
47
|
error => {
|
48
|
console.log(error);
|
49
|
this.showSpinner = false;
|
50
|
this.loadingMessage = '';
|
51
|
this.errorMessage = reposRetrievalError;
|
52
|
},
|
53
|
() => {
|
54
|
this.showSpinner = false;
|
55
|
this.loadingMessage = '';
|
56
|
}
|
57
|
);
|
58
|
}
|
59
|
|
60
|
/*NOT SURE IF THESE PARAMETERS ARE THE CORRECT ONES*/
|
61
|
confirmApproval(repoId: string) {
|
62
|
this.confirmApprovalModal.ids = [repoId];
|
63
|
this.confirmApprovalModal.showModal();
|
64
|
}
|
65
|
|
66
|
confirmedApproval(ids: string[]){
|
67
|
let id = ids[0];
|
68
|
console.log(`approved validation of piwik for repo with id: ${id}`);
|
69
|
}
|
70
|
|
71
|
}
|