From 898c6c4d7eef21713b42dd17170e6c547c7f1721 Mon Sep 17 00:00:00 2001 From: benjamin Date: Fri, 3 Jan 2025 15:59:00 +0100 Subject: [PATCH] add comments in show --- .../monitor/monitor.component.html | 1 + .../presentation/presentation.module.ts | 7 ++--- .../presentation/remote/remote.component.ts | 8 ++--- .../modules/shows/services/docx.service.ts | 29 ++++++++++++------- src/app/modules/shows/show/show.component.ts | 8 ++--- .../modules/songs/services/section-type.ts | 1 + .../songs/services/text-rendering.service.ts | 7 ++--- .../song-text/song-text.component.ts | 24 ++++++--------- 8 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/app/modules/presentation/monitor/monitor.component.html b/src/app/modules/presentation/monitor/monitor.component.html index 0935b9e..cced4b6 100644 --- a/src/app/modules/presentation/monitor/monitor.component.html +++ b/src/app/modules/presentation/monitor/monitor.component.html @@ -35,6 +35,7 @@ [header]="song.title" [index]="index??0" [showSwitch]="false" + [showComments]="false" [text]="song.text" chordMode="hide" > diff --git a/src/app/modules/presentation/presentation.module.ts b/src/app/modules/presentation/presentation.module.ts index 2d3dce9..b211d2e 100644 --- a/src/app/modules/presentation/presentation.module.ts +++ b/src/app/modules/presentation/presentation.module.ts @@ -8,9 +8,7 @@ import {CardModule} from '../../widget-modules/components/card/card.module'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatSelectModule} from '@angular/material/select'; import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module'; -import { - SectionTypeTranslatorModule, -} from '../../widget-modules/pipes/section-type-translator/section-type-translator.module'; +import {SectionTypeTranslatorModule} from '../../widget-modules/pipes/section-type-translator/section-type-translator.module'; import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module'; import {LegalComponent} from './monitor/legal/legal.component'; import {MatButtonModule} from '@angular/material/button'; @@ -45,5 +43,4 @@ import {UserNameModule} from '../../services/user/user-name/user-name.module'; UserNameModule, ], }) -export class PresentationModule { -} +export class PresentationModule {} diff --git a/src/app/modules/presentation/remote/remote.component.ts b/src/app/modules/presentation/remote/remote.component.ts index 7a3463a..a207d7b 100644 --- a/src/app/modules/presentation/remote/remote.component.ts +++ b/src/app/modules/presentation/remote/remote.component.ts @@ -12,6 +12,7 @@ import {fade} from '../../../animations'; import {TextRenderingService} from '../../songs/services/text-rendering.service'; import {Section} from '../../songs/services/section'; import {GlobalSettings} from '../../../services/global-settings'; +import {LineType} from '../../songs/services/line-type'; export interface PresentationSong { id: string; @@ -44,13 +45,12 @@ export class RemoteComponent { private showSongService: ShowSongService, private songService: SongService, private textRenderingService: TextRenderingService, - private globalSettingsService: GlobalSettingsService, + globalSettingsService: GlobalSettingsService, private cRef: ChangeDetectorRef, ) { globalSettingsService.get$ .pipe( filter(_ => !!_), - map(_ => _ as GlobalSettings), map(_ => _.currentShow), ) .subscribe(_ => { @@ -75,7 +75,7 @@ export class RemoteComponent { const presentationSongs = list.map(song => ({ id: song.id, 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.cRef.markForCheck(); @@ -83,7 +83,7 @@ export class RemoteComponent { } 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 { diff --git a/src/app/modules/shows/services/docx.service.ts b/src/app/modules/shows/services/docx.service.ts index a833608..78fece9 100644 --- a/src/app/modules/shows/services/docx.service.ts +++ b/src/app/modules/shows/services/docx.service.ts @@ -30,12 +30,10 @@ export class DocxService { public constructor( private showService: ShowService, private showSongService: ShowSongService, - private songService: SongService, private textRenderingService: TextRenderingService, private userService: UserService, private configService: ConfigService, - ) { - } + ) {} public async create(showId: string, options: DownloadOptions = {}): Promise { const data = await this.prepareData(showId); @@ -95,10 +93,14 @@ export class DocxService { }); } - private renderSongs(songs: { - showSong: ShowSong; - sections: Section[] - }[], options: DownloadOptions, config: Config): Paragraph[] { + private renderSongs( + songs: { + showSong: ShowSong; + sections: Section[]; + }[], + options: DownloadOptions, + config: Config + ): Paragraph[] { 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, }; }); - const songsLoaded = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as { - showSong: ShowSong; - sections: Section[] - }); + const songsLoaded = (await Promise.all(songsAsync)) + .filter(_ => !!_) + .map( + _ => + _ as { + showSong: ShowSong; + sections: Section[]; + } + ); const songs = show.order.map(_ => songsLoaded.filter(f => f.showSong.id === _)[0]); return {songs, show, user, config}; } diff --git a/src/app/modules/shows/show/show.component.ts b/src/app/modules/shows/show/show.component.ts index 03edbbf..f0858d5 100644 --- a/src/app/modules/shows/show/show.component.ts +++ b/src/app/modules/shows/show/show.component.ts @@ -10,6 +10,7 @@ import {ShowSongService} from '../services/show-song.service'; import {ShowSong} from '../services/show-song'; import {DocxService} from '../services/docx.service'; import { + faArrowUpRightFromSquare, faBox, faBoxOpen, faExternalLinkAlt, @@ -19,8 +20,7 @@ import { faLock, faMagnifyingGlassMinus, faMagnifyingGlassPlus, - faShare, - faSliders, + faSliders, faUnlock, faUser, faUsers, } from '@fortawesome/free-solid-svg-icons'; @@ -48,9 +48,9 @@ export class ShowComponent implements OnInit, OnDestroy { public faBox = faBox; public faBoxOpen = faBoxOpen; - public faPublish = faExternalLinkAlt; + public faPublish = faUnlock; public faUnpublish = faLock; - public faShare = faShare; + public faShare = faArrowUpRightFromSquare; public faDownload = faFileDownload; public faSliders = faSliders; public faUser = faUser; diff --git a/src/app/modules/songs/services/section-type.ts b/src/app/modules/songs/services/section-type.ts index 9e1cd2e..c28b6e0 100644 --- a/src/app/modules/songs/services/section-type.ts +++ b/src/app/modules/songs/services/section-type.ts @@ -2,4 +2,5 @@ export enum SectionType { Verse, Chorus, Bridge, + Comment, } diff --git a/src/app/modules/songs/services/text-rendering.service.ts b/src/app/modules/songs/services/text-rendering.service.ts index 88bbe86..16399e2 100644 --- a/src/app/modules/songs/services/text-rendering.service.ts +++ b/src/app/modules/songs/services/text-rendering.service.ts @@ -13,14 +13,13 @@ import {Line} from './line'; export class TextRenderingService { 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) { return []; } - const arrayOfLines = text.split(/\r?\n/).filter(_ => _); + const arrayOfLines = text.split(/\r?\n/).filter(_ => _ && (!_.startsWith('#') || withComments)); const indices = { [SectionType.Bridge]: 0, [SectionType.Chorus]: 0, diff --git a/src/app/widget-modules/components/song-text/song-text.component.ts b/src/app/widget-modules/components/song-text/song-text.component.ts index 0445d66..5fff08f 100644 --- a/src/app/widget-modules/components/song-text/song-text.component.ts +++ b/src/app/widget-modules/components/song-text/song-text.component.ts @@ -1,14 +1,4 @@ -import { - ChangeDetectorRef, - Component, - ElementRef, - EventEmitter, - Input, - OnInit, - Output, - QueryList, - ViewChildren, -} from '@angular/core'; +import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren} from '@angular/core'; import {TextRenderingService} from '../../../modules/songs/services/text-rendering.service'; import {faGripLines} from '@fortawesome/free-solid-svg-icons'; import {songSwitch} from './animation'; @@ -33,6 +23,7 @@ export class SongTextComponent implements OnInit { @Input() public index = -1; @Input() public fullscreen = false; @Input() public showSwitch = false; + @Input() public showComments = true; @Output() public chordModeChanged = new EventEmitter(); @ViewChildren('section') public viewSections: QueryList> | null = null; public faLines = faGripLines; @@ -41,8 +32,11 @@ export class SongTextComponent implements OnInit { private iText = ''; private iTranspose: TransposeMode | null = null; - public constructor(private textRenderingService: TextRenderingService, private elRef: ElementRef, private cRef: ChangeDetectorRef) { - } + public constructor( + private textRenderingService: TextRenderingService, + private elRef: ElementRef, + private cRef: ChangeDetectorRef + ) {} @Input() public set chordMode(value: ChordMode) { @@ -111,11 +105,11 @@ export class SongTextComponent implements OnInit { this.sections = []; if (this.fullscreen) { setTimeout(() => { - this.sections = this.textRenderingService.parse(this.iText, this.iTranspose); + this.sections = this.textRenderingService.parse(this.iText, this.iTranspose, this.showComments); this.cRef.markForCheck(); }, 100); } 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(); } }