#103 step into accomodating the new trigger logic

This commit is contained in:
Fabio Formosa
2024-02-02 22:58:56 +01:00
parent 727a11fcea
commit 412e455907
5 changed files with 38 additions and 12 deletions

View File

@@ -222,6 +222,13 @@ describe('SimpleTriggerConfig', () => {
const componentDe: DebugElement = fixture.debugElement;
const submitButton = componentDe.query(By.css('form button[color="primary"]'));
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
expect(component.simpleTriggerReactiveForm.value.triggerName).toBeNull();
});
it('should reset the form when a new trigger is selected', () => {
});
it('should display the warning if there are no eligible jobs', () => {

View File

@@ -34,9 +34,8 @@ export class SimpleTriggerConfigComponent implements OnInit {
scheduler: Scheduler;
triggerLoading = true;
triggerLoading = false;
private fetchedTriggers = false;
private triggerInProgress = false;
private selectedTriggerKey: TriggerKey;
@@ -64,6 +63,9 @@ export class SimpleTriggerConfigComponent implements OnInit {
}
openTriggerForm() {
// this.selectedTriggerKey = null;
// this.trigger = null;
// this.simpleTriggerReactiveForm.setValue(new SimpleTriggerReactiveForm());
this.enabledTriggerForm = true;
}
@@ -73,13 +75,26 @@ export class SimpleTriggerConfigComponent implements OnInit {
@Input()
set triggerKey(triggerKey: TriggerKey) {
if (!this.selectedTriggerKey || this.selectedTriggerKey.name !== triggerKey.name){
if (!triggerKey) {
this.selectedTriggerKey = null;
this.trigger = null;
this.simpleTriggerReactiveForm.reset(new SimpleTriggerReactiveForm());
} else if (!this.selectedTriggerKey || this.selectedTriggerKey.name !== triggerKey.name) {
this._resetTheTrigger();
this.selectedTriggerKey = {...triggerKey} as TriggerKey;
this.fetchSelectedTrigger();
}
this.openTriggerForm();
}
private _resetTheTrigger() {
this.trigger = null;
this.triggerInProgress = false;
this.selectedTriggerKey = null;
this.simpleTriggerReactiveForm.reset(new SimpleTriggerReactiveForm());
}
fetchSelectedTrigger = () => {
this.triggerLoading = true;
this.schedulerService.getSimpleTriggerConfig(this.selectedTriggerKey.name)
@@ -105,13 +120,13 @@ export class SimpleTriggerConfigComponent implements OnInit {
this.schedulerService.updateSimpleTriggerConfig : this.schedulerService.saveSimpleTriggerConfig;
const simpleTriggerCommand = this._fromReactiveFormToCommand();
this.triggerLoading = true;
schedulerServiceCall(simpleTriggerCommand)
.subscribe((retTrigger: SimpleTrigger) => {
this.trigger = retTrigger;
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(retTrigger));
this.fetchedTriggers = true;
this.triggerInProgress = this.trigger.mayFireAgain;
if (schedulerServiceCall === this.schedulerService.saveSimpleTriggerConfig) {
@@ -121,7 +136,7 @@ export class SimpleTriggerConfigComponent implements OnInit {
this.closeTriggerForm();
}, error => {
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(this.trigger));
});
}, () => {this.triggerLoading = true});
}

View File

@@ -9,7 +9,9 @@
<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': selectedTrigger && selectedTrigger.name==triggerKey.name}">
[ngClass]="{'selectedTrigger': selectedTrigger && selectedTrigger.name==triggerKey.name}"
(click)="selectTrigger(triggerKey)"
>
<a matLine>{{ triggerKey.name }}</a>
</mat-list-item>
</mat-nav-list>

View File

@@ -81,11 +81,12 @@ export class TriggerListComponent implements OnInit {
}
onNewTriggerBtnClicked() {
if (this.getTriggerKeyList() && this.getTriggerKeyList().length > 0) {
this.dialog.open(UnsupportedMultipleJobsDialog)
} else {
this.onNewTriggerClicked.emit();
}
this.onNewTriggerClicked.emit();
// if (this.getTriggerKeyList() && this.getTriggerKeyList().length > 0) {
// this.dialog.open(UnsupportedMultipleJobsDialog)
// } else {
// this.onNewTriggerClicked.emit();
// }
}
onNewTrigger(newTrigger: SimpleTrigger) {

View File

@@ -32,7 +32,8 @@ export class ManagerComponent implements OnInit {
}
onNewTriggerRequested() {
this.triggerConfigComponent.openTriggerForm();
this.selectedTriggerKey = null;
// this.triggerConfigComponent.openTriggerForm();
}
onNewTriggerCreated(newTrigger: SimpleTrigger) {