14 Commits

Author SHA1 Message Date
73d3ecfd42 optimize styling definitions 2024-06-09 22:51:14 +02:00
3ff7c8c17e RELEASE 1.6 2024-06-09 22:28:43 +02:00
2f523c5092 set song count 2024-06-09 22:28:18 +02:00
669bd0d852 better show filters 2024-04-09 20:33:59 +02:00
3d31594dbc RELEASE 1.5 2024-02-24 22:32:53 +01:00
107fc41c4f update packages 2024-02-24 22:18:15 +01:00
9025d2c8a5 add updater to script list 2024-02-24 22:15:31 +01:00
4aeb452434 guest mode 2024-02-24 22:01:48 +01:00
150e20ccfb update npm packages 2024-02-17 18:14:30 +01:00
9cd565acb8 update ng packages 2024-02-17 16:14:03 +01:00
5cb7b12508 fix console log 2024-02-17 16:01:51 +01:00
a364536127 fix textarea font 2024-02-17 16:00:31 +01:00
8a9e2d58c5 fix background 2024-02-13 17:32:18 +01:00
45677eb1c3 RELEASE 1.4 2024-02-11 18:01:34 +01:00
42 changed files with 3491 additions and 5478 deletions

12
.run/build.run.xml Normal file
View File

@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="build"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>

12
.run/deploy.run.xml Normal file
View File

@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="deploy" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json"/>
<command value="run"/>
<scripts>
<script value="deploy"/>
</scripts>
<node-interpreter value="project"/>
<envs/>
<method v="2"/>
</configuration>
</component>

View File

@@ -50,7 +50,8 @@
"namedChunks": true, "namedChunks": true,
"allowedCommonJsDependencies": [ "allowedCommonJsDependencies": [
"lodash", "lodash",
"docx" "docx",
"qrcode"
] ]
}, },
"configurations": { "configurations": {

View File

@@ -17,6 +17,10 @@ service cloud.firestore {
allow read: if request.auth.uid != null; allow read: if request.auth.uid != null;
} }
match /guest/{guestId} {
allow read: if true;
allow write: if request.auth.uid != null;
}
match /songs/{song} { match /songs/{song} {
allow read: if request.auth.uid != null; allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null; allow write: if request.auth.uid != null;

8268
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,73 +1,70 @@
{ {
"name": "wgenerator", "name": "wgenerator",
"version": "1.3", "version": "1.6",
"scripts": { "scripts": {
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"deploy": "ng build --configuration production && firebase deploy", "deploy": "ng build --configuration production && firebase deploy",
"test": "ng test", "test": "ng test",
"lint": "ng lint --fix" "lint": "ng lint --fix",
"update": "ng update @angular/cdk @angular/cli @angular/core @angular/material && ncu -u && npm i && npm fix"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^17.1.3", "@angular/animations": "^17.2.2",
"@angular/cdk": "^17.1.2", "@angular/cdk": "^17.2.1",
"@angular/common": "^17.1.3", "@angular/common": "^17.2.2",
"@angular/compiler": "^17.1.3", "@angular/compiler": "^17.2.2",
"@angular/core": "^17.1.3", "@angular/core": "^17.2.2",
"@angular/fire": "^17.0.1", "@angular/fire": "^17.0.1",
"@angular/forms": "^17.1.3", "@angular/forms": "^17.2.2",
"@angular/material": "^17.1.2", "@angular/material": "^17.2.1",
"@angular/platform-browser": "^17.1.3", "@angular/platform-browser": "^17.2.2",
"@angular/platform-browser-dynamic": "^17.1.3", "@angular/platform-browser-dynamic": "^17.2.2",
"@angular/router": "^17.1.3", "@angular/router": "^17.2.2",
"@angular/service-worker": "^17.1.3", "@angular/service-worker": "^17.2.2",
"@fortawesome/angular-fontawesome": "^0.13.0", "@fortawesome/angular-fontawesome": "^0.14.1",
"@fortawesome/fontawesome-svg-core": "^6.4.2", "@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/free-solid-svg-icons": "^6.5.1",
"docx": "^7.4.1", "docx": "^8.5.0",
"firebase": "^10.0.0", "firebase": "^10.8.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"ngx-mat-select-search": "^7.0.5", "ngx-mat-select-search": "^7.0.5",
"rxfire": "^6.0.3", "qrcode": "^1.5.3",
"rxfire": "^6.0.5",
"rxjs": "~7.8.1", "rxjs": "~7.8.1",
"swiper": "^9.3.2", "swiper": "^11.0.6",
"tslib": "^2.4.0", "tslib": "^2.6.2",
"uuid": "^8.3.2", "zone.js": "~0.14.4"
"zone.js": "~0.14.3"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/architect": "0.1701.3", "@angular-devkit/architect": "0.1702.1",
"@angular-devkit/build-angular": "^17.1.3", "@angular-devkit/build-angular": "^17.2.1",
"@angular-eslint/builder": "17.2.1", "@angular-eslint/builder": "17.2.1",
"@angular-eslint/eslint-plugin": "17.2.1", "@angular-eslint/eslint-plugin": "17.2.1",
"@angular-eslint/eslint-plugin-template": "17.2.1", "@angular-eslint/eslint-plugin-template": "17.2.1",
"@angular-eslint/schematics": "17.2.1", "@angular-eslint/schematics": "17.2.1",
"@angular-eslint/template-parser": "17.2.1", "@angular-eslint/template-parser": "17.2.1",
"@angular/cli": "^17.1.3", "@angular/cli": "^17.2.1",
"@angular/compiler-cli": "^17.1.3", "@angular/compiler-cli": "^17.2.2",
"@angular/language-service": "^17.1.3", "@angular/language-service": "^17.2.2",
"@types/jasmine": "~4.0.3", "@types/jasmine": "~5.1.4",
"@types/jasminewd2": "~2.0.10", "@types/jasminewd2": "~2.0.13",
"@types/lodash": "^4.14.182", "@types/lodash": "^4.14.202",
"@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^6.10.0", "@typescript-eslint/parser": "^7.0.2",
"eslint": "^8.53.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.1.3",
"firebase-tools": "^13.2.1", "firebase-tools": "^13.3.1",
"fuzzy": "^0.1.3", "jasmine-core": "~5.1.2",
"inquirer": "^9.1.0",
"inquirer-autocomplete-prompt": "^2.0.0",
"jasmine-core": "~4.3.0",
"jasmine-spec-reporter": "~7.0.0", "jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.0", "karma": "~6.4.2",
"karma-chrome-launcher": "~3.1.1", "karma-chrome-launcher": "~3.2.0",
"karma-coverage-istanbul-reporter": "~3.0.3", "karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0", "karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0", "karma-jasmine-html-reporter": "^2.1.0",
"prettier": "^2.7.1", "prettier": "^3.2.5",
"protractor": "~7.0.0",
"typescript": "~5.3.3" "typescript": "~5.3.3"
} }
} }

View File

@@ -54,6 +54,7 @@ const routes: Routes = [
imports: [ imports: [
RouterModule.forRoot(routes, { RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules, preloadingStrategy: PreloadAllModules,
scrollPositionRestoration: 'enabled',
// relativeLinkResolution: 'legacy', // relativeLinkResolution: 'legacy',
}), }),
], ],

View File

@@ -0,0 +1,23 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {DbService} from 'src/app/services/db.service';
import {GuestShow} from './guest-show';
@Injectable({
providedIn: 'root',
})
export class GuestShowDataService {
public list$: BehaviorSubject<GuestShow[]> = new BehaviorSubject<GuestShow[]>([]);
private collection = 'guest';
public constructor(private dbService: DbService) {
this.dbService.col$<GuestShow>(this.collection).subscribe(_ => this.list$.next(_));
}
public read$: (id: string) => Observable<GuestShow | null> = (id: string): Observable<GuestShow | null> => this.list$.pipe(map(_ => _.find(s => s.id === id) || null));
public update$: (id: string, data: Partial<GuestShow>) => Promise<void> = async (id: string, data: Partial<GuestShow>): Promise<void> =>
await this.dbService.doc(this.collection + '/' + id).update(data);
public add: (data: Partial<GuestShow>) => Promise<string> = async (data: Partial<GuestShow>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
public delete: (id: string) => Promise<void> = async (id: string): Promise<void> => await this.dbService.doc(this.collection + '/' + id).delete();
}

View File

@@ -0,0 +1,32 @@
import {Injectable} from '@angular/core';
import {Show} from '../shows/services/show';
import {Song} from '../songs/services/song';
import {GuestShowDataService} from './guest-show-data.service';
import {ShowService} from '../shows/services/show.service';
@Injectable({
providedIn: 'root',
})
export class GuestShowService {
public constructor(
private showService: ShowService,
private guestShowDataService: GuestShowDataService
) {}
public async share(show: Show, songs: Song[]): Promise<string> {
const data = {
showType: show.showType,
date: show.date,
songs: songs,
};
if (!show.shareId) {
const shareId = await this.guestShowDataService.add(data);
await this.showService.update$(show.id, {shareId});
} else {
await this.guestShowDataService.update$(show.shareId, data);
}
return window.location.protocol + '//' + window.location.host + '/guest/' + show.shareId;
}
}

View File

@@ -0,0 +1,10 @@
import firebase from 'firebase/compat/app';
import {Song} from '../songs/services/song';
import Timestamp = firebase.firestore.Timestamp;
export interface GuestShow {
id: string;
showType: string;
date: Timestamp;
songs: Song[];
}

View File

@@ -1,11 +1,25 @@
<div *ngIf="songs$ | async as songs" class="view"> <div *ngIf="show$|async as show" class="page">
<!-- <swiper>--> <div class="title">
<!-- <div *ngFor="let song of songs" class="song">--> <div class="left">{{ show.showType|showType }}</div>
<!-- <app-song-text--> <div class="right">{{ show.date.toDate() | date: 'dd.MM.yyyy' }}</div>
<!-- [showSwitch]="false"-->
<!-- [text]="song"-->
<!-- chordMode="hide"-->
<!-- ></app-song-text>-->
<!-- </div>-->
<!-- </swiper>-->
</div> </div>
<div class="view">
<swiper-container scrollbar="true">
<swiper-slide *ngFor="let song of show.songs; let i = index; trackBy: trackBy"
class="song-swipe">
<div class="song-title">{{ song.title }}</div>
<div class="legal">
<p *ngIf="song.artist">{{ song.artist }}</p>
</div>
<app-song-text
[text]="song.text"
></app-song-text>
</swiper-slide>
</swiper-container>
</div>
</div>

View File

@@ -1,12 +1,49 @@
.page {
background: #0009;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
backdrop-filter: blur(8px);
--swiper-scrollbar-bg-color: #fff3;
--swiper-scrollbar-drag-bg-color: #fff9;
--swiper-scrollbar-sides-offset: 20px;
--swiper-scrollbar-top: 100px;
--swiper-scrollbar-bottom: auto;
}
.title {
color: white;
padding: 70px 20px 0;
display: flex;
justify-content: space-between;
align-items: center;
.left {
font-size: 1.8em;
color: #fff;
}
}
.song-title {
padding: 20px 20px 0;
font-size: 1.3em;
}
.legal {
padding: 0 20px;
font-size: 0.6em;
color: #fff9;
}
.view { .view {
position: fixed; position: fixed;
top: 0; top: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
background: #0003;
backdrop-filter: blur(10px);
z-index: 1;
color: white; color: white;
} }
@@ -14,3 +51,9 @@ app-song-text {
margin: 20px; margin: 20px;
display: block; display: block;
} }
.song-swipe {
margin-top: 100px;
margin-bottom: 50px;
min-height: calc(100vh - 150px);
}

View File

@@ -1,11 +1,9 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {SongService} from '../songs/services/song.service'; import {GuestShowDataService} from './guest-show-data.service';
import {GlobalSettingsService} from '../../services/global-settings.service'; import {ActivatedRoute} from '@angular/router';
import {Observable} from 'rxjs'; import {map, switchMap} from 'rxjs/operators';
import {filter, map, switchMap} from 'rxjs/operators'; import {Song} from '../songs/services/song';
import {ShowSongService} from '../shows/services/show-song.service'; import {ConfigService} from '../../services/config.service';
import {GlobalSettings} from '../../services/global-settings';
import {ShowService} from '../shows/services/show.service';
@Component({ @Component({
selector: 'app-guest', selector: 'app-guest',
@@ -13,20 +11,17 @@ import {ShowService} from '../shows/services/show.service';
styleUrls: ['./guest.component.less'], styleUrls: ['./guest.component.less'],
}) })
export class GuestComponent { export class GuestComponent {
public songs$: Observable<string[]> = this.globalSettingsService.get$.pipe( public show$ = this.currentRoute.params.pipe(
filter(_ => !!_), map(param => param.id as string),
map(_ => _ as GlobalSettings), switchMap(id => this.service.read$(id))
map(_ => _.currentShow),
switchMap(_ => this.showSongService.list$(_).pipe(map(l => ({showSongs: l, currentShow: _})))),
switchMap(_ => this.showService.read$(_.currentShow).pipe(map(l => ({showSongs: _.showSongs, show: l})))),
filter(_ => !!_.showSongs),
map(_ => (_?.show ? _.show.order.map(o => _.showSongs.find(f => f.id === o) ?? _.showSongs[0]).map(m => m.text) : []))
); );
public config$ = this.configService.get$();
public constructor( public constructor(
private songService: SongService, private currentRoute: ActivatedRoute,
private showService: ShowService, private service: GuestShowDataService,
private globalSettingsService: GlobalSettingsService, private configService: ConfigService
private showSongService: ShowSongService
) {} ) {}
public trackBy = (index: number, show: Song) => show.id;
} }

View File

@@ -1,11 +1,23 @@
import {NgModule} from '@angular/core'; import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {GuestComponent} from './guest.component'; import {GuestComponent} from './guest.component';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module'; import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module';
import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module';
@NgModule({ @NgModule({
declarations: [GuestComponent], declarations: [GuestComponent],
imports: [CommonModule, RouterModule.forChild([{path: '', component: GuestComponent}]), SongTextModule], imports: [
CommonModule,
RouterModule.forChild([
{
path: ':id',
component: GuestComponent,
},
]),
SongTextModule,
ShowTypeTranslaterModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}) })
export class GuestModule {} export class GuestModule {}

View File

@@ -0,0 +1,13 @@
<div mat-dialog-content>
<a [href]="data.url">{{ data.url }}</a>
<div [style.background-image]="'url('+qrCode+')'" alt="qrcode" class="qrcode">
</div>
</div>
<div mat-dialog-actions>
<button [mat-dialog-close]="true" cdkFocusInitial mat-button>
Schließen
</button>
<button (click)="share()" mat-button>
Teilen
</button>
</div>

View File

@@ -0,0 +1,7 @@
.qrcode {
width: 300px;
height: 300px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}

View File

@@ -0,0 +1,22 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ShareDialogComponent} from './share-dialog.component';
describe('ShareDialogComponent', () => {
let component: ShareDialogComponent;
let fixture: ComponentFixture<ShareDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ShareDialogComponent],
}).compileComponents();
fixture = TestBed.createComponent(ShareDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,49 @@
import {Component, Inject} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogActions, MatDialogClose, MatDialogContent} from '@angular/material/dialog';
import {MatButton} from '@angular/material/button';
import QRCode from 'qrcode';
import {AsyncPipe} from '@angular/common';
import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translater/show-type.pipe';
import {Show} from '../../services/show';
export interface ShareDialogData {
url: string;
show: Show;
}
@Component({
selector: 'app-share-dialog',
standalone: true,
imports: [MatButton, MatDialogActions, MatDialogContent, MatDialogClose, AsyncPipe],
templateUrl: './share-dialog.component.html',
styleUrl: './share-dialog.component.less',
})
export class ShareDialogComponent {
public qrCode: string;
public constructor(@Inject(MAT_DIALOG_DATA) public data: ShareDialogData) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
QRCode.toDataURL(data.url, {
type: 'image/jpeg',
quality: 0.92,
width: 1280,
height: 1280,
color: {
dark: '#010414',
light: '#ffffff',
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return
}).then(_ => (this.qrCode = _));
}
public async share() {
if (navigator.clipboard) await navigator.clipboard.writeText(this.data.url);
if (navigator.share)
await navigator.share({
title: new ShowTypePipe().transform(this.data.show.showType),
text: new ShowTypePipe().transform(this.data.show.showType) + ' am ' + this.data.show.date.toDate().toLocaleString('de'),
url: this.data.url,
});
}
}

View File

@@ -1,3 +1,5 @@
export interface FilterValues { export interface FilterValues {
time: number; time: number;
owner: string;
showType: string;
} }

View File

@@ -10,6 +10,34 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Ersteller</mat-label>
<mat-select formControlName="owner">
<mat-option *ngFor="let owner of owners" [value]="owner.key">{{
owner.value
}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Art der Veranstaltung</mat-label>
<mat-select formControlName="showType">
<mat-optgroup label="öffentlich">
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
key | showType
}}
</mat-option>
</mat-optgroup>
<mat-optgroup label="privat">
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
key | showType
}}
</mat-option>
</mat-optgroup>
</mat-select>
</mat-form-field>
</div> </div>
<i>Anzahl der Suchergebnisse: {{ shows.length }}</i> <i>Anzahl der Suchergebnisse: {{ shows.length }}</i>

View File

@@ -1,5 +1,5 @@
.third { .third {
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
column-gap: 20px; column-gap: 20px;
} }

View File

@@ -4,6 +4,12 @@ import {ActivatedRoute, Router} from '@angular/router';
import {UntypedFormBuilder, UntypedFormGroup} from '@angular/forms'; import {UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
import {FilterValues} from './filter-values'; import {FilterValues} from './filter-values';
import {Show} from '../../services/show'; import {Show} from '../../services/show';
import {ShowService} from '../../services/show.service';
import {distinctUntilChanged, map} from 'rxjs/operators';
import {combineLatest, Observable} from 'rxjs';
import {dynamicSort, onlyUnique} from '../../../../services/filter.helper';
import {UserService} from '../../../../services/user/user.service';
import {isEqual} from 'lodash';
@Component({ @Component({
selector: 'app-filter', selector: 'app-filter',
@@ -14,6 +20,9 @@ export class FilterComponent {
@Input() public route = '/shows/'; @Input() public route = '/shows/';
@Input() public shows: Show[] = []; @Input() public shows: Show[] = [];
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
public filterFormGroup: UntypedFormGroup; public filterFormGroup: UntypedFormGroup;
public times: KeyValue<number, string>[] = [ public times: KeyValue<number, string>[] = [
{key: 1, value: 'letzter Monat'}, {key: 1, value: 'letzter Monat'},
@@ -22,9 +31,19 @@ export class FilterComponent {
{key: 99999, value: 'alle'}, {key: 99999, value: 'alle'},
]; ];
public constructor(private router: Router, activatedRoute: ActivatedRoute, fb: UntypedFormBuilder) { public owners: {key: string; value: string}[] = [];
public constructor(
private router: Router,
private showService: ShowService,
private userService: UserService,
activatedRoute: ActivatedRoute,
fb: UntypedFormBuilder
) {
this.filterFormGroup = fb.group({ this.filterFormGroup = fb.group({
time: 1, time: 1,
owner: null,
showType: null,
}); });
activatedRoute.queryParams.subscribe(params => { activatedRoute.queryParams.subscribe(params => {
@@ -33,8 +52,34 @@ export class FilterComponent {
}); });
this.filterFormGroup.controls.time.valueChanges.subscribe(_ => void this.filerValueChanged('time', _ as number)); this.filterFormGroup.controls.time.valueChanges.subscribe(_ => void this.filerValueChanged('time', _ as number));
this.filterFormGroup.controls.owner.valueChanges.subscribe(_ => void this.filerValueChanged('owner', _ as string));
this.filterFormGroup.controls.showType.valueChanges.subscribe(_ => void this.filerValueChanged('showType', _ as string));
this.owners$().subscribe(owners => (this.owners = owners));
} }
public owners$ = (): Observable<{key: string; value: string}[]> => {
return combineLatest([
this.showService.list$().pipe(
map(shows => {
return shows.map(show => show.owner).filter(onlyUnique);
})
),
this.userService.users$,
]).pipe(
map(([owners, users]) => {
return owners
.map(ownerId => ({
key: ownerId,
value: users.find(user => user.id === ownerId)?.name,
}))
.sort(dynamicSort('value'));
}),
distinctUntilChanged(isEqual),
map(_ => _ as {key: string; value: string}[])
);
};
private async filerValueChanged<T>(key: string, value: T): Promise<void> { private async filerValueChanged<T>(key: string, value: T): Promise<void> {
const route = this.router.createUrlTree([this.route], { const route = this.router.createUrlTree([this.route], {
queryParams: {[key]: value}, queryParams: {[key]: value},

View File

@@ -9,7 +9,7 @@
<app-card <app-card
*ngIf="shows.length > 0" *ngIf="shows.length > 0"
[padding]="false" [padding]="false"
heading="meine Veranstaltungen" heading="Meine Veranstaltungen"
> >
<app-list-item <app-list-item
*ngFor="let show of shows | sortBy: 'desc':'date'" *ngFor="let show of shows | sortBy: 'desc':'date'"
@@ -24,7 +24,7 @@
<app-card <app-card
*ngIf="shows.length > 0" *ngIf="shows.length > 0"
[padding]="false" [padding]="false"
heading="veröffentlichte Veranstaltungen" heading="Veröffentlichte Veranstaltungen"
> >
<app-list-item <app-list-item
*ngFor="let show of shows | sortBy: 'desc':'date'; trackBy: trackBy" *ngFor="let show of shows | sortBy: 'desc':'date'; trackBy: trackBy"

View File

@@ -23,18 +23,29 @@ export class ListComponent {
return +filterValues.time; return +filterValues.time;
}) })
); );
public owner$ = this.activatedRoute.queryParams.pipe(
map(params => {
const filterValues = params as FilterValues;
return filterValues?.owner;
})
);
public publicShows$ = combineLatest([this.shows$, this.lastMonths$]).pipe( public publicShows$ = combineLatest([this.shows$, this.lastMonths$, this.owner$]).pipe(
map(_ => map(([shows, lastMonths, owner]) =>
_[0].filter(f => { shows
.filter(f => {
const d = new Date(); const d = new Date();
d.setMonth(d.getMonth() - _[1]); d.setMonth(d.getMonth() - lastMonths);
return f.published && f.date.toDate() >= d; return f.published && f.date.toDate() >= d;
}) })
.filter(show => !owner || show.owner === owner)
) )
); );
public constructor(private showService: ShowService, private activatedRoute: ActivatedRoute) {} public constructor(
private showService: ShowService,
private activatedRoute: ActivatedRoute
) {}
public trackBy = (index: number, show: unknown) => (show as Show).id; public trackBy = (index: number, show: unknown) => (show as Show).id;
} }

View File

@@ -22,7 +22,11 @@ export class NewComponent implements OnInit {
}); });
public faSave = faSave; public faSave = faSave;
public constructor(private showService: ShowService, showDataService: ShowDataService, private router: Router) { public constructor(
private showService: ShowService,
showDataService: ShowDataService,
private router: Router
) {
this.shows$ = showDataService.list$; this.shows$ = showDataService.list$;
} }

View File

@@ -14,6 +14,7 @@ export class ShowDataService {
this.dbService.col$<Show>(this.collection).subscribe(_ => this.list$.next(_)); this.dbService.col$<Show>(this.collection).subscribe(_ => this.list$.next(_));
} }
public listRaw$ = () => this.dbService.col$<Show>(this.collection);
public list$ = new BehaviorSubject<Show[]>([]); public list$ = new BehaviorSubject<Show[]>([]);
public read$ = (showId: string): Observable<Show | null> => this.list$.pipe(map(_ => _.find(s => s.id === showId) || null)); public read$ = (showId: string): Observable<Show | null> => this.list$.pipe(map(_ => _.find(s => s.id === showId) || null));

View File

@@ -29,6 +29,7 @@ export class ShowSongService {
chordMode: user.chordMode, chordMode: user.chordMode,
addedLive, addedLive,
}; };
await this.userService.incSongCount(songId);
return await this.showSongDataService.add(showId, data); return await this.showSongDataService.add(showId, data);
} }
@@ -38,13 +39,15 @@ export class ShowSongService {
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId); public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId);
public list = (showId: string): Promise<ShowSong[]> => firstValueFrom(this.list$(showId)); public list = (showId: string): Promise<ShowSong[]> => firstValueFrom(this.list$(showId));
public async delete$(showId: string, songId: string, index: number): Promise<void> { public async delete$(showId: string, showSongId: string, index: number): Promise<void> {
await this.showSongDataService.delete(showId, songId); const showSong = await this.read(showId, showSongId);
await this.showSongDataService.delete(showId, showSongId);
const show = await firstValueFrom(this.showService.read$(showId)); const show = await firstValueFrom(this.showService.read$(showId));
if (!show) return; if (!show) return;
const order = show.order; const order = show.order;
order.splice(index, 1); order.splice(index, 1);
await this.showService.update$(showId, {order}); await this.showService.update$(showId, {order});
await this.userService.decSongCount(showSong.songId);
} }
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data); public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);

View File

@@ -13,6 +13,7 @@ export interface Show {
published: boolean; published: boolean;
archived: boolean; archived: boolean;
order: string[]; order: string[];
shareId: string;
presentationSongId: string; presentationSongId: string;
presentationDynamicCaption: string; presentationDynamicCaption: string;

View File

@@ -41,7 +41,8 @@
</div> </div>
<swiper-container *ngIf="useSwiper" scrollbar="true"> <swiper-container *ngIf="useSwiper" scrollbar="true">
<swiper-slide *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy" [style.font-size]="textSize + 'em'" <swiper-slide *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy"
[style.font-size]="textSize + 'em'"
class="song-swipe"> class="song-swipe">
<app-song <app-song
[fullscreen]="true" [fullscreen]="true"
@@ -76,6 +77,9 @@
<app-button (click)="onPublish(false)" *ngIf="show.published" [icon]="faUnpublish"> <app-button (click)="onPublish(false)" *ngIf="show.published" [icon]="faUnpublish">
Veröffentlichung zurückziehen Veröffentlichung zurückziehen
</app-button> </app-button>
<app-button (click)="onShare(show)" *ngIf="show.published" [icon]="faShare">
Teilen
</app-button>
<app-button (click)="onChange(show.id)" [icon]="faSliders" *ngIf="!show.published"> <app-button (click)="onChange(show.id)" [icon]="faSliders" *ngIf="!show.published">
Ändern Ändern
</app-button> </app-button>

View File

@@ -19,6 +19,7 @@ import {
faLock, faLock,
faMagnifyingGlassMinus, faMagnifyingGlassMinus,
faMagnifyingGlassPlus, faMagnifyingGlassPlus,
faShare,
faSliders, faSliders,
faUser, faUser,
faUsers, faUsers,
@@ -28,6 +29,8 @@ import {fade} from '../../../animations';
import {MatDialog} from '@angular/material/dialog'; import {MatDialog} from '@angular/material/dialog';
import {ArchiveDialogComponent} from '../dialog/archive-dialog/archive-dialog.component'; import {ArchiveDialogComponent} from '../dialog/archive-dialog/archive-dialog.component';
import {closeFullscreen, openFullscreen} from '../../../services/fullscreen'; import {closeFullscreen, openFullscreen} from '../../../services/fullscreen';
import {GuestShowService} from '../../guest/guest-show.service';
import {ShareDialogComponent} from '../dialog/share-dialog/share-dialog.component';
@Component({ @Component({
selector: 'app-show', selector: 'app-show',
@@ -46,14 +49,13 @@ export class ShowComponent implements OnInit, OnDestroy {
public faBoxOpen = faBoxOpen; public faBoxOpen = faBoxOpen;
public faPublish = faExternalLinkAlt; public faPublish = faExternalLinkAlt;
public faUnpublish = faLock; public faUnpublish = faLock;
public faShare = faShare;
public faDownload = faFileDownload; public faDownload = faFileDownload;
public faSliders = faSliders; public faSliders = faSliders;
public faUser = faUser; public faUser = faUser;
public faUsers = faUsers; public faUsers = faUsers;
public faZoomIn = faMagnifyingGlassPlus; public faZoomIn = faMagnifyingGlassPlus;
public faZoomOut = faMagnifyingGlassMinus; public faZoomOut = faMagnifyingGlassMinus;
public faPage = faFile;
public faLines = faFileLines;
private subs: Subscription[] = []; private subs: Subscription[] = [];
public useSwiper = false; public useSwiper = false;
@@ -65,7 +67,8 @@ export class ShowComponent implements OnInit, OnDestroy {
private docxService: DocxService, private docxService: DocxService,
private router: Router, private router: Router,
private cRef: ChangeDetectorRef, private cRef: ChangeDetectorRef,
public dialog: MatDialog public dialog: MatDialog,
private guestShowService: GuestShowService
) {} ) {}
public ngOnInit(): void { public ngOnInit(): void {
@@ -128,6 +131,11 @@ export class ShowComponent implements OnInit, OnDestroy {
if (this.showId != null) await this.showService.update$(this.showId, {published}); if (this.showId != null) await this.showService.update$(this.showId, {published});
} }
public onShare = async (show: Show): Promise<void> => {
const url = await this.guestShowService.share(show, this.orderedShowSongs(show));
this.dialog.open(ShareDialogComponent, {data: {url, show}});
};
public getStatus(show: Show): string { public getStatus(show: Show): string {
if (show.published) { if (show.published) {
return 'veröffentlicht'; return 'veröffentlicht';
@@ -162,7 +170,7 @@ export class ShowComponent implements OnInit, OnDestroy {
return show.order.map(_ => list.filter(f => f.id === _)[0]); return show.order.map(_ => list.filter(f => f.id === _)[0]);
} }
public trackBy = (index: number, show: ShowSong) => show.id; public trackBy = (_: number, show: ShowSong) => show.id;
public async onChange(showId: string) { public async onChange(showId: string) {
await this.router.navigateByUrl('/shows/' + showId + '/edit'); await this.router.navigateByUrl('/shows/' + showId + '/edit');

View File

@@ -24,6 +24,7 @@
<mat-form-field *ngIf="edit" appearance="outline"> <mat-form-field *ngIf="edit" appearance="outline">
<mat-label>Songtext</mat-label> <mat-label>Songtext</mat-label>
<textarea matTooltip="Tonart ändern" <textarea matTooltip="Tonart ändern"
class="edit"
[cdkTextareaAutosize]="true" [cdkTextareaAutosize]="true"
[formControl]="editSongControl" [formControl]="editSongControl"
matInput matInput

View File

@@ -78,6 +78,6 @@ button {
} }
textarea { textarea.edit {
font-family: 'Ubuntu Mono', monospace; font-family: 'Ubuntu Mono', monospace;
} }

View File

@@ -25,7 +25,10 @@ export class SongService {
// private list: Song[]; // private list: Song[];
public constructor(private songDataService: SongDataService, private userService: UserService) { public constructor(
private songDataService: SongDataService,
private userService: UserService
) {
// importCCLI = (songs: Song[]) => this.updateFromCLI(songs); // importCCLI = (songs: Song[]) => this.updateFromCLI(songs);
} }

View File

@@ -29,7 +29,7 @@ export class SongListComponent implements OnInit, OnDestroy {
const songs = _[1]; const songs = _[1];
const filter = _[0]; const filter = _[0];
this.anyFilterActive = this.checkIfFilterActive(filter); this.anyFilterActive = this.checkIfFilterActive(filter);
return songs.filter(song => this.filter(song, filter)).sort((a, b) => a.title.localeCompare(b.title)); return songs.filter(song => this.filter(song, filter)).sort((a, b) => a.title?.localeCompare(b.title));
}) })
); );
public anyFilterActive = false; public anyFilterActive = false;

View File

@@ -29,10 +29,10 @@
<div *ngIf="song.label">Verlag: {{ song.label }}</div> <div *ngIf="song.label">Verlag: {{ song.label }}</div>
<div *ngIf="song.origin">Quelle: {{ song.origin }}</div> <div *ngIf="song.origin">Quelle: {{ song.origin }}</div>
<div *ngIf="song.origin">Quelle: {{ song.origin }}</div> <div *ngIf="song.origin">Quelle: {{ song.origin }}</div>
<div *ngIf="songCount$()|async as count">Wie oft verwendet: {{ count }}</div>
</div> </div>
</div> </div>
<!-- <div class="text">{{song.text}}</div>-->
<app-song-text <app-song-text
*ngIf="user$ | async as user" *ngIf="user$ | async as user"
[chordMode]="user.chordMode" [chordMode]="user.chordMode"

View File

@@ -1,9 +1,9 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {SongService} from '../services/song.service'; import {SongService} from '../services/song.service';
import {map, switchMap} from 'rxjs/operators'; import {distinctUntilChanged, map, switchMap} from 'rxjs/operators';
import {Song} from '../services/song'; import {Song} from '../services/song';
import {Observable} from 'rxjs'; import {combineLatest, Observable} from 'rxjs';
import {FileDataService} from '../services/file-data.service'; import {FileDataService} from '../services/file-data.service';
import {File} from '../services/file'; import {File} from '../services/file';
import {UserService} from '../../../services/user/user.service'; import {UserService} from '../../../services/user/user.service';
@@ -71,4 +71,12 @@ export class SongComponent implements OnInit {
await this.showService.update$(show?.id, {order: [...show.order, newId ?? '']}); await this.showService.update$(show?.id, {order: [...show.order, newId ?? '']});
await this.router.navigateByUrl('/shows/' + show.id); await this.router.navigateByUrl('/shows/' + show.id);
} }
public songCount$ = () =>
combineLatest([this.user$, this.song$]).pipe(
map(([user, song]) => {
return user.songUsage[song.id];
}),
distinctUntilChanged()
);
} }

View File

@@ -13,3 +13,20 @@ export function filterSong(song: Song, filterValue: string): boolean {
function normalize(input: string): string { function normalize(input: string): string {
return input?.toLowerCase().replace(/[\s?!.,']/g, ''); return input?.toLowerCase().replace(/[\s?!.,']/g, '');
} }
export const onlyUnique = <T>(value: T, index: number, array: T[]) => array.indexOf(value) === index;
export function dynamicSort(property: string) {
let sortOrder = 1;
if (property[0] === '-') {
sortOrder = -1;
property = property.substr(1);
}
return function (a: unknown, b: unknown) {
/* next line works with strings and numbers,
* and you may want to customize it to your needs
*/
const result = a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
return result * sortOrder;
};
}

View File

@@ -6,6 +6,8 @@ import {User} from './user';
import {DbService} from '../db.service'; import {DbService} from '../db.service';
import {environment} from '../../../environments/environment'; import {environment} from '../../../environments/environment';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ShowDataService} from '../../modules/shows/services/show-data.service';
import {ShowSongDataService} from '../../modules/shows/services/show-song-data.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@@ -14,18 +16,7 @@ export class UserService {
private iUserId$ = new BehaviorSubject<string | null>(null); private iUserId$ = new BehaviorSubject<string | null>(null);
private iUser$ = new BehaviorSubject<User | null>(null); private iUser$ = new BehaviorSubject<User | null>(null);
public constructor(private afAuth: AngularFireAuth, private db: DbService, private router: Router) { public users$ = new BehaviorSubject<User[]>([]);
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid))
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public get userId$(): Observable<string | null> { public get userId$(): Observable<string | null> {
return this.iUserId$.asObservable(); return this.iUserId$.asObservable();
@@ -37,7 +28,24 @@ export class UserService {
public currentUser = async (): Promise<User | null> => firstValueFrom(this.user$); public currentUser = async (): Promise<User | null> => firstValueFrom(this.user$);
private users$ = new BehaviorSubject<User[]>([]); public constructor(
private afAuth: AngularFireAuth,
private db: DbService,
private router: Router,
private showDataService: ShowDataService,
private showSongDataService: ShowSongDataService
) {
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid))
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public getUserbyId = (userId: string): Promise<User | null> => firstValueFrom(this.getUserbyId$(userId)); public getUserbyId = (userId: string): Promise<User | null> => firstValueFrom(this.getUserbyId$(userId));
public getUserbyId$ = (userId: string): Observable<User | null> => this.users$.pipe(map(_ => _.find(f => f.id === userId) || null)); public getUserbyId$ = (userId: string): Observable<User | null> => this.users$.pipe(map(_ => _.find(f => f.id === userId) || null));
@@ -45,6 +53,7 @@ export class UserService {
const aUser = await this.afAuth.signInWithEmailAndPassword(user, password); const aUser = await this.afAuth.signInWithEmailAndPassword(user, password);
if (!aUser.user) return null; if (!aUser.user) return null;
const dUser = await this.readUser(aUser.user.uid); const dUser = await this.readUser(aUser.user.uid);
await this.initSongUsage(dUser);
this.iUser$.next(dUser); this.iUser$.next(dUser);
this.iUserId$.next(aUser.user.uid); this.iUserId$.next(aUser.user.uid);
@@ -80,6 +89,40 @@ export class UserService {
await this.router.navigateByUrl('/brand/new-user'); await this.router.navigateByUrl('/brand/new-user');
} }
public incSongCount = (songId: string) => this.updateSongUsage(songId, 1);
public decSongCount = (songId: string) => this.updateSongUsage(songId, -1);
private async updateSongUsage(songId: string, direction: number) {
const user = await firstValueFrom(this.user$);
if (!user) return null;
const songUsage = user?.songUsage ?? {};
let currentSongCount = songUsage[songId];
if (currentSongCount === null || currentSongCount === undefined) currentSongCount = 0;
else currentSongCount = currentSongCount + direction;
songUsage[songId] = Math.max(0, currentSongCount);
await this.update$(user.id, {songUsage});
}
private async initSongUsage(user: User) {
if (user.songUsage) return;
const shows = await firstValueFrom(this.showDataService.listRaw$());
const myShows = shows.filter(show => show.owner === user.id);
const songUsage: {[songId: string]: number} = {};
for (const show of myShows) {
const showSongs = await firstValueFrom(this.showSongDataService.list$(show.id));
for (const showSong of showSongs) {
const current = songUsage[showSong.songId] ?? 0;
songUsage[showSong.songId] = current + 1;
}
}
await this.update$(user.id, {songUsage});
return;
}
private readUser$ = (uid: string) => this.db.doc$<User>('users/' + uid); private readUser$ = (uid: string) => this.db.doc$<User>('users/' + uid);
private readUser: (uid: string) => Promise<User | null> = (uid: string) => firstValueFrom(this.readUser$(uid)); private readUser: (uid: string) => Promise<User | null> = (uid: string) => firstValueFrom(this.readUser$(uid));
} }

View File

@@ -5,4 +5,5 @@ export interface User {
name: string; name: string;
role: string; role: string;
chordMode: ChordMode; chordMode: ChordMode;
songUsage: {[songId: string]: number};
} }

View File

@@ -4,11 +4,10 @@
margin: 20px; margin: 20px;
border-radius: 8px; border-radius: 8px;
background: #fffc; background: #fffc;
backdrop-filter: blur(12px); backdrop-filter: blur(15px);
overflow: hidden; overflow: hidden;
width: 800px; width: 800px;
position: relative; position: relative;
transition: all 150ms ease-in-out;
@media screen and (max-width: 860px) { @media screen and (max-width: 860px) {
width: 100vw; width: 100vw;

View File

@@ -88,21 +88,3 @@ $wgenerator-theme: mat.define-light-theme($wgenerator-primary, $wgenerator-accen
// `@include mat.legacy-typography-hierarchy(mat.define-typography-config());` // `@include mat.legacy-typography-hierarchy(mat.define-typography-config());`
@include mat.all-component-typographies(); @include mat.all-component-typographies();
@include mat.core(); @include mat.core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$wgenerator-primary: mat.define-palette(mat.$indigo-palette);
$wgenerator-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
// The warn palette is optional (defaults to red).
$wgenerator-warn: mat.define-palette(mat.$red-palette);
// Create the theme object (a Sass map containing all of the palettes).
$wgenerator-theme: mat.define-light-theme($wgenerator-primary, $wgenerator-accent, $wgenerator-warn);
// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include mat.all-component-themes($wgenerator-theme);

View File

@@ -11,18 +11,19 @@
html { html {
scroll-behavior: smooth; scroll-behavior: smooth;
overflow: hidden;
} }
body { body {
margin: 0; margin: 0;
font-family: Roboto, "Helvetica Neue", sans-serif; font-family: Roboto, "Helvetica Neue", sans-serif;
font-size: 14px; font-size: 14px;
overscroll-behavior-y: none;
color: #333; color: #333;
background-attachment: fixed;
background-image: url("/assets/background.jpg"); background-image: url("/assets/background.jpg");
background-size: cover; background-size: cover;
background-position: center;
overflow: auto;
} }
p { p {
@@ -67,7 +68,7 @@ a {
} }
html, body { html, body {
height: 100%; height: 100vh;
} }
body { body {