1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { AuthenticationService } from '../../services/authentication.service';
|
3
|
import { RepositoryService } from '../../services/repository.service';
|
4
|
import {Repository, RepositorySnippet, RepositorySummaryInfo} from '../../domain/typeScriptClasses';
|
5
|
|
6
|
@Component ({
|
7
|
selector: 'app-dashboard',
|
8
|
templateUrl: 'dashboard.component.html'
|
9
|
})
|
10
|
|
11
|
export class DashboardComponent implements OnInit {
|
12
|
|
13
|
constructor(private authService: AuthenticationService,
|
14
|
private repositoryService: RepositoryService) { }
|
15
|
|
16
|
repositories: RepositorySummaryInfo[] = [];
|
17
|
userEmail: string;
|
18
|
|
19
|
loading: boolean = true;
|
20
|
|
21
|
ngOnInit() {
|
22
|
// this.getUserEmail();
|
23
|
this.userEmail = sessionStorage.getItem('email');
|
24
|
if (this.userEmail) {
|
25
|
this.getRepositoriesSummaryInfo(this.userEmail);
|
26
|
}
|
27
|
}
|
28
|
|
29
|
getIsUserLoggedIn() {
|
30
|
return this.authService.getIsUserLoggedIn();
|
31
|
}
|
32
|
|
33
|
getUserEmail() {
|
34
|
this.userEmail = this.authService.getUserEmail();
|
35
|
}
|
36
|
|
37
|
getRepos() {
|
38
|
console.log('in getRepos');
|
39
|
this.getRepositoriesSummaryInfo(this.userEmail);
|
40
|
}
|
41
|
|
42
|
getRepositoriesSummaryInfo(userEmail: string) {
|
43
|
this.repositoryService.getRepositoriesSummaryInfo(userEmail).subscribe(
|
44
|
repositories => { this.repositories = repositories; this.loading=false },
|
45
|
error => { console.log('Errrrror'); this.loading=false },
|
46
|
() => { console.log(this.repositories); this.loading=false }
|
47
|
);
|
48
|
}
|
49
|
}
|