diff --git a/client/src/app/core/ui-services/projection-dialog.service.ts b/client/src/app/core/ui-services/projection-dialog.service.ts index 6c137b7cf..11d19d40b 100644 --- a/client/src/app/core/ui-services/projection-dialog.service.ts +++ b/client/src/app/core/ui-services/projection-dialog.service.ts @@ -34,7 +34,7 @@ export class ProjectionDialogService { * * @param obj The projectable. */ - public async openProjectDialogFor(obj: Projectable | ProjectorElementBuildDeskriptor): Promise { + public async openProjectDialogFor(obj: Projectable | ProjectorElementBuildDeskriptor): Promise { let descriptor: ProjectorElementBuildDeskriptor; if (isProjectable(obj)) { descriptor = obj.getSlide(this.configService); @@ -55,10 +55,12 @@ export class ProjectionDialogService { const [action, projectors, projectorElement]: ProjectionDialogReturnType = response; if (action === 'project') { this.projectorService.projectOnMultiple(projectors, projectorElement); + return { fullscreen: projectorElement.fullscreen, displayType: projectorElement.displayType }; } else if (action === 'addToPreview') { projectors.forEach(projector => { this.projectorService.addElementToPreview(projector, projectorElement); }); + return null; } } } diff --git a/client/src/app/shared/components/projector-button/projector-button.component.ts b/client/src/app/shared/components/projector-button/projector-button.component.ts index 4a81beb25..60e8d1ad7 100644 --- a/client/src/app/shared/components/projector-button/projector-button.component.ts +++ b/client/src/app/shared/components/projector-button/projector-button.component.ts @@ -4,9 +4,10 @@ import { Subscription } from 'rxjs'; import { distinctUntilChanged } from 'rxjs/operators'; import { ProjectorService } from 'app/core/core-services/projector.service'; +import { StorageService } from 'app/core/core-services/storage.service'; import { ProjectorRepositoryService } from 'app/core/repositories/projector/projector-repository.service'; import { ProjectionDialogService } from 'app/core/ui-services/projection-dialog.service'; -import { Projector } from 'app/shared/models/core/projector'; +import { IdentifiableProjectorElement, Projector } from 'app/shared/models/core/projector'; import { isProjectable, isProjectorElementBuildDeskriptor, @@ -71,7 +72,8 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy { public constructor( private projectorRepo: ProjectorRepositoryService, private projectionDialogService: ProjectionDialogService, - private projectorService: ProjectorService + private projectorService: ProjectorService, + private storage: StorageService ) {} /** @@ -104,7 +106,7 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy { * * @param event the click event */ - public onClick(event?: Event): void { + public async onClick(event?: Event): Promise { if (event) { event.stopPropagation(); } @@ -115,8 +117,11 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy { // remove the projected object this.projectorService.removeFrom(this.projector, this.object); } else { + const projectorElement = this.getProjectorElement( + await this.storage.get('projectorElementOptions') + ); // instantly project the object - this.projectorService.projectOn(this.projector, this.object); + this.projectorService.projectOn(this.projector, projectorElement || this.object); } } else { // open the projection dialog @@ -139,4 +144,17 @@ export class ProjectorButtonComponent implements OnInit, OnDestroy { ? this.projectorService.isProjectedOn(this.object, this.projector) : this.projectorService.isProjected(this.object); } + + /** + * @param options The previous configured options of a projector. + */ + private getProjectorElement(options: object): IdentifiableProjectorElement | null { + let element = null; + if (isProjectable(this.object)) { + element = this.object.getSlide().getBasicProjectorElement(options); + } else if (isProjectorElementBuildDeskriptor(this.object)) { + element = this.object.getBasicProjectorElement(options); + } + return Object.assign(element, options); + } } diff --git a/client/src/app/site/projector/components/countdown-controls/countdown-controls.component.ts b/client/src/app/site/projector/components/countdown-controls/countdown-controls.component.ts index 732e515b8..46c9eac03 100644 --- a/client/src/app/site/projector/components/countdown-controls/countdown-controls.component.ts +++ b/client/src/app/site/projector/components/countdown-controls/countdown-controls.component.ts @@ -4,6 +4,7 @@ import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; +import { StorageService } from 'app/core/core-services/storage.service'; import { CountdownRepositoryService } from 'app/core/repositories/projector/countdown-repository.service'; import { ConfigService } from 'app/core/ui-services/config.service'; import { ProjectionDialogService } from 'app/core/ui-services/projection-dialog.service'; @@ -44,6 +45,11 @@ export class CountdownControlsComponent extends BaseViewComponent { */ public warningTime: number; + /** + * The key to storage. + */ + private storageKey = 'projectorElementOptions'; + /** * Constructor * @@ -61,7 +67,8 @@ export class CountdownControlsComponent extends BaseViewComponent { private repo: CountdownRepositoryService, private configService: ConfigService, private promptService: PromptService, - private projectionDialogService: ProjectionDialogService + private projectionDialogService: ProjectionDialogService, + private storage: StorageService ) { super(titleService, translate, matSnackBar); @@ -110,7 +117,9 @@ export class CountdownControlsComponent extends BaseViewComponent { * Brings the projection dialog */ public onBringDialog(): void { - this.projectionDialogService.openProjectDialogFor(this.countdown); + this.projectionDialogService + .openProjectDialogFor(this.countdown) + .then(options => this.storeSettings(options), null); } /** @@ -123,4 +132,13 @@ export class CountdownControlsComponent extends BaseViewComponent { this.repo.delete(this.countdown).then(() => {}, this.raiseError); } } + + /** + * Stores the options for a projector in the local-storage. + * + * @param element The configured options for projector + */ + private storeSettings(element: object): void { + this.storage.set(this.storageKey, element); + } }