From 23c704b5da387817741383a861f5759e86931160 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 10 Jul 2019 12:57:48 +0200 Subject: [PATCH] Projector improvements - Moved projector configs to group "General" - Removed unused projector config related to CLOS - debounce projector data requests for many projectors - add (foreground) color - custom, modifiable CSS classes per projector to cascade dynamic styles into slides --- .../core-services/projector-data.service.ts | 26 ++- .../projector/projector.component.html | 8 +- .../projector/projector.component.scss | 11 -- .../projector/projector.component.ts | 137 +++++++++++----- .../src/app/shared/models/core/projector.ts | 1 + .../projector-list-entry.component.html | 21 ++- .../projector-list-entry.component.ts | 45 +++++- .../site/projector/models/view-projector.ts | 4 + openslides/core/config_variables.py | 152 +++++++++--------- .../core/migrations/0025_projector_color.py | 16 ++ openslides/core/models.py | 1 + openslides/core/serializers.py | 1 + 12 files changed, 279 insertions(+), 144 deletions(-) create mode 100644 openslides/core/migrations/0025_projector_color.py diff --git a/client/src/app/core/core-services/projector-data.service.ts b/client/src/app/core/core-services/projector-data.service.ts index 1773496de..ab5a4d6a2 100644 --- a/client/src/app/core/core-services/projector-data.service.ts +++ b/client/src/app/core/core-services/projector-data.service.ts @@ -1,9 +1,10 @@ import { Injectable } from '@angular/core'; -import { Observable, BehaviorSubject } from 'rxjs'; +import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { WebsocketService } from 'app/core/core-services/websocket.service'; import { ProjectorElement, Projector } from 'app/shared/models/core/projector'; +import { auditTime } from 'rxjs/operators'; export interface SlideData { data: T; @@ -36,12 +37,19 @@ export class ProjectorDataService { */ private currentProjectorData: { [id: number]: BehaviorSubject } = {}; + /** + * When multiple projectory are requested, debounce these requests to just issue + * one request, with all the needed projectors. + */ + private readonly updateProjectorDataDebounceSubject = new Subject(); + /** * Constructor. * * @param websocketService */ public constructor(private websocketService: WebsocketService) { + // Dispatch projector data. this.websocketService.getOberservable('projector').subscribe((update: AllProjectorData) => { Object.keys(update).forEach(_id => { const id = parseInt(_id, 10); @@ -51,7 +59,16 @@ export class ProjectorDataService { }); }); + // The service need to re-register, if the websocket connection was lost. this.websocketService.generalConnectEvent.subscribe(() => this.updateProjectorDataSubscription()); + + // With a bit of debounce, update the needed projectors. + this.updateProjectorDataDebounceSubject.pipe(auditTime(10)).subscribe(() => { + const allActiveProjectorIds = Object.keys(this.openProjectorInstances) + .map(id => parseInt(id, 10)) + .filter(id => this.openProjectorInstances[id] > 0); + this.websocketService.send('listenToProjectors', { projector_ids: allActiveProjectorIds }); + }); } /** @@ -94,13 +111,10 @@ export class ProjectorDataService { } /** - * Gets initial data and keeps reuesting data. + * Requests to update the data subscription to the server. */ private updateProjectorDataSubscription(): void { - const allActiveProjectorIds = Object.keys(this.openProjectorInstances) - .map(id => parseInt(id, 10)) - .filter(id => this.openProjectorInstances[id] > 0); - this.websocketService.send('listenToProjectors', { projector_ids: allActiveProjectorIds }); + this.updateProjectorDataDebounceSubject.next(); } /** diff --git a/client/src/app/shared/components/projector/projector.component.html b/client/src/app/shared/components/projector/projector.component.html index a186e4bcf..8f8dfd9b5 100644 --- a/client/src/app/shared/components/projector/projector.component.html +++ b/client/src/app/shared/components/projector/projector.component.html @@ -1,11 +1,11 @@ -
-
+
+
fiber_manual_record
-