Skip to content

Commit

Permalink
Merge pull request #50 from fabioformosa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fabioformosa authored Nov 2, 2021
2 parents d243c3a + 27fab8a commit 69e2ab3
Show file tree
Hide file tree
Showing 50 changed files with 1,659 additions and 641 deletions.
6 changes: 3 additions & 3 deletions quartz-manager-frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@
"defaultProject": "angular-spring-starter",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"prefix": "qrzmng",
"style": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
"prefix": "qrzmng"
}
}
}
}
5 changes: 4 additions & 1 deletion quartz-manager-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@fortawesome/fontawesome-free-regular": "^5.0.8",
"@fortawesome/fontawesome-free-solid": "^5.0.8",
"@stomp/ng2-stompjs": "^0.6.3",
"@types/jest": "^27.0.2",
"core-js": "2.5.1",
"hammerjs": "2.0.8",
"net": "^1.0.2",
Expand Down Expand Up @@ -65,6 +66,8 @@
},
"jest": {
"preset": "jest-preset-angular",
"setupFilesAfterEnv": ["<rootDir>/jest.setup.ts"]
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.ts"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,64 @@
<mat-card-header>
<mat-card-title><b>SCHEDULER CONFIG</b></mat-card-title>
</mat-card-header>
<mat-card-content>

<!-- ADD BUTTON -->
<mat-card-content *ngIf="!existsATriggerInProgress() && !enabledTriggerForm">
<button mat-fab color="primary">
<mat-icon (click)="enableTriggerForm()">add</mat-icon>
</button>
</mat-card-content>

<!-- TRIGGER DETAILS -->
<mat-card-content *ngIf="existsATriggerInProgress() || enabledTriggerForm">
<div fxLayout="column">
<form name="configForm" fxFlex="1 1 100%" #configForm="ngForm">
<mat-form-field>
<input matInput placeholder="Freq [Num per day]" [(ngModel)]="config.triggerPerDay" name="triggerPerDay" type="number">
<mat-form-field [appearance]="enabledTriggerForm ? 'fill': 'none'">
<mat-label>Freq [Num per day]</mat-label>
<input [readonly]="!enabledTriggerForm"
matInput placeholder="Freq [Num per day]" name="triggerPerDay" type="number"
[(ngModel)]="config.triggerPerDay"
>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Max Occurrences" [(ngModel)]="config.maxCount" name="maxCount" type="number">
<mat-form-field [appearance]="enabledTriggerForm ? 'fill': 'none'">
<mat-label>Max Occurrences</mat-label>
<input [readonly]="!enabledTriggerForm"
matInput placeholder="Max Occurrences" name="maxCount" type="number"
[(ngModel)]="config.maxCount"
>
</mat-form-field>

<br>

<div>
<h5>Misfire Policy</h5>
<div>RESCHEDULE NEXT WITH EXISTING COUNT</div>
<div>RESCHEDULE NEXT WITH REMAINING COUNT</div>
<div class="small">
In case of misfire event, the trigger is re-scheduled to the next scheduled time after 'now' with the repeat count left unchanged (missed events are definitively lost).
In case of misfire event, the trigger is re-scheduled to the next scheduled time after 'now' with the repeat count set to what it would be, if it had not missed any firings.
<br/>
<strong>Warning:</strong> This policy could cause the trigger to go directly to the complete state if the end-time of the trigger has arrived,
so this misfire instruction doesn't guarantee that the repeat counter reaches your max value, but it guarantees that the end-time doesn't go over the expected final fire time.
<strong>Warning:</strong> This policy could cause the Trigger to go directly to the 'COMPLETE' state if all fire-times where missed.
</div>
</div>

<br>

<button mat-raised-button
type="button"
*ngIf="enabledTriggerForm"
(click)="cancelConfigForm()">
Cancel
</button>
<button mat-raised-button
type="button"
type="button" color="primary"
*ngIf="enabledTriggerForm"
(click)="submitConfig()">
Submit
</button>
<button mat-raised-button type="button"
*ngIf="!enabledTriggerForm"
(click)="enabledTriggerForm = true">
Reschedule
</button>
</form>
</div>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,69 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { SchedulerService } from '../../services';
import { SchedulerConfig } from '../../model/schedulerConfig.model'
import {Scheduler} from '../../model/scheduler.model';

@Component({
selector: 'scheduler-config',
selector: 'qrzmng-scheduler-config',
templateUrl: './scheduler-config.component.html',
styleUrls: ['./scheduler-config.component.scss']
})
export class SchedulerConfigComponent implements OnInit {

config: SchedulerConfig = new SchedulerConfig()
configBackup: SchedulerConfig = new SchedulerConfig()
scheduler: Scheduler;

triggerLoading = true;
enabledTriggerForm = false;
private fetchedTriggers = false;
private triggerInProgress = false;

constructor(
private schedulerService: SchedulerService
) { }

config : SchedulerConfig = new SchedulerConfig()
configBackup : SchedulerConfig = new SchedulerConfig()

ngOnInit() {
this.retrieveConfig()
this.triggerLoading = true;
this._getScheduler();
this.retrieveConfig();
}

retrieveConfig = () => {
this.schedulerService.getConfig()
.subscribe(res => {
this.config = new SchedulerConfig(res.triggerPerDay, res.maxCount)
this.config = new SchedulerConfig(res.triggerPerDay, res.maxCount, res.timesTriggered)
this.configBackup = res
this.triggerLoading = false;
this.triggerInProgress = res.timesTriggered < res.maxCount;
})
}

private _getScheduler() {
this.schedulerService.getScheduler()
.subscribe( res => {
this.scheduler = <Scheduler>res;
this.fetchedTriggers = this.scheduler.triggerKeys.length > 0
})
}

existsATriggerInProgress = (): boolean => this.fetchedTriggers && this.triggerInProgress;

cancelConfigForm = () => this.enabledTriggerForm = false;

submitConfig = () => {
this.schedulerService.updateConfig(this.config)
const schedulerServiceCall = this.existsATriggerInProgress() ? this.schedulerService.updateConfig : this.schedulerService.saveConfig;

schedulerServiceCall(this.config)
.subscribe(res => {
this.configBackup = this.config;
this.enabledTriggerForm = false;
this.fetchedTriggers = true;
this.triggerInProgress = true;
}, error => {
this.config = this.configBackup;
});
};

enableTriggerForm = () => this.enabledTriggerForm = true;
}
105 changes: 105 additions & 0 deletions quartz-manager-frontend/src/app/guards/admin.guard.disabledspec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { TestBed, async, inject } from '@angular/core/testing';
import { Router } from '@angular/router';
import { NO_AUTH, UserService } from '../services';
import { AdminGuard } from './admin.guard';
import {jest} from '@jest/globals'

export class RouterStub {
navigate(commands?: any[], extras?: any) {}
}

const RouterSpy = jest.spyOn(RouterStub.prototype, 'navigate');

const MockUserServiceNoAuth = jest.fn(() => ({currentUser: NO_AUTH}));
const MockUserService = jest.fn(() => ({
currentUser: {
authorities: ['ROLE_ADMIN']
}
}));
const MockUserServiceForbidden = jest.fn(() => ({
currentUser: {
authorities: ['ROLE_GUEST']
}
}));

// describe('AdminGuard NoAuth', () => {
// beforeEach(() => {
// TestBed.configureTestingModule({
// providers: [
// AdminGuard,
// {
// provide: Router,
// useClass: RouterStub
// },
// {
// provide: UserService,
// useClass: MockUserServiceNoAuth
// }
// ]
// });
// });
//
// test.skip('should run', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard).toBeTruthy();
// }));
//
// test.skip('returns true if user is NO_AUTH', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard.canActivate(null, null)).toBeTruthy();
// }));
//
// });

// describe('AdminGuard activates the route', () => {
// beforeEach(() => {
// TestBed.configureTestingModule({
// providers: [
// AdminGuard,
// {
// provide: Router,
// useClass: RouterStub
// },
// {
// provide: UserService,
// useClass: MockUserService
// }
// ]
// });
// });
//
// test.skip('should run', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard).toBeTruthy();
// }));
//
// test.skip('returns true if user has admin role', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard.canActivate(null, null)).toBeTruthy();
// }));
//
// });

// describe('AdminGuard redirects to 403', () => {
// beforeEach(() => {
// TestBed.configureTestingModule({
// providers: [
// AdminGuard,
// {
// provide: Router,
// useClass: RouterStub
// },
// {
// provide: UserService,
// useClass: MockUserServiceForbidden
// }
// ]
// });
// });
//
// test.skip('should run', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard).toBeTruthy();
// }));
//
// test.skip('returns false if user is not authorized', inject([AdminGuard], (guard: AdminGuard) => {
// expect(guard.canActivate(null, null)).toBeFalsy();
// expect(RouterSpy).toHaveBeenCalledTimes(1);
// }));
//
// });
105 changes: 0 additions & 105 deletions quartz-manager-frontend/src/app/guards/admin.guard.spec.ts

This file was deleted.

Loading

0 comments on commit 69e2ab3

Please sign in to comment.