This commit is contained in:
parent
6676c7f26c
commit
bc9fe2c716
|
@ -232,6 +232,14 @@ export interface WfConf {
|
||||||
userParams: Map<string, string>
|
userParams: Map<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WfParam {
|
||||||
|
name: string,
|
||||||
|
description?: string,
|
||||||
|
type?: string,
|
||||||
|
defaultValue?: any,
|
||||||
|
required: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface WfSubscription {
|
export interface WfSubscription {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
<ng-template matStepLabel>Choose Workflow</ng-template>
|
<ng-template matStepLabel>Choose Workflow</ng-template>
|
||||||
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
<mat-label>Workflow</mat-label>
|
<mat-label>Workflow</mat-label>
|
||||||
<input matInput formControlName="workflow" />
|
<mat-select matInput formControlName="workflow" (selectionChange)="onChangeWfTemplate($event)">
|
||||||
|
<mat-option *ngFor="let i of wfTemplates" [value]="i.id">{{i.name}} ({{i.subtype}})</mat-option>
|
||||||
|
</mat-select>
|
||||||
<mat-error *ngIf="wfConfFormStep1.get('workflow')?.invalid">This field is
|
<mat-error *ngIf="wfConfFormStep1.get('workflow')?.invalid">This field is
|
||||||
<strong>required</strong></mat-error>
|
<strong>required</strong></mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
@ -44,7 +46,16 @@
|
||||||
</mat-step>
|
</mat-step>
|
||||||
<mat-step [stepControl]="wfConfFormStep3" label="Worflow Parameters">
|
<mat-step [stepControl]="wfConfFormStep3" label="Worflow Parameters">
|
||||||
<form [formGroup]="wfConfFormStep3">
|
<form [formGroup]="wfConfFormStep3">
|
||||||
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;" *ngFor="let p of wfParameters">
|
||||||
|
<mat-label>{{p.name}}</mat-label>
|
||||||
|
<input matInput [formControlName]="p.name" *ngIf="p.type != 'boolean'" />
|
||||||
|
<mat-select matInput [formControlName]="p.name" *ngIf="p.type == 'boolean'">
|
||||||
|
<mat-option></mat-option>
|
||||||
|
<mat-option value="true">true</mat-option>
|
||||||
|
<mat-option value="false">false</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="wfConfFormStep3.get(p.name)?.invalid">Invalid value</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
<div>
|
<div>
|
||||||
<button mat-stroked-button color="primary" matStepperPrevious>Back</button>
|
<button mat-stroked-button color="primary" matStepperPrevious>Back</button>
|
||||||
<button mat-stroked-button color="primary" matStepperNext>Next</button>
|
<button mat-stroked-button color="primary" matStepperNext>Next</button>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { JsonPipe } from '@angular/common';
|
||||||
import { Component, Inject, OnInit, SecurityContext } from '@angular/core';
|
import { Component, Inject, OnInit, SecurityContext } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms';
|
||||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { MatSelectChange } from '@angular/material/select';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { KeyValue, WfConf, WfSection } from '../common/is.model';
|
import { KeyValue, SimpleResource, WfConf, WfParam, WfSection } from '../common/is.model';
|
||||||
import { ISService } from '../common/is.service';
|
import { ISService } from '../common/is.service';
|
||||||
import { ResMetadataDialog } from '../resources/resources.component';
|
import { ResMetadataDialog } from '../resources/resources.component';
|
||||||
|
|
||||||
|
@ -78,13 +80,16 @@ export class WfConfsComponent implements OnInit {
|
||||||
templateUrl: 'wf-conf-dialog.html',
|
templateUrl: 'wf-conf-dialog.html',
|
||||||
styleUrls: ['./wf-confs.component.css']
|
styleUrls: ['./wf-confs.component.css']
|
||||||
})
|
})
|
||||||
export class WfConfDialog {
|
|
||||||
|
export class WfConfDialog implements OnInit {
|
||||||
|
|
||||||
|
wfTemplates: SimpleResource[] = [];
|
||||||
|
wfParameters: WfParam[] = [];
|
||||||
|
|
||||||
wfConfFormStep1 = new FormGroup({
|
wfConfFormStep1 = new FormGroup({
|
||||||
workflow: new FormControl('', [Validators.required]),
|
workflow: new FormControl('', [Validators.required]),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
wfConfFormStep2 = new FormGroup({
|
wfConfFormStep2 = new FormGroup({
|
||||||
name: new FormControl('', [Validators.required]),
|
name: new FormControl('', [Validators.required]),
|
||||||
//details: Map<string, string>,
|
//details: Map<string, string>,
|
||||||
|
@ -120,6 +125,32 @@ export class WfConfDialog {
|
||||||
this.wfConfFormStep4.get('cronExpression')?.setValue(data.cronExpression);
|
this.wfConfFormStep4.get('cronExpression')?.setValue(data.cronExpression);
|
||||||
this.wfConfFormStep4.get('cronMinInterval')?.setValue(data.cronMinInterval);
|
this.wfConfFormStep4.get('cronMinInterval')?.setValue(data.cronMinInterval);
|
||||||
}
|
}
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.service.loadSimpleResources("wf_template", (data: SimpleResource[]) => this.wfTemplates = data);
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeWfTemplate(e: MatSelectChange): void {
|
||||||
|
this.service.loadSimpleResourceContent(e.value, (data: any) => {
|
||||||
|
console.log(data);
|
||||||
|
if (data.parameters) {
|
||||||
|
this.wfParameters = data.parameters;
|
||||||
|
} else {
|
||||||
|
this.wfParameters = JSON.parse(data).parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(this.wfParameters);
|
||||||
|
|
||||||
|
this.wfConfFormStep3.controls = {};
|
||||||
|
|
||||||
|
this.wfParameters.forEach(p => {
|
||||||
|
let validations: ValidatorFn[] = [];
|
||||||
|
if (p.required) { validations.push(Validators.required); }
|
||||||
|
if (p.type == 'number') { validations.push(Validators.pattern('^[0-9]*$')); }
|
||||||
|
this.wfConfFormStep3.addControl(p.name, new FormControl('', validations));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
const conf = Object.assign({}, this.data, this.wfConfFormStep1.value, this.wfConfFormStep2.value, this.wfConfFormStep3.value, this.wfConfFormStep4.value);
|
const conf = Object.assign({}, this.data, this.wfConfFormStep1.value, this.wfConfFormStep2.value, this.wfConfFormStep3.value, this.wfConfFormStep4.value);
|
||||||
|
|
Loading…
Reference in New Issue