Manage scheduler and cob jobs

This commit is contained in:
Jose Alberto Hernandez
2022-09-13 08:45:22 -05:00
parent 414fe2a2d7
commit a09853cee8
44 changed files with 1107 additions and 193 deletions
@@ -0,0 +1,44 @@
<div class="container">
<mat-card>
<form [formGroup]="jobForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field>
<mat-label>Job Name</mat-label>
<input matInput required formControlName="displayName">
<mat-error *ngIf="jobForm.controls.displayName.hasError('required')">
Job Name is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Cron Expression</mat-label>
<input matInput required formControlName="cronExpression">
<mat-error *ngIf="jobForm.controls.cronExpression.hasError('required')">
Cron Expression is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-checkbox labelPosition="before" formControlName="active">
Is job active?
</mat-checkbox>
</div>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!jobForm.valid" *mifosxHasPermission="'UPDATE_SCHEDULER'">Submit</button>
</mat-card-actions>
</mat-card-content>
</form>
</mat-card>
</div>
@@ -0,0 +1,3 @@
.container {
max-width: 37rem;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditSchedulerJobComponent } from './edit-scheduler-job.component';
describe('EditSchedulerJobComponent', () => {
let component: EditSchedulerJobComponent;
let fixture: ComponentFixture<EditSchedulerJobComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditSchedulerJobComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditSchedulerJobComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,68 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, Validators } from '@angular/forms';
/** Custom Services */
import { SystemService } from 'app/system/system.service';
/**
* Edit scheduler job component.
*/
@Component({
selector: 'mifosx-edit-scheduler-job',
templateUrl: './edit-scheduler-job.component.html',
styleUrls: ['./edit-scheduler-job.component.scss']
})
export class EditSchedulerJobComponent implements OnInit {
/** Job Data. */
jobData: any;
/** Job Form. */
jobForm: any;
/**
* Retrieves the selected job data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {SystemService} systemService System Service.
* @param {Router} router Router for navigation.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private systemService: SystemService,
private router: Router,
private formBuilder: FormBuilder ) {
this.route.data.subscribe((data: { jobSelected: any }) => {
this.jobData = data.jobSelected;
});
}
/**
* Creates and sets job form.
*/
ngOnInit() {
this.createJobForm();
}
/**
* Creates and sets job form.
*/
createJobForm() {
this.jobForm = this.formBuilder.group({
'displayName': [this.jobData.displayName, Validators.required],
'cronExpression': [this.jobData.cronExpression, Validators.required],
'active': [this.jobData.active]
});
}
/**
* Submits the edit job form.
*/
submit() {
this.systemService.updateScheduler(this.jobData.jobId, this.jobForm.value)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}