Revision 50504
Added by Myrto Koukouli over 6 years ago
compatibility-validate-type.component.ts | ||
---|---|---|
2 | 2 |
import { ActivatedRoute } from '@angular/router'; |
3 | 3 |
import { CompatibilityValidateStep1Component } from './compatibility-validate-forms/compatibility-validate-step1.component'; |
4 | 4 |
import { RepositoryService } from '../../services/repository.service'; |
5 |
import { Repository } from '../../domain/typeScriptClasses'; |
|
5 |
import { Repository, RuleSet } from '../../domain/typeScriptClasses';
|
|
6 | 6 |
import { AuthenticationService } from '../../services/authentication.service'; |
7 | 7 |
import { |
8 |
loadingReposMessage, loadingUserRepoInfo, loadingUserRepoInfoEmpty, |
|
9 |
loadingUserRepoInfoError |
|
8 |
loadingReposMessage, loadingRuleSets, loadingRuleSetsError, loadingUserRepoInfo, loadingUserRepoInfoEmpty,
|
|
9 |
loadingUserRepoInfoError, noRuleSets
|
|
10 | 10 |
} from '../../domain/shared-messages'; |
11 |
import { ValidatorService } from '../../services/validator.service'; |
|
12 |
import { CompatibilityValidateStep2Component } from './compatibility-validate-forms/compatibility-validate-step2.component'; |
|
11 | 13 |
|
12 | 14 |
@Component ({ |
13 | 15 |
selector: 'compatibility-validate-literature', |
... | ... | |
16 | 18 |
|
17 | 19 |
export class CompatibilityValidateTypeComponent implements OnInit { |
18 | 20 |
type: string = ''; |
21 |
|
|
19 | 22 |
showDatasource: boolean; |
20 | 23 |
showGuidelines: boolean; |
21 | 24 |
showParameters: boolean; |
22 | 25 |
showFinish: boolean; |
26 |
|
|
23 | 27 |
step2: string = ''; |
24 | 28 |
step3: string = ''; |
25 | 29 |
step4: string = ''; |
26 | 30 |
|
27 | 31 |
baseUrlList: string[] = []; |
32 |
ruleSets: RuleSet[] = []; |
|
33 |
|
|
28 | 34 |
errorMessage: string; |
29 | 35 |
loadingMessage: string; |
30 | 36 |
showSpinner: boolean; |
31 | 37 |
|
32 | 38 |
@ViewChild('step1ChooseBaseUrl') step1ChooseBaseUrl : CompatibilityValidateStep1Component; |
39 |
@ViewChild('step2ChooseGuidelines') step2ChooseGuidelines : CompatibilityValidateStep2Component; |
|
33 | 40 |
|
34 | 41 |
constructor(private route: ActivatedRoute, |
35 | 42 |
private authService: AuthenticationService, |
36 |
private repoService: RepositoryService) {} |
|
43 |
private repoService: RepositoryService, |
|
44 |
private valService: ValidatorService) {} |
|
37 | 45 |
|
38 | 46 |
ngOnInit() { |
39 | 47 |
this.readType(); |
... | ... | |
47 | 55 |
|
48 | 56 |
moveAStep(){ |
49 | 57 |
if (this.showDatasource) { |
50 |
this.step1ChooseBaseUrl.submitForm(); |
|
51 |
if (this.step1ChooseBaseUrl.chosenUrl) { |
|
52 |
this.showGuidelines = true; |
|
53 |
this.showDatasource = false; |
|
54 |
this.step2 = 'active'; |
|
58 |
if (this.step1ChooseBaseUrl.submitForm()) { |
|
59 |
this.getRuleSetsForType(); |
|
55 | 60 |
} |
56 | 61 |
} else if (this.showGuidelines) { |
57 | 62 |
this.showParameters = true; |
... | ... | |
64 | 69 |
} |
65 | 70 |
} |
66 | 71 |
|
67 |
moveBackAStep(){
|
|
72 |
moveBackAStep () {
|
|
68 | 73 |
if (this.showGuidelines) { |
69 | 74 |
this.showDatasource = true; |
70 | 75 |
this.showGuidelines = false; |
... | ... | |
110 | 115 |
); |
111 | 116 |
} |
112 | 117 |
|
118 |
getRuleSetsForType() { |
|
119 |
this.showSpinner = true; |
|
120 |
this.loadingMessage = loadingRuleSets; |
|
121 |
this.valService.getRuleSets(this.type) |
|
122 |
.subscribe( |
|
123 |
rules => this.ruleSets = rules, |
|
124 |
error => { |
|
125 |
this.showSpinner = false; |
|
126 |
this.loadingMessage = ''; |
|
127 |
this.errorMessage = loadingRuleSetsError; |
|
128 |
}, |
|
129 |
() => { |
|
130 |
this.showSpinner = false; |
|
131 |
this.loadingMessage = ''; |
|
132 |
this.showDatasource = false; |
|
133 |
this.step2 = 'active'; |
|
134 |
if (this.ruleSets.length) { |
|
135 |
this.showGuidelines = true; |
|
136 |
} else { |
|
137 |
this.errorMessage = noRuleSets; |
|
138 |
} |
|
139 |
} |
|
140 |
); |
|
141 |
} |
|
113 | 142 |
} |
Also available in: Unified diff
almost finished compatibility-validate-guidelines