Allow add new Job step to Workflow Jobs

This commit is contained in:
Jose Alberto Hernandez
2022-10-24 14:12:35 +02:00
committed by Arnold Gálovics
parent 1a18759c2f
commit 11b1e6793b
4 changed files with 67 additions and 4 deletions
@@ -72,8 +72,10 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit {
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe((data: { jobsScheduler: any }) => {
this.jobData = data.jobsScheduler[0];
this.schedulerData = data.jobsScheduler[1];
if (data.jobsScheduler) {
this.jobData = data.jobsScheduler[0];
this.schedulerData = data.jobsScheduler[1];
}
});
}
@@ -10,7 +10,7 @@
</mat-form-field>
<div class="action-button" fxLayoutGap="25px" *ngIf="jobStepsData.length > 0">
<button mat-raised-button color="primary">
<button mat-raised-button color="primary" (click)="addJobStep()">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Link Job Step
</button>
</div>
@@ -4,6 +4,9 @@ import { FormControl, Validators } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatTable } from '@angular/material/table';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
import { SystemService } from 'app/system/system.service';
import { JobStep } from './workflow-diagram/workflow-diagram.component';
@@ -17,6 +20,7 @@ export class WorkflowJobsComponent implements OnInit {
jobNameOptions: any = [];
jobStepsData: any = [];
jobAvailableStepsData: any = [];
jobStepsDataBase: any = [];
jobStepName: String = null;
@@ -77,6 +81,56 @@ export class WorkflowJobsComponent implements OnInit {
});
}
/**
* Add Job Step to Workflow
*/
addJobStep() {
if (this.jobStepName != null) {
const jobDatas = this.jobStepName.split('_');
this.jobAvailableStepsData = [];
this.systemService.getAvailablesJobSteps(jobDatas[0]).toPromise()
.then(jobData => {
this.jobAvailableStepsData = jobData.availableBusinessSteps.sort(function (a: any, b: any) {
return a.stepName - b.stepName;
});
const tmpStepsNames: any = [];
this.jobStepsData.forEach((step: any) => {
return tmpStepsNames.push(step.stepName);
});
if (this.jobAvailableStepsData.length > 0) {
this.jobAvailableStepsData = this.jobAvailableStepsData.filter((item: any) => {
return (tmpStepsNames.indexOf(item.stepName) < 0);
});
}
if (this.jobAvailableStepsData.length > 0) {
const frmFields: FormfieldBase[] = [
new SelectBase({
controlName: 'stepName',
label: 'Step',
options: { label: 'stepDescription', value: 'stepName', data: this.jobAvailableStepsData },
order: 1
})
];
const data = {
title: 'Add Job Step to Workflow',
layout: { addButtonText: 'Add' },
formfields: frmFields
};
const stepDialogRef = this.dialog.open(FormDialogComponent, { data });
stepDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
this.jobStepsData = this.jobStepsData.concat(response.data.value);
this.stepOrderHasChanged = true;
}
});
}
});
}
}
saveChanges() {
// Set the new Order
let stepOrder = 1;
+8 -1
View File
@@ -262,12 +262,19 @@ export class SystemService {
}
/**
* @returns {Observable<any>} Fetches Jobs.
* @returns {Observable<any>} Updates Jobs.
*/
putWorkflowJobSteps(jobName: String, payload: any): Observable<any> {
return this.http.put(`/jobs/${jobName}/steps`, payload);
}
/**
* @returns {Observable<any>} Fetches Steps.
*/
getAvailablesJobSteps(jobCategory: String): Observable<any> {
return this.http.get(`/jobs/${jobCategory}/available-steps`);
}
/**
* @returns {Observable<any>} Fetches Scheduler.
*/