diff --git a/src/app/group-monitor/group-monitor.component.html b/src/app/group-monitor/group-monitor.component.html index dc806f64b68c666413b4e990d712adad614ff9ac..5ef4de7b00ded5fdc2e29967172e39f3732a3718 100644 --- a/src/app/group-monitor/group-monitor.component.html +++ b/src/app/group-monitor/group-monitor.component.html @@ -77,11 +77,11 @@ </div> <div class="toolbar-section"> - <button mat-raised-button class="control" color="primary" (click)="testCommandResume()" [disabled]="!countCheckedSessions()"> + <button mat-raised-button class="control" color="primary" (click)="testCommandResume()" [disabled]="!isResumeAllowed()"> <mat-icon>play_arrow</mat-icon>WEITER </button> - <button mat-raised-button class="control" color="primary" (click)="testCommandPause()" [disabled]="!countCheckedSessions()"> + <button mat-raised-button class="control" color="primary" (click)="testCommandPause()" [disabled]="!isPauseAllowed()"> <mat-icon>pause</mat-icon>PAUSE </button> </div> diff --git a/src/app/group-monitor/group-monitor.component.ts b/src/app/group-monitor/group-monitor.component.ts index f5e0416199d496573881703fe7aac25b70f78b8a..206a195236d699c8461fb26c9dfa270a05c600ae 100644 --- a/src/app/group-monitor/group-monitor.component.ts +++ b/src/app/group-monitor/group-monitor.component.ts @@ -93,6 +93,10 @@ export class GroupMonitorComponent implements OnInit, OnDestroy { return session.personId * 10000 + session.testId; } + private static hasState(state: object, key: string, value: any = null): boolean { + return ((typeof state[key] !== 'undefined') && ((value !== null) ? (state[key] === value) : true)); + } + ngOnInit(): void { this.routingSubscription = this.route.params.subscribe(params => { this.ownGroup$ = this.bs.getGroupData(params['group-name']); @@ -232,14 +236,16 @@ export class GroupMonitorComponent implements OnInit, OnDestroy { testCommandResume() { const testIds = Object.values(this.checkedSessions) - .filter(session => session.testId && session.testId > -1) // TODO only paused tests... + .filter(session => session.testId && session.testId > -1) + .filter(session => GroupMonitorComponent.hasState(session.testState, 'CONTROLLER', 'PAUSED')) .map(session => session.testId); this.bs.command('resume', [], testIds); } testCommandPause() { const testIds = Object.values(this.checkedSessions) - .filter(session => session.testId && session.testId > -1) // TODO filter paused tests... + .filter(session => session.testId && session.testId > -1) + .filter(session => !GroupMonitorComponent.hasState(session.testState, 'CONTROLLER', 'PAUSED')) .map(session => session.testId); this.bs.command('pause', [], testIds); } @@ -247,7 +253,7 @@ export class GroupMonitorComponent implements OnInit, OnDestroy { testCommandGoto() { if ((this.sessionCheckedGroupCount === 1) && (Object.keys(this.checkedSessions).length > 0)) { const testIds = Object.values(this.checkedSessions) - .filter(session => session.testId && session.testId > -1) // TODO filter paused tests... + .filter(session => session.testId && session.testId > -1) .map(session => session.testId); this.bs.command('goto', ['id', GroupMonitorComponent.getFirstUnit(this.selectedElement.element).id], testIds); } @@ -342,4 +348,16 @@ export class GroupMonitorComponent implements OnInit, OnDestroy { this.selectedElement = null; } } + + isPauseAllowed(): boolean { + return Object.values(this.checkedSessions) + .filter(session => GroupMonitorComponent.hasState(session.testState, 'CONTROLLER', 'PAUSED')) + .length === 0; + } + + isResumeAllowed() { + return Object.values(this.checkedSessions) + .filter(session => !GroupMonitorComponent.hasState(session.testState, 'CONTROLLER', 'PAUSED')) + .length === 0; + } } diff --git a/src/app/group-monitor/test-view/test-view.component.css b/src/app/group-monitor/test-view/test-view.component.css index 6cb437d187c7797e808b0dfb7f872d8dd2057744..6c97a4a8f1d7e652fc9b9aa3f4c4f457c16eaad6 100644 --- a/src/app/group-monitor/test-view/test-view.component.css +++ b/src/app/group-monitor/test-view/test-view.component.css @@ -63,6 +63,7 @@ mat-icon + h1 { background: #001C1C; } +.pending .unit, .locked .unit { background: #333333; } @@ -87,6 +88,7 @@ mat-icon + h1 { color: #333333; } +.pending .unit.current, .locked .unit.current { background: #b2b2b2; color: #333333; diff --git a/src/app/group-monitor/test-view/test-view.component.html b/src/app/group-monitor/test-view/test-view.component.html index 75479b975ca6377dc05a7d809516f62dc5899d23..c465f9a9fed398d97924d4ea18985ec7ead63ec8 100644 --- a/src/app/group-monitor/test-view/test-view.component.html +++ b/src/app/group-monitor/test-view/test-view.component.html @@ -101,7 +101,8 @@ [class]="{ locked: hasState(testSession.testState, 'status', 'locked'), paused: hasState(testSession.testState, 'CONTROLLER', 'PAUSED'), - error: hasState(testSession.testState, 'CONTROLLER', 'ERROR') + error: hasState(testSession.testState, 'CONTROLLER', 'ERROR'), + pending: !hasState(testSession.testState, 'CONTROLLER') }" [ngSwitch]="displayOptions.view" (mouseleave)="mark()"