This commit is contained in:
Maximilian Krambach 2019-04-26 13:56:49 +02:00 committed by Emanuel Schütze
parent 78d107e37c
commit efbce9b645
4 changed files with 61 additions and 15 deletions

View File

@ -1,17 +1,17 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { MatSnackBar } from '@angular/material'; import { MatSnackBar } from '@angular/material';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { BaseViewComponent } from 'app/site/base/base-view'; import { BaseViewComponent } from 'app/site/base/base-view';
import { ViewProjector } from '../../models/view-projector';
import { ProjectorElements, ProjectorElement } from 'app/shared/models/core/projector';
import { Mediafile } from 'app/shared/models/mediafiles/mediafile'; import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
import { MediafileRepositoryService } from 'app/core/repositories/mediafiles/mediafile-repository.service'; import { MediafileRepositoryService } from 'app/core/repositories/mediafiles/mediafile-repository.service';
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile'; import { ProjectorElements, ProjectorElement } from 'app/shared/models/core/projector';
import { SlideManager } from 'app/slides/services/slide-manager.service';
import { ProjectorService } from 'app/core/core-services/projector.service'; import { ProjectorService } from 'app/core/core-services/projector.service';
import { SlideManager } from 'app/slides/services/slide-manager.service';
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
import { ViewProjector } from '../../models/view-projector';
/** /**
* The presentation controls. * The presentation controls.
@ -40,6 +40,16 @@ export class PresentationControlComponent extends BaseViewComponent {
// All mediafile elements. // All mediafile elements.
public elements: ProjectorElements = []; public elements: ProjectorElements = [];
/**
* Constructor
*
* @param titleService
* @param translate
* @param matSnackBar
* @param mediafileRepo
* @param slideManager
* @param projectorService
*/
public constructor( public constructor(
titleService: Title, titleService: Title,
translate: TranslateService, translate: TranslateService,
@ -51,6 +61,9 @@ export class PresentationControlComponent extends BaseViewComponent {
super(titleService, translate, matSnackBar); super(titleService, translate, matSnackBar);
} }
/**
* Updates incoming elements
*/
private updateElements(): void { private updateElements(): void {
this.elements = this.projector.elements.filter(element => { this.elements = this.projector.elements.filter(element => {
if (element.name !== Mediafile.COLLECTIONSTRING && !element.id) { if (element.name !== Mediafile.COLLECTIONSTRING && !element.id) {
@ -65,26 +78,48 @@ export class PresentationControlComponent extends BaseViewComponent {
return this.mediafileRepo.getViewModel(element.id); return this.mediafileRepo.getViewModel(element.id);
} }
/**
* @returns the currently used page number (1 in case of unnumbered elements)
*/
public getPage(element: ProjectorElement): number { public getPage(element: ProjectorElement): number {
return element.page || 1; return element.page || 1;
} }
/**
* moves the projected forward by one page (if not already at end)
*
* @param element
*/
public pdfForward(element: ProjectorElement): void { public pdfForward(element: ProjectorElement): void {
if (this.getPage(element) < this.getMediafile(element).pages) { if (this.getPage(element) < this.getMediafile(element).pages) {
this.pdfSetPage(element, this.getPage(element) + 1); this.pdfSetPage(element, this.getPage(element) + 1);
} }
} }
/**
* moves the projected one page backwards (if not already at beginnning)
*
* @param element
*/
public pdfBackward(element: ProjectorElement): void { public pdfBackward(element: ProjectorElement): void {
if (this.getPage(element) > 1) { if (this.getPage(element) > 1) {
this.pdfSetPage(element, this.getPage(element) - 1); this.pdfSetPage(element, this.getPage(element) - 1);
} }
} }
/**
* Moves the element to a specific given page. If the number given is greater
* than the amount of element pages, it does nothing
*
* @param element
* @param page
*/
public pdfSetPage(element: ProjectorElement, page: number): void { public pdfSetPage(element: ProjectorElement, page: number): void {
const idElement = this.slideManager.getIdentifialbeProjectorElement(element); const idElement = this.slideManager.getIdentifialbeProjectorElement(element);
idElement.page = page; if (this.getMediafile(element).pages >= page) {
this.projectorService.updateElement(this.projector.projector, idElement).then(null, this.raiseError); idElement.page = page;
this.projectorService.updateElement(this.projector.projector, idElement).then(null, this.raiseError);
}
} }
public pdfZoom(element: ProjectorElement, direction: 'in' | 'out' | 'reset'): void {} public pdfZoom(element: ProjectorElement, direction: 'in' | 'out' | 'reset'): void {}

View File

@ -262,6 +262,15 @@
</mat-list-item> </mat-list-item>
</mat-list> </mat-list>
</mat-expansion-panel> </mat-expansion-panel>
<!-- File display controls -->
<mat-expansion-panel>
<mat-expansion-panel-header>
<span translate>Media controls</span>
</mat-expansion-panel-header>
<os-presentation-control [projector]="projector">
</os-presentation-control>
</mat-expansion-panel>
</mat-accordion> </mat-accordion>
</div> </div>
</div> </div>

View File

@ -1,16 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ProjectorRoutingModule } from './projector-routing.module';
import { SharedModule } from '../../shared/shared.module';
import { ProjectorListComponent } from './components/projector-list/projector-list.component';
import { ProjectorDetailComponent } from './components/projector-detail/projector-detail.component';
import { CountdownControlsComponent } from './components/countdown-controls/countdown-controls.component'; import { CountdownControlsComponent } from './components/countdown-controls/countdown-controls.component';
import { CountdownDialogComponent } from './components/countdown-dialog/countdown-dialog.component'; import { CountdownDialogComponent } from './components/countdown-dialog/countdown-dialog.component';
import { MessageControlsComponent } from './components/message-controls/message-controls.component'; import { MessageControlsComponent } from './components/message-controls/message-controls.component';
import { MessageDialogComponent } from './components/message-dialog/message-dialog.component'; import { MessageDialogComponent } from './components/message-dialog/message-dialog.component';
import { PresentationControlComponent } from './components/presentation-control/presentation-control.component'; import { PresentationControlComponent } from './components/presentation-control/presentation-control.component';
import { ProjectorDetailComponent } from './components/projector-detail/projector-detail.component';
import { ProjectorListComponent } from './components/projector-list/projector-list.component';
import { ProjectorListEntryComponent } from './components/projector-list-entry/projector-list-entry.component'; import { ProjectorListEntryComponent } from './components/projector-list-entry/projector-list-entry.component';
import { ProjectorRoutingModule } from './projector-routing.module';
import { SharedModule } from '../../shared/shared.module';
@NgModule({ @NgModule({
imports: [CommonModule, ProjectorRoutingModule, SharedModule], imports: [CommonModule, ProjectorRoutingModule, SharedModule],
@ -21,12 +21,14 @@ import { ProjectorListEntryComponent } from './components/projector-list-entry/p
CountdownControlsComponent, CountdownControlsComponent,
CountdownDialogComponent, CountdownDialogComponent,
MessageControlsComponent, MessageControlsComponent,
MessageDialogComponent MessageDialogComponent,
PresentationControlComponent
], ],
entryComponents: [ entryComponents: [
CountdownDialogComponent, CountdownDialogComponent,
MessageDialogComponent, MessageDialogComponent,
PresentationControlComponent PresentationControlComponent,
ProjectorListEntryComponent
] ]
}) })
export class ProjectorModule {} export class ProjectorModule {}

View File

@ -4,8 +4,8 @@ import { CommonModule } from '@angular/common';
import { PdfViewerModule } from 'ng2-pdf-viewer'; import { PdfViewerModule } from 'ng2-pdf-viewer';
import { MediafileSlideComponent } from './mediafile-slide.component'; import { MediafileSlideComponent } from './mediafile-slide.component';
import { SLIDE } from 'app/slides/slide-token';
import { SharedModule } from 'app/shared/shared.module'; import { SharedModule } from 'app/shared/shared.module';
import { SLIDE } from 'app/slides/slide-token';
@NgModule({ @NgModule({
imports: [CommonModule, SharedModule, PdfViewerModule], imports: [CommonModule, SharedModule, PdfViewerModule],