-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from fabioformosa/develop
Develop
- Loading branch information
Showing
50 changed files
with
1,659 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 36 additions & 7 deletions
43
quartz-manager-frontend/src/app/components/scheduler-config/scheduler-config.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
105
quartz-manager-frontend/src/app/guards/admin.guard.disabledspec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
105
quartz-manager-frontend/src/app/guards/admin.guard.spec.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.