add comments in show

This commit is contained in:
2025-01-03 15:59:00 +01:00
parent 802c309679
commit 898c6c4d7e
8 changed files with 42 additions and 43 deletions

View File

@@ -35,6 +35,7 @@
[header]="song.title" [header]="song.title"
[index]="index??0" [index]="index??0"
[showSwitch]="false" [showSwitch]="false"
[showComments]="false"
[text]="song.text" [text]="song.text"
chordMode="hide" chordMode="hide"
></app-song-text> ></app-song-text>

View File

@@ -8,9 +8,7 @@ import {CardModule} from '../../widget-modules/components/card/card.module';
import {MatFormFieldModule} from '@angular/material/form-field'; import {MatFormFieldModule} from '@angular/material/form-field';
import {MatSelectModule} from '@angular/material/select'; import {MatSelectModule} from '@angular/material/select';
import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module'; import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module';
import { import {SectionTypeTranslatorModule} from '../../widget-modules/pipes/section-type-translator/section-type-translator.module';
SectionTypeTranslatorModule,
} from '../../widget-modules/pipes/section-type-translator/section-type-translator.module';
import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module'; import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module';
import {LegalComponent} from './monitor/legal/legal.component'; import {LegalComponent} from './monitor/legal/legal.component';
import {MatButtonModule} from '@angular/material/button'; import {MatButtonModule} from '@angular/material/button';
@@ -45,5 +43,4 @@ import {UserNameModule} from '../../services/user/user-name/user-name.module';
UserNameModule, UserNameModule,
], ],
}) })
export class PresentationModule { export class PresentationModule {}
}

View File

@@ -12,6 +12,7 @@ import {fade} from '../../../animations';
import {TextRenderingService} from '../../songs/services/text-rendering.service'; import {TextRenderingService} from '../../songs/services/text-rendering.service';
import {Section} from '../../songs/services/section'; import {Section} from '../../songs/services/section';
import {GlobalSettings} from '../../../services/global-settings'; import {GlobalSettings} from '../../../services/global-settings';
import {LineType} from '../../songs/services/line-type';
export interface PresentationSong { export interface PresentationSong {
id: string; id: string;
@@ -44,13 +45,12 @@ export class RemoteComponent {
private showSongService: ShowSongService, private showSongService: ShowSongService,
private songService: SongService, private songService: SongService,
private textRenderingService: TextRenderingService, private textRenderingService: TextRenderingService,
private globalSettingsService: GlobalSettingsService, globalSettingsService: GlobalSettingsService,
private cRef: ChangeDetectorRef, private cRef: ChangeDetectorRef,
) { ) {
globalSettingsService.get$ globalSettingsService.get$
.pipe( .pipe(
filter(_ => !!_), filter(_ => !!_),
map(_ => _ as GlobalSettings),
map(_ => _.currentShow), map(_ => _.currentShow),
) )
.subscribe(_ => { .subscribe(_ => {
@@ -75,7 +75,7 @@ export class RemoteComponent {
const presentationSongs = list.map(song => ({ const presentationSongs = list.map(song => ({
id: song.id, id: song.id,
title: song.title, title: song.title,
sections: this.textRenderingService.parse(song.text, null), sections: this.textRenderingService.parse(song.text, null, false),
})); }));
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? []; this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
this.cRef.markForCheck(); this.cRef.markForCheck();
@@ -83,7 +83,7 @@ export class RemoteComponent {
} }
public getFirstLine(section: Section): string { public getFirstLine(section: Section): string {
return section.lines.filter(_ => _.type === 1)[0].text; return section.lines.filter(_ => _.type === LineType.text)[0].text;
} }
public async onSectionClick(id: string, index: number, showId: string): Promise<void> { public async onSectionClick(id: string, index: number, showId: string): Promise<void> {

View File

@@ -30,12 +30,10 @@ export class DocxService {
public constructor( public constructor(
private showService: ShowService, private showService: ShowService,
private showSongService: ShowSongService, private showSongService: ShowSongService,
private songService: SongService,
private textRenderingService: TextRenderingService, private textRenderingService: TextRenderingService,
private userService: UserService, private userService: UserService,
private configService: ConfigService, private configService: ConfigService,
) { ) {}
}
public async create(showId: string, options: DownloadOptions = {}): Promise<void> { public async create(showId: string, options: DownloadOptions = {}): Promise<void> {
const data = await this.prepareData(showId); const data = await this.prepareData(showId);
@@ -95,10 +93,14 @@ export class DocxService {
}); });
} }
private renderSongs(songs: { private renderSongs(
songs: {
showSong: ShowSong; showSong: ShowSong;
sections: Section[] sections: Section[];
}[], options: DownloadOptions, config: Config): Paragraph[] { }[],
options: DownloadOptions,
config: Config
): Paragraph[] {
return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []); return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []);
} }
@@ -203,10 +205,15 @@ export class DocxService {
sections, sections,
}; };
}); });
const songsLoaded = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as { const songsLoaded = (await Promise.all(songsAsync))
.filter(_ => !!_)
.map(
_ =>
_ as {
showSong: ShowSong; showSong: ShowSong;
sections: Section[] sections: Section[];
}); }
);
const songs = show.order.map(_ => songsLoaded.filter(f => f.showSong.id === _)[0]); const songs = show.order.map(_ => songsLoaded.filter(f => f.showSong.id === _)[0]);
return {songs, show, user, config}; return {songs, show, user, config};
} }

View File

@@ -10,6 +10,7 @@ import {ShowSongService} from '../services/show-song.service';
import {ShowSong} from '../services/show-song'; import {ShowSong} from '../services/show-song';
import {DocxService} from '../services/docx.service'; import {DocxService} from '../services/docx.service';
import { import {
faArrowUpRightFromSquare,
faBox, faBox,
faBoxOpen, faBoxOpen,
faExternalLinkAlt, faExternalLinkAlt,
@@ -19,8 +20,7 @@ import {
faLock, faLock,
faMagnifyingGlassMinus, faMagnifyingGlassMinus,
faMagnifyingGlassPlus, faMagnifyingGlassPlus,
faShare, faSliders, faUnlock,
faSliders,
faUser, faUser,
faUsers, faUsers,
} from '@fortawesome/free-solid-svg-icons'; } from '@fortawesome/free-solid-svg-icons';
@@ -48,9 +48,9 @@ export class ShowComponent implements OnInit, OnDestroy {
public faBox = faBox; public faBox = faBox;
public faBoxOpen = faBoxOpen; public faBoxOpen = faBoxOpen;
public faPublish = faExternalLinkAlt; public faPublish = faUnlock;
public faUnpublish = faLock; public faUnpublish = faLock;
public faShare = faShare; public faShare = faArrowUpRightFromSquare;
public faDownload = faFileDownload; public faDownload = faFileDownload;
public faSliders = faSliders; public faSliders = faSliders;
public faUser = faUser; public faUser = faUser;

View File

@@ -2,4 +2,5 @@ export enum SectionType {
Verse, Verse,
Chorus, Chorus,
Bridge, Bridge,
Comment,
} }

View File

@@ -13,14 +13,13 @@ import {Line} from './line';
export class TextRenderingService { export class TextRenderingService {
private regexSection = /(Strophe|Refrain|Bridge)/; private regexSection = /(Strophe|Refrain|Bridge)/;
public constructor(private transposeService: TransposeService) { public constructor(private transposeService: TransposeService) {}
}
public parse(text: string, transpose: TransposeMode | null): Section[] { public parse(text: string, transpose: TransposeMode | null, withComments = true): Section[] {
if (!text) { if (!text) {
return []; return [];
} }
const arrayOfLines = text.split(/\r?\n/).filter(_ => _); const arrayOfLines = text.split(/\r?\n/).filter(_ => _ && (!_.startsWith('#') || withComments));
const indices = { const indices = {
[SectionType.Bridge]: 0, [SectionType.Bridge]: 0,
[SectionType.Chorus]: 0, [SectionType.Chorus]: 0,

View File

@@ -1,14 +1,4 @@
import { import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren} from '@angular/core';
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Input,
OnInit,
Output,
QueryList,
ViewChildren,
} from '@angular/core';
import {TextRenderingService} from '../../../modules/songs/services/text-rendering.service'; import {TextRenderingService} from '../../../modules/songs/services/text-rendering.service';
import {faGripLines} from '@fortawesome/free-solid-svg-icons'; import {faGripLines} from '@fortawesome/free-solid-svg-icons';
import {songSwitch} from './animation'; import {songSwitch} from './animation';
@@ -33,6 +23,7 @@ export class SongTextComponent implements OnInit {
@Input() public index = -1; @Input() public index = -1;
@Input() public fullscreen = false; @Input() public fullscreen = false;
@Input() public showSwitch = false; @Input() public showSwitch = false;
@Input() public showComments = true;
@Output() public chordModeChanged = new EventEmitter<ChordMode>(); @Output() public chordModeChanged = new EventEmitter<ChordMode>();
@ViewChildren('section') public viewSections: QueryList<ElementRef<HTMLElement>> | null = null; @ViewChildren('section') public viewSections: QueryList<ElementRef<HTMLElement>> | null = null;
public faLines = faGripLines; public faLines = faGripLines;
@@ -41,8 +32,11 @@ export class SongTextComponent implements OnInit {
private iText = ''; private iText = '';
private iTranspose: TransposeMode | null = null; private iTranspose: TransposeMode | null = null;
public constructor(private textRenderingService: TextRenderingService, private elRef: ElementRef<HTMLElement>, private cRef: ChangeDetectorRef) { public constructor(
} private textRenderingService: TextRenderingService,
private elRef: ElementRef<HTMLElement>,
private cRef: ChangeDetectorRef
) {}
@Input() @Input()
public set chordMode(value: ChordMode) { public set chordMode(value: ChordMode) {
@@ -111,11 +105,11 @@ export class SongTextComponent implements OnInit {
this.sections = []; this.sections = [];
if (this.fullscreen) { if (this.fullscreen) {
setTimeout(() => { setTimeout(() => {
this.sections = this.textRenderingService.parse(this.iText, this.iTranspose); this.sections = this.textRenderingService.parse(this.iText, this.iTranspose, this.showComments);
this.cRef.markForCheck(); this.cRef.markForCheck();
}, 100); }, 100);
} else { } else {
this.sections = this.textRenderingService.parse(this.iText, this.iTranspose); //.sort((a, b) => a.type - b.type); this.sections = this.textRenderingService.parse(this.iText, this.iTranspose, this.showComments); //.sort((a, b) => a.type - b.type);
this.cRef.markForCheck(); this.cRef.markForCheck();
} }
} }