1
|
import { Component, OnInit, Type } from '@angular/core';
|
2
|
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
3
|
import { DatasourceInterfaceFormComponent } from './sources-forms/datasource-interface-form.component';
|
4
|
import { Repository, RepositoryInterface } from '../../domain/typeScriptClasses';
|
5
|
import { RepositoryService } from '../../services/repository.service';
|
6
|
import { ActivatedRoute } from '@angular/router';
|
7
|
import {
|
8
|
Description,
|
9
|
interfaceFormDesc,
|
10
|
} from '../../domain/oa-description';
|
11
|
|
12
|
|
13
|
|
14
|
@Component ({
|
15
|
selector: 'sources-update-repo',
|
16
|
templateUrl: 'sources-update-repo.component.html'
|
17
|
})
|
18
|
|
19
|
export class SourcesUpdateRepoComponent implements OnInit {
|
20
|
|
21
|
repoId: string;
|
22
|
repo: Repository;
|
23
|
repoInterfaces: RepositoryInterface[] = [];
|
24
|
loadInterfaces: boolean;
|
25
|
|
26
|
group: FormGroup;
|
27
|
interfaceFormDesc: Description = interfaceFormDesc;
|
28
|
updateDatasourceInterfaces: Type<any> = DatasourceInterfaceFormComponent;
|
29
|
|
30
|
constructor (
|
31
|
private fb: FormBuilder,
|
32
|
private repoService: RepositoryService,
|
33
|
private route: ActivatedRoute )
|
34
|
{}
|
35
|
|
36
|
|
37
|
ngOnInit() {
|
38
|
this.readRepoId();
|
39
|
this.group = this.fb.group({});
|
40
|
this.getRepoInterfaces();
|
41
|
}
|
42
|
|
43
|
readRepoId() {
|
44
|
this.repoId = this.route.snapshot.paramMap.get('id');
|
45
|
console.log(`repoId is ${this.repoId}`);
|
46
|
}
|
47
|
|
48
|
|
49
|
getRepoInterfaces() {
|
50
|
this.repoService.getRepositoryInterface(this.repoId).subscribe(
|
51
|
interfaces => {
|
52
|
this.repoInterfaces = interfaces;
|
53
|
console.log(`the number of interfaces for ${this.repoId} is ${this.repoInterfaces.length}`);
|
54
|
},
|
55
|
error => console.log(error),
|
56
|
() => this.loadInterfaces = true
|
57
|
);
|
58
|
}
|
59
|
|
60
|
getCurrentRepo(repo: Repository) {
|
61
|
this.repo = repo;
|
62
|
}
|
63
|
|
64
|
|
65
|
}
|