Revision 58098
Added by Stefania Martziou about 4 years ago
metrics-usagestats.component.ts | ||
---|---|---|
1 | 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'; |
|
2 |
import { Repository } from '../../../domain/typeScriptClasses';
|
|
3 |
import { RepositoryService } from '../../../services/repository.service';
|
|
4 |
import { AuthenticationService } from '../../../services/authentication.service';
|
|
5 | 5 |
import { ActivatedRoute, Router } from '@angular/router'; |
6 |
import { SharedService } from "../../../services/shared.service"; |
|
6 | 7 |
|
7 | 8 |
@Component({ |
8 | 9 |
selector: 'metrics-usagestats', |
... | ... | |
15 | 16 |
title = 'Get usage statistics report'; |
16 | 17 |
|
17 | 18 |
repo: Repository; |
18 |
repoId: string; |
|
19 | 19 |
|
20 | 20 |
constructor(private repoService: RepositoryService, |
21 |
private sharedService: SharedService, |
|
21 | 22 |
private authService: AuthenticationService, |
22 | 23 |
private route: ActivatedRoute, |
23 | 24 |
private router: Router) {} |
24 | 25 |
|
25 | 26 |
ngOnInit() { |
26 |
this.getRepo(); |
|
27 |
|
|
28 |
if(this.sharedService.getRepository()) { |
|
29 |
this.repo = this.sharedService.getRepository(); |
|
30 |
this.title = this.title + ' for ' + this.repo.officialName; |
|
31 |
} |
|
32 |
|
|
33 |
this.sharedService.repository$.subscribe( |
|
34 |
r => { |
|
35 |
this.repo = r; |
|
36 |
this.title = this.title + ' for ' + this.repo.officialName; |
|
37 |
} |
|
38 |
); |
|
39 |
|
|
40 |
// this.getRepo(); |
|
27 | 41 |
let body = document.getElementsByTagName('body')[0]; |
28 | 42 |
body.classList.remove("top_bar_active"); //remove the class |
29 | 43 |
body.classList.remove("page_heading_active"); |
... | ... | |
31 | 45 |
body.classList.add("dashboard"); |
32 | 46 |
} |
33 | 47 |
|
34 |
getRepo() { |
|
35 |
this.repoId = this.route.snapshot.paramMap.get('id'); |
|
48 |
// getRepo() { |
|
49 |
// |
|
50 |
// if (this.repoId) { |
|
51 |
// this.repoService.getRepositoryById(this.repoId).subscribe( |
|
52 |
// repo => this.repo = repo, |
|
53 |
// error => { |
|
54 |
// console.log(error); |
|
55 |
// this.errorMessage = 'The repository could not be retrieved'; |
|
56 |
// }, |
|
57 |
// () => { |
|
58 |
// this.title = this.title + ' for ' + this.repo.officialName; |
|
59 |
// console.log(this.authService.getUserEmail(), this.repo.registeredBy); |
|
60 |
// } |
|
61 |
// ); |
|
62 |
// } |
|
63 |
// } |
|
36 | 64 |
|
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 | 65 |
} |
Also available in: Unified diff
Second commit for the new layout provided by the UX team