mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2025-12-30 14:13:16 +09:00
#52 no changes at the trigger list in case of rescheduling of an existing trigger
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>Trigger Name</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="triggerName"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput placeholder="Repeat Interval [in mills]" name="triggerName"
|
||||
[(ngModel)]="simpleTriggerForm.triggerName">
|
||||
</mat-form-field>
|
||||
@@ -19,7 +20,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>Job Class</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="jobClass"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput placeholder="Job Class Name" name="jobClass"
|
||||
[(ngModel)]="simpleTriggerForm.jobClass">
|
||||
</mat-form-field>
|
||||
@@ -28,7 +30,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>Start Date (optional)</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="startDate"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput name="startDate"
|
||||
[ngxMatDatetimePicker]="startDatePicker" placeholder="Choose a start date"
|
||||
[(ngModel)]="simpleTriggerForm.startDate">
|
||||
@@ -44,7 +47,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>End Date (optional)</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="endDate"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput name="endDate"
|
||||
[ngxMatDatetimePicker]="endDatePicker" placeholder="Choose a end date"
|
||||
[(ngModel)]="simpleTriggerForm.endDate"
|
||||
@@ -61,7 +65,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>Repeat Interval [in mills]</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="repeatInterval"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput placeholder="Repeat Interval [in mills]" name="repeatInterval" type="number"
|
||||
[(ngModel)]="simpleTriggerForm.repeatInterval"
|
||||
>
|
||||
@@ -70,7 +75,8 @@
|
||||
<div>
|
||||
<mat-form-field [appearance]="enabledTriggerForm ? 'standard': 'none'">
|
||||
<mat-label>Repeat Count</mat-label>
|
||||
<input [readonly]="!enabledTriggerForm"
|
||||
<input id="repeatCount"
|
||||
[readonly]="!enabledTriggerForm"
|
||||
matInput placeholder="Repeat Count (-1 REPEAT INDEFINITELY)" name="repeatCount" type="number"
|
||||
[(ngModel)]="simpleTriggerForm.repeatCount"
|
||||
>
|
||||
@@ -91,7 +97,7 @@
|
||||
|
||||
<button mat-raised-button
|
||||
type="button"
|
||||
*ngIf="enabledTriggerForm && !_newTriggerRequired"
|
||||
*ngIf="enabledTriggerForm"
|
||||
(click)="cancelConfigForm()">
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
@@ -11,13 +11,13 @@ import {MatIconModule} from '@angular/material/icon';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatNativeDateModule} from '@angular/material/core';
|
||||
import {MatDatepickerModule} from '@angular/material/datepicker';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {TriggerKey} from '../../model/triggerKey.model';
|
||||
import {Trigger} from '../../model/trigger.model';
|
||||
import {NgxMatDatetimePickerModule} from '@angular-material-components/datetime-picker';
|
||||
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
|
||||
import {JobDetail} from '../../model/jobDetail.model';
|
||||
import {SimpleTriggerForm} from '../../model/simple-trigger.form';
|
||||
import {SimpleTrigger} from '../../model/simple-trigger.model';
|
||||
|
||||
describe('SimpleTriggerConfig', () => {
|
||||
|
||||
@@ -44,6 +44,7 @@ describe('SimpleTriggerConfig', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SimpleTriggerConfigComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should fetch no triggers at the init', () => {
|
||||
@@ -51,6 +52,87 @@ describe('SimpleTriggerConfig', () => {
|
||||
httpTestingController.expectNone('/quartz-manager/simple-triggers/my-simple-trigger');
|
||||
});
|
||||
|
||||
function setInputValue(componentDe: DebugElement, inputSelector: string, value: string) {
|
||||
const inputDe = componentDe.query(By.css(inputSelector));
|
||||
const inputEl = inputDe.nativeElement;
|
||||
inputEl.value = value;
|
||||
inputEl.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
}
|
||||
|
||||
it('should emit an event when a new trigger is submitted', () => {
|
||||
const mockTrigger = new Trigger();
|
||||
mockTrigger.triggerKeyDTO = new TriggerKey('test-trigger', null);
|
||||
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: 'TestJob', description: null};
|
||||
|
||||
component.openTriggerForm();
|
||||
fixture.detectChanges();
|
||||
|
||||
const componentDe: DebugElement = fixture.debugElement;
|
||||
setInputValue(componentDe, '#triggerName', 'test-trigger');
|
||||
expect(component.simpleTriggerForm.triggerName).toEqual('test-trigger');
|
||||
setInputValue(componentDe, '#jobClass', 'TestJob');
|
||||
// setInputValue(componentDe, '#startDate', '19/11/2022, 10:34:00 PM');
|
||||
// setInputValue(componentDe, '#endDate', '21/11/2022, 10:34:00 PM');
|
||||
setInputValue(componentDe, '#repeatInterval', '2000');
|
||||
expect(component.simpleTriggerForm.repeatInterval).toEqual(2000);
|
||||
setInputValue(componentDe, '#repeatCount', '100');
|
||||
expect(component.simpleTriggerForm.repeatCount).toEqual(100);
|
||||
|
||||
const submitButton = componentDe.query(By.css('form > button[color="primary"]'));
|
||||
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
|
||||
|
||||
let actualNewTrigger;
|
||||
component.onNewTrigger.subscribe(simpleTrigger => actualNewTrigger = simpleTrigger);
|
||||
|
||||
submitButton.nativeElement.click();
|
||||
|
||||
const postSimpleTriggerReq = httpTestingController.expectOne('/quartz-manager/simple-triggers/test-trigger');
|
||||
postSimpleTriggerReq.flush(mockTrigger);
|
||||
|
||||
expect(actualNewTrigger).toEqual(mockTrigger);
|
||||
});
|
||||
|
||||
it('should not emit an event when an existing trigger is edited', () => {
|
||||
const mockTriggerKey = new TriggerKey('test-trigger', null);
|
||||
component.triggerKey = mockTriggerKey;
|
||||
fixture.detectChanges();
|
||||
|
||||
const mockTrigger = new SimpleTrigger();
|
||||
mockTrigger.triggerKeyDTO = new TriggerKey('test-trigger', null);
|
||||
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: 'TestJob', description: null};
|
||||
mockTrigger.mayFireAgain = true;
|
||||
const getSimpleTriggerReq = httpTestingController.expectOne('/quartz-manager/simple-triggers/test-trigger');
|
||||
getSimpleTriggerReq.flush(mockTrigger);
|
||||
|
||||
component.simpleTriggerForm = <SimpleTriggerForm>{
|
||||
triggerName: 'test-trigger',
|
||||
jobClass: 'TestJob',
|
||||
repeatInterval: 2000,
|
||||
repeatCount: 100
|
||||
};
|
||||
|
||||
component.openTriggerForm();
|
||||
fixture.detectChanges();
|
||||
|
||||
const componentDe: DebugElement = fixture.debugElement;
|
||||
setInputValue(componentDe, '#repeatInterval', '4000');
|
||||
expect(component.simpleTriggerForm.repeatInterval).toEqual(4000);
|
||||
|
||||
const submitButton = componentDe.query(By.css('form > button[color="primary"]'));
|
||||
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
|
||||
|
||||
let actualNewTrigger;
|
||||
component.onNewTrigger.subscribe(simpleTrigger => actualNewTrigger = simpleTrigger);
|
||||
|
||||
submitButton.nativeElement.click();
|
||||
|
||||
const putSimpleTriggerReq = httpTestingController.expectOne('/quartz-manager/simple-triggers/test-trigger');
|
||||
putSimpleTriggerReq.flush(mockTrigger);
|
||||
|
||||
expect(actualNewTrigger).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should fetch and display the trigger when the triggerKey is passed as input', () => {
|
||||
const mockTriggerKey = new TriggerKey('my-simple-trigger', null);
|
||||
component.triggerKey = mockTriggerKey;
|
||||
@@ -58,6 +140,7 @@ describe('SimpleTriggerConfig', () => {
|
||||
|
||||
const mockTrigger = new Trigger();
|
||||
mockTrigger.triggerKeyDTO = mockTriggerKey;
|
||||
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: 'TestJob', description: null};
|
||||
const getSimpleTriggerReq = httpTestingController.expectOne('/quartz-manager/simple-triggers/my-simple-trigger');
|
||||
getSimpleTriggerReq.flush(mockTrigger);
|
||||
|
||||
|
||||
@@ -85,7 +85,10 @@ export class SimpleTriggerConfigComponent implements OnInit {
|
||||
this.fetchedTriggers = true;
|
||||
this.triggerInProgress = this.trigger.mayFireAgain;
|
||||
|
||||
this.onNewTrigger.emit(retTrigger);
|
||||
if (schedulerServiceCall === this.schedulerService.saveSimpleTriggerConfig) {
|
||||
this.onNewTrigger.emit(retTrigger);
|
||||
}
|
||||
|
||||
this.closeTriggerForm();
|
||||
}, error => {
|
||||
this.simpleTriggerForm = this.formBackup;
|
||||
@@ -108,8 +111,8 @@ export class SimpleTriggerConfigComponent implements OnInit {
|
||||
simpleTriggerCommand.triggerName = simpleTriggerForm.triggerName;
|
||||
simpleTriggerCommand.repeatCount = simpleTriggerForm.repeatCount;
|
||||
simpleTriggerCommand.repeatInterval = simpleTriggerForm.repeatInterval;
|
||||
simpleTriggerCommand.startDate = simpleTriggerForm.startDate.toDate();
|
||||
simpleTriggerCommand.endDate = simpleTriggerForm.endDate.toDate();
|
||||
simpleTriggerCommand.startDate = simpleTriggerForm.startDate?.toDate();
|
||||
simpleTriggerCommand.endDate = simpleTriggerForm.endDate?.toDate();
|
||||
return simpleTriggerCommand;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<mat-card-content style="position: relative; height: 100%">
|
||||
<mat-nav-list style="overflow-y: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: auto; height: calc(100% - 3em)">
|
||||
<mat-list-item *ngFor="let triggerKey of getTriggerKeyList()" class="triggerItemList"
|
||||
[ngClass]="{'selectedTrigger': triggerKey.name == selectedTrigger.name}">
|
||||
[ngClass]="{'selectedTrigger': selectedTrigger && selectedTrigger.name==triggerKey.name}">
|
||||
<a matLine>{{ triggerKey.name }}</a>
|
||||
</mat-list-item>
|
||||
</mat-nav-list>
|
||||
|
||||
@@ -50,8 +50,7 @@ export class TriggerListComponent implements OnInit {
|
||||
this.triggerKeys = triggerKeys;
|
||||
if (!triggerKeys || triggerKeys.length === 0) {
|
||||
this.onNewTriggerBtnClicked();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.selectTrigger(this.triggerKeys[0]);
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user