diff --git a/ui/src/app/streams/stream-deploy/builder/builder.component.ts b/ui/src/app/streams/stream-deploy/builder/builder.component.ts index 2ed931a0d..9200d4fbd 100644 --- a/ui/src/app/streams/stream-deploy/builder/builder.component.ts +++ b/ui/src/app/streams/stream-deploy/builder/builder.component.ts @@ -233,7 +233,9 @@ export class StreamDeployBuilderComponent implements OnInit, OnDestroy { if (appNames.indexOf(appKey) > -1) { const appProperties = builder.streamDeployConfig.apps[appNames.indexOf(appKey)]; if (appProperties.options && !appProperties.optionsState.isInvalid) { - const option = builder.builderAppsProperties[appKey].find(opt => opt.name === keyReduce); + const option = builder.builderAppsProperties[appKey].find(opt => { + return opt.name === keyReduce || opt.id === keyReduce; + }); if (option) { option.value = value; free = false; @@ -502,7 +504,7 @@ export class StreamDeployBuilderComponent implements OnInit, OnDestroy { } return appProperties.map((property: Properties.Property) => { return (property.value !== undefined && property.value.toString() !== '' && property.value !== property.defaultValue) ? ({ - key: `${property.name}`, + key: `${property.id}`, value: property.value }) : null; }).filter((app) => app !== null); diff --git a/ui/src/app/streams/stream-deploy/stream-deploy.component.ts b/ui/src/app/streams/stream-deploy/stream-deploy.component.ts index b0ff74958..a08cd53ea 100644 --- a/ui/src/app/streams/stream-deploy/stream-deploy.component.ts +++ b/ui/src/app/streams/stream-deploy/stream-deploy.component.ts @@ -10,6 +10,9 @@ import { StreamsService } from '../streams.service'; import { Subject } from 'rxjs/Subject'; import { ToastyService } from 'ng2-toasty'; import { BusyService } from '../../shared/services/busy.service'; +import { StreamDefinition } from '../model/stream-definition'; +import { Parser } from '../../shared/services/parser'; +import { StreamDeployService } from './stream-deploy.service'; /** * Component used to deploy stream definitions. @@ -89,6 +92,51 @@ export class StreamDeployComponent implements OnInit, OnDestroy { }; } )) + .pipe(mergeMap( + val => this.streamsService.getDeploymentInfo(val.id), + (config: any, deploymentInfo: StreamDefinition) => { + const properties = []; + + // Deployer properties + Object.keys(deploymentInfo.deploymentProperties).map(app => { + Object.keys(deploymentInfo.deploymentProperties[app]).forEach((key: string) => { + const value = deploymentInfo.deploymentProperties[app][key]; + if (key === StreamDeployService.version.keyEdit) { + properties.push(`version.${app}=${value}`); + } else if (key.startsWith(StreamDeployService.deployer.keyEdit)) { + const keyShort = key.substring(StreamDeployService.deployer.keyEdit.length, key.length); + if (keyShort !== 'group') { + properties.push(`deployer.${app}.${keyShort}=${value}`); + } else { + console.log(`${key} is bypassed (app: ${app}, value: ${value})`); + } + } else { + console.log(`${key} is bypassed (app: ${app}, value: ${value})`); + } + }); + }); + + // Application properties + const dslTextParsed = Parser.parse(deploymentInfo.dslText, 'stream'); + dslTextParsed.lines[0].nodes.forEach((node) => { + const app = node['label'] || node['name']; + const appType = node['name']; + if (node['options']) { + node.options.forEach((value, key) => { + let keyShort = key; + if (key.startsWith(`${appType}.`)) { + keyShort = key.substring(`${appType}.`.length, key.length); + } + properties.push(`app.${app}.${keyShort}=${value}`); + }); + } + }); + + this.properties = properties; + config.streamDefinition = deploymentInfo; + return config; + } + )) .pipe(map((config) => { this.refConfig = config; return config; @@ -140,7 +188,15 @@ export class StreamDeployComponent implements OnInit, OnDestroy { propertiesMap[arr[0]] = arr[1]; } }); - const busy = this.streamsService.deployDefinition(this.refConfig.id, propertiesMap) + + let obs = Observable.of({}); + if (['deployed', 'deploying'].indexOf(this.refConfig.streamDefinition.status) > -1) { + obs = this.streamsService.undeployDefinition(this.refConfig.streamDefinition); + } + const busy = obs.pipe(mergeMap( + val => this.streamsService.deployDefinition(this.refConfig.id, propertiesMap), + (val1, val2) => val2 + )) .pipe(takeUntil(this.ngUnsubscribe$)) .subscribe( data => { @@ -148,13 +204,12 @@ export class StreamDeployComponent implements OnInit, OnDestroy { this.router.navigate(['streams']); }, error => { - console.log(error); - console.log(error.message); this.toastyService.error(`${error.message ? error.message : error.toString()}`); } ); this.busyService.addSubscription(busy); + } } diff --git a/ui/src/app/streams/stream-deploy/stream-deploy.service.ts b/ui/src/app/streams/stream-deploy/stream-deploy.service.ts index 056406497..d2286d15f 100644 --- a/ui/src/app/streams/stream-deploy/stream-deploy.service.ts +++ b/ui/src/app/streams/stream-deploy/stream-deploy.service.ts @@ -36,12 +36,17 @@ export class StreamDeployService { * Deployer key validation */ public static deployer = { + keyEdit: 'spring.cloud.deployer.', is: (key: string): boolean => { return /^(deployer.)/.test(key); }, extract: (key: string): string => { const result = key.split('.'); - return result.length > 2 ? result[2] : ''; + if (result.length < 3) { + return ''; + } + return result.slice(2, result.length) + .join('.'); }, }; @@ -49,6 +54,7 @@ export class StreamDeployService { * Version key validation */ public static version = { + keyEdit: 'version', is: (key: string): boolean => { return /^(version.)/.test(key); } @@ -63,7 +69,11 @@ export class StreamDeployService { }, extract: (key: string): string => { const result = key.split('.'); - return result.length > 2 ? result[2] : ''; + if (result.length < 3) { + return ''; + } + return result.slice(2, result.length) + .join('.'); } }; diff --git a/ui/src/app/streams/stream/summary/stream-summary.component.html b/ui/src/app/streams/stream/summary/stream-summary.component.html index 4b32c0432..70faf4ed0 100644 --- a/ui/src/app/streams/stream/summary/stream-summary.component.html +++ b/ui/src/app/streams/stream/summary/stream-summary.component.html @@ -10,8 +10,7 @@ Undeploy