1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { RepositoryService } from "../../services/repository.service";
|
3
|
import { AuthenticationService } from "../../services/authentication.service";
|
4
|
import { ActivatedRoute } from "@angular/router";
|
5
|
import { Repository, RepositoryInterface } from "../../domain/typeScriptClasses";
|
6
|
import { formInfoLoading, loadingRepoError } from "../../domain/shared-messages";
|
7
|
import { SharedService } from "../../services/shared.service";
|
8
|
|
9
|
@Component ({
|
10
|
selector: 'app-repository',
|
11
|
templateUrl: './repository.component.html',
|
12
|
})
|
13
|
|
14
|
export class RepositoryComponent implements OnInit {
|
15
|
|
16
|
repositoryId: string;
|
17
|
repository: Repository;
|
18
|
repositoryInterfaces: RepositoryInterface[] = [];
|
19
|
|
20
|
loadingMessage: string = '';
|
21
|
errorMessage: string = '';
|
22
|
|
23
|
constructor(private repoService: RepositoryService,
|
24
|
private sharedService: SharedService,
|
25
|
private authService: AuthenticationService,
|
26
|
private route: ActivatedRoute) {
|
27
|
|
28
|
route.params.subscribe(val => {
|
29
|
// put the code from `ngOnInit` here
|
30
|
this.repositoryId = this.route.snapshot.paramMap.get('id');
|
31
|
this.getRepository();
|
32
|
});
|
33
|
}
|
34
|
|
35
|
ngOnInit() {
|
36
|
// console.log("ngOnit repository component");
|
37
|
|
38
|
}
|
39
|
|
40
|
getRepository() {
|
41
|
this.errorMessage = '';
|
42
|
|
43
|
if (this.repositoryId) {
|
44
|
this.loadingMessage = 'Retrieving datasource info';
|
45
|
this.repoService.getRepositoryById(this.repositoryId).subscribe(
|
46
|
repository => {
|
47
|
console.log("Repository component - Repository id: " + repository.id);
|
48
|
this.sharedService.setRepository(repository);
|
49
|
this.loadingMessage = '';
|
50
|
},
|
51
|
error => {
|
52
|
console.log(error);
|
53
|
this.loadingMessage = '';
|
54
|
this.errorMessage = loadingRepoError;
|
55
|
}
|
56
|
);
|
57
|
|
58
|
this.sharedService.repository$.subscribe(r => this.repository = r);
|
59
|
}
|
60
|
}
|
61
|
|
62
|
}
|