From c5748d5e34650e651986bfb08c3a2cfd5c92aaa3 Mon Sep 17 00:00:00 2001 From: smuddyx Date: Fri, 17 Apr 2020 15:13:39 +0200 Subject: [PATCH] publish show --- .../monitor/legal/legal.component.less | 13 +++++++++ .../monitor/monitor.component.html | 2 -- .../monitor/monitor.component.less | 1 + .../presentation/monitor/monitor.component.ts | 2 +- .../presentation/presentation.module.ts | 6 ++++- .../presentation/remote/remote.component.html | 23 +++++++++------- .../presentation/remote/remote.component.less | 5 ++++ .../presentation/remote/remote.component.ts | 27 ++++++------------- src/app/modules/shows/list/list.component.ts | 6 ++--- .../shows/services/show-data.service.ts | 2 +- .../modules/shows/services/show.service.ts | 22 ++++++++++++++- src/app/modules/shows/services/show.ts | 2 ++ .../modules/shows/show/show.component.html | 22 ++++++++++----- src/app/modules/shows/show/show.component.ts | 14 ++++++++++ .../shows/show/song/song.component.html | 2 +- .../shows/show/song/song.component.less | 2 -- .../modules/songs/song/song.component.html | 3 ++- src/app/services/user.service.ts | 13 +++++---- .../song-text/song-text.component.ts | 22 ++++++++------- 19 files changed, 126 insertions(+), 63 deletions(-) diff --git a/src/app/modules/presentation/monitor/legal/legal.component.less b/src/app/modules/presentation/monitor/legal/legal.component.less index cb8839f..5ff28d7 100644 --- a/src/app/modules/presentation/monitor/legal/legal.component.less +++ b/src/app/modules/presentation/monitor/legal/legal.component.less @@ -1,3 +1,16 @@ +:host { + position: fixed; + display: block; + z-index: 1; + bottom: 0; + left: 0; + right: 0; + background: #000c; + padding: 50px; + box-sizing: border-box; + box-shadow: 0px 0px 26px 10px #000; +} + p { font-size: 15px; margin: 10px 0 0 0; diff --git a/src/app/modules/presentation/monitor/monitor.component.html b/src/app/modules/presentation/monitor/monitor.component.html index 98a0ed2..ba8e6e9 100644 --- a/src/app/modules/presentation/monitor/monitor.component.html +++ b/src/app/modules/presentation/monitor/monitor.component.html @@ -1,6 +1,4 @@
- -
diff --git a/src/app/modules/presentation/monitor/monitor.component.less b/src/app/modules/presentation/monitor/monitor.component.less index db62d57..6f08e3d 100644 --- a/src/app/modules/presentation/monitor/monitor.component.less +++ b/src/app/modules/presentation/monitor/monitor.component.less @@ -14,4 +14,5 @@ display: flex; flex-direction: column; justify-content: space-between; + transition: 300ms all ease-in-out; } diff --git a/src/app/modules/presentation/monitor/monitor.component.ts b/src/app/modules/presentation/monitor/monitor.component.ts index 344f0d4..928546c 100644 --- a/src/app/modules/presentation/monitor/monitor.component.ts +++ b/src/app/modules/presentation/monitor/monitor.component.ts @@ -13,8 +13,8 @@ import {Song} from '../../songs/services/song'; }) export class MonitorComponent implements OnInit { public song: Song; + public zoom: number; private index: number; - private zoom: number; private sections: Section[]; constructor( diff --git a/src/app/modules/presentation/presentation.module.ts b/src/app/modules/presentation/presentation.module.ts index d2e5998..afaa240 100644 --- a/src/app/modules/presentation/presentation.module.ts +++ b/src/app/modules/presentation/presentation.module.ts @@ -13,6 +13,8 @@ import {SongTextModule} from '../../widget-modules/components/song-text/song-tex import {LegalComponent} from './monitor/legal/legal.component'; import {MatButtonModule} from '@angular/material/button'; import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; +import {MatSliderModule} from '@angular/material/slider'; +import {FormsModule} from '@angular/forms'; @NgModule({ @@ -27,7 +29,9 @@ import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; SectionTypeTranslatorModule, SongTextModule, MatButtonModule, - FontAwesomeModule + FontAwesomeModule, + MatSliderModule, + FormsModule ] }) export class PresentationModule { diff --git a/src/app/modules/presentation/remote/remote.component.html b/src/app/modules/presentation/remote/remote.component.html index 9b48d65..1c39fde 100644 --- a/src/app/modules/presentation/remote/remote.component.html +++ b/src/app/modules/presentation/remote/remote.component.html @@ -1,6 +1,9 @@
- + +

Es ist derzeit keine Veranstaltung vorhanden

+ + Veranstaltung @@ -21,18 +24,20 @@
-
+
- - {{show.presentationZoom}}px - + +
diff --git a/src/app/modules/presentation/remote/remote.component.less b/src/app/modules/presentation/remote/remote.component.less index 8184f62..a7a9292 100644 --- a/src/app/modules/presentation/remote/remote.component.less +++ b/src/app/modules/presentation/remote/remote.component.less @@ -65,3 +65,8 @@ .fragment { padding: 10px; } + +.div-bottom { + display: grid; + grid-template-columns: 40px auto; +} diff --git a/src/app/modules/presentation/remote/remote.component.ts b/src/app/modules/presentation/remote/remote.component.ts index 78e49ab..9ac0ad5 100644 --- a/src/app/modules/presentation/remote/remote.component.ts +++ b/src/app/modules/presentation/remote/remote.component.ts @@ -1,5 +1,4 @@ import {Component} from '@angular/core'; -import {ShowDataService} from '../../shows/services/show-data.service'; import {Observable} from 'rxjs'; import {Show} from '../../shows/services/show'; import {MatSelectChange} from '@angular/material/select'; @@ -7,9 +6,8 @@ import {ShowSongService} from '../../shows/services/show-song.service'; import {SongService} from '../../songs/services/song.service'; import {Song} from '../../songs/services/song'; import {Section, TextRenderingService} from '../../songs/services/text-rendering.service'; -import {faSearchPlus} from '@fortawesome/free-solid-svg-icons/faSearchPlus'; -import {faSearchMinus} from '@fortawesome/free-solid-svg-icons/faSearchMinus'; import {faDesktop} from '@fortawesome/free-solid-svg-icons/faDesktop'; +import {ShowService} from '../../shows/services/show.service'; export interface PresentationSong { id: string; @@ -29,23 +27,21 @@ export class RemoteComponent { public presentationSongs: PresentationSong[]; public currentShowId: string; - public faZoomIn = faSearchPlus; - public faZoomOut = faSearchMinus; public faDesktop = faDesktop; constructor( - private showDataService: ShowDataService, + private showService: ShowService, private showSongService: ShowSongService, private songService: SongService, private textRenderingService: TextRenderingService ) { - this.shows$ = showDataService.list$(); + this.shows$ = showService.list$(true); songService.list$().subscribe(_ => this.songs = _); } public onShowChanged(change: MatSelectChange): void { this.currentShowId = change.value; - this.showDataService.read$(change.value).subscribe(_ => this.show = _); + this.showService.read$(change.value).subscribe(_ => this.show = _); this.showSongService.list$(change.value).subscribe(_ => { this.presentationSongs = _ .map(song => this.songs.filter(f => f.id == song.songId)[0]) @@ -62,22 +58,15 @@ export class RemoteComponent { } public async onSectionClick(id: string, index: number): Promise { - await this.showDataService.update(this.currentShowId, { + await this.showService.update$(this.currentShowId, { presentationSongId: id, presentationSection: index }) } - public async onZoomIn() { - debugger - await this.showDataService.update(this.currentShowId, { - presentationZoom: (this.show.presentationZoom ?? 30) + 2, - }); - } - - public async onZoomOut() { - await this.showDataService.update(this.currentShowId, { - presentationZoom: (this.show.presentationZoom ?? 30) - 2, + public async onZoom(zoom: number) { + await this.showService.update$(this.currentShowId, { + presentationZoom: zoom, }); } } diff --git a/src/app/modules/shows/list/list.component.ts b/src/app/modules/shows/list/list.component.ts index 0d256bb..b80abbc 100644 --- a/src/app/modules/shows/list/list.component.ts +++ b/src/app/modules/shows/list/list.component.ts @@ -1,8 +1,8 @@ import {Component} from '@angular/core'; import {Observable} from 'rxjs'; import {Show} from '../services/show'; -import {ShowDataService} from '../services/show-data.service'; import {fade} from '../../../animations'; +import {ShowService} from '../services/show.service'; @Component({ selector: 'app-list', @@ -13,8 +13,8 @@ import {fade} from '../../../animations'; export class ListComponent { public shows$: Observable; - constructor(showDataService: ShowDataService) { - this.shows$ = showDataService.list$(); + constructor(showService: ShowService) { + this.shows$ = showService.list$(); } } diff --git a/src/app/modules/shows/services/show-data.service.ts b/src/app/modules/shows/services/show-data.service.ts index b1ddf80..109f912 100644 --- a/src/app/modules/shows/services/show-data.service.ts +++ b/src/app/modules/shows/services/show-data.service.ts @@ -12,7 +12,7 @@ export class ShowDataService { constructor(private dbService: DbService) { } - public list$ = (): Observable => this.dbService.col$(this.collection); + public list$ = (queryFn?): Observable => this.dbService.col$(this.collection, queryFn); public read$ = (showId: string): Observable => this.dbService.doc$(`${this.collection}/${showId}`); public update = async (showId: string, data: Partial): Promise => await this.dbService.doc(`${this.collection}/${showId}`).update(data); public add = async (data: Partial): Promise => (await this.dbService.col(this.collection).add(data)).id diff --git a/src/app/modules/shows/services/show.service.ts b/src/app/modules/shows/services/show.service.ts index e4c7ba9..fc8b6bd 100644 --- a/src/app/modules/shows/services/show.service.ts +++ b/src/app/modules/shows/services/show.service.ts @@ -2,6 +2,9 @@ import {Injectable} from '@angular/core'; import {ShowDataService} from './show-data.service'; import {Show} from './show'; import {Observable} from 'rxjs'; +import {UserService} from '../../../services/user.service'; +import {map, switchMap} from 'rxjs/operators'; +import {User} from '../../../services/user'; @Injectable({ providedIn: 'root' @@ -11,15 +14,32 @@ export class ShowService { public static SHOW_TYPE = ['service-worship', 'service-praise', 'home-group-big', 'home-group', 'prayer-group', 'teens-group', 'kids-group', 'misc-public', 'misc-private']; public static SHOW_TYPE_PUBLIC = ['service-worship', 'service-praise', 'home-group-big', 'teens-group', 'kids-group', 'misc-public']; public static SHOW_TYPE_PRIVATE = ['home-group', 'prayer-group', 'misc-private',]; + private user: User; - constructor(private showDataService: ShowDataService) { + constructor(private showDataService: ShowDataService, private userService: UserService) { + userService.user$.subscribe(_ => this.user = _); } public read$ = (showId: string): Observable => this.showDataService.read$(showId); + public list$(publishedOnly: boolean = false): Observable { + + return this.userService.user$.pipe( + switchMap(_ => this.showDataService.list$(), (user: User, shows: Show[]) => ({user, shows})), + map(_ => _.shows + .filter(_ => !_.archived) + .filter(show => show.published || (show.owner === _.user.id && !publishedOnly)) + ) + ) + + } + + public update$ = async (showId: string, data: Partial): Promise => this.showDataService.update(showId, data); + public async new$(data: Partial): Promise { const calculatedData: Partial = { ...data, + owner: this.user.id, public: ShowService.SHOW_TYPE_PUBLIC.indexOf(data.showType) !== -1, }; return await this.showDataService.add(calculatedData); diff --git a/src/app/modules/shows/services/show.ts b/src/app/modules/shows/services/show.ts index c95ed99..abc7ecb 100644 --- a/src/app/modules/shows/services/show.ts +++ b/src/app/modules/shows/services/show.ts @@ -8,6 +8,8 @@ export interface Show { owner: string; public: boolean; reported: boolean; + published: boolean; + archived: boolean; presentationSongId: string; presentationSection: number; diff --git a/src/app/modules/shows/show/show.component.html b/src/app/modules/shows/show/show.component.html index a6b7c7c..35a39a7 100644 --- a/src/app/modules/shows/show/show.component.html +++ b/src/app/modules/shows/show/show.component.html @@ -1,16 +1,18 @@
- - Text anzeigen - + heading="{{show.showType|showType}}, {{show.date.toDate()|date:'dd.MM.yyyy'}} - {{getStatus(show)}}"> + öffentliche Veranstaltung + geschlossene Veranstaltung +

+ Text anzeigen +

-
@@ -23,5 +25,11 @@
+ + + + + +
diff --git a/src/app/modules/shows/show/show.component.ts b/src/app/modules/shows/show/show.component.ts index 88d2e0c..5d1a765 100644 --- a/src/app/modules/shows/show/show.component.ts +++ b/src/app/modules/shows/show/show.component.ts @@ -69,4 +69,18 @@ export class ShowComponent implements OnInit { const filtered = this.songs.filter(_ => _.id === songId); return filtered.length > 0 ? filtered[0] : null; } + + public async onArchive(archived: boolean): Promise { + await this.showService.update$(this.showId, {archived}); + } + + public async onPublish(published: boolean): Promise { + await this.showService.update$(this.showId, {published}); + } + + public getStatus(show: Show): string { + if (show.published) return 'veröffentlicht'; + if (show.reported) return 'gemeldet'; + return 'entwurf'; + } } diff --git a/src/app/modules/shows/show/song/song.component.html b/src/app/modules/shows/show/song/song.component.html index 143c80e..552566c 100644 --- a/src/app/modules/shows/show/song/song.component.html +++ b/src/app/modules/shows/show/song/song.component.html @@ -14,5 +14,5 @@ + [showSwitch]="true" [text]="_song.text"> diff --git a/src/app/modules/shows/show/song/song.component.less b/src/app/modules/shows/show/song/song.component.less index 1626cd7..0f8de81 100644 --- a/src/app/modules/shows/show/song/song.component.less +++ b/src/app/modules/shows/show/song/song.component.less @@ -1,6 +1,4 @@ - - .song { display: grid; grid-template-columns: 20px 20px auto 70px 25px; diff --git a/src/app/modules/songs/song/song.component.html b/src/app/modules/songs/song/song.component.html index 23c6168..01412a3 100644 --- a/src/app/modules/songs/song/song.component.html +++ b/src/app/modules/songs/song/song.component.html @@ -16,7 +16,8 @@ - +
{{song.comment}}
diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 40cdc90..2c21343 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {AngularFireAuth} from '@angular/fire/auth'; -import {Observable} from 'rxjs'; +import {BehaviorSubject, Observable} from 'rxjs'; import {filter, switchMap} from 'rxjs/operators'; import {User} from './user'; import {DbService} from './db.service'; @@ -10,13 +10,16 @@ import {DbService} from './db.service'; }) export class UserService { constructor(private afAuth: AngularFireAuth, private db: DbService) { + this.afAuth.authState.pipe( + filter(_ => !!_), + switchMap(auth => this.db.doc$('user/' + auth.uid)), + ).subscribe(_ => this._user$.next(_)); } + private _user$ = new BehaviorSubject(null); + public get user$(): Observable { - return this.afAuth.authState.pipe( - filter(_ => !!_), - switchMap(auth => this.db.doc$('user/' + auth.uid)) - ); + return this._user$.pipe(filter(_ => !!_)); } public async update$(uid: string, data: Partial): Promise { 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 46156b7..99704ae 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 @@ -17,19 +17,21 @@ export type ChordMode = 'show' | 'hide' | 'onlyFirst' }) export class SongTextComponent implements OnInit { public sections: Section[]; - public _chordMode: ChordMode = 'hide'; + @Input() public scrollIndex = 0; @Input() showSwitch = false; - @Input() - public set chordMode(value: ChordMode) { - this._chordMode = value ?? 'hide'; - } - @Output() public chordModeChanged = new EventEmitter(); public faLines = faGripLines; constructor(private textRenderingService: TextRenderingService, private elRef: ElementRef) { } + public _chordMode: ChordMode = 'hide'; + + @Input() + public set chordMode(value: ChordMode) { + this._chordMode = value ?? 'hide'; + } + @Input() public set text(value: string) { this.sections = this.textRenderingService.parse(value).sort((a, b) => a.type - b.type); @@ -61,6 +63,10 @@ export class SongTextComponent implements OnInit { this.chordModeChanged.emit(next); } + public onClick() { + scrollTo(0, this.elRef.nativeElement.offsetTop - 20); + } + private getNextChordMode(): ChordMode { switch (this._chordMode) { case 'show': @@ -71,8 +77,4 @@ export class SongTextComponent implements OnInit { return 'show'; } } - - public onClick() { - scrollTo(0, this.elRef.nativeElement.offsetTop - 20); - } }