1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { Repository } from '../../domain/typeScriptClasses';
|
3
|
import { RepositoryService } from '../../services/repository.service';
|
4
|
import { AuthenticationService } from '../../services/authentication.service';
|
5
|
import { ActivatedRoute, Router } from '@angular/router';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'metrics-usagestats',
|
9
|
templateUrl: 'metrics-usagestats.component.html'
|
10
|
})
|
11
|
|
12
|
export class MetricsUsagestatsComponent implements OnInit {
|
13
|
|
14
|
errorMessage: string;
|
15
|
title = 'Get usage statistics report';
|
16
|
|
17
|
repo: Repository;
|
18
|
repoId: string;
|
19
|
|
20
|
constructor(private repoService: RepositoryService,
|
21
|
private authService: AuthenticationService,
|
22
|
private route: ActivatedRoute,
|
23
|
private router: Router) {}
|
24
|
|
25
|
ngOnInit() {
|
26
|
this.getRepo();
|
27
|
let body = document.getElementsByTagName('body')[0];
|
28
|
body.classList.remove("top_bar_active"); //remove the class
|
29
|
body.classList.remove("page_heading_active");
|
30
|
body.classList.remove("landing");
|
31
|
body.classList.add("dashboard");
|
32
|
}
|
33
|
|
34
|
getRepo() {
|
35
|
this.repoId = this.route.snapshot.paramMap.get('id');
|
36
|
|
37
|
if (this.repoId) {
|
38
|
this.repoService.getRepositoryById(this.repoId).subscribe(
|
39
|
repo => this.repo = repo,
|
40
|
error => {
|
41
|
console.log(error);
|
42
|
this.errorMessage = 'The repository could not be retrieved';
|
43
|
},
|
44
|
() => {
|
45
|
this.title = this.title + ' for ' + this.repo.officialName;
|
46
|
console.log(this.authService.getUserEmail(), this.repo.registeredBy);
|
47
|
}
|
48
|
);
|
49
|
}
|
50
|
}
|
51
|
|
52
|
}
|