1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { RepositoryService } from "../../services/repository.service";
|
3
|
import { SharedService } from "../../services/shared.service";
|
4
|
import { RepositorySnippet } from "../../domain/typeScriptClasses";
|
5
|
import { Router } from "@angular/router";
|
6
|
|
7
|
@Component ({
|
8
|
selector: 'app-empty-page',
|
9
|
templateUrl: './empty-page.component.html',
|
10
|
})
|
11
|
|
12
|
export class EmptyPageComponent implements OnInit {
|
13
|
|
14
|
repositoriesOfUser: RepositorySnippet[];
|
15
|
|
16
|
constructor(private repositoryService: RepositoryService,
|
17
|
private sharedService: SharedService,
|
18
|
private router: Router) {
|
19
|
}
|
20
|
|
21
|
ngOnInit() {
|
22
|
|
23
|
let body = document.getElementsByTagName('body')[0];
|
24
|
body.classList.remove("landing");
|
25
|
body.classList.add("dashboard");
|
26
|
|
27
|
if(this.sharedService.getRepositoriesOfUser() && this.sharedService.getRepositoriesOfUser().length>0) {
|
28
|
this.repositoriesOfUser = this.sharedService.getRepositoriesOfUser();
|
29
|
if(this.repositoriesOfUser.length>0)
|
30
|
this.router.navigate([`/repository/${this.repositoriesOfUser[0].id}/dashboard`]);
|
31
|
// this.getSelectedRepositorySummaryInfo(this.repository);
|
32
|
} else {
|
33
|
this.getReposOfUser();
|
34
|
}
|
35
|
|
36
|
// this.sharedService.repositoriesOfUser$.subscribe(
|
37
|
// r => {
|
38
|
// this.repositoriesOfUser = r;
|
39
|
// }
|
40
|
// );
|
41
|
|
42
|
}
|
43
|
|
44
|
getReposOfUser(): void {
|
45
|
this.repositoryService.getRepositoriesOfUser()
|
46
|
.subscribe(
|
47
|
repos => {
|
48
|
this.repositoriesOfUser = repos;
|
49
|
// this.sharedService.setRepositoriesOfUser(repos);
|
50
|
if(this.repositoriesOfUser.length>0)
|
51
|
this.router.navigate([`/repository/${this.repositoriesOfUser[0].id}/dashboard`]);
|
52
|
},
|
53
|
error => { console.log(error); }
|
54
|
);
|
55
|
}
|
56
|
}
|