Compare commits
10 Commits
36e1241539
...
db6a230696
| Author | SHA1 | Date | |
|---|---|---|---|
| db6a230696 | |||
| 0d0873730a | |||
| bb08e46b0c | |||
| 26c99a0dae | |||
| 0203d4ea9d | |||
| b6c2fe1645 | |||
| a569c070c5 | |||
| f7be5c082a | |||
| a46eeeee04 | |||
| 6edfb7e297 |
@@ -1,12 +1,7 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
> 0.5%
|
||||
last 2 versions
|
||||
# Angular 21-supported baseline to avoid unsupported-browser build warnings.
|
||||
last 2 Chrome major versions
|
||||
last 2 Edge major versions
|
||||
last 2 Firefox major versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
|
||||
24
angular.json
24
angular.json
@@ -155,6 +155,30 @@
|
||||
},
|
||||
"@angular-eslint/schematics:library": {
|
||||
"setParserOptionsProject": true
|
||||
},
|
||||
"@schematics/angular:component": {
|
||||
"type": "component"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"type": "directive"
|
||||
},
|
||||
"@schematics/angular:service": {
|
||||
"type": "service"
|
||||
},
|
||||
"@schematics/angular:guard": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:interceptor": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:module": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:pipe": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:resolver": {
|
||||
"typeSeparator": "."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
76
codex-session.json
Normal file
76
codex-session.json
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"updated_at": "2026-03-09",
|
||||
"project": "wgenerator",
|
||||
"summary": {
|
||||
"css_theme": [
|
||||
"LESS @-Variablen durch CSS-Custom-Properties ersetzt",
|
||||
"natuerlichere Farbpalette auf Basis des Body-Gradients eingefuehrt",
|
||||
"Material Icon Buttons auf die Primaerfarbe abgestimmt",
|
||||
"mehrere harte Farben in normale App-Views auf Tokens umgestellt",
|
||||
"Monitor-/Beamer-Ansicht bewusst kontrastreich belassen"
|
||||
],
|
||||
"material_theme": [
|
||||
"src/custom-theme.scss auf map-basierte Angular-Material-M2-Theme-Definition umgestellt",
|
||||
"Warnung zu legacy define-light-theme-Signatur behoben"
|
||||
],
|
||||
"transpose": [
|
||||
"TransposeService auf Halbtonlogik umgebaut",
|
||||
"unbekannte Akkorde rendern bewusst als X",
|
||||
"dynamisches Rendern statt festem 100-Zeichen-Template",
|
||||
"Tests fuer Enharmonik, B/H, X-Faelle und Key-Helper ergaenzt",
|
||||
"key.helper Korrekturen: Gb-Mapping und D-Skala"
|
||||
],
|
||||
"firebase_reads": [
|
||||
"ConfigService und GlobalSettingsService auf Singleton-Streams umgestellt",
|
||||
"read$ fuer shows, songs und guest wieder direkt ueber doc$ statt list$.find(...)",
|
||||
"songUsage Login-Backfill entfernt",
|
||||
"songUsage-Inkremente auf FieldValue.increment(...) umgestellt",
|
||||
"Admin-Konsoleintrag window.wgeneratorAdmin.rebuildSongUsage() hinzugefuegt",
|
||||
"showSongDataService.list$(showId) pro showId gecacht",
|
||||
"monitor.component.ts entkoppelt, damit Show-Metadaten keine unnoetigen Song-Reads triggern"
|
||||
],
|
||||
"shows_filter": [
|
||||
"showType-Filter funktioniert wieder clientseitig",
|
||||
"Zeitraumfilter fachlich auf heute minus n*30 Tage umgestellt",
|
||||
"oeffentliche Shows werden fuer den Zeitraum serverseitig per Firestore-Query geladen",
|
||||
"owner und showType filtern weiterhin clientseitig auf dem kleineren Resultset",
|
||||
"Null-Fall im Filter-Template abgesichert"
|
||||
]
|
||||
},
|
||||
"important_files": [
|
||||
"src/styles/styles.less",
|
||||
"src/custom-theme.scss",
|
||||
"src/app/modules/songs/services/transpose.service.ts",
|
||||
"src/app/modules/songs/services/transpose.service.spec.ts",
|
||||
"src/app/modules/songs/services/key.helper.ts",
|
||||
"src/app/modules/songs/services/key.helper.spec.ts",
|
||||
"src/app/services/config.service.ts",
|
||||
"src/app/services/global-settings.service.ts",
|
||||
"src/app/services/user/user.service.ts",
|
||||
"src/main.ts",
|
||||
"src/app/modules/shows/services/show-song-data.service.ts",
|
||||
"src/app/modules/presentation/monitor/monitor.component.ts",
|
||||
"src/app/modules/presentation/remote/remote.component.ts",
|
||||
"src/app/modules/shows/services/show-data.service.ts",
|
||||
"src/app/modules/shows/list/list.component.ts",
|
||||
"src/app/modules/shows/list/filter/filter.component.ts",
|
||||
"src/app/modules/shows/list/filter/filter.component.html",
|
||||
"src/app/modules/songs/song/song.component.ts",
|
||||
"src/app/modules/songs/song/song.component.html",
|
||||
"README.md"
|
||||
],
|
||||
"console_commands": {
|
||||
"song_usage_rebuild": "await window.wgeneratorAdmin.rebuildSongUsage()"
|
||||
},
|
||||
"known_tradeoffs": [
|
||||
"songUsage wird historisch nicht mehr automatisch beim Login rekonstruiert; dafuer ist die Admin-Migration gedacht",
|
||||
"songUsage decrement kann bei inkonsistenten Aufrufpfaden theoretisch unter 0 laufen",
|
||||
"owner- und showType-Filter fuer Shows laufen noch clientseitig",
|
||||
"oeffentliche Show-Zeitraumquery kann Firestore-Indexe benoetigen"
|
||||
},
|
||||
"next_candidates": [
|
||||
"remote.component.ts weiter entkoppeln, damit textRendering.parse(...) nicht bei jeder Show-Metadatenaenderung fuer alle Songs neu laeuft",
|
||||
"users$ als Voll-Collection-Livestream spaeter auf Einzelreads bzw. gezieltere Nutzung pruefen",
|
||||
"weitere Firestore-Read-Hotspots mit echten Metriken gegenpruefen"
|
||||
]
|
||||
}
|
||||
34517
package-lock.json
generated
34517
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
89
package.json
89
package.json
@@ -11,60 +11,57 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^19.0.5",
|
||||
"@angular/cdk": "^19.0.4",
|
||||
"@angular/common": "^19.0.5",
|
||||
"@angular/compiler": "^19.0.5",
|
||||
"@angular/core": "^19.0.5",
|
||||
"@angular/fire": "^18.0.1",
|
||||
"@angular/forms": "^19.0.5",
|
||||
"@angular/material": "^19.0.4",
|
||||
"@angular/platform-browser": "^19.0.5",
|
||||
"@angular/platform-browser-dynamic": "^19.0.5",
|
||||
"@angular/router": "^19.0.5",
|
||||
"@angular/service-worker": "^19.0.5",
|
||||
"@fortawesome/angular-fontawesome": "^0.14.1",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
||||
"docx": "^8.5.0",
|
||||
"firebase": "^10.8.0",
|
||||
"lodash": "^4.17.21",
|
||||
"ngx-mat-select-search": "^7.0.5",
|
||||
"qrcode": "^1.5.3",
|
||||
"rxfire": "^6.0.5",
|
||||
"@angular/animations": "^21.2.2",
|
||||
"@angular/cdk": "^21.2.1",
|
||||
"@angular/common": "^21.2.2",
|
||||
"@angular/compiler": "^21.2.2",
|
||||
"@angular/core": "^21.2.2",
|
||||
"@angular/fire": "21.0.0-rc.0",
|
||||
"@angular/forms": "^21.2.2",
|
||||
"@angular/material": "^21.2.1",
|
||||
"@angular/platform-browser": "^21.2.2",
|
||||
"@angular/platform-browser-dynamic": "^21.2.2",
|
||||
"@angular/router": "^21.2.2",
|
||||
"@angular/service-worker": "^21.2.2",
|
||||
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
||||
"docx": "^9.6.0",
|
||||
"firebase": "^12.10.0",
|
||||
"ngx-mat-select-search": "^8.0.4",
|
||||
"qrcode": "^1.5.4",
|
||||
"rxjs": "~7.8.1",
|
||||
"swiper": "^11.0.6",
|
||||
"tslib": "^2.6.2",
|
||||
"swiper": "^12.1.2",
|
||||
"tslib": "^2.8.1",
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/architect": "0.1900.6",
|
||||
"@angular-devkit/build-angular": "^19.0.6",
|
||||
"@angular-eslint/builder": "19.0.2",
|
||||
"@angular-eslint/eslint-plugin": "19.0.2",
|
||||
"@angular-eslint/eslint-plugin-template": "19.0.2",
|
||||
"@angular-eslint/schematics": "19.0.2",
|
||||
"@angular-eslint/template-parser": "19.0.2",
|
||||
"@angular/cli": "^19.0.6",
|
||||
"@angular/compiler-cli": "^19.0.5",
|
||||
"@angular/language-service": "^19.0.5",
|
||||
"@types/jasmine": "~5.1.4",
|
||||
"@angular-devkit/architect": "0.2102.1",
|
||||
"@angular-devkit/build-angular": "^21.2.1",
|
||||
"@angular-eslint/builder": "21.3.0",
|
||||
"@angular-eslint/eslint-plugin": "21.3.0",
|
||||
"@angular-eslint/eslint-plugin-template": "21.3.0",
|
||||
"@angular-eslint/schematics": "21.3.0",
|
||||
"@angular-eslint/template-parser": "21.3.0",
|
||||
"@angular/cli": "^21.2.1",
|
||||
"@angular/compiler-cli": "^21.2.2",
|
||||
"@angular/language-service": "^21.2.2",
|
||||
"@types/jasmine": "~6.0.0",
|
||||
"@types/jasminewd2": "~2.0.13",
|
||||
"@types/lodash": "^4.14.202",
|
||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||
"@typescript-eslint/parser": "^7.2.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"firebase-tools": "^13.3.1",
|
||||
"jasmine-core": "~5.1.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
||||
"@typescript-eslint/parser": "^8.57.0",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"firebase-tools": "^15.9.1",
|
||||
"jasmine-core": "~6.1.0",
|
||||
"jasmine-spec-reporter": "~7.0.0",
|
||||
"karma": "~6.4.2",
|
||||
"karma": "~6.4.4",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage-istanbul-reporter": "~3.0.3",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "^2.1.0",
|
||||
"prettier": "^3.2.5",
|
||||
"typescript": "~5.5.4"
|
||||
"karma-jasmine-html-reporter": "^2.2.0",
|
||||
"prettier": "^3.8.1",
|
||||
"typescript": "~5.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';
|
||||
import {AngularFireAuthGuard, redirectUnauthorizedTo} from '@angular/fire/compat/auth-guard';
|
||||
import {RoleGuard} from './widget-modules/guards/role.guard';
|
||||
import {AuthGuard} from './widget-modules/guards/auth.guard';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -12,27 +12,24 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'songs',
|
||||
loadChildren: () => import('./modules/songs/songs.module').then(m => m.SongsModule),
|
||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
||||
canActivate: [AuthGuard, RoleGuard],
|
||||
data: {
|
||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
||||
requiredRoles: ['user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'shows',
|
||||
loadChildren: () => import('./modules/shows/shows.module').then(m => m.ShowsModule),
|
||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
||||
canActivate: [AuthGuard, RoleGuard],
|
||||
data: {
|
||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
||||
requiredRoles: ['leader', 'member'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'presentation',
|
||||
loadChildren: () => import('./modules/presentation/presentation.module').then(m => m.PresentationModule),
|
||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
||||
canActivate: [AuthGuard, RoleGuard],
|
||||
data: {
|
||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
||||
requiredRoles: ['presenter'],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, OnInit, inject} from '@angular/core';
|
||||
import {fader} from './animations';
|
||||
import {ScrollService} from './services/scroll.service';
|
||||
import {register} from 'swiper/element/bundle';
|
||||
@@ -14,7 +14,9 @@ import {NavigationComponent} from './widget-modules/components/application-frame
|
||||
imports: [RouterOutlet, NavigationComponent],
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
public constructor(private scrollService: ScrollService) {
|
||||
private scrollService = inject(ScrollService);
|
||||
|
||||
public constructor() {
|
||||
register();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="brand">
|
||||
<app-logo></app-logo>
|
||||
<div class="copyright">© 2019 - 2024 - Benjamin Ifland</div>
|
||||
<div class="copyright">© 2019 - 2026 - Benjamin Ifland</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<div class="frame">
|
||||
<app-brand class="brand"></app-brand>
|
||||
<div *ngIf="user$ | async as user" class="text">
|
||||
@if (user$ | async; as user) {
|
||||
<div class="text">
|
||||
<div class="welcome">WILLKOMMEN</div>
|
||||
<div class="name">{{ user.name }}</div>
|
||||
<div class="roles">
|
||||
@@ -8,4 +9,5 @@
|
||||
Administrator!
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../../services/user/user';
|
||||
import {BrandComponent} from '../brand.component';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-user',
|
||||
templateUrl: './new-user.component.html',
|
||||
styleUrls: ['./new-user.component.less'],
|
||||
imports: [BrandComponent, NgIf, AsyncPipe],
|
||||
imports: [BrandComponent, AsyncPipe],
|
||||
})
|
||||
export class NewUserComponent {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public user$: Observable<User | null> | null = null;
|
||||
|
||||
public constructor(private userService: UserService) {
|
||||
public constructor() {
|
||||
const userService = this.userService;
|
||||
|
||||
this.user$ = userService.user$;
|
||||
}
|
||||
}
|
||||
|
||||
75
src/app/modules/guest/guest-show-data.service.spec.ts
Normal file
75
src/app/modules/guest/guest-show-data.service.spec.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {of} from 'rxjs';
|
||||
import {DbService} from 'src/app/services/db.service';
|
||||
import {GuestShowDataService} from './guest-show-data.service';
|
||||
|
||||
describe('GuestShowDataService', () => {
|
||||
let service: GuestShowDataService;
|
||||
let docUpdateSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docDeleteSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docSpy: jasmine.Spy;
|
||||
let colAddSpy: jasmine.Spy<() => Promise<{id: string}>>;
|
||||
let colSpy: jasmine.Spy;
|
||||
let dbServiceSpy: jasmine.SpyObj<DbService>;
|
||||
|
||||
beforeEach(() => {
|
||||
docUpdateSpy = jasmine.createSpy('update').and.resolveTo();
|
||||
docDeleteSpy = jasmine.createSpy('delete').and.resolveTo();
|
||||
docSpy = jasmine.createSpy('doc').and.returnValue({
|
||||
update: docUpdateSpy,
|
||||
delete: docDeleteSpy,
|
||||
});
|
||||
colAddSpy = jasmine.createSpy('add').and.resolveTo({id: 'guest-2'});
|
||||
colSpy = jasmine.createSpy('col').and.returnValue({add: colAddSpy});
|
||||
dbServiceSpy = jasmine.createSpyObj<DbService>('DbService', ['col$', 'doc$', 'doc', 'col']);
|
||||
dbServiceSpy.col$.and.returnValue(of([{id: 'guest-1'}]) as never);
|
||||
dbServiceSpy.doc$.and.returnValue(of({id: 'guest-1'}) as never);
|
||||
dbServiceSpy.doc.and.callFake(docSpy);
|
||||
dbServiceSpy.col.and.callFake(colSpy);
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||
});
|
||||
|
||||
service = TestBed.inject(GuestShowDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should read the guest collection for list$', () => {
|
||||
service.list$.subscribe();
|
||||
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('guest');
|
||||
});
|
||||
|
||||
it('should read a single guest show by id', () => {
|
||||
service.read$('guest-7').subscribe();
|
||||
|
||||
expect(dbServiceSpy.doc$).toHaveBeenCalledWith('guest/guest-7');
|
||||
});
|
||||
|
||||
it('should update a guest show document', async () => {
|
||||
await service.update$('guest-7', {published: true} as never);
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('guest/guest-7');
|
||||
const [updatePayload] = docUpdateSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(updatePayload).toEqual({published: true});
|
||||
});
|
||||
|
||||
it('should add a guest show and return the created id', async () => {
|
||||
await expectAsync(service.add({published: false} as never)).toBeResolvedTo('guest-2');
|
||||
|
||||
expect(colSpy).toHaveBeenCalledWith('guest');
|
||||
const [addPayload] = colAddSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(addPayload).toEqual({published: false});
|
||||
});
|
||||
|
||||
it('should delete a guest show document', async () => {
|
||||
await service.delete('guest-7');
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('guest/guest-7');
|
||||
expect(docDeleteSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {shareReplay} from 'rxjs/operators';
|
||||
import {DbService} from 'src/app/services/db.service';
|
||||
@@ -8,6 +8,8 @@ import {GuestShow} from './guest-show';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GuestShowDataService {
|
||||
private dbService = inject(DbService);
|
||||
|
||||
private collection = 'guest';
|
||||
public list$: Observable<GuestShow[]> = this.dbService.col$<GuestShow>(this.collection).pipe(
|
||||
shareReplay({
|
||||
@@ -16,8 +18,6 @@ export class GuestShowDataService {
|
||||
})
|
||||
);
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
|
||||
public read$: (id: string) => Observable<GuestShow | null> = (id: string): Observable<GuestShow | null> => this.dbService.doc$(`${this.collection}/${id}`);
|
||||
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);
|
||||
|
||||
62
src/app/modules/guest/guest-show.service.spec.ts
Normal file
62
src/app/modules/guest/guest-show.service.spec.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {GuestShowDataService} from './guest-show-data.service';
|
||||
import {GuestShowService} from './guest-show.service';
|
||||
import {ShowService} from '../shows/services/show.service';
|
||||
|
||||
describe('GuestShowService', () => {
|
||||
let service: GuestShowService;
|
||||
let guestShowDataServiceSpy: jasmine.SpyObj<GuestShowDataService>;
|
||||
let showServiceSpy: jasmine.SpyObj<ShowService>;
|
||||
|
||||
beforeEach(() => {
|
||||
guestShowDataServiceSpy = jasmine.createSpyObj<GuestShowDataService>('GuestShowDataService', ['add', 'update$']);
|
||||
showServiceSpy = jasmine.createSpyObj<ShowService>('ShowService', ['update$']);
|
||||
guestShowDataServiceSpy.add.and.resolveTo('share-1');
|
||||
guestShowDataServiceSpy.update$.and.resolveTo();
|
||||
showServiceSpy.update$.and.resolveTo();
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: GuestShowDataService, useValue: guestShowDataServiceSpy},
|
||||
{provide: ShowService, useValue: showServiceSpy},
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(GuestShowService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should create a new guest share, persist the generated shareId on the show and return the share url', async () => {
|
||||
const show = {id: 'show-1', showType: 'service-worship', date: new Date(), shareId: ''} as any;
|
||||
const songs = [{id: 'song-1'}] as any;
|
||||
const expectedUrl = window.location.protocol + '//' + window.location.host + '/guest/share-1';
|
||||
|
||||
await expectAsync(service.share(show, songs)).toBeResolvedTo(expectedUrl);
|
||||
|
||||
expect(guestShowDataServiceSpy.add).toHaveBeenCalledWith({
|
||||
showType: 'service-worship',
|
||||
date: show.date,
|
||||
songs,
|
||||
});
|
||||
expect(showServiceSpy.update$).toHaveBeenCalledWith('show-1', {shareId: 'share-1'});
|
||||
});
|
||||
|
||||
it('should update an existing share and reuse its id in the returned url', async () => {
|
||||
const show = {id: 'show-1', showType: 'service-worship', date: new Date(), shareId: 'share-9'} as any;
|
||||
const songs = [{id: 'song-1'}] as any;
|
||||
const expectedUrl = window.location.protocol + '//' + window.location.host + '/guest/share-9';
|
||||
|
||||
await expectAsync(service.share(show, songs)).toBeResolvedTo(expectedUrl);
|
||||
|
||||
expect(guestShowDataServiceSpy.update$).toHaveBeenCalledWith('share-9', {
|
||||
showType: 'service-worship',
|
||||
date: show.date,
|
||||
songs,
|
||||
});
|
||||
expect(guestShowDataServiceSpy.add).not.toHaveBeenCalled();
|
||||
expect(showServiceSpy.update$).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Show} from '../shows/services/show';
|
||||
import {Song} from '../songs/services/song';
|
||||
import {GuestShowDataService} from './guest-show-data.service';
|
||||
@@ -8,10 +8,8 @@ import {ShowService} from '../shows/services/show.service';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GuestShowService {
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private guestShowDataService: GuestShowDataService
|
||||
) {}
|
||||
private showService = inject(ShowService);
|
||||
private guestShowDataService = inject(GuestShowDataService);
|
||||
|
||||
public async share(show: Show, songs: Song[]): Promise<string> {
|
||||
const data = {
|
||||
@@ -19,14 +17,15 @@ export class GuestShowService {
|
||||
date: show.date,
|
||||
songs: songs,
|
||||
};
|
||||
let shareId = show.shareId;
|
||||
|
||||
if (!show.shareId) {
|
||||
const shareId = await this.guestShowDataService.add(data);
|
||||
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;
|
||||
return window.location.protocol + '//' + window.location.host + '/guest/' + shareId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import firebase from 'firebase/compat/app';
|
||||
import {Song} from '../songs/services/song';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
export interface GuestShow {
|
||||
id: string;
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
<div *ngIf="show$|async as show" class="page">
|
||||
@if (show$|async; as show) {
|
||||
<div class="page">
|
||||
<div class="title">
|
||||
<div class="left">{{ show.showType|showType }}</div>
|
||||
<div class="right">{{ show.date.toDate() | date: 'dd.MM.yyyy' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="view">
|
||||
<swiper-container scrollbar="true">
|
||||
<swiper-slide *ngFor="let song of show.songs; let i = index; trackBy: trackBy"
|
||||
@for (song of show.songs; track trackBy(i, song); let i = $index) {
|
||||
<swiper-slide
|
||||
class="song-swipe">
|
||||
<div class="song-title">{{ song.title }}</div>
|
||||
|
||||
<div class="legal">
|
||||
<p *ngIf="song.artist">{{ song.artist }}</p>
|
||||
@if (song.artist) {
|
||||
<p>{{ song.artist }}</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-song-text
|
||||
[text]="song.text"
|
||||
></app-song-text>
|
||||
</swiper-slide>
|
||||
}
|
||||
</swiper-container>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {Component, CUSTOM_ELEMENTS_SCHEMA, inject} from '@angular/core';
|
||||
import {GuestShowDataService} from './guest-show-data.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {map, switchMap} from 'rxjs/operators';
|
||||
import {Song} from '../songs/services/song';
|
||||
import {ConfigService} from '../../services/config.service';
|
||||
import {AsyncPipe, DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {SongTextComponent} from '../../widget-modules/components/song-text/song-text.component';
|
||||
import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||
|
||||
@@ -13,20 +13,18 @@ import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show
|
||||
templateUrl: './guest.component.html',
|
||||
styleUrls: ['./guest.component.less'],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
imports: [NgIf, NgFor, SongTextComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
imports: [SongTextComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
})
|
||||
export class GuestComponent {
|
||||
private currentRoute = inject(ActivatedRoute);
|
||||
private service = inject(GuestShowDataService);
|
||||
private configService = inject(ConfigService);
|
||||
|
||||
public show$ = this.currentRoute.params.pipe(
|
||||
map(param => param.id as string),
|
||||
switchMap(id => this.service.read$(id))
|
||||
);
|
||||
public config$ = this.configService.get$();
|
||||
|
||||
public constructor(
|
||||
private currentRoute: ActivatedRoute,
|
||||
private service: GuestShowDataService,
|
||||
private configService: ConfigService
|
||||
) {}
|
||||
|
||||
public trackBy = (index: number, show: Song) => show.id;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
<ng-container *ngIf="song">
|
||||
<p *ngIf="song.artist">{{ song.artist }}</p>
|
||||
<p *ngIf="song.label">{{ song.label }}</p>
|
||||
<p *ngIf="song.termsOfUse" class="terms-of-use">{{ song.termsOfUse }}</p>
|
||||
<p *ngIf="song.origin">{{ song.origin }}</p>
|
||||
|
||||
<div *ngIf="song.legalOwnerId">
|
||||
<p *ngIf="song.legalOwner === 'CCLI' && config">
|
||||
@if (song) {
|
||||
@if (song.artist) {
|
||||
<p>{{ song.artist }}</p>
|
||||
}
|
||||
@if (song.label) {
|
||||
<p>{{ song.label }}</p>
|
||||
}
|
||||
@if (song.termsOfUse) {
|
||||
<p class="terms-of-use">{{ song.termsOfUse }}</p>
|
||||
}
|
||||
@if (song.origin) {
|
||||
<p>{{ song.origin }}</p>
|
||||
}
|
||||
@if (song.legalOwnerId) {
|
||||
<div>
|
||||
@if (song.legalOwner === 'CCLI' && config) {
|
||||
<p>
|
||||
CCLI-Liednummer {{ song.legalOwnerId }}, CCLI-Lizenznummer
|
||||
{{ config.ccliLicenseId }}
|
||||
</p>
|
||||
<p *ngIf="song.legalOwner !== 'CCLI'">Liednummer {{ song.legalOwnerId }}</p>
|
||||
}
|
||||
@if (song.legalOwner !== 'CCLI') {
|
||||
<p>Liednummer {{ song.legalOwnerId }}</p>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Song} from '../../../songs/services/song';
|
||||
import {Config} from '../../../../services/config';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-legal',
|
||||
templateUrl: './legal.component.html',
|
||||
styleUrls: ['./legal.component.less'],
|
||||
imports: [NgIf],
|
||||
imports: [],
|
||||
})
|
||||
export class LegalComponent {
|
||||
@Input() public song: Song | null = null;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<div class="fullscreen background"></div>
|
||||
<div *ngIf="song && showType" [style.font-size.px]="zoom" class="fullscreen background">
|
||||
|
||||
@if (showType) {
|
||||
<div [style.font-size.px]="zoom" class="fullscreen background">
|
||||
<div [class.visible]="presentationBackground==='blue'" class="bg-blue fullscreen bg-image"></div>
|
||||
<div [class.visible]="presentationBackground==='green'" class="bg-green fullscreen bg-image"></div>
|
||||
<div [class.visible]="presentationBackground==='leder'" class="bg-leder fullscreen bg-image"></div>
|
||||
<div [class.visible]="presentationBackground==='praise'" class="bg-praise fullscreen bg-image"></div>
|
||||
<div [class.visible]="presentationBackground==='bible'" class="bg-bible fullscreen bg-image"></div>
|
||||
|
||||
|
||||
<div
|
||||
[@songSwitch]="songId"
|
||||
[class.blur]="songId === 'title' || songId === 'dynamicText'"
|
||||
@@ -17,19 +15,20 @@
|
||||
>
|
||||
<app-logo></app-logo>
|
||||
</div>
|
||||
|
||||
<div *ngIf="songId === 'title'" @songSwitch class="start fullscreen">
|
||||
@if (songId === 'title') {
|
||||
<div @songSwitch class="start fullscreen">
|
||||
<div>{{ showType | showType }}</div>
|
||||
<div class="date">{{ date | date: "dd.MM.yyyy" }}</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="songId === 'dynamicText'" @songSwitch class="start fullscreen dynamic-text">
|
||||
}
|
||||
@if (songId === 'dynamicText') {
|
||||
<div @songSwitch class="start fullscreen dynamic-text">
|
||||
<div>{{ presentationDynamicCaption }}</div>
|
||||
<div class="date">{{ presentationDynamicText }}</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
@if (song && songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText') {
|
||||
<app-song-text
|
||||
*ngIf="songId !== 'title' && songId !== 'empty'"
|
||||
[@songSwitch]="songId"
|
||||
[fullscreen]="true"
|
||||
[header]="song.title"
|
||||
@@ -39,10 +38,13 @@
|
||||
[text]="song.text"
|
||||
chordMode="hide"
|
||||
></app-song-text>
|
||||
}
|
||||
@if (song && songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText') {
|
||||
<app-legal
|
||||
*ngIf="songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText'"
|
||||
[@songSwitch]="songId"
|
||||
[config]="config$ | async"
|
||||
[song]="song"
|
||||
></app-legal>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {debounceTime, distinctUntilChanged, filter, map, shareReplay, switchMap, takeUntil, tap} from 'rxjs/operators';
|
||||
import {ChangeDetectorRef, Component, OnDestroy, OnInit, inject} from '@angular/core';
|
||||
import {distinctUntilChanged, filter, map, shareReplay, switchMap, takeUntil, tap} from 'rxjs/operators';
|
||||
import {ShowService} from '../../shows/services/show.service';
|
||||
import {Song} from '../../songs/services/song';
|
||||
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
||||
@@ -11,7 +11,7 @@ import {PresentationBackground, Show} from '../../shows/services/show';
|
||||
import {ShowSong} from '../../shows/services/show-song';
|
||||
import {ShowSongService} from '../../shows/services/show-song.service';
|
||||
import {openFullscreen} from '../../../services/fullscreen';
|
||||
import {AsyncPipe, DatePipe, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {LogoComponent} from './logo/logo.component';
|
||||
import {SongTextComponent} from '../../../widget-modules/components/song-text/song-text.component';
|
||||
import {LegalComponent} from './legal/legal.component';
|
||||
@@ -22,9 +22,15 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
templateUrl: './monitor.component.html',
|
||||
styleUrls: ['./monitor.component.less'],
|
||||
animations: [songSwitch],
|
||||
imports: [NgIf, LogoComponent, SongTextComponent, LegalComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
imports: [LogoComponent, SongTextComponent, LegalComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
})
|
||||
export class MonitorComponent implements OnInit, OnDestroy {
|
||||
private showService = inject(ShowService);
|
||||
private showSongService = inject(ShowSongService);
|
||||
private globalSettingsService = inject(GlobalSettingsService);
|
||||
private configService = inject(ConfigService);
|
||||
private cRef = inject(ChangeDetectorRef);
|
||||
|
||||
public song: Song | null = null;
|
||||
public zoom = 10;
|
||||
public currentShowId: string | null = null;
|
||||
@@ -38,31 +44,24 @@ export class MonitorComponent implements OnInit, OnDestroy {
|
||||
public presentationBackground: PresentationBackground = 'none';
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private showSongService: ShowSongService,
|
||||
private globalSettingsService: GlobalSettingsService,
|
||||
private configService: ConfigService,
|
||||
private cRef: ChangeDetectorRef
|
||||
) {
|
||||
public constructor() {
|
||||
const configService = this.configService;
|
||||
|
||||
this.config$ = configService.get$();
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
openFullscreen();
|
||||
const currentShowId$ = this.globalSettingsService.get$
|
||||
.pipe(
|
||||
debounceTime(100),
|
||||
filter(_ => !!_),
|
||||
map(_ => _),
|
||||
map(_ => _.currentShow),
|
||||
const currentShowId$ = this.globalSettingsService.get$.pipe(
|
||||
filter((settings): settings is NonNullable<typeof settings> => !!settings),
|
||||
map(settings => settings.currentShow),
|
||||
filter((showId): showId is string => !!showId),
|
||||
distinctUntilChanged(),
|
||||
tap(_ => (this.currentShowId = _)),
|
||||
takeUntil(this.destroy$)
|
||||
);
|
||||
|
||||
const show$ = currentShowId$
|
||||
.pipe(
|
||||
const show$ = currentShowId$.pipe(
|
||||
switchMap(showId => this.showService.read$(showId)),
|
||||
filter((show): show is Show => !!show),
|
||||
shareReplay({
|
||||
@@ -92,6 +91,9 @@ export class MonitorComponent implements OnInit, OnDestroy {
|
||||
map(show => ({showId: show.id, presentationSongId: show.presentationSongId})),
|
||||
distinctUntilChanged((a, b) => a.showId === b.showId && a.presentationSongId === b.presentationSongId),
|
||||
tap(({presentationSongId}) => {
|
||||
if (presentationSongId === 'title' || presentationSongId === 'dynamicText' || !presentationSongId) {
|
||||
this.song = null;
|
||||
}
|
||||
if (this.songId !== presentationSongId) {
|
||||
this.songId = 'empty';
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<div *ngIf="show" @fade>
|
||||
@if (show) {
|
||||
<div @fade>
|
||||
<app-card [closeIcon]="faIcon" [heading]="show.showType | showType"
|
||||
[subheading]="show.date.toDate() | date:'dd.MM.yyyy'" closeLink="/presentation/select">
|
||||
|
||||
<ng-container *ngIf="!progress">
|
||||
@if (!progress) {
|
||||
<div class="song">
|
||||
<div *ngIf="show" class="song-parts">
|
||||
@if (show) {
|
||||
<div class="song-parts">
|
||||
<div
|
||||
(click)="onSectionClick('title', -1, show.id)"
|
||||
[class.active]="show.presentationSongId === 'title'"
|
||||
@@ -20,10 +21,12 @@
|
||||
<div class="head">Leer</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div *ngFor="let song of presentationSongs; trackBy: trackBy" class="song">
|
||||
<div *ngIf="show"
|
||||
@for (song of presentationSongs; track trackBy($index, song)) {
|
||||
<div class="song">
|
||||
@if (show) {
|
||||
<div
|
||||
[class.active]="show.presentationSongId === song.id"
|
||||
class="title song-part"
|
||||
>
|
||||
@@ -31,10 +34,12 @@
|
||||
{{ song.title }}
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="show" class="song-parts">
|
||||
}
|
||||
@if (show) {
|
||||
<div class="song-parts">
|
||||
@for (section of song.sections; track section; let i = $index) {
|
||||
<div
|
||||
(click)="onSectionClick(song.id, i, show.id)"
|
||||
*ngFor="let section of song.sections; index as i"
|
||||
[class.active]="
|
||||
show.presentationSongId === song.id &&
|
||||
show.presentationSection === i
|
||||
@@ -46,11 +51,14 @@
|
||||
</div>
|
||||
<div class="fragment">{{ getFirstLine(section) }}</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
}
|
||||
<div class="song">
|
||||
<div *ngIf="show"
|
||||
@if (show) {
|
||||
<div
|
||||
[class.active]="show.presentationSongId === 'dynamicText'"
|
||||
class="title song-part"
|
||||
>
|
||||
@@ -58,7 +66,7 @@
|
||||
Freier Text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Überschrift</mat-label>
|
||||
<input (ngModelChange)="onDynamicCaption($event, show.id)" [ngModel]="show.presentationDynamicCaption"
|
||||
@@ -66,24 +74,19 @@
|
||||
matInput
|
||||
type="text">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Text</mat-label>
|
||||
<textarea (ngModelChange)="onDynamicText($event, show.id)" [ngModel]="show.presentationDynamicText"
|
||||
autocomplete="off" id="dynamic-text"
|
||||
matInput></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf="show" class="div-bottom">
|
||||
|
||||
@if (show) {
|
||||
<div class="div-bottom">
|
||||
<button class="btn-start-presentation" mat-button routerLink="/presentation/monitor">
|
||||
<fa-icon [icon]="faDesktop"></fa-icon>
|
||||
Präsentation starten
|
||||
</button>
|
||||
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Hintergrund</mat-label>
|
||||
<mat-select
|
||||
@@ -97,7 +100,6 @@
|
||||
<mat-option value="bible">Bibel</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-slider
|
||||
#slider
|
||||
[max]="100"
|
||||
@@ -110,17 +112,17 @@
|
||||
[ngModel]="show.presentationZoom"
|
||||
matSliderThumb>
|
||||
</mat-slider>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
}
|
||||
@if (show) {
|
||||
<app-add-song
|
||||
*ngIf="show"
|
||||
[addedLive]="true"
|
||||
[showSongs]="showSongs"
|
||||
[show]="show"
|
||||
[songs]="songs$|async"
|
||||
></app-add-song>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
</app-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
margin-bottom: 10px;
|
||||
box-sizing: border-box;
|
||||
color: var(--text);
|
||||
border: 1px solid var(--surface-border);
|
||||
|
||||
@media screen and (max-width: 860px) {
|
||||
width: 100vw;
|
||||
@@ -46,7 +45,7 @@
|
||||
overflow: hidden;
|
||||
transition: var(--transition);
|
||||
cursor: pointer;
|
||||
outline: 1px solid var(--divider);
|
||||
outline: 1px solid var(--surface-muted);
|
||||
|
||||
&:hover {
|
||||
outline: 1px solid var(--primary-hover);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, inject} from '@angular/core';
|
||||
import {combineLatest, Subject} from 'rxjs';
|
||||
import {PresentationBackground, Show} from '../../shows/services/show';
|
||||
import {ShowSongService} from '../../shows/services/show-song.service';
|
||||
@@ -12,7 +12,7 @@ import {fade} from '../../../animations';
|
||||
import {TextRenderingService} from '../../songs/services/text-rendering.service';
|
||||
import {Section} from '../../songs/services/section';
|
||||
import {LineType} from '../../songs/services/line-type';
|
||||
import {AsyncPipe, DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
@@ -40,9 +40,7 @@ export interface PresentationSong {
|
||||
animations: [fade],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [
|
||||
NgIf,
|
||||
CardComponent,
|
||||
NgFor,
|
||||
MatFormField,
|
||||
MatLabel,
|
||||
MatInput,
|
||||
@@ -63,6 +61,12 @@ export interface PresentationSong {
|
||||
],
|
||||
})
|
||||
export class RemoteComponent implements OnDestroy {
|
||||
private showService = inject(ShowService);
|
||||
private showSongService = inject(ShowSongService);
|
||||
private songService = inject(SongService);
|
||||
private textRenderingService = inject(TextRenderingService);
|
||||
private cRef = inject(ChangeDetectorRef);
|
||||
|
||||
public show: Show | null = null;
|
||||
public showSongs: ShowSong[] = [];
|
||||
public songs$ = this.songService.list$();
|
||||
@@ -75,39 +79,42 @@ export class RemoteComponent implements OnDestroy {
|
||||
public presentationDynamicTextChanged$ = new Subject<{presentationDynamicText: string; showId: string}>();
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private showSongService: ShowSongService,
|
||||
private songService: SongService,
|
||||
private textRenderingService: TextRenderingService,
|
||||
globalSettingsService: GlobalSettingsService,
|
||||
private cRef: ChangeDetectorRef
|
||||
) {
|
||||
globalSettingsService.get$
|
||||
.pipe(
|
||||
public constructor() {
|
||||
const globalSettingsService = inject(GlobalSettingsService);
|
||||
|
||||
const currentShowId$ = globalSettingsService.get$.pipe(
|
||||
filter((settings): settings is NonNullable<typeof settings> => !!settings),
|
||||
map(_ => _.currentShow),
|
||||
filter((showId): showId is string => !!showId),
|
||||
distinctUntilChanged(),
|
||||
switchMap(showId =>
|
||||
combineLatest([this.showService.read$(showId), this.showSongService.list$(showId)]).pipe(
|
||||
map(([show, list]) => {
|
||||
const presentationSongs = list.map(song => ({
|
||||
takeUntil(this.destroy$)
|
||||
);
|
||||
|
||||
const show$ = currentShowId$.pipe(
|
||||
switchMap(showId => this.showService.read$(showId)),
|
||||
takeUntil(this.destroy$)
|
||||
);
|
||||
|
||||
const parsedSongs$ = currentShowId$.pipe(
|
||||
switchMap(showId => this.showSongService.list$(showId)),
|
||||
map(list => ({
|
||||
list,
|
||||
parsed: list.map(song => ({
|
||||
id: song.id,
|
||||
title: song.title,
|
||||
sections: this.textRenderingService.parse(song.text, null, false),
|
||||
}));
|
||||
return {show, list, presentationSongs};
|
||||
})
|
||||
)
|
||||
),
|
||||
})),
|
||||
})),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe(({show, list, presentationSongs}) => {
|
||||
this.showSongs = list;
|
||||
);
|
||||
|
||||
combineLatest([show$, parsedSongs$])
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(([show, parsedSongs]) => {
|
||||
this.showSongs = parsedSongs.list;
|
||||
this.show = show;
|
||||
const order = show?.order ?? [];
|
||||
const presentationSongsById = new Map(presentationSongs.map(song => [song.id, song] as const));
|
||||
const presentationSongsById = new Map(parsedSongs.parsed.map(song => [song.id, song] as const));
|
||||
this.presentationSongs = order.map(id => presentationSongsById.get(id) ?? null).filter((s): s is PresentationSong => !!s);
|
||||
this.cRef.markForCheck();
|
||||
});
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
<div *ngIf="shows$ | async as shows" @fade>
|
||||
<app-card *ngIf="visible" heading="Bitte eine Veranstaltung auswählen">
|
||||
<p *ngIf="!shows.length">
|
||||
@if (shows$ | async; as shows) {
|
||||
<div @fade>
|
||||
@if (visible) {
|
||||
<app-card heading="Bitte eine Veranstaltung auswählen">
|
||||
@if (!shows.length) {
|
||||
<p>
|
||||
Es ist derzeit keine Veranstaltung vorhanden
|
||||
</p>
|
||||
|
||||
<div *ngIf="shows.length>0" class="list">
|
||||
<button (click)="selectShow(show)" *ngFor="let show of shows" mat-stroked-button>
|
||||
}
|
||||
@if (shows.length>0) {
|
||||
<div class="list">
|
||||
@for (show of shows; track show) {
|
||||
<button (click)="selectShow(show)" mat-stroked-button>
|
||||
<app-user-name [userId]="show.owner"></app-user-name>
|
||||
,
|
||||
{{ show.showType | showType }},
|
||||
{{ show.date.toDate() | date: "dd.MM.yyyy" }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</app-card>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {ShowService} from '../../shows/services/show.service';
|
||||
import {Show} from '../../shows/services/show';
|
||||
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {fade} from '../../../animations';
|
||||
import {AsyncPipe, DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {MatButton} from '@angular/material/button';
|
||||
import {UserNameComponent} from '../../../services/user/user-name/user-name.component';
|
||||
@@ -16,20 +16,18 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
templateUrl: './select.component.html',
|
||||
styleUrls: ['./select.component.less'],
|
||||
animations: [fade],
|
||||
imports: [NgIf, CardComponent, NgFor, MatButton, UserNameComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
imports: [CardComponent, MatButton, UserNameComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||
})
|
||||
export class SelectComponent implements OnInit {
|
||||
private showService = inject(ShowService);
|
||||
private globalSettingsService = inject(GlobalSettingsService);
|
||||
private router = inject(Router);
|
||||
|
||||
public visible = false;
|
||||
public shows$ = this.showService
|
||||
.list$(true)
|
||||
.pipe(map(_ => _.filter(_ => _.date.toDate() > new Date(new Date().setMonth(new Date().getMonth() - 1))).sort((a, b) => (b.date < a.date ? -1 : b.date > a.date ? 1 : 0))));
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private globalSettingsService: GlobalSettingsService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public async selectShow(show: Show) {
|
||||
this.visible = false;
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ShareDialogComponent} from './share-dialog.component';
|
||||
import QRCode from 'qrcode';
|
||||
|
||||
describe('ShareDialogComponent', () => {
|
||||
let component: ShareDialogComponent;
|
||||
let fixture: ComponentFixture<ShareDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
spyOn(QRCode, 'toDataURL').and.resolveTo('data:image/jpeg;base64,test');
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ShareDialogComponent],
|
||||
}).compileComponents();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Inject} from '@angular/core';
|
||||
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';
|
||||
@@ -17,9 +17,13 @@ export interface ShareDialogData {
|
||||
styleUrl: './share-dialog.component.less',
|
||||
})
|
||||
export class ShareDialogComponent {
|
||||
public data = inject<ShareDialogData>(MAT_DIALOG_DATA);
|
||||
|
||||
public qrCode: string;
|
||||
|
||||
public constructor(@Inject(MAT_DIALOG_DATA) public data: ShareDialogData) {
|
||||
public constructor() {
|
||||
const data = this.data;
|
||||
|
||||
// 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',
|
||||
|
||||
@@ -5,16 +5,20 @@
|
||||
<mat-label>Art der Veranstaltung</mat-label>
|
||||
<mat-select formControlName="showType">
|
||||
<mat-optgroup label="öffentlich">
|
||||
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
|
||||
@for (key of showTypePublic; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
<mat-optgroup label="privat">
|
||||
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
|
||||
@for (key of showTypePrivate; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ShowDataService} from '../services/show-data.service';
|
||||
import {Observable, take} from 'rxjs';
|
||||
import {Show} from '../services/show';
|
||||
@@ -7,18 +7,17 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
||||
import {map, switchMap} from 'rxjs/operators';
|
||||
import firebase from 'firebase/compat/app';
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {MatFormField, MatLabel, MatSuffix} from '@angular/material/form-field';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
import {MatOptgroup, MatOption} from '@angular/material/core';
|
||||
import {NgFor} from '@angular/common';
|
||||
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {MatDatepicker, MatDatepickerInput, MatDatepickerToggle} from '@angular/material/datepicker';
|
||||
import {ButtonRowComponent} from '../../../widget-modules/components/button-row/button-row.component';
|
||||
import {ButtonComponent} from '../../../widget-modules/components/button/button.component';
|
||||
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit',
|
||||
@@ -31,7 +30,6 @@ import Timestamp = firebase.firestore.Timestamp;
|
||||
MatLabel,
|
||||
MatSelect,
|
||||
MatOptgroup,
|
||||
NgFor,
|
||||
MatOption,
|
||||
MatInput,
|
||||
MatDatepickerInput,
|
||||
@@ -44,6 +42,10 @@ import Timestamp = firebase.firestore.Timestamp;
|
||||
],
|
||||
})
|
||||
export class EditComponent implements OnInit {
|
||||
private showService = inject(ShowService);
|
||||
private router = inject(Router);
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
|
||||
public shows$: Observable<Show[]>;
|
||||
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
||||
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
||||
@@ -54,12 +56,9 @@ export class EditComponent implements OnInit {
|
||||
});
|
||||
public faSave = faSave;
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
showDataService: ShowDataService,
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute
|
||||
) {
|
||||
public constructor() {
|
||||
const showDataService = inject(ShowDataService);
|
||||
|
||||
this.shows$ = showDataService.list$;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Zeitraum</mat-label>
|
||||
<mat-select formControlName="time">
|
||||
<mat-option *ngFor="let time of times" [value]="time.key">{{
|
||||
@for (time of times; track time) {
|
||||
<mat-option [value]="time.key">{{
|
||||
time.value
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -15,10 +17,12 @@
|
||||
<mat-label>Ersteller</mat-label>
|
||||
<mat-select formControlName="owner">
|
||||
<mat-option [value]="null">Alle</mat-option>
|
||||
<mat-option *ngFor="let owner of owners" [value]="owner.key">{{
|
||||
@for (owner of owners; track owner) {
|
||||
<mat-option [value]="owner.key">{{
|
||||
owner.value
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -27,16 +31,20 @@
|
||||
<mat-select formControlName="showType">
|
||||
<mat-option [value]="null">Alle</mat-option>
|
||||
<mat-optgroup label="öffentlich">
|
||||
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
|
||||
@for (key of showTypePublic; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
<mat-optgroup label="privat">
|
||||
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
|
||||
@for (key of showTypePrivate; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {KeyValue, NgFor} from '@angular/common';
|
||||
import {Component, Input, inject} from '@angular/core';
|
||||
import {KeyValue} from '@angular/common';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
|
||||
import {FilterValues} from './filter-values';
|
||||
import {Show} from '../../services/show';
|
||||
import {ShowService} from '../../services/show.service';
|
||||
import {distinctUntilChanged, map} from 'rxjs/operators';
|
||||
import {combineLatest, Observable} from 'rxjs';
|
||||
import {distinctUntilChanged, map, switchMap} from 'rxjs/operators';
|
||||
import {combineLatest, Observable, of} from 'rxjs';
|
||||
import {dynamicSort, onlyUnique} from '../../../../services/filter.helper';
|
||||
import {UserService} from '../../../../services/user/user.service';
|
||||
import {isEqual} from 'lodash';
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
import {MatOptgroup, MatOption} from '@angular/material/core';
|
||||
@@ -19,9 +18,13 @@ import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translate
|
||||
selector: 'app-filter',
|
||||
templateUrl: './filter.component.html',
|
||||
styleUrls: ['./filter.component.less'],
|
||||
imports: [ReactiveFormsModule, MatFormField, MatLabel, MatSelect, NgFor, MatOption, MatOptgroup, ShowTypePipe],
|
||||
imports: [ReactiveFormsModule, MatFormField, MatLabel, MatSelect, MatOption, MatOptgroup, ShowTypePipe],
|
||||
})
|
||||
export class FilterComponent {
|
||||
private router = inject(Router);
|
||||
private showService = inject(ShowService);
|
||||
private userService = inject(UserService);
|
||||
|
||||
@Input() public route = '/shows/';
|
||||
@Input() public shows: Show[] = [];
|
||||
|
||||
@@ -38,13 +41,10 @@ export class FilterComponent {
|
||||
|
||||
public owners: {key: string; value: string}[] = [];
|
||||
|
||||
public constructor(
|
||||
private router: Router,
|
||||
private showService: ShowService,
|
||||
private userService: UserService,
|
||||
activatedRoute: ActivatedRoute,
|
||||
fb: UntypedFormBuilder
|
||||
) {
|
||||
public constructor() {
|
||||
const activatedRoute = inject(ActivatedRoute);
|
||||
const fb = inject(UntypedFormBuilder);
|
||||
|
||||
this.filterFormGroup = fb.group({
|
||||
time: 1,
|
||||
owner: null,
|
||||
@@ -66,23 +66,33 @@ export class FilterComponent {
|
||||
}
|
||||
|
||||
public owners$ = (): Observable<{key: string; value: string}[]> => {
|
||||
return combineLatest([
|
||||
this.showService.list$().pipe(
|
||||
map(shows => {
|
||||
return shows.map(show => show.owner).filter(onlyUnique);
|
||||
})
|
||||
return this.showService.list$().pipe(
|
||||
map(shows =>
|
||||
shows
|
||||
.map(show => show.owner)
|
||||
.filter(onlyUnique)
|
||||
.filter((ownerId): ownerId is string => !!ownerId)
|
||||
),
|
||||
this.userService.users$,
|
||||
]).pipe(
|
||||
map(([owners, users]) => {
|
||||
return owners
|
||||
.map(ownerId => ({
|
||||
switchMap(ownerIds => {
|
||||
if (ownerIds.length === 0) {
|
||||
return of([] as {key: string; value: string}[]);
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
ownerIds.map(ownerId =>
|
||||
this.userService.getUserbyId$(ownerId).pipe(
|
||||
map(user => ({
|
||||
key: ownerId,
|
||||
value: users.find(user => user.id === ownerId)?.name,
|
||||
value: user?.name,
|
||||
}))
|
||||
.sort(dynamicSort('value'));
|
||||
)
|
||||
)
|
||||
);
|
||||
}),
|
||||
distinctUntilChanged(isEqual),
|
||||
map(owners => {
|
||||
return owners.sort(dynamicSort('value'));
|
||||
}),
|
||||
distinctUntilChanged((left, right) => this.sameOwners(left, right)),
|
||||
map(_ => _ as {key: string; value: string}[])
|
||||
);
|
||||
};
|
||||
@@ -94,4 +104,12 @@ export class FilterComponent {
|
||||
});
|
||||
await this.router.navigateByUrl(route);
|
||||
}
|
||||
|
||||
private sameOwners(left: {key: string; value: string}[], right: {key: string; value: string}[]): boolean {
|
||||
if (left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return left.every((owner, index) => owner.key === right[index]?.key && owner.value === right[index]?.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<div *ngIf="show" class="list-item">
|
||||
@if (show) {
|
||||
<div class="list-item">
|
||||
<div>{{ show.date.toDate() | date: "dd.MM.yyyy" }}</div>
|
||||
<div>
|
||||
<app-user-name [userId]="show.owner"></app-user-name>
|
||||
</div>
|
||||
<div>{{ show.showType | showType }}</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Show} from '../../services/show';
|
||||
import {DatePipe, NgIf} from '@angular/common';
|
||||
import {DatePipe} from '@angular/common';
|
||||
import {UserNameComponent} from '../../../../services/user/user-name/user-name.component';
|
||||
import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||
|
||||
@@ -8,7 +8,7 @@ import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translate
|
||||
selector: 'app-list-item',
|
||||
templateUrl: './list-item.component.html',
|
||||
styleUrls: ['./list-item.component.less'],
|
||||
imports: [NgIf, UserNameComponent, DatePipe, ShowTypePipe],
|
||||
imports: [UserNameComponent, DatePipe, ShowTypePipe],
|
||||
})
|
||||
export class ListItemComponent {
|
||||
@Input() public show: Show | null = null;
|
||||
|
||||
@@ -1,36 +1,42 @@
|
||||
<div>
|
||||
<!-- <app-list-header *appRole="['leader']"></app-list-header>-->
|
||||
<app-list-header *appRole="['leader']">
|
||||
<app-filter *ngIf="shows$ | async as shows" [shows]="publicShows$ | async"></app-filter>
|
||||
@if (shows$ | async; as shows) {
|
||||
<app-filter [shows]="publicShows$ | async"></app-filter>
|
||||
}
|
||||
</app-list-header>
|
||||
|
||||
<ng-container *appRole="['leader']">
|
||||
<ng-container *ngIf="privateShows$ | async as shows">
|
||||
@if (privateShows$ | async; as shows) {
|
||||
@if (shows.length > 0) {
|
||||
<app-card
|
||||
*ngIf="shows.length > 0"
|
||||
[padding]="false"
|
||||
heading="Meine Veranstaltungen"
|
||||
>
|
||||
@for (show of shows | sortBy: 'desc':'date'; track show) {
|
||||
<app-list-item
|
||||
*ngFor="let show of shows | sortBy: 'desc':'date'"
|
||||
[routerLink]="show.id"
|
||||
[show]="show"
|
||||
></app-list-item>
|
||||
}
|
||||
</app-card>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="publicShows$ | async as shows">
|
||||
@if (publicShows$ | async; as shows) {
|
||||
@if (shows.length > 0) {
|
||||
<app-card
|
||||
*ngIf="shows.length > 0"
|
||||
[padding]="false"
|
||||
heading="Veröffentlichte Veranstaltungen"
|
||||
>
|
||||
@for (show of shows | sortBy: 'desc':'date'; track trackBy($index, show)) {
|
||||
<app-list-item
|
||||
*ngFor="let show of shows | sortBy: 'desc':'date'; trackBy: trackBy"
|
||||
[routerLink]="show.id"
|
||||
[show]="show"
|
||||
></app-list-item>
|
||||
}
|
||||
</app-card>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {combineLatest} from 'rxjs';
|
||||
import {Show} from '../services/show';
|
||||
import {fade} from '../../../animations';
|
||||
@@ -8,7 +8,7 @@ import {ActivatedRoute, RouterLink} from '@angular/router';
|
||||
import {map, switchMap} from 'rxjs/operators';
|
||||
import {RoleDirective} from '../../../services/user/role.directive';
|
||||
import {ListHeaderComponent} from '../../../widget-modules/components/list-header/list-header.component';
|
||||
import {AsyncPipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {FilterComponent} from './filter/filter.component';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {ListItemComponent} from './list-item/list-item.component';
|
||||
@@ -19,11 +19,12 @@ import {SortByPipe} from '../../../widget-modules/pipes/sort-by/sort-by.pipe';
|
||||
templateUrl: './list.component.html',
|
||||
styleUrls: ['./list.component.less'],
|
||||
animations: [fade],
|
||||
imports: [RoleDirective, ListHeaderComponent, NgIf, FilterComponent, CardComponent, NgFor, ListItemComponent, RouterLink, AsyncPipe, SortByPipe],
|
||||
imports: [RoleDirective, ListHeaderComponent, FilterComponent, CardComponent, ListItemComponent, RouterLink, AsyncPipe, SortByPipe],
|
||||
})
|
||||
export class ListComponent {
|
||||
public shows$ = this.showService.list$();
|
||||
public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published)));
|
||||
private showService = inject(ShowService);
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
|
||||
public lastMonths$ = this.activatedRoute.queryParams.pipe(
|
||||
map(params => {
|
||||
const filterValues = params as FilterValues;
|
||||
@@ -43,8 +44,9 @@ export class ListComponent {
|
||||
return filterValues?.showType;
|
||||
})
|
||||
);
|
||||
public shows$ = this.showService.list$();
|
||||
public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published)));
|
||||
public queriedPublicShows$ = this.lastMonths$.pipe(switchMap(lastMonths => this.showService.listPublicSince$(lastMonths)));
|
||||
|
||||
public fallbackPublicShows$ = combineLatest([this.shows$, this.lastMonths$]).pipe(
|
||||
map(([shows, lastMonths]) => {
|
||||
const startDate = new Date();
|
||||
@@ -54,21 +56,13 @@ export class ListComponent {
|
||||
return shows.filter(show => show.published && !show.archived && show.date.toDate() >= startDate);
|
||||
})
|
||||
);
|
||||
|
||||
public publicShows$ = combineLatest([this.queriedPublicShows$, this.fallbackPublicShows$, this.owner$, this.showType$]).pipe(
|
||||
map(([queriedShows, fallbackShows, owner, showType]) => {
|
||||
const shows = queriedShows.length > 0 || fallbackShows.length === 0 ? queriedShows : fallbackShows;
|
||||
|
||||
return shows
|
||||
.filter(show => !owner || show.owner === owner)
|
||||
.filter(show => !showType || show.showType === showType);
|
||||
return shows.filter(show => !owner || show.owner === owner).filter(show => !showType || show.showType === showType);
|
||||
})
|
||||
);
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private activatedRoute: ActivatedRoute
|
||||
) {}
|
||||
|
||||
public trackBy = (index: number, show: unknown) => (show as Show).id;
|
||||
}
|
||||
|
||||
@@ -5,16 +5,20 @@
|
||||
<mat-label>Art der Veranstaltung</mat-label>
|
||||
<mat-select formControlName="showType">
|
||||
<mat-optgroup label="öffentlich">
|
||||
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
|
||||
@for (key of showTypePublic; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
<mat-optgroup label="privat">
|
||||
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
|
||||
@for (key of showTypePrivate; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | showType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ShowDataService} from '../services/show-data.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Show} from '../services/show';
|
||||
@@ -10,7 +10,7 @@ import {CardComponent} from '../../../widget-modules/components/card/card.compon
|
||||
import {MatFormField, MatLabel, MatSuffix} from '@angular/material/form-field';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
import {MatOptgroup, MatOption} from '@angular/material/core';
|
||||
import {NgFor} from '@angular/common';
|
||||
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {MatDatepicker, MatDatepickerInput, MatDatepickerToggle} from '@angular/material/datepicker';
|
||||
import {ButtonRowComponent} from '../../../widget-modules/components/button-row/button-row.component';
|
||||
@@ -28,7 +28,6 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
MatLabel,
|
||||
MatSelect,
|
||||
MatOptgroup,
|
||||
NgFor,
|
||||
MatOption,
|
||||
MatInput,
|
||||
MatDatepickerInput,
|
||||
@@ -41,6 +40,9 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
],
|
||||
})
|
||||
export class NewComponent implements OnInit {
|
||||
private showService = inject(ShowService);
|
||||
private router = inject(Router);
|
||||
|
||||
public shows$: Observable<Show[]>;
|
||||
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
||||
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
||||
@@ -50,11 +52,9 @@ export class NewComponent implements OnInit {
|
||||
});
|
||||
public faSave = faSave;
|
||||
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
showDataService: ShowDataService,
|
||||
private router: Router
|
||||
) {
|
||||
public constructor() {
|
||||
const showDataService = inject(ShowDataService);
|
||||
|
||||
this.shows$ = showDataService.list$;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Document, HeadingLevel, ISectionOptions, Packer, Paragraph} from 'docx';
|
||||
import {ShowService} from './show.service';
|
||||
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||
@@ -26,13 +26,11 @@ export interface DownloadOptions {
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DocxService {
|
||||
public constructor(
|
||||
private showService: ShowService,
|
||||
private showSongService: ShowSongService,
|
||||
private textRenderingService: TextRenderingService,
|
||||
private userService: UserService,
|
||||
private configService: ConfigService
|
||||
) {}
|
||||
private showService = inject(ShowService);
|
||||
private showSongService = inject(ShowSongService);
|
||||
private textRenderingService = inject(TextRenderingService);
|
||||
private userService = inject(UserService);
|
||||
private configService = inject(ConfigService);
|
||||
|
||||
public async create(showId: string, options: DownloadOptions = {}): Promise<void> {
|
||||
const data = await this.prepareData(showId);
|
||||
@@ -194,7 +192,8 @@ export class DocxService {
|
||||
if (!config) return null;
|
||||
|
||||
const showSongs = await this.showSongService.list(showId);
|
||||
const songsAsync = showSongs.map(showSong => {
|
||||
const songsLoaded = showSongs
|
||||
.map(showSong => {
|
||||
const sections = this.textRenderingService.parse(showSong.text, {
|
||||
baseKey: showSong.keyOriginal,
|
||||
targetKey: showSong.key,
|
||||
@@ -203,8 +202,7 @@ export class DocxService {
|
||||
showSong,
|
||||
sections,
|
||||
};
|
||||
});
|
||||
const songsLoaded = (await Promise.all(songsAsync))
|
||||
})
|
||||
.filter(_ => !!_)
|
||||
.map(
|
||||
_ =>
|
||||
|
||||
@@ -1,12 +1,115 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {firstValueFrom, of, Subject} from 'rxjs';
|
||||
import {skip, take} from 'rxjs/operators';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {ShowDataService} from './show-data.service';
|
||||
|
||||
describe('ShowDataService', () => {
|
||||
beforeEach(() => void TestBed.configureTestingModule({}));
|
||||
let service: ShowDataService;
|
||||
let shows$: Subject<Array<{id: string; date: {toMillis: () => number}; archived?: boolean}>>;
|
||||
let docUpdateSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docSpy: jasmine.Spy;
|
||||
let colAddSpy: jasmine.Spy<() => Promise<{id: string}>>;
|
||||
let colSpy: jasmine.Spy;
|
||||
let dbServiceSpy: jasmine.SpyObj<DbService>;
|
||||
|
||||
beforeEach(() => {
|
||||
shows$ = new Subject<Array<{id: string; date: {toMillis: () => number}; archived?: boolean}>>();
|
||||
docUpdateSpy = jasmine.createSpy('update').and.resolveTo();
|
||||
docSpy = jasmine.createSpy('doc').and.returnValue({update: docUpdateSpy});
|
||||
colAddSpy = jasmine.createSpy('add').and.resolveTo({id: 'show-3'});
|
||||
colSpy = jasmine.createSpy('col').and.returnValue({add: colAddSpy});
|
||||
dbServiceSpy = jasmine.createSpyObj<DbService>('DbService', ['col$', 'doc$', 'doc', 'col']);
|
||||
dbServiceSpy.col$.and.returnValue(shows$.asObservable());
|
||||
dbServiceSpy.doc$.and.returnValue(of(null));
|
||||
dbServiceSpy.doc.and.callFake(docSpy);
|
||||
dbServiceSpy.col.and.callFake(colSpy);
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||
});
|
||||
|
||||
service = TestBed.inject(ShowDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
const service: ShowDataService = TestBed.inject(ShowDataService);
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should load the raw show list from the shows collection on creation', () => {
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows');
|
||||
});
|
||||
|
||||
it('should sort the list by ascending show date', async () => {
|
||||
const listPromise = firstValueFrom(service.list$.pipe(take(1)));
|
||||
|
||||
shows$.next([
|
||||
{id: 'show-2', date: {toMillis: () => 200}},
|
||||
{id: 'show-1', date: {toMillis: () => 100}},
|
||||
{id: 'show-3', date: {toMillis: () => 300}},
|
||||
]);
|
||||
|
||||
const list = await listPromise;
|
||||
|
||||
expect(list.map(show => show.id)).toEqual(['show-1', 'show-2', 'show-3']);
|
||||
});
|
||||
|
||||
it('should replay the latest sorted list to late subscribers', async () => {
|
||||
const initialSubscription = service.list$.subscribe();
|
||||
|
||||
shows$.next([
|
||||
{id: 'show-2', date: {toMillis: () => 200}},
|
||||
{id: 'show-1', date: {toMillis: () => 100}},
|
||||
]);
|
||||
|
||||
const replayedList = await firstValueFrom(service.list$.pipe(take(1)));
|
||||
|
||||
expect(replayedList.map(show => show.id)).toEqual(['show-1', 'show-2']);
|
||||
|
||||
initialSubscription.unsubscribe();
|
||||
});
|
||||
|
||||
it('should expose the raw list without sorting via listRaw$', () => {
|
||||
service.listRaw$().subscribe();
|
||||
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows');
|
||||
});
|
||||
|
||||
it('should request only published recent shows and filter archived entries', async () => {
|
||||
const publicShows$ = of([
|
||||
{id: 'show-1', archived: false},
|
||||
{id: 'show-2', archived: true},
|
||||
{id: 'show-3'},
|
||||
]);
|
||||
dbServiceSpy.col$.and.returnValue(publicShows$ as never);
|
||||
|
||||
const result = await firstValueFrom(service.listPublicSince$(3));
|
||||
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows', jasmine.any(Array));
|
||||
const [, queryConstraints] = dbServiceSpy.col$.calls.mostRecent().args as [string, unknown[]];
|
||||
expect(queryConstraints.length).toBe(3);
|
||||
expect(result.map(show => show.id)).toEqual(['show-1', 'show-3']);
|
||||
});
|
||||
|
||||
it('should read a single show by id', () => {
|
||||
service.read$('show-7').subscribe();
|
||||
|
||||
expect(dbServiceSpy.doc$).toHaveBeenCalledWith('shows/show-7');
|
||||
});
|
||||
|
||||
it('should update a show at the expected document path', async () => {
|
||||
await service.update('show-8', {archived: true});
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('shows/show-8');
|
||||
const [updatePayload] = docUpdateSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(updatePayload).toEqual({archived: true});
|
||||
});
|
||||
|
||||
it('should add a show to the shows collection and return the new id', async () => {
|
||||
await expectAsync(service.add({published: true})).toBeResolvedTo('show-3');
|
||||
|
||||
expect(colSpy).toHaveBeenCalledWith('shows');
|
||||
const [addPayload] = colAddSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(addPayload).toEqual({published: true});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {Show} from './show';
|
||||
import {map, shareReplay} from 'rxjs/operators';
|
||||
import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
|
||||
import firebase from 'firebase/compat/app';
|
||||
import {orderBy, QueryConstraint, Timestamp, where} from 'firebase/firestore';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowDataService {
|
||||
private dbService = inject(DbService);
|
||||
|
||||
private collection = 'shows';
|
||||
public list$: Observable<Show[]> = this.dbService.col$<Show>(this.collection).pipe(
|
||||
// server-side ordering cuts client work and keeps stable order across subscribers
|
||||
@@ -20,19 +21,17 @@ export class ShowDataService {
|
||||
})
|
||||
);
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
|
||||
public listRaw$ = () => this.dbService.col$<Show>(this.collection);
|
||||
|
||||
public listPublicSince$(lastMonths: number): Observable<Show[]> {
|
||||
const startDate = new Date();
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
startDate.setDate(startDate.getDate() - lastMonths * 30);
|
||||
const startTimestamp = firebase.firestore.Timestamp.fromDate(startDate);
|
||||
const startTimestamp = Timestamp.fromDate(startDate);
|
||||
|
||||
const queryFn: QueryFn = ref => ref.where('published', '==', true).where('date', '>=', startTimestamp).orderBy('date', 'desc');
|
||||
const queryConstraints: QueryConstraint[] = [where('published', '==', true), where('date', '>=', startTimestamp), orderBy('date', 'desc')];
|
||||
|
||||
return this.dbService.col$<Show>(this.collection, queryFn).pipe(
|
||||
return this.dbService.col$<Show>(this.collection, queryConstraints).pipe(
|
||||
map(shows => shows.filter(show => !show.archived)),
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
|
||||
@@ -1,16 +1,98 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {of} from 'rxjs';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
|
||||
describe('ShowSongDataService', () => {
|
||||
let service: ShowSongDataService;
|
||||
let docUpdateSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docDeleteSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docSpy: jasmine.Spy;
|
||||
let colAddSpy: jasmine.Spy<() => Promise<{id: string}>>;
|
||||
let colSpy: jasmine.Spy;
|
||||
let dbServiceSpy: jasmine.SpyObj<DbService>;
|
||||
|
||||
beforeEach(() => {
|
||||
void TestBed.configureTestingModule({});
|
||||
docUpdateSpy = jasmine.createSpy('update').and.resolveTo();
|
||||
docDeleteSpy = jasmine.createSpy('delete').and.resolveTo();
|
||||
docSpy = jasmine.createSpy('doc').and.returnValue({
|
||||
update: docUpdateSpy,
|
||||
delete: docDeleteSpy,
|
||||
});
|
||||
colAddSpy = jasmine.createSpy('add').and.resolveTo({id: 'show-song-3'});
|
||||
colSpy = jasmine.createSpy('col').and.returnValue({add: colAddSpy});
|
||||
dbServiceSpy = jasmine.createSpyObj<DbService>('DbService', ['col$', 'doc$', 'doc', 'col']);
|
||||
dbServiceSpy.col$.and.callFake(() => of([{id: 'show-song-1'}]) as never);
|
||||
dbServiceSpy.doc$.and.returnValue(of({id: 'show-song-1'}) as never);
|
||||
dbServiceSpy.doc.and.callFake(docSpy);
|
||||
dbServiceSpy.col.and.callFake(colSpy);
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||
});
|
||||
|
||||
service = TestBed.inject(ShowSongDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should cache the list observable per show id when no query constraints are passed', () => {
|
||||
const first = service.list$('show-1');
|
||||
const second = service.list$('show-1');
|
||||
|
||||
expect(first).toBe(second);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledTimes(1);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows/show-1/songs');
|
||||
});
|
||||
|
||||
it('should not reuse the cache when query constraints are passed', () => {
|
||||
const constraints = [{}] as never[];
|
||||
|
||||
const first = service.list$('show-1', constraints as never);
|
||||
const second = service.list$('show-1', constraints as never);
|
||||
|
||||
expect(first).not.toBe(second);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledTimes(2);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows/show-1/songs', constraints as never);
|
||||
});
|
||||
|
||||
it('should keep separate caches for different shows', () => {
|
||||
service.list$('show-1');
|
||||
service.list$('show-2');
|
||||
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledTimes(2);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows/show-1/songs');
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('shows/show-2/songs');
|
||||
});
|
||||
|
||||
it('should read a single show song by nested document path', () => {
|
||||
service.read$('show-4', 'song-5').subscribe();
|
||||
|
||||
expect(dbServiceSpy.doc$).toHaveBeenCalledWith('shows/show-4/songs/song-5');
|
||||
});
|
||||
|
||||
it('should update a nested show song document', async () => {
|
||||
await service.update$('show-4', 'song-5', {title: 'Updated'} as never);
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('shows/show-4/songs/song-5');
|
||||
const [updatePayload] = docUpdateSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(updatePayload).toEqual({title: 'Updated'});
|
||||
});
|
||||
|
||||
it('should delete a nested show song document', async () => {
|
||||
await service.delete('show-4', 'song-5');
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('shows/show-4/songs/song-5');
|
||||
expect(docDeleteSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should add a song to the nested show songs collection and return the id', async () => {
|
||||
await expectAsync(service.add('show-4', {songId: 'song-5'} as never)).toBeResolvedTo('show-song-3');
|
||||
|
||||
expect(colSpy).toHaveBeenCalledWith('shows/show-4/songs');
|
||||
const [addPayload] = colAddSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(addPayload).toEqual({songId: 'song-5'});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ShowSong} from './show-song';
|
||||
import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
|
||||
import {QueryConstraint} from '@angular/fire/firestore';
|
||||
import {shareReplay} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowSongDataService {
|
||||
private dbService = inject(DbService);
|
||||
|
||||
private collection = 'shows';
|
||||
private subCollection = 'songs';
|
||||
private listCache = new Map<string, Observable<ShowSong[]>>();
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
|
||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> => {
|
||||
if (queryFn) {
|
||||
return this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public list$ = (showId: string, queryConstraints?: QueryConstraint[]): Observable<ShowSong[]> => {
|
||||
if (queryConstraints && queryConstraints.length > 0) {
|
||||
return this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryConstraints);
|
||||
}
|
||||
|
||||
const cached = this.listCache.get(showId);
|
||||
|
||||
@@ -1,16 +1,131 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {BehaviorSubject, of} from 'rxjs';
|
||||
import {SongDataService} from '../../songs/services/song-data.service';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {ShowService} from './show.service';
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
import {ShowSongService} from './show-song.service';
|
||||
|
||||
describe('ShowSongService', () => {
|
||||
let service: ShowSongService;
|
||||
let showSongDataServiceSpy: jasmine.SpyObj<ShowSongDataService>;
|
||||
let songDataServiceSpy: jasmine.SpyObj<SongDataService>;
|
||||
let userServiceSpy: jasmine.SpyObj<UserService>;
|
||||
let showServiceSpy: jasmine.SpyObj<ShowService>;
|
||||
let user$: BehaviorSubject<any>;
|
||||
const song = {id: 'song-1', key: 'G', title: 'Amazing Grace'} as any;
|
||||
const showSong = {id: 'show-song-1', songId: 'song-1'} as any;
|
||||
const show = {id: 'show-1', order: ['show-song-1', 'show-song-2']} as any;
|
||||
|
||||
beforeEach(() => {
|
||||
void TestBed.configureTestingModule({});
|
||||
user$ = new BehaviorSubject<any>({id: 'user-1', name: 'Benjamin', role: 'editor', chordMode: 'letters', songUsage: {}});
|
||||
showSongDataServiceSpy = jasmine.createSpyObj<ShowSongDataService>('ShowSongDataService', ['add', 'read$', 'list$', 'delete', 'update$']);
|
||||
songDataServiceSpy = jasmine.createSpyObj<SongDataService>('SongDataService', ['read$']);
|
||||
userServiceSpy = jasmine.createSpyObj<UserService>('UserService', ['incSongCount', 'decSongCount'], {
|
||||
user$: user$.asObservable(),
|
||||
});
|
||||
showServiceSpy = jasmine.createSpyObj<ShowService>('ShowService', ['read$', 'update$']);
|
||||
|
||||
showSongDataServiceSpy.add.and.resolveTo('show-song-2');
|
||||
showSongDataServiceSpy.read$.and.returnValue(of(showSong));
|
||||
showSongDataServiceSpy.list$.and.returnValue(of([showSong]));
|
||||
showSongDataServiceSpy.delete.and.resolveTo();
|
||||
showSongDataServiceSpy.update$.and.resolveTo();
|
||||
songDataServiceSpy.read$.and.returnValue(of(song));
|
||||
userServiceSpy.incSongCount.and.resolveTo();
|
||||
userServiceSpy.decSongCount.and.resolveTo();
|
||||
showServiceSpy.read$.and.returnValue(of(show));
|
||||
showServiceSpy.update$.and.resolveTo();
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: ShowSongDataService, useValue: showSongDataServiceSpy},
|
||||
{provide: SongDataService, useValue: songDataServiceSpy},
|
||||
{provide: UserService, useValue: userServiceSpy},
|
||||
{provide: ShowService, useValue: showServiceSpy},
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(ShowSongService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should create a show song from the song and current user', async () => {
|
||||
await expectAsync(service.new$('show-1', 'song-1', true)).toBeResolvedTo('show-song-2');
|
||||
|
||||
expect(userServiceSpy.incSongCount).toHaveBeenCalledWith('song-1');
|
||||
expect(showSongDataServiceSpy.add).toHaveBeenCalledWith('show-1', {
|
||||
...song,
|
||||
songId: 'song-1',
|
||||
key: 'G',
|
||||
keyOriginal: 'G',
|
||||
chordMode: 'letters',
|
||||
addedLive: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return null when the song is missing', async () => {
|
||||
songDataServiceSpy.read$.and.returnValue(of(null));
|
||||
|
||||
await expectAsync(service.new$('show-1', 'song-1')).toBeResolvedTo(null);
|
||||
|
||||
expect(showSongDataServiceSpy.add).not.toHaveBeenCalled();
|
||||
expect(userServiceSpy.incSongCount).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return null when the current user is missing', async () => {
|
||||
user$.next(null);
|
||||
|
||||
await expectAsync(service.new$('show-1', 'song-1')).toBeResolvedTo(null);
|
||||
|
||||
expect(showSongDataServiceSpy.add).not.toHaveBeenCalled();
|
||||
expect(userServiceSpy.incSongCount).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should delegate reads to the data service', async () => {
|
||||
await expectAsync(service.read('show-1', 'show-song-1')).toBeResolvedTo(showSong);
|
||||
expect(showSongDataServiceSpy.read$).toHaveBeenCalledWith('show-1', 'show-song-1');
|
||||
});
|
||||
|
||||
it('should delegate list access to the data service', async () => {
|
||||
await expectAsync(service.list('show-1')).toBeResolvedTo([showSong]);
|
||||
expect(showSongDataServiceSpy.list$).toHaveBeenCalledWith('show-1');
|
||||
});
|
||||
|
||||
it('should delete a show song, update the order and decrement song usage', async () => {
|
||||
await service.delete$('show-1', 'show-song-1', 0);
|
||||
|
||||
expect(showSongDataServiceSpy.delete).toHaveBeenCalledWith('show-1', 'show-song-1');
|
||||
expect(showServiceSpy.update$).toHaveBeenCalledWith('show-1', {order: ['show-song-2']});
|
||||
expect(userServiceSpy.decSongCount).toHaveBeenCalledWith('song-1');
|
||||
});
|
||||
|
||||
it('should stop delete when the show is missing', async () => {
|
||||
showServiceSpy.read$.and.returnValue(of(null));
|
||||
|
||||
await service.delete$('show-1', 'show-song-1', 0);
|
||||
|
||||
expect(showSongDataServiceSpy.delete).not.toHaveBeenCalled();
|
||||
expect(showServiceSpy.update$).not.toHaveBeenCalled();
|
||||
expect(userServiceSpy.decSongCount).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should stop delete when the show song is missing', async () => {
|
||||
showSongDataServiceSpy.read$.and.returnValue(of(null));
|
||||
|
||||
await service.delete$('show-1', 'show-song-1', 0);
|
||||
|
||||
expect(showSongDataServiceSpy.delete).not.toHaveBeenCalled();
|
||||
expect(showServiceSpy.update$).not.toHaveBeenCalled();
|
||||
expect(userServiceSpy.decSongCount).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should delegate updates to the data service', async () => {
|
||||
await service.update$('show-1', 'show-song-1', {title: 'Updated'} as never);
|
||||
|
||||
expect(showSongDataServiceSpy.update$).toHaveBeenCalledWith('show-1', 'show-song-1', {title: 'Updated'} as never);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {ShowSong} from './show-song';
|
||||
@@ -10,12 +10,10 @@ import {ShowService} from './show.service';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowSongService {
|
||||
public constructor(
|
||||
private showSongDataService: ShowSongDataService,
|
||||
private songDataService: SongDataService,
|
||||
private userService: UserService,
|
||||
private showService: ShowService
|
||||
) {}
|
||||
private showSongDataService = inject(ShowSongDataService);
|
||||
private songDataService = inject(SongDataService);
|
||||
private userService = inject(UserService);
|
||||
private showService = inject(ShowService);
|
||||
|
||||
public async new$(showId: string, songId: string, addedLive = false): Promise<string | null> {
|
||||
const song = await firstValueFrom(this.songDataService.read$(songId));
|
||||
|
||||
@@ -1,27 +1,102 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ShowService} from './show.service';
|
||||
import {BehaviorSubject, of} from 'rxjs';
|
||||
import {ShowDataService} from './show-data.service';
|
||||
import {ShowService} from './show.service';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
|
||||
describe('ShowService', () => {
|
||||
const mockShowDataService = {add: Promise.resolve(null)};
|
||||
beforeEach(
|
||||
() =>
|
||||
let service: ShowService;
|
||||
let showDataServiceSpy: jasmine.SpyObj<ShowDataService>;
|
||||
let user$: BehaviorSubject<unknown>;
|
||||
const shows = [
|
||||
{id: 'show-1', owner: 'user-1', published: false, archived: false},
|
||||
{id: 'show-2', owner: 'other-user', published: true, archived: false},
|
||||
{id: 'show-3', owner: 'user-1', published: true, archived: true},
|
||||
] as never;
|
||||
|
||||
beforeEach(() => {
|
||||
user$ = new BehaviorSubject<unknown>({id: 'user-1'});
|
||||
showDataServiceSpy = jasmine.createSpyObj<ShowDataService>('ShowDataService', ['read$', 'listPublicSince$', 'update', 'add'], {
|
||||
list$: of(shows),
|
||||
});
|
||||
showDataServiceSpy.read$.and.returnValue(of(shows[0]));
|
||||
showDataServiceSpy.listPublicSince$.and.returnValue(of([shows[1]]));
|
||||
showDataServiceSpy.update.and.resolveTo();
|
||||
showDataServiceSpy.add.and.resolveTo('new-show-id');
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: ShowDataService, useValue: mockShowDataService}],
|
||||
})
|
||||
);
|
||||
providers: [
|
||||
{provide: ShowDataService, useValue: showDataServiceSpy},
|
||||
{provide: UserService, useValue: {user$: user$.asObservable()}},
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(ShowService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should list published shows and own drafts, but exclude archived ones', done => {
|
||||
service.list$().subscribe(result => {
|
||||
expect(result.map(show => show.id)).toEqual(['show-1', 'show-2']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should filter out private drafts when publishedOnly is true', done => {
|
||||
service.list$(true).subscribe(result => {
|
||||
expect(result.map(show => show.id)).toEqual(['show-2']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate public listing to the data service', done => {
|
||||
service.listPublicSince$(6).subscribe(result => {
|
||||
expect(result).toEqual([shows[1]]);
|
||||
expect(showDataServiceSpy.listPublicSince$).toHaveBeenCalledWith(6);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate reads to the data service', done => {
|
||||
service.read$('show-1').subscribe(result => {
|
||||
expect(result).toEqual(shows[0]);
|
||||
expect(showDataServiceSpy.read$).toHaveBeenCalledWith('show-1');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate updates to the data service', async () => {
|
||||
await service.update$('show-1', {published: true});
|
||||
|
||||
expect(showDataServiceSpy.update).toHaveBeenCalledWith('show-1', {published: true});
|
||||
});
|
||||
|
||||
it('should return null when creating a show without showType', async () => {
|
||||
await expectAsync(service.new$({published: true})).toBeResolvedTo(null);
|
||||
|
||||
expect(showDataServiceSpy.add).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return null when no user is available for show creation', async () => {
|
||||
user$.next(null);
|
||||
|
||||
await expectAsync(service.new$({showType: 'misc-public'})).toBeResolvedTo(null);
|
||||
|
||||
expect(showDataServiceSpy.add).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
ShowService.SHOW_TYPE_PUBLIC.forEach(type => {
|
||||
it('should calc public flag for ' + type, async () => {
|
||||
const service: ShowService = TestBed.inject(ShowService);
|
||||
const addSpy = spyOn(TestBed.inject(ShowDataService), 'add').and.returnValue(Promise.resolve('id'));
|
||||
|
||||
const id = await service.new$({showType: type});
|
||||
|
||||
void expect(id).toBe('id');
|
||||
void expect(addSpy).toHaveBeenCalledWith({
|
||||
expect(id).toBe('new-show-id');
|
||||
expect(showDataServiceSpy.add).toHaveBeenCalledWith({
|
||||
showType: type,
|
||||
owner: 'user-1',
|
||||
order: [],
|
||||
public: true,
|
||||
});
|
||||
});
|
||||
@@ -29,14 +104,13 @@ describe('ShowService', () => {
|
||||
|
||||
ShowService.SHOW_TYPE_PRIVATE.forEach(type => {
|
||||
it('should calc private flag for ' + type, async () => {
|
||||
const service: ShowService = TestBed.inject(ShowService);
|
||||
const addSpy = spyOn(TestBed.inject(ShowDataService), 'add').and.returnValue(Promise.resolve('id'));
|
||||
|
||||
const id = await service.new$({showType: type});
|
||||
|
||||
void expect(id).toBe('id');
|
||||
void expect(addSpy).toHaveBeenCalledWith({
|
||||
expect(id).toBe('new-show-id');
|
||||
expect(showDataServiceSpy.add).toHaveBeenCalledWith({
|
||||
showType: type,
|
||||
owner: 'user-1',
|
||||
order: [],
|
||||
public: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {ShowDataService} from './show-data.service';
|
||||
import {Show} from './show';
|
||||
import {Observable} from 'rxjs';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {map, switchMap} from 'rxjs/operators';
|
||||
import {User} from '../../../services/user/user';
|
||||
@@ -10,17 +10,12 @@ import {User} from '../../../services/user/user';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowService {
|
||||
private showDataService = inject(ShowDataService);
|
||||
private userService = inject(UserService);
|
||||
|
||||
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 | null = null;
|
||||
|
||||
public constructor(
|
||||
private showDataService: ShowDataService,
|
||||
private userService: UserService
|
||||
) {
|
||||
userService.user$.subscribe(_ => (this.user = _));
|
||||
}
|
||||
|
||||
public read$ = (showId: string): Observable<Show | null> => this.showDataService.read$(showId);
|
||||
public listPublicSince$ = (lastMonths: number): Observable<Show[]> => this.showDataService.listPublicSince$(lastMonths);
|
||||
@@ -38,10 +33,11 @@ export class ShowService {
|
||||
public update$ = async (showId: string, data: Partial<Show>): Promise<void> => this.showDataService.update(showId, data);
|
||||
|
||||
public async new$(data: Partial<Show>): Promise<string | null> {
|
||||
if (!data.showType || !this.user) return null;
|
||||
const user = await firstValueFrom(this.userService.user$);
|
||||
if (!data.showType || !user) return null;
|
||||
const calculatedData: Partial<Show> = {
|
||||
...data,
|
||||
owner: this.user.id,
|
||||
owner: user.id,
|
||||
order: [],
|
||||
public: ShowService.SHOW_TYPE_PUBLIC.indexOf(data.showType) !== -1,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import firebase from 'firebase/compat/app';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
export type PresentationBackground = 'none' | 'blue' | 'green' | 'leder' | 'praise' | 'bible';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div *ngIf="show$ | async as show">
|
||||
@if (show$ | async; as show) {
|
||||
<div>
|
||||
<app-card
|
||||
[fullscreen]="useSwiper"
|
||||
closeLink="../"
|
||||
@@ -6,12 +7,16 @@
|
||||
show.date.toDate() | date: 'dd.MM.yyyy'
|
||||
}} - {{ getStatus(show) }}"
|
||||
>
|
||||
<p *ngIf="!useSwiper">{{ show.public ? 'öffentliche' : 'geschlossene' }} Veranstaltung von
|
||||
@if (!useSwiper) {
|
||||
<p>{{ show.public ? 'öffentliche' : 'geschlossene' }} Veranstaltung von
|
||||
<app-user-name [userId]="show.owner"></app-user-name>
|
||||
</p>
|
||||
}
|
||||
<div class="head">
|
||||
<div>
|
||||
<mat-checkbox *ngIf="!useSwiper" [(ngModel)]="showText">Text anzeigen</mat-checkbox>
|
||||
@if (!useSwiper) {
|
||||
<mat-checkbox [(ngModel)]="showText">Text anzeigen</mat-checkbox>
|
||||
}
|
||||
</div>
|
||||
<div [class.floating]="useSwiper">
|
||||
<app-menu-button (click)="onZoomOut()" @fade [icon]="faZoomOut" class="btn-delete btn-icon"
|
||||
@@ -23,13 +28,15 @@
|
||||
matTooltip="Vollbild"></app-menu-button>
|
||||
</div>
|
||||
</div>
|
||||
<div (cdkDropListDropped)="drop($event, show)" *ngIf="showSongs && !useSwiper"
|
||||
@if (showSongs && !useSwiper) {
|
||||
<div (cdkDropListDropped)="drop($event, show)"
|
||||
[cdkDropListDisabled]="show.published || showText"
|
||||
[style.cursor]="!(show.published || showText) ? 'drag' : 'inherit'"
|
||||
[style.font-size]="textSize + 'em'"
|
||||
cdkDropList
|
||||
class="song-list">
|
||||
<div *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy" cdkDrag class="song-row">
|
||||
@for (song of orderedShowSongs(show); track trackBy(i, song); let i = $index) {
|
||||
<div cdkDrag class="song-row">
|
||||
<app-song
|
||||
[fullscreen]="useSwiper"
|
||||
[index]="i"
|
||||
@@ -39,10 +46,13 @@
|
||||
[show]="show"
|
||||
></app-song>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<swiper-container *ngIf="useSwiper" scrollbar="true">
|
||||
<swiper-slide *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy"
|
||||
}
|
||||
@if (useSwiper) {
|
||||
<swiper-container scrollbar="true">
|
||||
@for (song of orderedShowSongs(show); track trackBy(i, song); let i = $index) {
|
||||
<swiper-slide
|
||||
[style.font-size]="textSize + 'em'"
|
||||
class="song-swipe">
|
||||
<app-song
|
||||
@@ -54,43 +64,60 @@
|
||||
[show]="show"
|
||||
></app-song>
|
||||
<div class="time">{{ currentTime | date: 'HH:mm' }}</div>
|
||||
<div *ngIf="getNextSong(orderedShowSongs(show), i) as next" class="next-song">{{ next }}
|
||||
@if (getNextSong(orderedShowSongs(show), i); as next) {
|
||||
<div class="next-song">{{ next }}
|
||||
<fa-icon [icon]="faNextSong"></fa-icon>
|
||||
</div>
|
||||
}
|
||||
</swiper-slide>
|
||||
}
|
||||
</swiper-container>
|
||||
|
||||
}
|
||||
@if (songs$ | async; as songs) {
|
||||
@if (songs && !show.published && !useSwiper) {
|
||||
<app-add-song
|
||||
*ngIf="songs && !show.published && !useSwiper"
|
||||
[showSongs]="showSongs"
|
||||
[show]="show"
|
||||
[songs]="songs"
|
||||
></app-add-song>
|
||||
|
||||
<app-button-row *ngIf="!useSwiper">
|
||||
}
|
||||
}
|
||||
@if (!useSwiper) {
|
||||
<app-button-row>
|
||||
<ng-container *appRole="['leader']">
|
||||
<ng-container *appOwner="show.owner">
|
||||
<app-button (click)="onArchive(true)" *ngIf="!show.archived" [icon]="faBox">
|
||||
@if (!show.archived) {
|
||||
<app-button (click)="onArchive(true)" [icon]="faBox">
|
||||
Archivieren
|
||||
</app-button>
|
||||
<app-button (click)="onArchive(false)" *ngIf="show.archived" [icon]="faBoxOpen">
|
||||
}
|
||||
@if (show.archived) {
|
||||
<app-button (click)="onArchive(false)" [icon]="faBoxOpen">
|
||||
Wiederherstellen
|
||||
</app-button>
|
||||
<app-button (click)="onPublish(true)" *ngIf="!show.published" [icon]="faPublish">
|
||||
}
|
||||
@if (!show.published) {
|
||||
<app-button (click)="onPublish(true)" [icon]="faPublish">
|
||||
Veröffentlichen
|
||||
</app-button>
|
||||
<app-button (click)="onPublish(false)" *ngIf="show.published" [icon]="faUnpublish">
|
||||
}
|
||||
@if (show.published) {
|
||||
<app-button (click)="onPublish(false)" [icon]="faUnpublish">
|
||||
Veröffentlichung zurückziehen
|
||||
</app-button>
|
||||
<app-button (click)="onShare(show)" *ngIf="show.published" [icon]="faShare">
|
||||
}
|
||||
@if (show.published) {
|
||||
<app-button (click)="onShare(show)" [icon]="faShare">
|
||||
Teilen
|
||||
</app-button>
|
||||
<app-button (click)="onChange(show.id)" *ngIf="!show.published" [icon]="faSliders">
|
||||
}
|
||||
@if (!show.published) {
|
||||
<app-button (click)="onChange(show.id)" [icon]="faSliders">
|
||||
Ändern
|
||||
</app-button>
|
||||
}
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<app-button [icon]="faDownload" [matMenuTriggerFor]="menu">
|
||||
Herunterladen
|
||||
</app-button>
|
||||
@@ -103,5 +130,7 @@
|
||||
</app-button>
|
||||
</mat-menu>
|
||||
</app-button-row>
|
||||
}
|
||||
</app-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, HostListener, OnDestroy, OnInit} from '@angular/core';
|
||||
import {filter, map, switchMap, tap} from 'rxjs/operators';
|
||||
import {ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, HostListener, OnDestroy, OnInit, inject} from '@angular/core';
|
||||
import {filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ShowService} from '../services/show.service';
|
||||
import {Observable, Subscription} from 'rxjs';
|
||||
import {Observable, of, Subscription} from 'rxjs';
|
||||
import {Show} from '../services/show';
|
||||
import {SongService} from '../../songs/services/song.service';
|
||||
import {Song} from '../../songs/services/song';
|
||||
@@ -32,7 +32,7 @@ import {ArchiveDialogComponent} from '../dialog/archive-dialog/archive-dialog.co
|
||||
import {closeFullscreen, openFullscreen} from '../../../services/fullscreen';
|
||||
import {GuestShowService} from '../../guest/guest-show.service';
|
||||
import {ShareDialogComponent} from '../dialog/share-dialog/share-dialog.component';
|
||||
import {AsyncPipe, DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {UserNameComponent} from '../../../services/user/user-name/user-name.component';
|
||||
import {MatCheckbox} from '@angular/material/checkbox';
|
||||
@@ -56,7 +56,6 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
animations: [fade],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
imports: [
|
||||
NgIf,
|
||||
CardComponent,
|
||||
UserNameComponent,
|
||||
MatCheckbox,
|
||||
@@ -65,7 +64,6 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
MenuButtonComponent,
|
||||
MatTooltip,
|
||||
CdkDropList,
|
||||
NgFor,
|
||||
CdkDrag,
|
||||
SongComponent,
|
||||
FaIconComponent,
|
||||
@@ -82,8 +80,18 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
],
|
||||
})
|
||||
export class ShowComponent implements OnInit, OnDestroy {
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private showService = inject(ShowService);
|
||||
private songService = inject(SongService);
|
||||
private showSongService = inject(ShowSongService);
|
||||
private docxService = inject(DocxService);
|
||||
private router = inject(Router);
|
||||
private cRef = inject(ChangeDetectorRef);
|
||||
public dialog = inject(MatDialog);
|
||||
private guestShowService = inject(GuestShowService);
|
||||
|
||||
public show$: Observable<Show | null> | null = null;
|
||||
public songs: Song[] | null = null;
|
||||
public songs$: Observable<Song[] | null> | null = null;
|
||||
public showSongs: ShowSong[] | null = null;
|
||||
public showId: string | null = null;
|
||||
public showText = false;
|
||||
@@ -107,18 +115,6 @@ export class ShowComponent implements OnInit, OnDestroy {
|
||||
public currentTime: Date;
|
||||
private subs: Subscription[] = [];
|
||||
|
||||
public constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private showService: ShowService,
|
||||
private songService: SongService,
|
||||
private showSongService: ShowSongService,
|
||||
private docxService: DocxService,
|
||||
private router: Router,
|
||||
private cRef: ChangeDetectorRef,
|
||||
public dialog: MatDialog,
|
||||
private guestShowService: GuestShowService
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.currentTime = new Date();
|
||||
setInterval(() => {
|
||||
@@ -128,7 +124,11 @@ export class ShowComponent implements OnInit, OnDestroy {
|
||||
map(param => param as {showId: string}),
|
||||
map(param => param.showId),
|
||||
tap((_: string) => (this.showId = _)),
|
||||
switchMap((showId: string) => this.showService.read$(showId))
|
||||
switchMap((showId: string) => this.showService.read$(showId)),
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
refCount: true,
|
||||
})
|
||||
);
|
||||
this.subs.push(
|
||||
this.activatedRoute.params
|
||||
@@ -141,13 +141,14 @@ export class ShowComponent implements OnInit, OnDestroy {
|
||||
.subscribe(_ => {
|
||||
this.showSongs = _;
|
||||
this.cRef.markForCheck();
|
||||
}),
|
||||
this.songService
|
||||
.list$()
|
||||
.pipe(filter(_ => !!_))
|
||||
.subscribe(_ => {
|
||||
this.songs = _;
|
||||
this.cRef.markForCheck();
|
||||
})
|
||||
);
|
||||
|
||||
this.songs$ = this.show$.pipe(
|
||||
switchMap(show => (show && !show.published ? this.songService.list$() : of(null))),
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
refCount: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -217,7 +218,8 @@ export class ShowComponent implements OnInit, OnDestroy {
|
||||
public orderedShowSongs(show: Show): ShowSong[] {
|
||||
const list = this.showSongs;
|
||||
if (!list) return [];
|
||||
return show.order.map(_ => list.filter(f => f.id === _)[0]);
|
||||
const byId = new Map(list.map(item => [item.id, item] as const));
|
||||
return show.order.map(id => byId.get(id)).filter((song): song is ShowSong => !!song);
|
||||
}
|
||||
|
||||
public trackBy = (_: number, show: ShowSong) => show?.id;
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
<div *ngIf="iSong && iSong && show">
|
||||
<div *ngIf="show.published || fullscreen" class="title published">
|
||||
@if (iSong && iSong && show) {
|
||||
<div>
|
||||
@if (show.published || fullscreen) {
|
||||
<div class="title published">
|
||||
<div class="key">{{ iSong.key }}</div>
|
||||
<div>{{ iSong.title }}</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!show.published && !fullscreen" class="song">
|
||||
}
|
||||
@if (!show.published && !fullscreen) {
|
||||
<div class="song">
|
||||
<span class="title">{{ iSong.title }}</span>
|
||||
<span *ngIf="!edit" class="keys">
|
||||
<span *ngIf="iSong.keyOriginal !== iSong.key">{{ iSong.keyOriginal }} → </span><span
|
||||
@if (!edit) {
|
||||
<span class="keys">
|
||||
@if (iSong.keyOriginal !== iSong.key) {
|
||||
<span>{{ iSong.keyOriginal }} → </span>
|
||||
}<span
|
||||
(click)="openKeySelect()">{{ iSong.key }}</span>
|
||||
<mat-form-field (click)="option.open()" *ngIf="keys" class="transpose">
|
||||
@if (keys) {
|
||||
<mat-form-field (click)="option.open()" class="transpose">
|
||||
<mat-select #option [formControl]="keyFormControl">
|
||||
<mat-option *ngFor="let key of keys" [value]="key">{{ key }}</mat-option>
|
||||
@for (key of keys; track key) {
|
||||
<mat-option [value]="key">{{ key }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
}
|
||||
</span>
|
||||
<app-menu-button (click)="onEdit()" *ngIf="!edit" [icon]="faEdit" class="btn-edit btn-icon"
|
||||
}
|
||||
@if (!edit) {
|
||||
<app-menu-button (click)="onEdit()" [icon]="faEdit" class="btn-edit btn-icon"
|
||||
matTooltip="Lied für diese Veranstaltung bearbeiten"></app-menu-button>
|
||||
<app-menu-button (click)="onDelete()" *ngIf="!edit" [icon]="faDelete" class="btn-delete btn-icon"
|
||||
}
|
||||
@if (!edit) {
|
||||
<app-menu-button (click)="onDelete()" [icon]="faDelete" class="btn-delete btn-icon"
|
||||
matTooltip="Lied aus Veranstaltung entfernen"></app-menu-button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<mat-form-field *ngIf="edit" appearance="outline">
|
||||
}
|
||||
@if (edit) {
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Songtext</mat-label>
|
||||
<textarea [cdkTextareaAutosize]="true"
|
||||
[formControl]="editSongControl"
|
||||
@@ -30,18 +46,24 @@
|
||||
matTooltip="Tonart ändern"
|
||||
></textarea>
|
||||
</mat-form-field>
|
||||
<div *ngIf="edit">Es wird nur der Liedtext für dieser Veranstaltung geändert.</div>
|
||||
<app-button-row *ngIf="edit">
|
||||
}
|
||||
@if (edit) {
|
||||
<div>Es wird nur der Liedtext für dieser Veranstaltung geändert.</div>
|
||||
}
|
||||
@if (edit) {
|
||||
<app-button-row>
|
||||
<app-button (click)="onSave()" [icon]="faSave">Speichern</app-button>
|
||||
<app-button (click)="onDiscard()" [icon]="faEraser">Verwerfen</app-button>
|
||||
</app-button-row>
|
||||
|
||||
}
|
||||
@if (!edit && (showText )) {
|
||||
<app-song-text
|
||||
(chordModeChanged)="onChordModeChanged($event)"
|
||||
*ngIf="!edit && (showText )"
|
||||
[chordMode]="iSong.chordMode"
|
||||
[showSwitch]="!show.published"
|
||||
[text]="iSong.text"
|
||||
[transpose]="{ baseKey: iSong.keyOriginal, targetKey: iSong.key }"
|
||||
></app-song-text>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, Input, OnInit, ViewChild, inject} from '@angular/core';
|
||||
import {ShowSongService} from '../../services/show-song.service';
|
||||
import {ShowSong} from '../../services/show-song';
|
||||
import {getScale} from '../../../songs/services/key.helper';
|
||||
@@ -8,7 +8,7 @@ import {Show} from '../../services/show';
|
||||
import {faEraser, faPenToSquare, faSave, faTrash} from '@fortawesome/free-solid-svg-icons';
|
||||
import {fade} from '../../../../animations';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatOption} from '@angular/material/core';
|
||||
import {MenuButtonComponent} from '../../../../widget-modules/components/menu-button/menu-button.component';
|
||||
@@ -24,11 +24,9 @@ import {ButtonComponent} from '../../../../widget-modules/components/button/butt
|
||||
styleUrls: ['./song.component.less'],
|
||||
animations: [fade],
|
||||
imports: [
|
||||
NgIf,
|
||||
MatFormField,
|
||||
MatSelect,
|
||||
ReactiveFormsModule,
|
||||
NgFor,
|
||||
MatOption,
|
||||
MenuButtonComponent,
|
||||
MatTooltip,
|
||||
@@ -41,6 +39,8 @@ import {ButtonComponent} from '../../../../widget-modules/components/button/butt
|
||||
],
|
||||
})
|
||||
export class SongComponent implements OnInit {
|
||||
private showSongService = inject(ShowSongService);
|
||||
|
||||
@Input() public show: Show | null = null;
|
||||
@Input() public showId: string | null = null;
|
||||
@Input() public showText: boolean | null = null;
|
||||
@@ -57,8 +57,6 @@ export class SongComponent implements OnInit {
|
||||
public editSongControl = new UntypedFormControl();
|
||||
@ViewChild('option') private keyOptions: MatSelect;
|
||||
|
||||
public constructor(private showSongService: ShowSongService) {}
|
||||
|
||||
@Input()
|
||||
public set showSong(song: ShowSong) {
|
||||
this.iSong = song;
|
||||
|
||||
@@ -1,12 +1,68 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {of} from 'rxjs';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {FileDataService} from './file-data.service';
|
||||
|
||||
describe('FileDataService', () => {
|
||||
beforeEach(() => void TestBed.configureTestingModule({}));
|
||||
let service: FileDataService;
|
||||
let filesCollectionValueChangesSpy: jasmine.Spy;
|
||||
let filesCollectionAddSpy: jasmine.Spy;
|
||||
let songDocCollectionSpy: jasmine.Spy;
|
||||
let songDocSpy: jasmine.Spy;
|
||||
let fileDeleteSpy: jasmine.Spy;
|
||||
let dbServiceSpy: jasmine.SpyObj<DbService>;
|
||||
|
||||
beforeEach(() => {
|
||||
filesCollectionValueChangesSpy = jasmine.createSpy('valueChanges').and.returnValue(of([{id: 'file-1', name: 'plan.pdf'}]));
|
||||
filesCollectionAddSpy = jasmine.createSpy('add').and.resolveTo({id: 'file-2'});
|
||||
songDocCollectionSpy = jasmine.createSpy('collection').and.returnValue({
|
||||
add: filesCollectionAddSpy,
|
||||
valueChanges: filesCollectionValueChangesSpy,
|
||||
});
|
||||
songDocSpy = jasmine.createSpy('songDoc').and.callFake((path: string) => {
|
||||
if (path.includes('/files/')) {
|
||||
return {delete: fileDeleteSpy};
|
||||
}
|
||||
|
||||
return {collection: songDocCollectionSpy};
|
||||
});
|
||||
fileDeleteSpy = jasmine.createSpy('delete').and.resolveTo();
|
||||
dbServiceSpy = jasmine.createSpyObj<DbService>('DbService', ['doc']);
|
||||
dbServiceSpy.doc.and.callFake(songDocSpy);
|
||||
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||
});
|
||||
|
||||
service = TestBed.inject(FileDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
const service: FileDataService = TestBed.inject(FileDataService);
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should add files to the song files subcollection and return the generated id', async () => {
|
||||
const file = {name: 'setlist.pdf', path: 'songs/song-1/files', createdAt: new Date()};
|
||||
|
||||
await expectAsync(service.set('song-1', file)).toBeResolvedTo('file-2');
|
||||
|
||||
expect(songDocSpy).toHaveBeenCalledWith('songs/song-1');
|
||||
expect(songDocCollectionSpy).toHaveBeenCalledWith('files');
|
||||
expect(filesCollectionAddSpy).toHaveBeenCalledWith(file);
|
||||
});
|
||||
|
||||
it('should delete files from the nested file document path', async () => {
|
||||
await service.delete('song-4', 'file-9');
|
||||
|
||||
expect(songDocSpy).toHaveBeenCalledWith('songs/song-4/files/file-9');
|
||||
expect(fileDeleteSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should read files from the files subcollection with the id field attached', () => {
|
||||
service.read$('song-3').subscribe();
|
||||
|
||||
expect(songDocSpy).toHaveBeenCalledWith('songs/song-3');
|
||||
expect(songDocCollectionSpy).toHaveBeenCalledWith('files');
|
||||
expect(filesCollectionValueChangesSpy).toHaveBeenCalledWith({idField: 'id'});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {File} from './file';
|
||||
import {Observable} from 'rxjs';
|
||||
import {FileServer} from './fileServer';
|
||||
@@ -8,7 +8,7 @@ import {DbService} from '../../../services/db.service';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FileDataService {
|
||||
public constructor(private db: DbService) {}
|
||||
private db = inject(DbService);
|
||||
|
||||
public async set(songId: string, file: FileServer): Promise<string> {
|
||||
const songRef = this.db.doc('songs/' + songId);
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {Storage} from '@angular/fire/storage';
|
||||
|
||||
import {FileService} from './file.service';
|
||||
import {FileDataService} from './file-data.service';
|
||||
|
||||
describe('FileService', () => {
|
||||
let service: FileService;
|
||||
|
||||
beforeEach(() => {
|
||||
void TestBed.configureTestingModule({});
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: Storage, useValue: {}},
|
||||
{provide: FileDataService, useValue: {delete: () => Promise.resolve()}},
|
||||
],
|
||||
});
|
||||
service = TestBed.inject(FileService);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AngularFireStorage} from '@angular/fire/compat/storage';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {EnvironmentInjector, Injectable, inject, runInInjectionContext} from '@angular/core';
|
||||
import {deleteObject, getDownloadURL, ref, Storage} from '@angular/fire/storage';
|
||||
import {from, Observable} from 'rxjs';
|
||||
import {FileDataService} from './file-data.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FileService {
|
||||
public constructor(
|
||||
private storage: AngularFireStorage,
|
||||
private fileDataService: FileDataService
|
||||
) {}
|
||||
private storage = inject(Storage);
|
||||
private fileDataService = inject(FileDataService);
|
||||
private environmentInjector = inject(EnvironmentInjector);
|
||||
|
||||
public getDownloadUrl(path: string): Observable<string> {
|
||||
const ref = this.storage.ref(path);
|
||||
return ref.getDownloadURL() as Observable<string>;
|
||||
return from(runInInjectionContext(this.environmentInjector, () => getDownloadURL(ref(this.storage, path))));
|
||||
}
|
||||
|
||||
public delete(path: string, songId: string, fileId: string): void {
|
||||
const ref = this.storage.ref(path);
|
||||
void firstValueFrom(ref.delete());
|
||||
void runInInjectionContext(this.environmentInjector, () => deleteObject(ref(this.storage, path)));
|
||||
void this.fileDataService.delete(songId, fileId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import {getScale, scaleMapping} from './key.helper';
|
||||
|
||||
describe('key.helper', () => {
|
||||
it('should render Gb correctly', () => {
|
||||
expect(scaleMapping['Gb']).toBe('G♭');
|
||||
void expect(scaleMapping['Gb']).toBe('G♭');
|
||||
});
|
||||
|
||||
it('should expose a sharp-based scale for D', () => {
|
||||
expect(getScale('D')).toEqual(['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'H']);
|
||||
void expect(getScale('D')).toEqual(['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'H']);
|
||||
});
|
||||
|
||||
it('should keep flat-based spelling for Db', () => {
|
||||
expect(getScale('Db')).toEqual(['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'B', 'H']);
|
||||
void expect(getScale('Db')).toEqual(['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'B', 'H']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,35 +1,104 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {firstValueFrom, Subject} from 'rxjs';
|
||||
import {skip, take, toArray} from 'rxjs/operators';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {SongDataService} from './song-data.service';
|
||||
import {AngularFirestore} from '@angular/fire/compat/firestore';
|
||||
import {firstValueFrom, of} from 'rxjs';
|
||||
|
||||
describe('SongDataService', () => {
|
||||
const songs = [{title: 'title1'}];
|
||||
let service: SongDataService;
|
||||
let songs$: Subject<Array<{id: string; title: string}>>;
|
||||
let docUpdateSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docDeleteSpy: jasmine.Spy<() => Promise<void>>;
|
||||
let docSpy: jasmine.Spy;
|
||||
let colAddSpy: jasmine.Spy<() => Promise<{id: string}>>;
|
||||
let colSpy: jasmine.Spy;
|
||||
let dbServiceSpy: jasmine.SpyObj<DbService>;
|
||||
|
||||
const angularFirestoreCollection = {
|
||||
valueChanges: () => of(songs),
|
||||
};
|
||||
beforeEach(() => {
|
||||
songs$ = new Subject<Array<{id: string; title: string}>>();
|
||||
docUpdateSpy = jasmine.createSpy('update').and.resolveTo();
|
||||
docDeleteSpy = jasmine.createSpy('delete').and.resolveTo();
|
||||
docSpy = jasmine.createSpy('doc').and.callFake(() => ({
|
||||
update: docUpdateSpy,
|
||||
delete: docDeleteSpy,
|
||||
}));
|
||||
colAddSpy = jasmine.createSpy('add').and.resolveTo({id: 'song-3'});
|
||||
colSpy = jasmine.createSpy('col').and.returnValue({
|
||||
add: colAddSpy,
|
||||
});
|
||||
dbServiceSpy = jasmine.createSpyObj<DbService>('DbService', ['col$', 'doc$', 'doc', 'col']);
|
||||
dbServiceSpy.col$.and.returnValue(songs$.asObservable());
|
||||
dbServiceSpy.doc$.and.returnValue(songs$.asObservable() as never);
|
||||
dbServiceSpy.doc.and.callFake(docSpy);
|
||||
dbServiceSpy.col.and.callFake(colSpy);
|
||||
|
||||
const mockAngularFirestore = {
|
||||
collection: () => angularFirestoreCollection,
|
||||
};
|
||||
|
||||
beforeEach(
|
||||
() =>
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: AngularFirestore, useValue: mockAngularFirestore}],
|
||||
})
|
||||
);
|
||||
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||
});
|
||||
|
||||
service = TestBed.inject(SongDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
const service: SongDataService = TestBed.inject(SongDataService);
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should list songs', async () => {
|
||||
const service: SongDataService = TestBed.inject(SongDataService);
|
||||
const list = await firstValueFrom(service.list$);
|
||||
void expect(list[0].title).toEqual('title1');
|
||||
it('should load songs from the songs collection once on creation', () => {
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledTimes(1);
|
||||
expect(dbServiceSpy.col$).toHaveBeenCalledWith('songs');
|
||||
});
|
||||
|
||||
it('should emit an empty list first and then the loaded songs', async () => {
|
||||
const emissionsPromise = firstValueFrom(service.list$.pipe(take(2), toArray()));
|
||||
|
||||
songs$.next([{id: 'song-1', title: 'Amazing Grace'}]);
|
||||
|
||||
const emissions = await emissionsPromise;
|
||||
|
||||
expect(emissions[0]).toEqual([]);
|
||||
expect(emissions[1].map(song => song.id)).toEqual(['song-1']);
|
||||
expect(emissions[1].map(song => song.title)).toEqual(['Amazing Grace']);
|
||||
});
|
||||
|
||||
it('should replay the latest songs to late subscribers', async () => {
|
||||
const initialSubscription = service.list$.subscribe();
|
||||
|
||||
songs$.next([{id: 'song-2', title: 'How Great'}]);
|
||||
|
||||
const latestSongs = await firstValueFrom(service.list$.pipe(take(1)));
|
||||
|
||||
expect(latestSongs.map(song => song.id)).toEqual(['song-2']);
|
||||
expect(latestSongs.map(song => song.title)).toEqual(['How Great']);
|
||||
|
||||
initialSubscription.unsubscribe();
|
||||
});
|
||||
|
||||
it('should read a single song by id', () => {
|
||||
service.read$('song-7');
|
||||
|
||||
expect(dbServiceSpy.doc$).toHaveBeenCalledWith('songs/song-7');
|
||||
});
|
||||
|
||||
it('should update a song at the expected document path', async () => {
|
||||
await service.update$('song-8', {title: 'Updated'});
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('songs/song-8');
|
||||
const [updatePayload] = docUpdateSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(updatePayload).toEqual({title: 'Updated'});
|
||||
});
|
||||
|
||||
it('should add a song to the songs collection and return the new id', async () => {
|
||||
await expectAsync(service.add({title: 'New Song'})).toBeResolvedTo('song-3');
|
||||
|
||||
expect(colSpy).toHaveBeenCalledWith('songs');
|
||||
const [addPayload] = colAddSpy.calls.mostRecent().args as unknown as [Record<string, unknown>];
|
||||
expect(addPayload).toEqual({title: 'New Song'});
|
||||
});
|
||||
|
||||
it('should delete a song at the expected document path', async () => {
|
||||
await service.delete('song-9');
|
||||
|
||||
expect(docSpy).toHaveBeenCalledWith('songs/song-9');
|
||||
expect(docDeleteSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Song} from './song';
|
||||
import {Observable} from 'rxjs';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
@@ -8,6 +8,8 @@ import {shareReplay, startWith} from 'rxjs/operators';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SongDataService {
|
||||
private dbService = inject(DbService);
|
||||
|
||||
private collection = 'songs';
|
||||
public list$: Observable<Song[]> = this.dbService.col$<Song>(this.collection).pipe(
|
||||
startWith([] as Song[]), // immediate empty emit keeps UI responsive while first snapshot arrives
|
||||
@@ -17,11 +19,6 @@ export class SongDataService {
|
||||
})
|
||||
);
|
||||
|
||||
public constructor(private dbService: DbService) {
|
||||
// Warm the shared stream once at startup to avoid first-navigation delay.
|
||||
// this.list$.subscribe();
|
||||
}
|
||||
|
||||
public read$ = (songId: string): Observable<Song | null> => this.dbService.doc$(this.collection + '/' + songId);
|
||||
public update$ = async (songId: string, data: Partial<Song>): Promise<void> => await this.dbService.doc(this.collection + '/' + songId).update(data);
|
||||
public add = async (data: Partial<Song>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
|
||||
import {Observable} from 'rxjs';
|
||||
import {SongService} from './song.service';
|
||||
@@ -9,7 +9,7 @@ import {take} from 'rxjs/operators';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SongListResolver {
|
||||
public constructor(private songService: SongService) {}
|
||||
private songService = inject(SongService);
|
||||
|
||||
public resolve(): Observable<Song[]> {
|
||||
return this.songService.list$().pipe(take(1));
|
||||
|
||||
@@ -1,32 +1,100 @@
|
||||
import {TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import {SongService} from './song.service';
|
||||
import {SongDataService} from './song-data.service';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {of} from 'rxjs';
|
||||
import {SongDataService} from './song-data.service';
|
||||
import {SongService} from './song.service';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
describe('SongService', () => {
|
||||
const songs = [{title: 'title1'}];
|
||||
let service: SongService;
|
||||
let songDataServiceSpy: jasmine.SpyObj<SongDataService>;
|
||||
let userServiceSpy: jasmine.SpyObj<UserService>;
|
||||
const song = {
|
||||
id: 'song-1',
|
||||
title: 'Amazing Grace',
|
||||
edits: [],
|
||||
} as never;
|
||||
|
||||
const mockSongDataService = {
|
||||
list: () => of(songs),
|
||||
};
|
||||
beforeEach(() => {
|
||||
songDataServiceSpy = jasmine.createSpyObj<SongDataService>('SongDataService', ['read$', 'update$', 'add', 'delete'], {
|
||||
list$: of([song]),
|
||||
});
|
||||
userServiceSpy = jasmine.createSpyObj<UserService>('UserService', ['currentUser']);
|
||||
|
||||
songDataServiceSpy.read$.and.returnValue(of(song));
|
||||
songDataServiceSpy.update$.and.resolveTo();
|
||||
songDataServiceSpy.add.and.resolveTo('song-2');
|
||||
songDataServiceSpy.delete.and.resolveTo();
|
||||
userServiceSpy.currentUser.and.resolveTo({name: 'Benjamin'} as never);
|
||||
|
||||
beforeEach(
|
||||
() =>
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: SongDataService, useValue: mockSongDataService}],
|
||||
})
|
||||
);
|
||||
providers: [
|
||||
{provide: SongDataService, useValue: songDataServiceSpy},
|
||||
{provide: UserService, useValue: userServiceSpy},
|
||||
],
|
||||
});
|
||||
|
||||
service = TestBed.inject(SongService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
const service: SongService = TestBed.inject(SongService);
|
||||
void expect(service).toBeTruthy();
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should list songs', waitForAsync(() => {
|
||||
const service: SongService = TestBed.inject(SongService);
|
||||
service.list$().subscribe(s => {
|
||||
void expect(s[0].title).toEqual('title1');
|
||||
it('should list songs from the data service', done => {
|
||||
service.list$().subscribe(songs => {
|
||||
expect(songs).toEqual([song]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate reads to the data service', async () => {
|
||||
await expectAsync(service.read('song-1')).toBeResolvedTo(song);
|
||||
expect(songDataServiceSpy.read$).toHaveBeenCalledWith('song-1');
|
||||
});
|
||||
|
||||
it('should append an edit with the current user when updating a song', async () => {
|
||||
const timestamp = {seconds: 1} as never;
|
||||
spyOn(Timestamp, 'now').and.returnValue(timestamp);
|
||||
|
||||
await service.update$('song-1', {title: 'Updated'});
|
||||
|
||||
expect(songDataServiceSpy.update$).toHaveBeenCalled();
|
||||
const [, payload] = songDataServiceSpy.update$.calls.mostRecent().args as unknown as [string, Record<string, unknown>];
|
||||
expect(payload.title).toBe('Updated');
|
||||
expect(payload.edits).toEqual([{username: 'Benjamin', timestamp}]);
|
||||
});
|
||||
|
||||
it('should not update when the song does not exist', async () => {
|
||||
songDataServiceSpy.read$.and.returnValue(of(null));
|
||||
|
||||
await service.update$('missing-song', {title: 'Updated'});
|
||||
|
||||
expect(songDataServiceSpy.update$).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not update when no current user is available', async () => {
|
||||
userServiceSpy.currentUser.and.resolveTo(null);
|
||||
|
||||
await service.update$('song-1', {title: 'Updated'});
|
||||
|
||||
expect(songDataServiceSpy.update$).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create new songs with the expected defaults', async () => {
|
||||
await expectAsync(service.new(42, 'New Song')).toBeResolvedTo('song-2');
|
||||
|
||||
expect(songDataServiceSpy.add).toHaveBeenCalledWith({
|
||||
number: 42,
|
||||
title: 'New Song',
|
||||
status: 'draft',
|
||||
legalType: 'open',
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete songs via the data service', async () => {
|
||||
await service.delete('song-1');
|
||||
|
||||
expect(songDataServiceSpy.delete).toHaveBeenCalledWith('song-1');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {Song} from './song';
|
||||
import {SongDataService} from './song-data.service';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import firebase from 'firebase/compat/app';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
// declare let importCCLI: any;
|
||||
|
||||
@@ -17,21 +16,15 @@ export type SongLegalType = 'open' | 'allowed';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SongService {
|
||||
private songDataService = inject(SongDataService);
|
||||
private userService = inject(UserService);
|
||||
|
||||
public static TYPES: SongType[] = ['Praise', 'Worship', 'Misc'];
|
||||
public static STATUS: SongStatus[] = ['draft', 'set', 'final'];
|
||||
|
||||
public static LEGAL_OWNER: SongLegalOwner[] = ['CCLI', 'other'];
|
||||
public static LEGAL_TYPE: SongLegalType[] = ['open', 'allowed'];
|
||||
|
||||
// private list: Song[];
|
||||
|
||||
public constructor(
|
||||
private songDataService: SongDataService,
|
||||
private userService: UserService
|
||||
) {
|
||||
// importCCLI = (songs: Song[]) => this.updateFromCLI(songs);
|
||||
}
|
||||
|
||||
public list$ = (): Observable<Song[]> => this.songDataService.list$; //.pipe(tap(_ => (this.list = _)));
|
||||
public read$ = (songId: string): Observable<Song | null> => this.songDataService.read$(songId);
|
||||
public read = (songId: string): Promise<Song | null> => firstValueFrom(this.read$(songId));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import firebase from 'firebase/compat/app';
|
||||
import {SongLegalOwner, SongLegalType, SongStatus, SongType} from './song.service';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
export interface Song {
|
||||
id: string;
|
||||
|
||||
@@ -73,7 +73,7 @@ Cool bridge without any chords
|
||||
void expect(sections[1].lines[2].type).toBe(LineType.chord);
|
||||
void expect(sections[1].lines[2].text).toBe(' a d e f g a h c b');
|
||||
void expect(sections[2].lines[0].type).toBe(LineType.chord);
|
||||
void expect(sections[2].lines[0].text).toBe('c c# db c7 cmaj7 c/e');
|
||||
void expect(sections[2].lines[0].text).toBe('c c♯ d♭ c7 cmaj7 c/e');
|
||||
|
||||
// c c# db c7 cmaj7 c/e
|
||||
void expect(sections[2].lines[0].chords).toEqual([
|
||||
@@ -93,7 +93,7 @@ g# F# E g# F# E
|
||||
text`;
|
||||
const sections = service.parse(text, null);
|
||||
void expect(sections[0].lines[0].type).toBe(LineType.chord);
|
||||
void expect(sections[0].lines[0].text).toBe('g# F# E g# F# E');
|
||||
void expect(sections[0].lines[0].text).toBe('g♯ F♯ E g♯ F♯ E');
|
||||
void expect(sections[0].lines[1].type).toBe(LineType.text);
|
||||
void expect(sections[0].lines[1].text).toBe('text');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {TransposeService} from './transpose.service';
|
||||
import {TransposeMode} from './transpose-mode';
|
||||
import {SectionType} from './section-type';
|
||||
@@ -11,9 +11,9 @@ import {Line} from './line';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TextRenderingService {
|
||||
private regexSection = /(Strophe|Refrain|Bridge)/;
|
||||
private transposeService = inject(TransposeService);
|
||||
|
||||
public constructor(private transposeService: TransposeService) {}
|
||||
private regexSection = /(Strophe|Refrain|Bridge)/;
|
||||
|
||||
public parse(text: string, transpose: TransposeMode | null, withComments = true): Section[] {
|
||||
if (!text) {
|
||||
|
||||
@@ -34,60 +34,54 @@ describe('TransposeService', () => {
|
||||
const distance = service.getDistance('C', 'Db');
|
||||
const map = service.getMap('C', 'Db', distance);
|
||||
|
||||
expect(distance).toBe(1);
|
||||
expect(map?.['C']).toBe('Db');
|
||||
expect(map?.['G']).toBe('Ab');
|
||||
void expect(distance).toBe(1);
|
||||
void expect(map?.['C']).toBe('Db');
|
||||
void expect(map?.['G']).toBe('Ab');
|
||||
});
|
||||
|
||||
it('should keep german B/H notation consistent', () => {
|
||||
const distance = service.getDistance('H', 'C');
|
||||
const map = service.getMap('H', 'C', distance);
|
||||
|
||||
expect(distance).toBe(1);
|
||||
expect(map?.['H']).toBe('C');
|
||||
expect(map?.['B']).toBe('C#');
|
||||
void expect(distance).toBe(1);
|
||||
void expect(map?.['H']).toBe('C');
|
||||
void expect(map?.['B']).toBe('H');
|
||||
});
|
||||
|
||||
it('should render unknown chords as X', () => {
|
||||
const line: Line = {
|
||||
type: LineType.chord,
|
||||
text: '',
|
||||
chords: [
|
||||
{chord: 'Q', add: 'sus4', slashChord: null, position: 0, length: 1},
|
||||
],
|
||||
chords: [{chord: 'Q', add: 'sus4', slashChord: null, position: 0, length: 1}],
|
||||
};
|
||||
|
||||
const rendered = service.renderChords(line);
|
||||
|
||||
expect(rendered.text).toBe('Xsus4');
|
||||
void expect(rendered.text).toBe('Xsus4');
|
||||
});
|
||||
|
||||
it('should render unknown slash chords as X', () => {
|
||||
const line: Line = {
|
||||
type: LineType.chord,
|
||||
text: '',
|
||||
chords: [
|
||||
{chord: 'C', add: null, slashChord: 'Q', position: 0, length: 1},
|
||||
],
|
||||
chords: [{chord: 'C', add: null, slashChord: 'Q', position: 0, length: 1}],
|
||||
};
|
||||
|
||||
const rendered = service.renderChords(line);
|
||||
|
||||
expect(rendered.text).toBe('C/X');
|
||||
void expect(rendered.text).toBe('C/X');
|
||||
});
|
||||
|
||||
it('should transpose lines with long chord positions without truncating', () => {
|
||||
const line: Line = {
|
||||
type: LineType.chord,
|
||||
text: '',
|
||||
chords: [
|
||||
{chord: 'C', add: null, slashChord: null, position: 120, length: 1},
|
||||
],
|
||||
chords: [{chord: 'C', add: null, slashChord: null, position: 120, length: 1}],
|
||||
};
|
||||
|
||||
const rendered = service.renderChords(line);
|
||||
|
||||
expect(rendered.text.length).toBe(121);
|
||||
expect(rendered.text.endsWith('C')).toBeTrue();
|
||||
void expect(rendered.text.length).toBe(121);
|
||||
void expect(rendered.text.endsWith('C')).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,6 +11,19 @@ type ScaleVariants = [string[], string[]];
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TransposeService {
|
||||
private readonly enharmonicAliases: Array<[string, string]> = [
|
||||
['C#', 'Db'],
|
||||
['D#', 'Eb'],
|
||||
['F#', 'Gb'],
|
||||
['G#', 'Ab'],
|
||||
['A#', 'B'],
|
||||
['c#', 'db'],
|
||||
['d#', 'eb'],
|
||||
['f#', 'gb'],
|
||||
['g#', 'ab'],
|
||||
['a#', 'b'],
|
||||
];
|
||||
|
||||
private readonly keyToSemitone: Record<string, number> = {
|
||||
C: 0,
|
||||
'C#': 1,
|
||||
@@ -105,13 +118,22 @@ export class TransposeService {
|
||||
}
|
||||
});
|
||||
|
||||
this.enharmonicAliases.forEach(([left, right]) => {
|
||||
if (map[left] && !map[right]) {
|
||||
map[right] = map[left];
|
||||
}
|
||||
if (map[right] && !map[left]) {
|
||||
map[left] = map[right];
|
||||
}
|
||||
});
|
||||
|
||||
this.mapCache.set(cacheKey, map);
|
||||
return map;
|
||||
}
|
||||
|
||||
private transposeChord(chord: Chord, map: TransposeMap): Chord {
|
||||
const translatedChord = map[chord.chord] ?? 'X';
|
||||
const translatedSlashChord = chord.slashChord ? map[chord.slashChord] ?? 'X' : null;
|
||||
const translatedSlashChord = chord.slashChord ? (map[chord.slashChord] ?? 'X') : null;
|
||||
|
||||
return {
|
||||
...chord,
|
||||
@@ -147,7 +169,7 @@ export class TransposeService {
|
||||
|
||||
private renderChord(chord: Chord): string {
|
||||
const renderedChord = scaleMapping[chord.chord] ?? 'X';
|
||||
const renderedSlashChord = chord.slashChord ? scaleMapping[chord.slashChord] ?? 'X' : '';
|
||||
const renderedSlashChord = chord.slashChord ? (scaleMapping[chord.slashChord] ?? 'X') : '';
|
||||
|
||||
return renderedChord + (chord.add ?? '') + (renderedSlashChord ? '/' + renderedSlashChord : '');
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {Storage} from '@angular/fire/storage';
|
||||
|
||||
import {UploadService} from './upload.service';
|
||||
import {FileDataService} from './file-data.service';
|
||||
|
||||
describe('UploadServiceService', () => {
|
||||
beforeEach(() => void TestBed.configureTestingModule({}));
|
||||
beforeEach(
|
||||
() =>
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: Storage, useValue: {}},
|
||||
{provide: FileDataService, useValue: {set: () => Promise.resolve('')}},
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
it('should be created', () => {
|
||||
const service: UploadService = TestBed.inject(UploadService);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {EnvironmentInjector, Injectable, inject, runInInjectionContext} from '@angular/core';
|
||||
import {Upload} from './upload';
|
||||
import {FileDataService} from './file-data.service';
|
||||
import {AngularFireStorage} from '@angular/fire/compat/storage';
|
||||
import {finalize} from 'rxjs/operators';
|
||||
import {ref, Storage, uploadBytesResumable} from '@angular/fire/storage';
|
||||
import {FileBase} from './fileBase';
|
||||
import {FileServer} from './fileServer';
|
||||
|
||||
@@ -10,26 +9,32 @@ import {FileServer} from './fileServer';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UploadService extends FileBase {
|
||||
public constructor(
|
||||
private fileDataService: FileDataService,
|
||||
private angularFireStorage: AngularFireStorage
|
||||
) {
|
||||
super();
|
||||
}
|
||||
private fileDataService = inject(FileDataService);
|
||||
private storage = inject(Storage);
|
||||
private environmentInjector = inject(EnvironmentInjector);
|
||||
|
||||
public pushUpload(songId: string, upload: Upload): void {
|
||||
const directory = this.directory(songId);
|
||||
const filePath = `${directory}/${upload.file.name}`;
|
||||
upload.path = directory;
|
||||
|
||||
const ref = this.angularFireStorage.ref(filePath);
|
||||
const task = ref.put(upload.file);
|
||||
const {task} = runInInjectionContext(this.environmentInjector, () => {
|
||||
const storageRef = ref(this.storage, filePath);
|
||||
return {
|
||||
task: uploadBytesResumable(storageRef, upload.file),
|
||||
};
|
||||
});
|
||||
|
||||
task.percentageChanges().subscribe(percent => (upload.progress = percent ?? 0));
|
||||
task
|
||||
.snapshotChanges()
|
||||
.pipe(finalize(() => void this.saveFileData(songId, upload)))
|
||||
.subscribe();
|
||||
task.on(
|
||||
'state_changed',
|
||||
snapshot => {
|
||||
upload.progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
||||
},
|
||||
() => {
|
||||
// Keep current UX: upload errors are ignored by this service.
|
||||
},
|
||||
() => void this.saveFileData(songId, upload)
|
||||
);
|
||||
}
|
||||
|
||||
private async saveFileData(songId: string, upload: Upload) {
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
<mat-label>Typ</mat-label>
|
||||
<mat-select formControlName="type">
|
||||
<mat-option [value]="null">- kein Filter -</mat-option>
|
||||
<mat-option *ngFor="let type of types" [value]="type">{{
|
||||
@for (type of types; track type) {
|
||||
<mat-option [value]="type">{{
|
||||
type | songType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -20,10 +22,12 @@
|
||||
<mat-label>Tonart</mat-label>
|
||||
<mat-select formControlName="key">
|
||||
<mat-option [value]="null">- kein Filter -</mat-option>
|
||||
<mat-option *ngFor="let key of keys" [value]="key">{{
|
||||
@for (key of keys; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | key
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -31,10 +35,12 @@
|
||||
<mat-label>Rechtlicher Status</mat-label>
|
||||
<mat-select formControlName="legalType">
|
||||
<mat-option [value]="null">- kein Filter -</mat-option>
|
||||
<mat-option *ngFor="let key of legalType" [value]="key">{{
|
||||
@for (key of legalType; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | legalType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -42,10 +48,12 @@
|
||||
<mat-label>Attribute</mat-label>
|
||||
<mat-select formControlName="flag">
|
||||
<mat-option [value]="null">- kein Filter -</mat-option>
|
||||
<mat-option *ngFor="let flag of getFlags()" [value]="flag">{{
|
||||
@for (flag of getFlags(); track flag) {
|
||||
<mat-option [value]="flag">{{
|
||||
flag
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Input, inject} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
|
||||
import {SongService} from '../../services/song.service';
|
||||
@@ -9,7 +9,7 @@ import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
import {MatOption} from '@angular/material/core';
|
||||
import {NgFor} from '@angular/common';
|
||||
|
||||
import {LegalTypePipe} from '../../../../widget-modules/pipes/legal-type-translator/legal-type.pipe';
|
||||
import {KeyPipe} from '../../../../widget-modules/pipes/key-translator/key.pipe';
|
||||
import {SongTypePipe} from '../../../../widget-modules/pipes/song-type-translater/song-type.pipe';
|
||||
@@ -18,9 +18,11 @@ import {SongTypePipe} from '../../../../widget-modules/pipes/song-type-translate
|
||||
selector: 'app-filter',
|
||||
templateUrl: './filter.component.html',
|
||||
styleUrls: ['./filter.component.less'],
|
||||
imports: [ReactiveFormsModule, MatFormField, MatLabel, MatInput, MatSelect, MatOption, NgFor, LegalTypePipe, KeyPipe, SongTypePipe],
|
||||
imports: [ReactiveFormsModule, MatFormField, MatLabel, MatInput, MatSelect, MatOption, LegalTypePipe, KeyPipe, SongTypePipe],
|
||||
})
|
||||
export class FilterComponent {
|
||||
private router = inject(Router);
|
||||
|
||||
public filterFormGroup: UntypedFormGroup;
|
||||
@Input() public route = '/';
|
||||
@Input() public songs: Song[] = [];
|
||||
@@ -28,11 +30,10 @@ export class FilterComponent {
|
||||
public legalType = SongService.LEGAL_TYPE;
|
||||
public keys = KEYS;
|
||||
|
||||
public constructor(
|
||||
private router: Router,
|
||||
activatedRoute: ActivatedRoute,
|
||||
fb: UntypedFormBuilder
|
||||
) {
|
||||
public constructor() {
|
||||
const activatedRoute = inject(ActivatedRoute);
|
||||
const fb = inject(UntypedFormBuilder);
|
||||
|
||||
this.filterFormGroup = fb.group({
|
||||
q: '',
|
||||
type: '',
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
<div *ngIf="songs$ | async as songs">
|
||||
@if (songs$ | async; as songs) {
|
||||
<div>
|
||||
<app-list-header [anyFilterActive]="anyFilterActive">
|
||||
<app-filter [songs]="songs" route="songs"></app-filter>
|
||||
</app-list-header>
|
||||
|
||||
<app-card [padding]="false">
|
||||
<div *ngFor="let song of songs; trackBy: trackBy" [routerLink]="song.id" class="list-item">
|
||||
@for (song of songs; track trackBy($index, song)) {
|
||||
<div [routerLink]="song.id" class="list-item">
|
||||
<div class="number">{{ song.number }}</div>
|
||||
<div>{{ song.title }}</div>
|
||||
<div>
|
||||
<ng-container *appRole="['contributor']">
|
||||
<div *ngIf="song.status === 'draft'" class="warning">
|
||||
@if (song.status === 'draft') {
|
||||
<div class="warning">
|
||||
<fa-icon [icon]="faDraft"></fa-icon>
|
||||
</div>
|
||||
<div *ngIf="song.status === 'set'" class="neutral">
|
||||
}
|
||||
@if (song.status === 'set') {
|
||||
<div class="neutral">
|
||||
<fa-icon [icon]="faDraft"></fa-icon>
|
||||
</div>
|
||||
<div *ngIf="song.status === 'final'" class="success">
|
||||
}
|
||||
@if (song.status === 'final') {
|
||||
<div class="success">
|
||||
<fa-icon [icon]="faFinal"></fa-icon>
|
||||
</div>
|
||||
}
|
||||
</ng-container>
|
||||
<div *ngIf="song.legalType === 'open'" class="warning">
|
||||
@if (song.legalType === 'open') {
|
||||
<div class="warning">
|
||||
<fa-icon [icon]="faLegal"></fa-icon>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div>{{ song.key }}</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
</app-card>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('SongListComponent', () => {
|
||||
const songs = [{title: 'title1'}];
|
||||
|
||||
const mockSongService = {
|
||||
list: () => of(songs),
|
||||
list$: () => of(songs),
|
||||
};
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit, inject} from '@angular/core';
|
||||
import {SongService} from '../services/song.service';
|
||||
import {Song} from '../services/song';
|
||||
import {map} from 'rxjs/operators';
|
||||
@@ -9,7 +9,7 @@ import {filterSong} from '../../../services/filter.helper';
|
||||
import {FilterValues} from './filter/filter-values';
|
||||
import {ScrollService} from '../../../services/scroll.service';
|
||||
import {faBalanceScaleRight, faCheck, faPencilRuler} from '@fortawesome/free-solid-svg-icons';
|
||||
import {AsyncPipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {ListHeaderComponent} from '../../../widget-modules/components/list-header/list-header.component';
|
||||
import {FilterComponent} from './filter/filter.component';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
@@ -22,9 +22,13 @@ import {FaIconComponent} from '@fortawesome/angular-fontawesome';
|
||||
styleUrls: ['./song-list.component.less'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
animations: [fade],
|
||||
imports: [NgIf, ListHeaderComponent, FilterComponent, CardComponent, NgFor, RouterLink, RoleDirective, FaIconComponent, AsyncPipe],
|
||||
imports: [ListHeaderComponent, FilterComponent, CardComponent, RouterLink, RoleDirective, FaIconComponent, AsyncPipe],
|
||||
})
|
||||
export class SongListComponent implements OnInit, OnDestroy {
|
||||
private songService = inject(SongService);
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private scrollService = inject(ScrollService);
|
||||
|
||||
public anyFilterActive = false;
|
||||
public songs$: Observable<Song[]> = combineLatest([
|
||||
this.activatedRoute.queryParams.pipe(map(_ => _ as FilterValues)),
|
||||
@@ -39,12 +43,6 @@ export class SongListComponent implements OnInit, OnDestroy {
|
||||
public faDraft = faPencilRuler;
|
||||
public faFinal = faCheck;
|
||||
|
||||
public constructor(
|
||||
private songService: SongService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private scrollService: ScrollService
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 100);
|
||||
setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 300);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<app-card heading="Angehängte Dateien">
|
||||
<div *ngIf="currentUpload">
|
||||
@if (currentUpload) {
|
||||
<div>
|
||||
<div class="progress">
|
||||
<div
|
||||
[ngStyle]="{ width: currentUpload?.progress + '%' }"
|
||||
@@ -9,6 +10,7 @@
|
||||
Progress: {{ currentUpload?.name }} | {{ currentUpload?.progress }}%
|
||||
Complete
|
||||
</div>
|
||||
}
|
||||
<div class="upload">
|
||||
<label>
|
||||
<input (change)="detectFiles($event)" type="file" />
|
||||
@@ -23,7 +25,9 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p *ngFor="let file of files$ | async">
|
||||
@for (file of files$ | async; track file) {
|
||||
<p>
|
||||
<app-file [file]="file" [songId]="songId"></app-file>
|
||||
</p>
|
||||
}
|
||||
</app-card>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Upload} from '../../../services/upload';
|
||||
import {UploadService} from '../../../services/upload.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
@@ -7,7 +7,7 @@ import {FileDataService} from '../../../services/file-data.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {File} from '../../../services/file';
|
||||
import {CardComponent} from '../../../../../widget-modules/components/card/card.component';
|
||||
import {AsyncPipe, NgFor, NgIf, NgStyle} from '@angular/common';
|
||||
import {AsyncPipe, NgStyle} from '@angular/common';
|
||||
import {MatIconButton} from '@angular/material/button';
|
||||
import {MatIcon} from '@angular/material/icon';
|
||||
import {FileComponent} from './file/file.component';
|
||||
@@ -16,19 +16,19 @@ import {FileComponent} from './file/file.component';
|
||||
selector: 'app-edit-file',
|
||||
templateUrl: './edit-file.component.html',
|
||||
styleUrls: ['./edit-file.component.less'],
|
||||
imports: [CardComponent, NgIf, NgStyle, MatIconButton, MatIcon, NgFor, FileComponent, AsyncPipe],
|
||||
imports: [CardComponent, NgStyle, MatIconButton, MatIcon, FileComponent, AsyncPipe],
|
||||
})
|
||||
export class EditFileComponent {
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private uploadService = inject(UploadService);
|
||||
private fileService = inject(FileDataService);
|
||||
|
||||
public selectedFiles: FileList | null = null;
|
||||
public currentUpload: Upload | null = null;
|
||||
public songId: string | null = null;
|
||||
public files$: Observable<File[]>;
|
||||
|
||||
public constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private uploadService: UploadService,
|
||||
private fileService: FileDataService
|
||||
) {
|
||||
public constructor() {
|
||||
this.activatedRoute.params
|
||||
.pipe(
|
||||
map(param => param as {songId: string}),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Input, inject} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {File} from '../../../../services/file';
|
||||
import {faTrashAlt} from '@fortawesome/free-solid-svg-icons';
|
||||
@@ -14,6 +14,8 @@ import {AsyncPipe} from '@angular/common';
|
||||
imports: [MatIconButton, FaIconComponent, AsyncPipe],
|
||||
})
|
||||
export class FileComponent {
|
||||
private fileService = inject(FileService);
|
||||
|
||||
public url$: Observable<string> | null = null;
|
||||
public name = '';
|
||||
public faTrash = faTrashAlt;
|
||||
@@ -21,8 +23,6 @@ export class FileComponent {
|
||||
private fileId: string | null = null;
|
||||
private path: string | null = null;
|
||||
|
||||
public constructor(private fileService: FileService) {}
|
||||
|
||||
@Input()
|
||||
public set file(file: File) {
|
||||
this.url$ = this.fileService.getDownloadUrl(file.path + '/' + file.name);
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
<app-card *ngIf="song" [heading]="song.number + ' bearbeiten'" closeLink="../">
|
||||
@if (song) {
|
||||
<app-card [heading]="song.number + ' bearbeiten'" closeLink="../">
|
||||
<form [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Titel</mat-label>
|
||||
<input formControlName="title" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
<div class="fourth">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Typ</mat-label>
|
||||
<mat-select formControlName="type">
|
||||
<mat-option *ngFor="let type of types" [value]="type">{{
|
||||
@for (type of types; track type) {
|
||||
<mat-option [value]="type">{{
|
||||
type | songType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Tonart</mat-label>
|
||||
<mat-select formControlName="key">
|
||||
<mat-option *ngFor="let key of keys" [value]="key">{{
|
||||
@for (key of keys; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | key
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
@@ -31,14 +35,15 @@
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Status</mat-label>
|
||||
<mat-select formControlName="status">
|
||||
<mat-option *ngFor="let status of status" [value]="status">{{
|
||||
@for (status of status; track status) {
|
||||
<mat-option [value]="status">{{
|
||||
status | status
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Songtext</mat-label>
|
||||
<textarea
|
||||
@@ -49,7 +54,8 @@
|
||||
matInput
|
||||
></textarea>
|
||||
</mat-form-field>
|
||||
<div *ngIf="songtextFocus" class="song-text-help">
|
||||
@if (songtextFocus) {
|
||||
<div class="song-text-help">
|
||||
<h3>Vorschau</h3>
|
||||
<app-song-text [text]="form.value.text" chordMode="show"></app-song-text>
|
||||
<h3>Hinweise zur Bearbeitung</h3>
|
||||
@@ -59,10 +65,8 @@
|
||||
<pre>
|
||||
Strophe
|
||||
Text der ersten Strophe
|
||||
|
||||
Strophe
|
||||
Text der zweiten Strophe
|
||||
|
||||
Refrain
|
||||
Und hier der Refrain
|
||||
</pre>
|
||||
@@ -87,7 +91,7 @@
|
||||
sed diam nonumy eirmod tempor invidunt ut labore et dolore
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
}
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Kommentar</mat-label>
|
||||
<textarea
|
||||
@@ -96,17 +100,17 @@
|
||||
matInput
|
||||
></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-chip-grid #chipList>
|
||||
@for (flag of flags; track flag) {
|
||||
<mat-chip-row
|
||||
(removed)="removeFlag(flag)"
|
||||
*ngFor="let flag of flags"
|
||||
[removable]="true"
|
||||
>
|
||||
{{ flag }}
|
||||
<fa-icon (click)="removeFlag(flag)" [icon]="faRemove"></fa-icon>
|
||||
</mat-chip-row>
|
||||
}
|
||||
<input
|
||||
(matChipInputTokenEnd)="addFlag($event)"
|
||||
[matChipInputAddOnBlur]="true"
|
||||
@@ -116,33 +120,34 @@
|
||||
/>
|
||||
</mat-chip-grid>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="half">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Rechtlicher Status</mat-label>
|
||||
<mat-select formControlName="legalType">
|
||||
<mat-option *ngFor="let key of legalType" [value]="key">{{
|
||||
@for (key of legalType; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | legalType
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Rechteinhaber</mat-label>
|
||||
<mat-select formControlName="legalOwner">
|
||||
<mat-option *ngFor="let key of legalOwner" [value]="key">{{
|
||||
@for (key of legalOwner; track key) {
|
||||
<mat-option [value]="key">{{
|
||||
key | legalOwner
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Rechteinhaber ID (z.B. CCLI Liednummer)</mat-label>
|
||||
<input formControlName="legalOwnerId" matInput />
|
||||
@if (form.value.legalOwner === 'CCLI') {
|
||||
<a
|
||||
*ngIf="form.value.legalOwner === 'CCLI'"
|
||||
class="link-ccli"
|
||||
href="https://songselect.ccli.com/Songs/{{ form.value.legalOwnerId }}"
|
||||
matSuffix
|
||||
@@ -154,31 +159,28 @@
|
||||
>
|
||||
<fa-icon [icon]="faLink"></fa-icon>
|
||||
</a>
|
||||
}
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Künstler</mat-label>
|
||||
<input formControlName="artist" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Verlag / Copyright</mat-label>
|
||||
<input formControlName="label" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Nutzungsbedingungen</mat-label>
|
||||
<input formControlName="termsOfUse" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>abweichende Quelle</mat-label>
|
||||
<input formControlName="origin" matInput />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<app-button-row>
|
||||
<app-button (click)="onSave()" [icon]="faSave">Speichern</app-button>
|
||||
</app-button-row>
|
||||
</app-card>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {Song} from '../../../services/song';
|
||||
import {ReactiveFormsModule, UntypedFormGroup} from '@angular/forms';
|
||||
import {ActivatedRoute, Router, RouterStateSnapshot} from '@angular/router';
|
||||
@@ -11,7 +11,7 @@ import {MatChipGrid, MatChipInput, MatChipInputEvent, MatChipRow} from '@angular
|
||||
import {faExternalLinkAlt, faSave, faTimesCircle} from '@fortawesome/free-solid-svg-icons';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import {SaveDialogComponent} from './save-dialog/save-dialog.component';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
|
||||
import {CardComponent} from '../../../../../widget-modules/components/card/card.component';
|
||||
import {MatFormField, MatLabel, MatSuffix} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
@@ -34,14 +34,12 @@ import {StatusPipe} from '../../../../../widget-modules/pipes/status-translater/
|
||||
templateUrl: './edit-song.component.html',
|
||||
styleUrls: ['./edit-song.component.less'],
|
||||
imports: [
|
||||
NgIf,
|
||||
CardComponent,
|
||||
ReactiveFormsModule,
|
||||
MatFormField,
|
||||
MatLabel,
|
||||
MatInput,
|
||||
MatSelect,
|
||||
NgFor,
|
||||
MatOption,
|
||||
CdkTextareaAutosize,
|
||||
SongTextComponent,
|
||||
@@ -61,6 +59,12 @@ import {StatusPipe} from '../../../../../widget-modules/pipes/status-translater/
|
||||
],
|
||||
})
|
||||
export class EditSongComponent implements OnInit {
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private songService = inject(SongService);
|
||||
private editService = inject(EditService);
|
||||
private router = inject(Router);
|
||||
public dialog = inject(MatDialog);
|
||||
|
||||
public song: Song | null = null;
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({});
|
||||
public keys = KEYS;
|
||||
@@ -75,14 +79,6 @@ export class EditSongComponent implements OnInit {
|
||||
public faLink = faExternalLinkAlt;
|
||||
public songtextFocus = false;
|
||||
|
||||
public constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private songService: SongService,
|
||||
private editService: EditService,
|
||||
private router: Router,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.activatedRoute.params
|
||||
.pipe(
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('SaveDialogComponent', () => {
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [SaveDialogComponent],
|
||||
imports: [SaveDialogComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<app-card *ngIf="song && song.edits" heading="letzte Änderungen">
|
||||
<div *ngFor="let edit of song.edits" class="list">
|
||||
@if (song && song.edits) {
|
||||
<app-card heading="letzte Änderungen">
|
||||
@for (edit of song.edits; track edit) {
|
||||
<div class="list">
|
||||
<div>{{ edit.username }}</div>
|
||||
<div>{{ edit.timestamp.toDate() | date: "dd.MM.yyyy" }}</div>
|
||||
</div>
|
||||
}
|
||||
</app-card>
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {first, map, switchMap} from 'rxjs/operators';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {SongService} from '../../../services/song.service';
|
||||
import {Song} from '../../../services/song';
|
||||
import {DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {DatePipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../../../widget-modules/components/card/card.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-history',
|
||||
templateUrl: './history.component.html',
|
||||
styleUrls: ['./history.component.less'],
|
||||
imports: [NgIf, CardComponent, NgFor, DatePipe],
|
||||
imports: [CardComponent, DatePipe],
|
||||
})
|
||||
export class HistoryComponent implements OnInit {
|
||||
public song: Song | null = null;
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private songService = inject(SongService);
|
||||
|
||||
public constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private songService: SongService
|
||||
) {}
|
||||
public song: Song | null = null;
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.activatedRoute.params
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
import {Storage} from '@angular/fire/storage';
|
||||
|
||||
import {FileComponent} from './file.component';
|
||||
|
||||
@@ -9,6 +10,7 @@ describe('FileComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
imports: [FileComponent],
|
||||
providers: [{provide: Storage, useValue: {}}],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, EnvironmentInjector, Input, inject, runInInjectionContext} from '@angular/core';
|
||||
import {File} from '../../services/file';
|
||||
import {AngularFireStorage} from '@angular/fire/compat/storage';
|
||||
import {Observable} from 'rxjs';
|
||||
import {getDownloadURL, ref, Storage} from '@angular/fire/storage';
|
||||
import {from, Observable} from 'rxjs';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
@@ -11,15 +11,15 @@ import {AsyncPipe} from '@angular/common';
|
||||
imports: [AsyncPipe],
|
||||
})
|
||||
export class FileComponent {
|
||||
private storage = inject(Storage);
|
||||
private environmentInjector = inject(EnvironmentInjector);
|
||||
|
||||
public url$: Observable<string> | null = null;
|
||||
public name = '';
|
||||
|
||||
public constructor(private storage: AngularFireStorage) {}
|
||||
|
||||
@Input()
|
||||
public set file(file: File) {
|
||||
const ref = this.storage.ref(file.path + '/' + file.name);
|
||||
this.url$ = ref.getDownloadURL() as Observable<string>;
|
||||
this.url$ = from(runInInjectionContext(this.environmentInjector, () => getDownloadURL(ref(this.storage, file.path + '/' + file.name))));
|
||||
this.name = file.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Component, OnDestroy, OnInit, inject} from '@angular/core';
|
||||
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
||||
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {SongService} from '../../services/song.service';
|
||||
import {Song} from '../../services/song';
|
||||
import {Router} from '@angular/router';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {take} from 'rxjs/operators';
|
||||
import {CardComponent} from '../../../../widget-modules/components/card/card.component';
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
@@ -18,6 +19,9 @@ import {ButtonComponent} from '../../../../widget-modules/components/button/butt
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent],
|
||||
})
|
||||
export class NewComponent implements OnInit, OnDestroy {
|
||||
private songService = inject(SongService);
|
||||
private router = inject(Router);
|
||||
|
||||
public faSave = faSave;
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({
|
||||
number: new UntypedFormControl(null, Validators.required),
|
||||
@@ -25,16 +29,14 @@ export class NewComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
private subs: Subscription[] = [];
|
||||
|
||||
public constructor(
|
||||
private songService: SongService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset();
|
||||
|
||||
this.subs.push(
|
||||
this.songService.list$().subscribe(songs => {
|
||||
this.songService
|
||||
.list$()
|
||||
.pipe(take(1))
|
||||
.subscribe(songs => {
|
||||
const freeSongnumber = this.getFreeSongNumber(songs);
|
||||
this.form.controls.number.setValue(freeSongnumber);
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="split">
|
||||
@if (song$ | async; as song) {
|
||||
<app-card
|
||||
*ngIf="song$ | async as song"
|
||||
[heading]="song.number + ' - ' + song.title"
|
||||
closeLink="../"
|
||||
>
|
||||
@@ -11,10 +11,13 @@
|
||||
<div>Tonart: {{ song.key }}</div>
|
||||
<div>Tempo: {{ song.tempo }}</div>
|
||||
<div>Status: {{ (song.status | status) || "entwurf" }}</div>
|
||||
<div *ngIf="song.legalOwner">
|
||||
@if (song.legalOwner) {
|
||||
<div>
|
||||
Rechteinhaber: {{ song.legalOwner | legalOwner }}
|
||||
</div>
|
||||
<div *ngIf="song.legalOwnerId && song.legalOwner === 'CCLI'">
|
||||
}
|
||||
@if (song.legalOwnerId && song.legalOwner === 'CCLI') {
|
||||
<div>
|
||||
<a
|
||||
href="https://songselect.ccli.com/Songs/{{ song.legalOwnerId }}"
|
||||
target="_blank"
|
||||
@@ -22,38 +25,46 @@
|
||||
CCLI Nummer: {{ song.legalOwnerId }}
|
||||
</a>
|
||||
</div>
|
||||
<div *ngIf="song.legalOwnerId && song.legalOwner !== 'CCLI'">
|
||||
}
|
||||
@if (song.legalOwnerId && song.legalOwner !== 'CCLI') {
|
||||
<div>
|
||||
Rechteinhaber ID: {{ song.legalOwnerId }}
|
||||
</div>
|
||||
<div *ngIf="song.artist">Künstler: {{ song.artist }}</div>
|
||||
<div *ngIf="song.label">Verlag: {{ song.label }}</div>
|
||||
<div *ngIf="song.origin">Quelle: {{ song.origin }}</div>
|
||||
}
|
||||
@if (song.artist) {
|
||||
<div>Künstler: {{ song.artist }}</div>
|
||||
}
|
||||
@if (song.label) {
|
||||
<div>Verlag: {{ song.label }}</div>
|
||||
}
|
||||
@if (song.origin) {
|
||||
<div>Quelle: {{ song.origin }}</div>
|
||||
}
|
||||
<div>Wie oft verwendet: {{ songCount$ | async }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (user$ | async; as user) {
|
||||
<app-song-text
|
||||
*ngIf="user$ | async as user"
|
||||
[chordMode]="user.chordMode"
|
||||
[showSwitch]="true"
|
||||
[text]="song.text"
|
||||
></app-song-text>
|
||||
|
||||
}
|
||||
<mat-chip-listbox
|
||||
*appRole="['leader', 'contributor']"
|
||||
aria-label="Attribute"
|
||||
>
|
||||
<mat-chip-option *ngFor="let flag of getFlags(song.flags)">{{
|
||||
@for (flag of getFlags(song.flags); track flag) {
|
||||
<mat-chip-option>{{
|
||||
flag
|
||||
}}
|
||||
</mat-chip-option>
|
||||
}
|
||||
</mat-chip-listbox>
|
||||
|
||||
<div *appRole="['leader', 'contributor']" class="text">
|
||||
{{ song.comment }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-button-row>
|
||||
<app-button
|
||||
(click)="onDelete(song.id)"
|
||||
@@ -69,18 +80,25 @@
|
||||
Zu Veranstaltung hinzufügen
|
||||
</app-button>
|
||||
<mat-menu #menu="matMenu">
|
||||
<app-button (click)="addSongToShow(show, song)" *ngFor="let show of privateShows$|async">
|
||||
@for (show of privateShows$|async; track show) {
|
||||
<app-button (click)="addSongToShow(show, song)">
|
||||
{{ show.date.toDate() | date: "dd.MM.yyyy" }} {{ show.showType | showType }}
|
||||
</app-button>
|
||||
}
|
||||
</mat-menu>
|
||||
</ng-container>
|
||||
</app-button-row>
|
||||
</app-card>
|
||||
<ng-container *ngIf="files$ | async as files">
|
||||
<app-card *ngIf="files.length > 0" heading="Anhänge">
|
||||
<p *ngFor="let file of files$ | async">
|
||||
}
|
||||
@if (files$ | async; as files) {
|
||||
@if (files.length > 0) {
|
||||
<app-card heading="Anhänge">
|
||||
@for (file of files$ | async; track file) {
|
||||
<p>
|
||||
<app-file [file]="file"></app-file>
|
||||
</p>
|
||||
}
|
||||
</app-card>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ActivatedRoute, Router, RouterLink} from '@angular/router';
|
||||
import {SongService} from '../services/song.service';
|
||||
import {distinctUntilChanged, map, switchMap} from 'rxjs/operators';
|
||||
@@ -12,7 +12,7 @@ import {faEdit, faFileCirclePlus, faTrash} from '@fortawesome/free-solid-svg-ico
|
||||
import {ShowService} from '../../shows/services/show.service';
|
||||
import {Show} from '../../shows/services/show';
|
||||
import {ShowSongService} from '../../shows/services/show-song.service';
|
||||
import {AsyncPipe, DatePipe, NgFor, NgIf} from '@angular/common';
|
||||
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {RoleDirective} from '../../../services/user/role.directive';
|
||||
import {SongTextComponent} from '../../../widget-modules/components/song-text/song-text.component';
|
||||
@@ -31,12 +31,10 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
templateUrl: './song.component.html',
|
||||
styleUrls: ['./song.component.less'],
|
||||
imports: [
|
||||
NgIf,
|
||||
CardComponent,
|
||||
RoleDirective,
|
||||
SongTextComponent,
|
||||
MatChipListbox,
|
||||
NgFor,
|
||||
MatChipOption,
|
||||
ButtonRowComponent,
|
||||
ButtonComponent,
|
||||
@@ -53,6 +51,14 @@ import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/s
|
||||
],
|
||||
})
|
||||
export class SongComponent implements OnInit {
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private songService = inject(SongService);
|
||||
private fileService = inject(FileDataService);
|
||||
private userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
private showService = inject(ShowService);
|
||||
private showSongService = inject(ShowSongService);
|
||||
|
||||
public song$: Observable<Song | null> | null = null;
|
||||
public files$: Observable<File[] | null> | null = null;
|
||||
public user$: Observable<User | null> | null = null;
|
||||
@@ -62,15 +68,9 @@ export class SongComponent implements OnInit {
|
||||
public faFileCirclePlus = faFileCirclePlus;
|
||||
public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published).sort((a, b) => b.date.toMillis() - a.date.toMillis())));
|
||||
|
||||
public constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private songService: SongService,
|
||||
private fileService: FileDataService,
|
||||
private userService: UserService,
|
||||
private router: Router,
|
||||
private showService: ShowService,
|
||||
private showSongService: ShowSongService
|
||||
) {
|
||||
public constructor() {
|
||||
const userService = this.userService;
|
||||
|
||||
this.user$ = userService.user$;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<app-card *ngIf="user$ | async as user" heading="Hallo {{ user.name }}">
|
||||
@if (user$ | async; as user) {
|
||||
<app-card heading="Hallo {{ user.name }}">
|
||||
<p>
|
||||
<span *ngIf="getUserRoles(user.role).length === 0" class="warn"
|
||||
@if (getUserRoles(user.role).length === 0) {
|
||||
<span class="warn"
|
||||
>Es wurden noch keine Berechtigungen zugeteilt, bitte wende Dich an den
|
||||
Administrator!</span
|
||||
>
|
||||
}
|
||||
<span>{{ transdormUserRoles(user.role) }}</span>
|
||||
</p>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>bevorzugte Anzeige der Akkorde</mat-label>
|
||||
<mat-select
|
||||
@@ -25,10 +27,10 @@
|
||||
werden.
|
||||
</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
<app-button [icon]="faSignOut" routerLink="../logout">Abmelden</app-button>
|
||||
</app-button-row>
|
||||
</app-card>
|
||||
}
|
||||
|
||||
<app-users *appRole="['admin']"></app-users>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../../services/user/user';
|
||||
@@ -6,7 +6,7 @@ import {ChordMode} from '../../../widget-modules/components/song-text/song-text.
|
||||
import {faSignOutAlt} from '@fortawesome/free-solid-svg-icons';
|
||||
import {RolePipe} from './role.pipe';
|
||||
import {roles} from '../../../services/user/roles';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {CardComponent} from '../../../widget-modules/components/card/card.component';
|
||||
import {MatFormField, MatHint, MatLabel} from '@angular/material/form-field';
|
||||
import {MatSelect} from '@angular/material/select';
|
||||
@@ -23,7 +23,6 @@ import {UsersComponent} from './users/users.component';
|
||||
templateUrl: './info.component.html',
|
||||
styleUrls: ['./info.component.less'],
|
||||
imports: [
|
||||
NgIf,
|
||||
CardComponent,
|
||||
MatFormField,
|
||||
MatLabel,
|
||||
@@ -41,11 +40,11 @@ import {UsersComponent} from './users/users.component';
|
||||
],
|
||||
})
|
||||
export class InfoComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public user$: Observable<User | null> | null = null;
|
||||
public faSignOut = faSignOutAlt;
|
||||
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.user$ = this.userService.user$;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<div *ngIf="edit" class="users">
|
||||
@if (edit) {
|
||||
<div class="users">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Name</mat-label>
|
||||
<input (change)="onNameChanged(id, $event)" [ngModel]="name" matInput />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Rolle</mat-label>
|
||||
<mat-select
|
||||
@@ -11,21 +11,27 @@
|
||||
[ngModel]="roles"
|
||||
multiple
|
||||
>
|
||||
<mat-option *ngFor="let role of ROLE_TYPES" [value]="role">{{
|
||||
@for (role of ROLE_TYPES; track role) {
|
||||
<mat-option [value]="role">{{
|
||||
role | role
|
||||
}}
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<button (click)="edit = false" mat-icon-button>
|
||||
<fa-icon [icon]="faClose"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div (click)="edit = true" *ngIf="!edit" class="users list-item">
|
||||
@if (!edit) {
|
||||
<div (click)="edit = true" class="users list-item">
|
||||
<span>{{ name }}</span>
|
||||
<span
|
||||
><span *ngFor="let role of roles">{{ role | role }}, </span></span
|
||||
>@for (role of roles; track role) {
|
||||
<span>{{ role | role }}, </span>
|
||||
}</span
|
||||
>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Input, inject} from '@angular/core';
|
||||
import {User} from '../../../../../services/user/user';
|
||||
import {UserService} from '../../../../../services/user/user.service';
|
||||
import {ROLE_TYPES} from '../../../../../services/user/roles';
|
||||
import {faTimes} from '@fortawesome/free-solid-svg-icons';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
@@ -17,9 +17,11 @@ import {RolePipe} from '../../role.pipe';
|
||||
selector: 'app-user',
|
||||
templateUrl: './user.component.html',
|
||||
styleUrls: ['./user.component.less'],
|
||||
imports: [NgIf, MatFormField, MatLabel, MatInput, ReactiveFormsModule, FormsModule, MatSelect, NgFor, MatOption, MatIconButton, FaIconComponent, RolePipe],
|
||||
imports: [MatFormField, MatLabel, MatInput, ReactiveFormsModule, FormsModule, MatSelect, MatOption, MatIconButton, FaIconComponent, RolePipe],
|
||||
})
|
||||
export class UserComponent {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public id = '';
|
||||
public name = '';
|
||||
public roles: string[] = [];
|
||||
@@ -27,8 +29,6 @@ export class UserComponent {
|
||||
public edit = false;
|
||||
public faClose = faTimes;
|
||||
|
||||
public constructor(private userService: UserService) {}
|
||||
|
||||
@Input()
|
||||
public set user(value: User) {
|
||||
this.id = value.id;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<app-card heading="registrierte Benutzer">
|
||||
<app-user *ngFor="let user of users$ | async | sortBy: 'asc':'name'" [user]="user"></app-user>
|
||||
@for (user of users$ | async | sortBy: 'asc':'name'; track user) {
|
||||
<app-user [user]="user"></app-user>
|
||||
}
|
||||
</app-card>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {UserService} from '../../../../services/user/user.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../../../services/user/user';
|
||||
import {CardComponent} from '../../../../widget-modules/components/card/card.component';
|
||||
import {AsyncPipe, NgFor} from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {UserComponent} from './user/user.component';
|
||||
import {SortByPipe} from '../../../../widget-modules/pipes/sort-by/sort-by.pipe';
|
||||
|
||||
@@ -11,12 +11,16 @@ import {SortByPipe} from '../../../../widget-modules/pipes/sort-by/sort-by.pipe'
|
||||
selector: 'app-users',
|
||||
templateUrl: './users.component.html',
|
||||
styleUrls: ['./users.component.less'],
|
||||
imports: [CardComponent, NgFor, UserComponent, AsyncPipe, SortByPipe],
|
||||
imports: [CardComponent, UserComponent, AsyncPipe, SortByPipe],
|
||||
})
|
||||
export class UsersComponent {
|
||||
private userService = inject(UserService);
|
||||
|
||||
public users$: Observable<User[]>;
|
||||
|
||||
public constructor(private userService: UserService) {
|
||||
public constructor() {
|
||||
const userService = this.userService;
|
||||
|
||||
this.users$ = userService.list$();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
type="password"
|
||||
/>
|
||||
</mat-form-field>
|
||||
<p *ngIf="errorMessage" class="error">{{ errorMessage | authMessage }}</p>
|
||||
@if (errorMessage) {
|
||||
<p class="error">{{ errorMessage | authMessage }}</p>
|
||||
}
|
||||
<button
|
||||
(click)="onLogin()"
|
||||
class="btn-login"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {Router, RouterLink} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
@@ -6,7 +6,7 @@ import {faSignInAlt, faUserPlus} from '@fortawesome/free-solid-svg-icons';
|
||||
import {LogoComponent} from '../../../widget-modules/components/logo/logo.component';
|
||||
import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {MatButton} from '@angular/material/button';
|
||||
import {AuthMessagePipe} from './auth-message.pipe';
|
||||
|
||||
@@ -14,9 +14,12 @@ import {AuthMessagePipe} from './auth-message.pipe';
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.less'],
|
||||
imports: [LogoComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, NgIf, MatButton, RouterLink, AuthMessagePipe],
|
||||
imports: [LogoComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, MatButton, RouterLink, AuthMessagePipe],
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({
|
||||
user: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
pass: new UntypedFormControl(null, [Validators.required]),
|
||||
@@ -25,13 +28,8 @@ export class LoginComponent implements OnInit {
|
||||
public faSignIn = faSignInAlt;
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
public constructor(
|
||||
private userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset;
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
public async onLogin(): Promise<void> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AfterViewInit, Component} from '@angular/core';
|
||||
import {AfterViewInit, Component, inject} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
|
||||
@@ -8,13 +8,13 @@ import {UserService} from '../../../services/user/user.service';
|
||||
styleUrls: ['./logout.component.less'],
|
||||
})
|
||||
export class LogoutComponent implements AfterViewInit {
|
||||
public constructor(
|
||||
private userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
private userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public async ngAfterViewInit(): Promise<void> {
|
||||
public ngAfterViewInit(): void {
|
||||
void (async () => {
|
||||
await this.userService.logout();
|
||||
await this.router.navigateByUrl('/');
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {faUserPlus} from '@fortawesome/free-solid-svg-icons';
|
||||
@@ -15,6 +15,9 @@ import {ButtonComponent} from '../../../widget-modules/components/button/button.
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent],
|
||||
})
|
||||
export class NewComponent implements OnInit {
|
||||
private fb = inject(UntypedFormBuilder);
|
||||
private userService = inject(UserService);
|
||||
|
||||
public form: UntypedFormGroup = this.fb.group({
|
||||
email: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
name: new UntypedFormControl(null, [Validators.required]),
|
||||
@@ -22,11 +25,6 @@ export class NewComponent implements OnInit {
|
||||
});
|
||||
public faNewUser = faUserPlus;
|
||||
|
||||
public constructor(
|
||||
private fb: UntypedFormBuilder,
|
||||
private userService: UserService
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
<app-button (click)="onResetPassword()" [icon]="faNewPassword"
|
||||
>neues Passwort anfordern
|
||||
</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{ errorMessage | authMessage }}</p>
|
||||
@if (errorMessage) {
|
||||
<p class="error">{{ errorMessage | authMessage }}</p>
|
||||
}
|
||||
</app-button-row>
|
||||
</div>
|
||||
</app-card>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, OnInit, inject} from '@angular/core';
|
||||
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
@@ -8,16 +8,19 @@ import {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {ButtonRowComponent} from '../../../widget-modules/components/button-row/button-row.component';
|
||||
import {ButtonComponent} from '../../../widget-modules/components/button/button.component';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {AuthMessagePipe} from '../login/auth-message.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
styleUrls: ['./password.component.less'],
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent, NgIf, AuthMessagePipe],
|
||||
imports: [CardComponent, ReactiveFormsModule, MatFormField, MatLabel, MatInput, ButtonRowComponent, ButtonComponent, AuthMessagePipe],
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
public userService = inject(UserService);
|
||||
private router = inject(Router);
|
||||
|
||||
public form: UntypedFormGroup = new UntypedFormGroup({
|
||||
user: new UntypedFormControl(null, [Validators.required, Validators.email]),
|
||||
});
|
||||
@@ -25,11 +28,6 @@ export class PasswordComponent implements OnInit {
|
||||
public errorMessage = '';
|
||||
public faNewPassword = faWindowRestore;
|
||||
|
||||
public constructor(
|
||||
public userService: UserService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ import {RouterModule, Routes} from '@angular/router';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {InfoComponent} from './info/info.component';
|
||||
import {LogoutComponent} from './logout/logout.component';
|
||||
import {AngularFireAuthGuard, redirectUnauthorizedTo} from '@angular/fire/compat/auth-guard';
|
||||
import {PasswordComponent} from './password/password.component';
|
||||
import {PasswordSendComponent} from './password-send/password-send.component';
|
||||
import {NewComponent} from './new/new.component';
|
||||
import {AuthGuard} from '../../widget-modules/guards/auth.guard';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -37,8 +37,7 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'info',
|
||||
component: InfoComponent,
|
||||
canActivate: [AngularFireAuthGuard],
|
||||
data: {authGuardPipe: () => redirectUnauthorizedTo(['user', 'login'])},
|
||||
canActivate: [AuthGuard],
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user