Display the next service item in Stage View.

This commit is contained in:
Chris Witterholt 2023-05-02 05:14:43 +00:00 committed by Raoul Snyman
parent 87159eb637
commit 5691809791
3 changed files with 36 additions and 10 deletions

View File

@ -39,6 +39,9 @@
<mat-icon>keyboard_arrow_up</mat-icon> <mat-icon>keyboard_arrow_up</mat-icon>
</button> </button>
</div> </div>
<div class="next-service-item" [matTooltip]="'Next item'" *ngIf="!embedded && activeSlide+1 === currentSlides.length">
{{ nextServiceItemTitle }}
</div>
<div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div> <div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div>
</div> </div>
</div> </div>

View File

@ -28,6 +28,9 @@
> >
<mat-icon>sticky_note_2</mat-icon> <mat-icon>sticky_note_2</mat-icon>
</button> </button>
<div class="next-service-item" [matTooltip]="'Next item'" *ngIf="!embedded && activeSlide+1 === currentSlides.length">
{{ nextServiceItemTitle }}
</div>
<div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div> <div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div>
</div> </div>
<div class="sidebar" *ngIf="(showNotes || embedded) && notes"> <div class="sidebar" *ngIf="(showNotes || embedded) && notes">

View File

@ -19,6 +19,7 @@ interface Tag {
export class StageViewComponent implements OnInit, OnDestroy { export class StageViewComponent implements OnInit, OnDestroy {
@Input() embedded = false; @Input() embedded = false;
serviceItem: ServiceItem = null; serviceItem: ServiceItem = null;
nextServiceItemTitle = '';
notes = ''; notes = '';
currentSlides: Slide[] = []; currentSlides: Slide[] = [];
activeSlide = 0; activeSlide = 0;
@ -45,7 +46,9 @@ export class StageViewComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.updateCurrentSlides(null, null); this.updateCurrentSlides(null, null);
this.openlpService.stateChanged$.subscribe(item => this.updateCurrentSlides(item.item, item.slide)); this.openlpService.stateChanged$.subscribe((item: { item: string; slide: number }) =>
this.updateCurrentSlides(item.item, item.slide)
);
this.fontScale = this.settingsService.get( this.fontScale = this.settingsService.get(
this.stageProperty + 'FontScale' as keyof SettingsProperties this.stageProperty + 'FontScale' as keyof SettingsProperties
) as number / 100; ) as number / 100;
@ -62,21 +65,38 @@ export class StageViewComponent implements OnInit, OnDestroy {
this.fontScaleSubscription$?.unsubscribe(); this.fontScaleSubscription$?.unsubscribe();
} }
updateCurrentSlides(serviceItemId: string, currentSlide: number): void { updateCurrentSlides(_serviceItemId: string, currentSlide: number): void {
this.serviceItemSubscription$?.unsubscribe(); this.serviceItemSubscription$?.unsubscribe();
this.serviceItemSubscription$ = this.openlpService.getServiceItem().subscribe(serviceItem => { this.serviceItemSubscription$ = this.openlpService.getServiceItem().subscribe(currentServiceItem => {
this.serviceItem = serviceItem; this.serviceItem = currentServiceItem;
if (serviceItem instanceof Array) { if (currentServiceItem instanceof Array) {
this.setNewSlides(serviceItem, currentSlide); this.setNewSlides(currentServiceItem, currentSlide);
} }
else { else {
this.setNewSlides(serviceItem.slides, currentSlide); this.setNewSlides(currentServiceItem.slides, currentSlide);
this.setNotes(serviceItem.notes); this.setNotes(currentServiceItem.notes);
} }
this.getNextServiceItemTitle();
}); });
} }
setNewSlides(slides: Slide[], currentSlide: number): void { getNextServiceItemTitle(): void {
this.nextServiceItemTitle = '';
let doStoreServiceItemTitle = false;
this.openlpService.getServiceItems().subscribe(serviceItems => {
serviceItems.forEach((serviceItem, _index) => {
if (doStoreServiceItemTitle) {
this.nextServiceItemTitle = serviceItem.title;
doStoreServiceItemTitle = false;
}
if (serviceItem.id === this.serviceItem.id) {
doStoreServiceItemTitle = true;
}
});
});
}
setNewSlides(slides: Slide[], _currentSlide: number): void {
if (slides.length === 0) { if (slides.length === 0) {
return; return;
} }
@ -129,7 +149,7 @@ export class StageViewComponent implements OnInit, OnDestroy {
} }
} }
trackByIndex(index: number, el: any) { trackByIndex(index: number) {
return index; return index;
} }
} }