Skip to content

Commit

Permalink
Load parameters on re-launch a task
Browse files Browse the repository at this point in the history
Resolves #1387
  • Loading branch information
oodamien committed Mar 25, 2020
1 parent f6fb3ce commit 09dec1f
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions ui/src/app/tasks/task-launch/task-launch.component.ts
Expand Up @@ -12,6 +12,7 @@ import { TaskLaunchParams } from '../components/tasks.interface';
import { TaskLaunchValidator } from './task-launch.validator';
import { KvRichTextValidator } from '../../shared/components/kv-rich-text/kv-rich-text.validator';
import { BlockerService } from '../../shared/components/blocker/blocker.service';
import { OrderParams } from '../../shared/components/shared.interface';

/**
* Component that provides a launcher of task.
Expand Down Expand Up @@ -67,6 +68,7 @@ export class TaskLaunchComponent implements OnInit, OnDestroy {
* @param {TasksService} tasksService
* @param {NotificationService} notificationService
* @param {RoutingStateService} routingStateService
* @param {BlockerService} blockerService
* @param {ActivatedRoute} route
* @param {Router} router
*/
Expand All @@ -86,27 +88,54 @@ export class TaskLaunchComponent implements OnInit, OnDestroy {
this.task$ = this.route.params
.pipe(
mergeMap(val => this.tasksService.getDefinition(val.id)),
mergeMap(val => this.tasksService.getTaskExecutions({
sort: 'TASK_EXECUTION_ID',
order: OrderParams.DESC,
page: 0,
size: 1,
q: val.name
}).pipe(
map(val2 => {
let parameters = '';
if (val2.items.length === 1) {
if (val2.items[0].deploymentProperties) {
parameters = Object.keys(val2.items[0].deploymentProperties).map(key => {
if (val2.items[0].deploymentProperties[key] === '******') {
return '';
}
return `${key}=${val2.items[0].deploymentProperties[key]}`;
})
.filter(param => !!param)
.join('\n');
}
}
return {
taskDefinition: val,
parameters
};
})
)),
mergeMap(
val => this.tasksService.getPlatforms()
.pipe(map(val2 => {
if (val2.length === 0) {
this.form = new FormGroup({
args: new FormControl('', KvRichTextValidator.validateKvRichText(this.kvValidators.args)),
props: new FormControl('', KvRichTextValidator.validateKvRichText(this.kvValidators.props)),
props: new FormControl(val.parameters, KvRichTextValidator.validateKvRichText(this.kvValidators.props)),
platform: new FormControl('')
});
} else {
this.form = new FormGroup({
args: new FormControl('', KvRichTextValidator.validateKvRichText(this.kvValidators.args)),
props: new FormControl('', KvRichTextValidator.validateKvRichText(this.kvValidators.props)),
props: new FormControl(val.parameters, KvRichTextValidator.validateKvRichText(this.kvValidators.props)),
platform: new FormControl('', Validators.required)
});
}
if (val2.length === 1) {
this.form.get('platform').setValue(val2[0].name);
}
return {
taskDefinition: val,
taskDefinition: val.taskDefinition,
platforms: val2
};
}))
Expand Down

0 comments on commit 09dec1f

Please sign in to comment.