This commit is contained in:
2026-03-15 12:50:33 +01:00
parent dd68a6b21d
commit d907c89eb6
36 changed files with 309 additions and 286 deletions

View File

@@ -3,6 +3,7 @@ import {filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';
import {ActivatedRoute, Router} from '@angular/router';
import {ShowService} from '../services/show.service';
import {Observable, of, Subscription} from 'rxjs';
import {take} from 'rxjs/operators';
import {Show} from '../services/show';
import {SongService} from '../../songs/services/song.service';
import {Song} from '../../songs/services/song';
@@ -112,12 +113,13 @@ export class ShowComponent implements OnInit, OnDestroy {
public faRestore = faMinimize;
public faMaximize = faMaximize;
public faNextSong = faChevronRight;
public currentTime: Date;
public currentTime!: Date;
private subs: Subscription[] = [];
private clockIntervalId: ReturnType<typeof setInterval> | null = null;
public ngOnInit(): void {
this.currentTime = new Date();
setInterval(() => {
this.clockIntervalId = setInterval(() => {
this.currentTime = new Date();
}, 10000);
this.show$ = this.activatedRoute.params.pipe(
@@ -155,6 +157,9 @@ export class ShowComponent implements OnInit, OnDestroy {
public ngOnDestroy(): void {
this.subs.forEach(_ => _.unsubscribe());
if (this.clockIntervalId) {
clearInterval(this.clockIntervalId);
}
}
public onZoomIn() {
@@ -172,7 +177,7 @@ export class ShowComponent implements OnInit, OnDestroy {
width: '350px',
});
dialogRef.afterClosed().subscribe((archive: boolean) => {
dialogRef.afterClosed().pipe(take(1)).subscribe((archive: boolean) => {
if (archive && this.showId != null) void this.showService.update$(this.showId, {archived});
});
}

View File

@@ -1,8 +1,9 @@
import {Component, Input, OnInit, ViewChild, inject} from '@angular/core';
import {Component, DestroyRef, Input, OnInit, ViewChild, inject} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {ShowSongService} from '../../services/show-song.service';
import {ShowSong} from '../../services/show-song';
import {getScale} from '../../../songs/services/key.helper';
import {ReactiveFormsModule, UntypedFormControl} from '@angular/forms';
import {FormControl, ReactiveFormsModule} from '@angular/forms';
import {ChordMode, SongTextComponent} from '../../../../widget-modules/components/song-text/song-text.component';
import {Show} from '../../services/show';
import {faEraser, faPenToSquare, faSave, faTrash} from '@fortawesome/free-solid-svg-icons';
@@ -42,6 +43,7 @@ import {CdkDragHandle} from '@angular/cdk/drag-drop';
})
export class SongComponent implements OnInit {
private showSongService = inject(ShowSongService);
private destroyRef = inject(DestroyRef);
@Input() public show: Show | null = null;
@Input() public showId: string | null = null;
@@ -54,11 +56,11 @@ export class SongComponent implements OnInit {
public faEdit = faPenToSquare;
public faSave = faSave;
public faEraser = faEraser;
public keyFormControl: UntypedFormControl = new UntypedFormControl();
public keyFormControl = new FormControl<string>('', {nonNullable: true});
public iSong: ShowSong | null = null;
public edit = false;
public editSongControl = new UntypedFormControl();
@ViewChild('option') private keyOptions: MatSelect;
public editSongControl = new FormControl<string | null>(null);
@ViewChild('option') private keyOptions!: MatSelect;
@Input()
public set showSong(song: ShowSong) {
@@ -68,8 +70,8 @@ export class SongComponent implements OnInit {
public ngOnInit(): void {
if (!this.iSong) return;
this.keyFormControl = new UntypedFormControl(this.iSong.key);
this.keyFormControl.valueChanges.subscribe((value: string) => {
this.keyFormControl = new FormControl<string>(this.iSong.key, {nonNullable: true});
this.keyFormControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => {
if (!this.showId || !this.iSong) return;
void this.showSongService.update$(this.showId, this.iSong.id, {key: value});
});