Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 306cdc0

Browse files
committed
Stream Deploy Edit
Resolves #625
1 parent 55a202c commit 306cdc0

File tree

5 files changed

+76
-10
lines changed

5 files changed

+76
-10
lines changed

ui/src/app/streams/stream-deploy/builder/builder.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ export class StreamDeployBuilderComponent implements OnInit, OnDestroy {
233233
if (appNames.indexOf(appKey) > -1) {
234234
const appProperties = builder.streamDeployConfig.apps[appNames.indexOf(appKey)];
235235
if (appProperties.options && !appProperties.optionsState.isInvalid) {
236-
const option = builder.builderAppsProperties[appKey].find(opt => opt.name === keyReduce);
236+
const option = builder.builderAppsProperties[appKey].find(opt => {
237+
return opt.name === keyReduce || opt.id === keyReduce;
238+
});
237239
if (option) {
238240
option.value = value;
239241
free = false;
@@ -502,7 +504,7 @@ export class StreamDeployBuilderComponent implements OnInit, OnDestroy {
502504
}
503505
return appProperties.map((property: Properties.Property) => {
504506
return (property.value !== undefined && property.value.toString() !== '' && property.value !== property.defaultValue) ? ({
505-
key: `${property.name}`,
507+
key: `${property.id}`,
506508
value: property.value
507509
}) : null;
508510
}).filter((app) => app !== null);

ui/src/app/streams/stream-deploy/stream-deploy.component.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { StreamsService } from '../streams.service';
1010
import { Subject } from 'rxjs/Subject';
1111
import { ToastyService } from 'ng2-toasty';
1212
import { BusyService } from '../../shared/services/busy.service';
13+
import { StreamDefinition } from '../model/stream-definition';
14+
import { Parser } from '../../shared/services/parser';
15+
import { StreamDeployService } from './stream-deploy.service';
1316

1417
/**
1518
* Component used to deploy stream definitions.
@@ -89,6 +92,51 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
8992
};
9093
}
9194
))
95+
.pipe(mergeMap(
96+
val => this.streamsService.getDeploymentInfo(val.id),
97+
(config: any, deploymentInfo: StreamDefinition) => {
98+
const properties = [];
99+
100+
// Deployer properties
101+
Object.keys(deploymentInfo.deploymentProperties).map(app => {
102+
Object.keys(deploymentInfo.deploymentProperties[app]).forEach((key: string) => {
103+
const value = deploymentInfo.deploymentProperties[app][key];
104+
if (key === StreamDeployService.version.keyEdit) {
105+
properties.push(`version.${app}=${value}`);
106+
} else if (key.startsWith(StreamDeployService.deployer.keyEdit)) {
107+
const keyShort = key.substring(StreamDeployService.deployer.keyEdit.length, key.length);
108+
if (keyShort !== 'group') {
109+
properties.push(`deployer.${app}.${keyShort}=${value}`);
110+
} else {
111+
console.log(`${key} is bypassed (app: ${app}, value: ${value})`);
112+
}
113+
} else {
114+
console.log(`${key} is bypassed (app: ${app}, value: ${value})`);
115+
}
116+
});
117+
});
118+
119+
// Application properties
120+
const dslTextParsed = Parser.parse(deploymentInfo.dslText, 'stream');
121+
dslTextParsed.lines[0].nodes.forEach((node) => {
122+
const app = node['label'] || node['name'];
123+
const appType = node['name'];
124+
if (node['options']) {
125+
node.options.forEach((value, key) => {
126+
let keyShort = key;
127+
if (key.startsWith(`${appType}.`)) {
128+
keyShort = key.substring(`${appType}.`.length, key.length);
129+
}
130+
properties.push(`app.${app}.${keyShort}=${value}`);
131+
});
132+
}
133+
});
134+
135+
this.properties = properties;
136+
config.streamDefinition = deploymentInfo;
137+
return config;
138+
}
139+
))
92140
.pipe(map((config) => {
93141
this.refConfig = config;
94142
return config;
@@ -140,21 +188,28 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
140188
propertiesMap[arr[0]] = arr[1];
141189
}
142190
});
143-
const busy = this.streamsService.deployDefinition(this.refConfig.id, propertiesMap)
191+
192+
let obs = Observable.of({});
193+
if (['deployed', 'deploying'].indexOf(this.refConfig.streamDefinition.status) > -1) {
194+
obs = this.streamsService.undeployDefinition(this.refConfig.streamDefinition);
195+
}
196+
const busy = obs.pipe(mergeMap(
197+
val => this.streamsService.deployDefinition(this.refConfig.id, propertiesMap),
198+
(val1, val2) => val2
199+
))
144200
.pipe(takeUntil(this.ngUnsubscribe$))
145201
.subscribe(
146202
data => {
147203
this.toastyService.success(`Successfully deployed stream definition "${this.refConfig.id}"`);
148204
this.router.navigate(['streams']);
149205
},
150206
error => {
151-
console.log(error);
152-
console.log(error.message);
153207
this.toastyService.error(`${error.message ? error.message : error.toString()}`);
154208
}
155209
);
156210

157211
this.busyService.addSubscription(busy);
212+
158213
}
159214

160215
}

ui/src/app/streams/stream-deploy/stream-deploy.service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,25 @@ export class StreamDeployService {
3636
* Deployer key validation
3737
*/
3838
public static deployer = {
39+
keyEdit: 'spring.cloud.deployer.',
3940
is: (key: string): boolean => {
4041
return /^(deployer.)/.test(key);
4142
},
4243
extract: (key: string): string => {
4344
const result = key.split('.');
44-
return result.length > 2 ? result[2] : '';
45+
if (result.length < 3) {
46+
return '';
47+
}
48+
return result.slice(2, result.length)
49+
.join('.');
4550
},
4651
};
4752

4853
/**
4954
* Version key validation
5055
*/
5156
public static version = {
57+
keyEdit: 'version',
5258
is: (key: string): boolean => {
5359
return /^(version.)/.test(key);
5460
}
@@ -63,7 +69,11 @@ export class StreamDeployService {
6369
},
6470
extract: (key: string): string => {
6571
const result = key.split('.');
66-
return result.length > 2 ? result[2] : '';
72+
if (result.length < 3) {
73+
return '';
74+
}
75+
return result.slice(2, result.length)
76+
.join('.');
6777
}
6878
};
6979

ui/src/app/streams/stream/summary/stream-summary.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
Undeploy
1111
</button>
1212
<button name="stream-deploy" type="button" [appRoles]="['ROLE_CREATE']"
13-
[disabled]="(stream.streamDefinition.status === 'deployed'
14-
|| stream.streamDefinition.status==='deploying')" (click)="deploy(stream.streamDefinition)"
13+
(click)="deploy(stream.streamDefinition)"
1514
class="btn btn-default" style="margin-left: 0;" title="Deploy">
1615
<span class="glyphicon glyphicon-play"></span>
1716
Deploy

ui/src/app/streams/streams/streams.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h1 class="no-user-selection">Streams</h1>
150150
<span class="glyphicon glyphicon-stop"></span>
151151
</button>
152152
<button name="stream-deploy{{ i }}" type="button" [appRoles]="['ROLE_CREATE']"
153-
[disabled]="(item.status==='deployed' || item.status==='deploying')" (click)="deploy(item)"
153+
[disabled]="(item.status==='deploying')" (click)="deploy(item)"
154154
class="btn btn-default" style="margin-left: 0;" title="Deploy">
155155
<span class="glyphicon glyphicon-play"></span>
156156
</button>

0 commit comments

Comments
 (0)