1 |
58109
|
stefania.m
|
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-join',
|
9 |
|
|
templateUrl: './join.component.html',
|
10 |
|
|
})
|
11 |
|
|
|
12 |
|
|
export class JoinComponent implements OnInit {
|
13 |
|
|
|
14 |
|
|
repositoriesOfUser: RepositorySnippet[];
|
15 |
|
|
|
16 |
58281
|
stefania.m
|
loadingMessage: string;
|
17 |
|
|
|
18 |
58109
|
stefania.m
|
constructor(private repositoryService: RepositoryService,
|
19 |
|
|
private sharedService: SharedService,
|
20 |
|
|
private router: Router) {
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
ngOnInit() {
|
24 |
|
|
|
25 |
58281
|
stefania.m
|
this.loadingMessage = ' ';
|
26 |
|
|
|
27 |
58109
|
stefania.m
|
let body = document.getElementsByTagName('body')[0];
|
28 |
|
|
body.classList.remove("landing");
|
29 |
|
|
body.classList.add("dashboard");
|
30 |
|
|
|
31 |
|
|
if(this.sharedService.getRepositoriesOfUser() && this.sharedService.getRepositoriesOfUser().length>0) {
|
32 |
|
|
this.repositoriesOfUser = this.sharedService.getRepositoriesOfUser();
|
33 |
|
|
if(this.repositoriesOfUser.length>0)
|
34 |
|
|
this.router.navigate([`/repository/${this.repositoriesOfUser[0].id}/dashboard`]);
|
35 |
58281
|
stefania.m
|
else
|
36 |
|
|
this.loadingMessage = null;
|
37 |
58109
|
stefania.m
|
} else {
|
38 |
|
|
this.getReposOfUser();
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
getReposOfUser(): void {
|
44 |
61394
|
stefania.m
|
this.repositoryService.getRepositoriesSnippetsOfUser()
|
45 |
58109
|
stefania.m
|
.subscribe(
|
46 |
|
|
repos => {
|
47 |
|
|
this.repositoriesOfUser = repos;
|
48 |
|
|
if(this.repositoriesOfUser.length>0)
|
49 |
|
|
this.router.navigate([`/repository/${this.repositoriesOfUser[0].id}/dashboard`]);
|
50 |
58281
|
stefania.m
|
else
|
51 |
|
|
this.loadingMessage = null;
|
52 |
58109
|
stefania.m
|
},
|
53 |
|
|
error => { console.log(error); }
|
54 |
|
|
);
|
55 |
|
|
}
|
56 |
|
|
}
|