|
1 | 1 |
|
2 |
| -import {Observable, of as observableOf} from 'rxjs'; |
3 |
| - |
4 | 2 | import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
5 | 3 | import {Router} from '@angular/router';
|
6 | 4 | import {TranslateService} from '@ngx-translate/core';
|
7 | 5 | import {cloneDeep} from 'lodash';
|
| 6 | +import {Observable, of as observableOf} from 'rxjs'; |
8 | 7 | import {finalize, first, map} from 'rxjs/operators';
|
9 | 8 | import {Application} from '../../../../model/application.model';
|
10 | 9 | import {Environment} from '../../../../model/environment.model';
|
@@ -95,6 +94,8 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
|
95 | 94 | loadingCreateEnvironment = false;
|
96 | 95 | newEnvironment: Environment = new Environment();
|
97 | 96 | _createNewEnvironment = false;
|
| 97 | + platforms: IdName[] = []; |
| 98 | + loadingPlatforms = false; |
98 | 99 |
|
99 | 100 | constructor(private _router: Router,
|
100 | 101 | private _translate: TranslateService,
|
@@ -207,10 +208,34 @@ export class WorkflowNodeAddWizardComponent implements OnInit {
|
207 | 208 | return this.createApplication().pipe(
|
208 | 209 | map(() => 'environment'));
|
209 | 210 | }
|
| 211 | + this.getPlatforms(); |
210 | 212 | this.pipelineSection = 'environment';
|
211 | 213 | return observableOf('environment');
|
212 | 214 | }
|
213 | 215 |
|
| 216 | + getPlatforms() { |
| 217 | + this.loadingPlatforms = true; |
| 218 | + let app = this.project.application_names.find((a) => a.id === this.node.context.application_id); |
| 219 | + this._appStore.getDeploymentStrategies(this.project.key, app.name).pipe( |
| 220 | + first(), |
| 221 | + finalize(() => this.loadingPlatforms = false) |
| 222 | + ).subscribe( |
| 223 | + (data) => { |
| 224 | + this.platforms = [new IdName()]; |
| 225 | + let pfNames = Object.keys(data); |
| 226 | + pfNames.forEach(s => { |
| 227 | + let pf = this.project.platforms.find(p => p.name === s); |
| 228 | + if (pf) { |
| 229 | + let idName = new IdName(); |
| 230 | + idName.id = pf.id; |
| 231 | + idName.name = pf.name; |
| 232 | + this.platforms.push(idName); |
| 233 | + } |
| 234 | + }) |
| 235 | + } |
| 236 | + ); |
| 237 | + } |
| 238 | + |
214 | 239 | createEnvironment(): Observable<Project> {
|
215 | 240 | this.loadingCreateEnvironment = true;
|
216 | 241 | return this._projectStore.addProjectEnvironment(this.project.key, this.newEnvironment)
|
|
0 commit comments