Compare commits
53 Commits
song-usage
...
db6a230696
| Author | SHA1 | Date | |
|---|---|---|---|
| db6a230696 | |||
| 0d0873730a | |||
| bb08e46b0c | |||
| 26c99a0dae | |||
| 0203d4ea9d | |||
| b6c2fe1645 | |||
| a569c070c5 | |||
| f7be5c082a | |||
| a46eeeee04 | |||
| 6edfb7e297 | |||
| 36e1241539 | |||
| 194f9ac556 | |||
| ce9e5b5585 | |||
| 3e10762eaf | |||
| d81fb3743b | |||
| 4141824b00 | |||
| f7e11b792c | |||
| a12e1ccb2f | |||
| 4e8a50374e | |||
| 0c2157bd0a | |||
| 0b831e45d5 | |||
| 3fb2e8b341 | |||
| ed69d9e972 | |||
| f49404f8be | |||
| 83573fde31 | |||
| 2d38af1c27 | |||
| 26fd61e90a | |||
| 189478f078 | |||
| 54ee9a5b11 | |||
| 8b8395fc3c | |||
| 597e89ffb3 | |||
| e3fa1678c2 | |||
| 88a574aa80 | |||
| 898c6c4d7e | |||
| 802c309679 | |||
| 73d3ecfd42 | |||
| 3ff7c8c17e | |||
| 2f523c5092 | |||
| 669bd0d852 | |||
| 3d31594dbc | |||
| 107fc41c4f | |||
| 9025d2c8a5 | |||
| 4aeb452434 | |||
| 150e20ccfb | |||
| 9cd565acb8 | |||
| 5cb7b12508 | |||
| a364536127 | |||
| 8a9e2d58c5 | |||
| 45677eb1c3 | |||
| 28b669fc2d | |||
| 2f5a732ffc | |||
| d71bd41495 | |||
| c19e115b43 |
@@ -1,12 +1,7 @@
|
|||||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
# Angular 21-supported baseline to avoid unsupported-browser build warnings.
|
||||||
# For additional information regarding the format and rule options, please see:
|
last 2 Chrome major versions
|
||||||
# https://github.com/browserslist/browserslist#queries
|
last 2 Edge major versions
|
||||||
|
last 2 Firefox major versions
|
||||||
# You can see what browsers were selected by your queries by running:
|
|
||||||
# npx browserslist
|
|
||||||
|
|
||||||
> 0.5%
|
|
||||||
last 2 versions
|
|
||||||
Firefox ESR
|
Firefox ESR
|
||||||
not dead
|
last 2 Safari major versions
|
||||||
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
last 2 iOS major versions
|
||||||
|
|||||||
12
.run/build.run.xml
Normal file
12
.run/build.run.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
|
||||||
|
<package-json value="$PROJECT_DIR$/package.json"/>
|
||||||
|
<command value="run"/>
|
||||||
|
<scripts>
|
||||||
|
<script value="build"/>
|
||||||
|
</scripts>
|
||||||
|
<node-interpreter value="project"/>
|
||||||
|
<envs/>
|
||||||
|
<method v="2"/>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
12
.run/deploy.run.xml
Normal file
12
.run/deploy.run.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="deploy" type="js.build_tools.npm" nameIsGenerated="true">
|
||||||
|
<package-json value="$PROJECT_DIR$/package.json"/>
|
||||||
|
<command value="run"/>
|
||||||
|
<scripts>
|
||||||
|
<script value="deploy"/>
|
||||||
|
</scripts>
|
||||||
|
<node-interpreter value="project"/>
|
||||||
|
<envs/>
|
||||||
|
<method v="2"/>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="start" type="js.build_tools.npm" nameIsGenerated="true">
|
<configuration default="false" name="start" type="js.build_tools.npm" nameIsGenerated="true">
|
||||||
<package-json value="$PROJECT_DIR$/package.json"/>
|
<package-json value="$PROJECT_DIR$/package.json" />
|
||||||
<command value="run"/>
|
<command value="run" />
|
||||||
<scripts>
|
<scripts>
|
||||||
<script value="start"/>
|
<script value="start" />
|
||||||
</scripts>
|
</scripts>
|
||||||
<node-interpreter value="project"/>
|
<node-interpreter value="project" />
|
||||||
<envs/>
|
<envs />
|
||||||
<method v="2"/>
|
<EXTENSION ID="com.intellij.lang.javascript.buildTools.npm.rc.StartBrowserRunConfigurationExtension">
|
||||||
|
<browser name="98ca6316-2f89-46d9-a9e5-fa9e2b0625b3" start="true" with-js-debugger="true" url="http://localhost.4200" />
|
||||||
|
</EXTENSION>
|
||||||
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -1 +1,19 @@
|
|||||||
# wgenerator
|
# wgenerator
|
||||||
|
|
||||||
|
## Admin migration
|
||||||
|
|
||||||
|
If `songUsage` needs to be rebuilt from all existing shows, log in with a user that has the `admin` role and run this in the browser console:
|
||||||
|
|
||||||
|
```js
|
||||||
|
await window.wgeneratorAdmin.rebuildSongUsage()
|
||||||
|
```
|
||||||
|
|
||||||
|
The migration:
|
||||||
|
|
||||||
|
- resets `songUsage` for all users
|
||||||
|
- scans all shows and all `shows/{id}/songs` entries
|
||||||
|
- rebuilds the per-user counters based on show ownership
|
||||||
|
|
||||||
|
It returns a summary object with processed user, show and show-song counts.
|
||||||
|
|
||||||
|
This is intended as a manual one-off migration and is read-heavy by design.
|
||||||
|
|||||||
63
angular.json
63
angular.json
@@ -15,12 +15,15 @@
|
|||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:application",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/wgenerator",
|
"outputPath": {
|
||||||
|
"base": "dist/wgenerator"
|
||||||
|
},
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"polyfills": [
|
||||||
"polyfills": "src/polyfills.ts",
|
"src/polyfills.ts"
|
||||||
|
],
|
||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
"aot": false,
|
"aot": false,
|
||||||
"assets": [
|
"assets": [
|
||||||
@@ -42,15 +45,16 @@
|
|||||||
"src/styles/shadow.less"
|
"src/styles/shadow.less"
|
||||||
],
|
],
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
"vendorChunk": true,
|
|
||||||
"extractLicenses": false,
|
"extractLicenses": false,
|
||||||
"buildOptimizer": false,
|
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"optimization": false,
|
"optimization": false,
|
||||||
"namedChunks": true,
|
"namedChunks": true,
|
||||||
"allowedCommonJsDependencies": [
|
"allowedCommonJsDependencies": [
|
||||||
"lodash", "docx"
|
"lodash",
|
||||||
]
|
"docx",
|
||||||
|
"qrcode"
|
||||||
|
],
|
||||||
|
"browser": "src/main.ts"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
@@ -66,8 +70,6 @@
|
|||||||
"namedChunks": false,
|
"namedChunks": false,
|
||||||
"aot": true,
|
"aot": true,
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
"vendorChunk": false,
|
|
||||||
"buildOptimizer": true,
|
|
||||||
"budgets": [
|
"budgets": [
|
||||||
{
|
{
|
||||||
"type": "initial",
|
"type": "initial",
|
||||||
@@ -80,26 +82,25 @@
|
|||||||
"maximumError": "10kb"
|
"maximumError": "10kb"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"serviceWorker": true,
|
"serviceWorker": "ngsw-config.json"
|
||||||
"ngswConfigPath": "ngsw-config.json"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"serve": {
|
"serve": {
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "wgenerator:build"
|
"buildTarget": "wgenerator:build"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"browserTarget": "wgenerator:build:production"
|
"buildTarget": "wgenerator:build:production"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extract-i18n": {
|
"extract-i18n": {
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "wgenerator:build"
|
"buildTarget": "wgenerator:build"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
@@ -147,5 +148,37 @@
|
|||||||
"schematicCollections": [
|
"schematicCollections": [
|
||||||
"@angular-eslint/schematics"
|
"@angular-eslint/schematics"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"schematics": {
|
||||||
|
"@angular-eslint/schematics:application": {
|
||||||
|
"setParserOptionsProject": true
|
||||||
|
},
|
||||||
|
"@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"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"indexes": "firestore.indexes.json"
|
"indexes": "firestore.indexes.json"
|
||||||
},
|
},
|
||||||
"hosting": {
|
"hosting": {
|
||||||
"public": "dist/wgenerator",
|
"public": "dist/wgenerator/browser",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"firebase.json",
|
"firebase.json",
|
||||||
"**/.*",
|
"**/.*",
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ service cloud.firestore {
|
|||||||
allow read: if request.auth.uid != null;
|
allow read: if request.auth.uid != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match /guest/{guestId} {
|
||||||
|
allow read: if true;
|
||||||
|
allow write: if request.auth.uid != null;
|
||||||
|
}
|
||||||
match /songs/{song} {
|
match /songs/{song} {
|
||||||
allow read: if request.auth.uid != null;
|
allow read: if request.auth.uid != null;
|
||||||
allow write: if request.auth.uid != null;
|
allow write: if request.auth.uid != null;
|
||||||
|
|||||||
60244
package-lock.json
generated
60244
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
106
package.json
106
package.json
@@ -1,75 +1,67 @@
|
|||||||
{
|
{
|
||||||
"name": "wgenerator",
|
"name": "wgenerator",
|
||||||
"version": "1.3",
|
"version": "1.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"deploy": "ng build --configuration production && firebase deploy",
|
"deploy": "ng build --configuration production && firebase deploy",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint --fix",
|
"lint": "ng lint --fix",
|
||||||
"postinstall": "ngcc"
|
"update": "ng update @angular/cdk @angular/cli @angular/core @angular/material && ncu -u && npm i && npm fix"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^14.2.10",
|
"@angular/animations": "^21.2.2",
|
||||||
"@angular/cdk": "^14.2.6",
|
"@angular/cdk": "^21.2.1",
|
||||||
"@angular/common": "^14.2.10",
|
"@angular/common": "^21.2.2",
|
||||||
"@angular/compiler": "^14.2.10",
|
"@angular/compiler": "^21.2.2",
|
||||||
"@angular/core": "^14.2.10",
|
"@angular/core": "^21.2.2",
|
||||||
"@angular/fire": "^7.4.1",
|
"@angular/fire": "21.0.0-rc.0",
|
||||||
"@angular/forms": "^14.2.10",
|
"@angular/forms": "^21.2.2",
|
||||||
"@angular/material": "^14.2.6",
|
"@angular/material": "^21.2.1",
|
||||||
"@angular/platform-browser": "^14.2.10",
|
"@angular/platform-browser": "^21.2.2",
|
||||||
"@angular/platform-browser-dynamic": "^14.2.10",
|
"@angular/platform-browser-dynamic": "^21.2.2",
|
||||||
"@angular/router": "^14.2.10",
|
"@angular/router": "^21.2.2",
|
||||||
"@angular/service-worker": "^14.2.10",
|
"@angular/service-worker": "^21.2.2",
|
||||||
"@fortawesome/angular-fontawesome": "^0.11.1",
|
"@fortawesome/angular-fontawesome": "^4.0.0",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.1.2",
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.1.2",
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
||||||
"docx": "^7.4.1",
|
"docx": "^9.6.0",
|
||||||
"firebase": "^9.6.10",
|
"firebase": "^12.10.0",
|
||||||
"lodash": "^4.17.21",
|
"ngx-mat-select-search": "^8.0.4",
|
||||||
"ngx-mat-select-search": "^4.2.1",
|
"qrcode": "^1.5.4",
|
||||||
"ngx-perfect-scrollbar": "^10.1.1",
|
"rxjs": "~7.8.1",
|
||||||
"rxfire": "^6.0.3",
|
"swiper": "^12.1.2",
|
||||||
"rxjs": "~7.5.6",
|
"tslib": "^2.8.1",
|
||||||
"swiper": "^9.3.2",
|
"zone.js": "~0.15.0"
|
||||||
"tslib": "^2.4.0",
|
|
||||||
"uuid": "^8.3.2",
|
|
||||||
"zone.js": "~0.11.8"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/architect": "0.1402.9",
|
"@angular-devkit/architect": "0.2102.1",
|
||||||
"@angular-devkit/build-angular": "^14.2.9",
|
"@angular-devkit/build-angular": "^21.2.1",
|
||||||
"@angular-eslint/builder": "14.1.2",
|
"@angular-eslint/builder": "21.3.0",
|
||||||
"@angular-eslint/eslint-plugin": "14.1.2",
|
"@angular-eslint/eslint-plugin": "21.3.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "14.1.2",
|
"@angular-eslint/eslint-plugin-template": "21.3.0",
|
||||||
"@angular-eslint/schematics": "14.1.2",
|
"@angular-eslint/schematics": "21.3.0",
|
||||||
"@angular-eslint/template-parser": "14.1.2",
|
"@angular-eslint/template-parser": "21.3.0",
|
||||||
"@angular/cli": "^14.2.9",
|
"@angular/cli": "^21.2.1",
|
||||||
"@angular/compiler-cli": "^14.2.10",
|
"@angular/compiler-cli": "^21.2.2",
|
||||||
"@angular/language-service": "^14.2.10",
|
"@angular/language-service": "^21.2.2",
|
||||||
"@types/jasmine": "~4.0.3",
|
"@types/jasmine": "~6.0.0",
|
||||||
"@types/jasminewd2": "~2.0.10",
|
"@types/jasminewd2": "~2.0.13",
|
||||||
"@types/lodash": "^4.14.182",
|
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
"@typescript-eslint/parser": "^8.57.0",
|
||||||
"@typescript-eslint/parser": "^5.33.0",
|
"eslint": "^9.39.4",
|
||||||
"eslint": "^8.22.0",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"firebase-tools": "^15.9.1",
|
||||||
"firebase-tools": "^11.6.0",
|
"jasmine-core": "~6.1.0",
|
||||||
"fuzzy": "^0.1.3",
|
|
||||||
"inquirer": "^9.1.0",
|
|
||||||
"inquirer-autocomplete-prompt": "^2.0.0",
|
|
||||||
"jasmine-core": "~4.3.0",
|
|
||||||
"jasmine-spec-reporter": "~7.0.0",
|
"jasmine-spec-reporter": "~7.0.0",
|
||||||
"karma": "~6.4.0",
|
"karma": "~6.4.4",
|
||||||
"karma-chrome-launcher": "~3.1.1",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
"karma-coverage-istanbul-reporter": "~3.0.3",
|
"karma-coverage-istanbul-reporter": "~3.0.3",
|
||||||
"karma-jasmine": "~5.1.0",
|
"karma-jasmine": "~5.1.0",
|
||||||
"karma-jasmine-html-reporter": "^2.0.0",
|
"karma-jasmine-html-reporter": "^2.2.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^3.8.1",
|
||||||
"protractor": "~7.0.0",
|
"typescript": "~5.9.3"
|
||||||
"typescript": "~4.7.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';
|
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 {RoleGuard} from './widget-modules/guards/role.guard';
|
||||||
|
import {AuthGuard} from './widget-modules/guards/auth.guard';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -12,27 +12,24 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'songs',
|
path: 'songs',
|
||||||
loadChildren: () => import('./modules/songs/songs.module').then(m => m.SongsModule),
|
loadChildren: () => import('./modules/songs/songs.module').then(m => m.SongsModule),
|
||||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
canActivate: [AuthGuard, RoleGuard],
|
||||||
data: {
|
data: {
|
||||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
|
||||||
requiredRoles: ['user'],
|
requiredRoles: ['user'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'shows',
|
path: 'shows',
|
||||||
loadChildren: () => import('./modules/shows/shows.module').then(m => m.ShowsModule),
|
loadChildren: () => import('./modules/shows/shows.module').then(m => m.ShowsModule),
|
||||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
canActivate: [AuthGuard, RoleGuard],
|
||||||
data: {
|
data: {
|
||||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
|
||||||
requiredRoles: ['leader', 'member'],
|
requiredRoles: ['leader', 'member'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'presentation',
|
path: 'presentation',
|
||||||
loadChildren: () => import('./modules/presentation/presentation.module').then(m => m.PresentationModule),
|
loadChildren: () => import('./modules/presentation/presentation.module').then(m => m.PresentationModule),
|
||||||
canActivate: [AngularFireAuthGuard, RoleGuard],
|
canActivate: [AuthGuard, RoleGuard],
|
||||||
data: {
|
data: {
|
||||||
authGuardPipe: () => redirectUnauthorizedTo(['user', 'login']),
|
|
||||||
requiredRoles: ['presenter'],
|
requiredRoles: ['presenter'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -54,7 +51,8 @@ const routes: Routes = [
|
|||||||
imports: [
|
imports: [
|
||||||
RouterModule.forRoot(routes, {
|
RouterModule.forRoot(routes, {
|
||||||
preloadingStrategy: PreloadAllModules,
|
preloadingStrategy: PreloadAllModules,
|
||||||
relativeLinkResolution: 'legacy',
|
scrollPositionRestoration: 'enabled',
|
||||||
|
// relativeLinkResolution: 'legacy',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
exports: [RouterModule],
|
exports: [RouterModule],
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
<app-navigation></app-navigation>
|
<app-navigation></app-navigation>
|
||||||
<perfect-scrollbar
|
|
||||||
#scrollbar
|
<div [@fader]="o.isActivated ? o.activatedRoute : ''" class="content">
|
||||||
(psScrollY)="onScoll($event)"
|
<router-outlet #o="outlet"></router-outlet>
|
||||||
[perfectScrollbar]
|
</div>
|
||||||
class="scroll"
|
|
||||||
style="max-height: calc(100vh); width: 100%; overflow: hidden"
|
|
||||||
>
|
|
||||||
<div [@fader]="o.isActivated ? o.activatedRoute : ''" class="content">
|
|
||||||
<router-outlet #o="outlet"></router-outlet>
|
|
||||||
</div>
|
|
||||||
</perfect-scrollbar>
|
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
h1 {
|
h1 {
|
||||||
color: red;
|
color: var(--text);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.manager {
|
|
||||||
//display: grid;
|
|
||||||
//grid-template-columns: 1fr 1fr;
|
|
||||||
//transition: all 1s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,11 @@ import {RouterTestingModule} from '@angular/router/testing';
|
|||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [RouterTestingModule, AppComponent],
|
||||||
imports: [RouterTestingModule],
|
}).compileComponents();
|
||||||
declarations: [AppComponent],
|
}));
|
||||||
}).compileComponents();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should create the app', () => {
|
it('should create the app', () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, OnInit, inject} from '@angular/core';
|
||||||
import {fader} from './animations';
|
import {fader} from './animations';
|
||||||
import {ScrollService} from './services/scroll.service';
|
import {ScrollService} from './services/scroll.service';
|
||||||
import {PerfectScrollbarComponent} from 'ngx-perfect-scrollbar';
|
|
||||||
import {register} from 'swiper/element/bundle';
|
import {register} from 'swiper/element/bundle';
|
||||||
|
import {RouterOutlet} from '@angular/router';
|
||||||
|
import {NavigationComponent} from './widget-modules/components/application-frame/navigation/navigation.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -10,14 +11,12 @@ import {register} from 'swiper/element/bundle';
|
|||||||
styleUrls: ['./app.component.less'],
|
styleUrls: ['./app.component.less'],
|
||||||
animations: [fader],
|
animations: [fader],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
imports: [RouterOutlet, NavigationComponent],
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
@ViewChild('scrollbar', {static: false}) public scrollbar: PerfectScrollbarComponent | null = null;
|
private scrollService = inject(ScrollService);
|
||||||
|
|
||||||
public constructor(private scrollService: ScrollService) {
|
public constructor() {
|
||||||
scrollService.restoreScrollPosition$.subscribe(pos => {
|
|
||||||
if (this.scrollbar && pos) this.scrollbar.directiveRef?.scrollTo(0, pos, 300);
|
|
||||||
});
|
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
import {BrowserModule} from '@angular/platform-browser';
|
|
||||||
import {NgModule} from '@angular/core';
|
|
||||||
|
|
||||||
import {AppRoutingModule} from './app-routing.module';
|
|
||||||
import {AppComponent} from './app.component';
|
|
||||||
import {ServiceWorkerModule} from '@angular/service-worker';
|
|
||||||
import {environment} from '../environments/environment';
|
|
||||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
|
||||||
import {ApplicationFrameModule} from './widget-modules/components/application-frame/application-frame.module';
|
|
||||||
import {AngularFireModule} from '@angular/fire/compat';
|
|
||||||
import {AngularFirestoreModule} from '@angular/fire/compat/firestore';
|
|
||||||
import {AngularFireStorageModule} from '@angular/fire/compat/storage';
|
|
||||||
import {AngularFireDatabaseModule} from '@angular/fire/compat/database';
|
|
||||||
import {AngularFireAuthModule} from '@angular/fire/compat/auth';
|
|
||||||
import {AngularFireAuthGuardModule} from '@angular/fire/compat/auth-guard';
|
|
||||||
import {MAT_DATE_LOCALE} from '@angular/material/core';
|
|
||||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
|
||||||
import {PerfectScrollbarModule} from 'ngx-perfect-scrollbar';
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [AppComponent],
|
|
||||||
imports: [
|
|
||||||
BrowserModule,
|
|
||||||
BrowserAnimationsModule,
|
|
||||||
AppRoutingModule,
|
|
||||||
ServiceWorkerModule.register('ngsw-worker.js', {
|
|
||||||
enabled: environment.production,
|
|
||||||
}),
|
|
||||||
BrowserAnimationsModule,
|
|
||||||
|
|
||||||
ApplicationFrameModule,
|
|
||||||
|
|
||||||
AngularFireModule.initializeApp(environment.firebase),
|
|
||||||
AngularFirestoreModule.enablePersistence({synchronizeTabs: true}),
|
|
||||||
AngularFireStorageModule,
|
|
||||||
AngularFireDatabaseModule,
|
|
||||||
AngularFireAuthModule,
|
|
||||||
AngularFireAuthGuardModule,
|
|
||||||
FontAwesomeModule,
|
|
||||||
PerfectScrollbarModule,
|
|
||||||
],
|
|
||||||
providers: [{provide: MAT_DATE_LOCALE, useValue: 'de-DE'}],
|
|
||||||
bootstrap: [AppComponent],
|
|
||||||
})
|
|
||||||
export class AppModule {}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="brand">
|
<div class="brand">
|
||||||
<app-logo></app-logo>
|
<app-logo></app-logo>
|
||||||
<div class="copyright">© 2019 - 2023 - Benjamin Ifland</div>
|
<div class="copyright">© 2019 - 2026 - Benjamin Ifland</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('BrandComponent', () => {
|
|||||||
let component: BrandComponent;
|
let component: BrandComponent;
|
||||||
let fixture: ComponentFixture<BrandComponent>;
|
let fixture: ComponentFixture<BrandComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [BrandComponent],
|
||||||
declarations: [BrandComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(BrandComponent);
|
fixture = TestBed.createComponent(BrandComponent);
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
|
import {LogoComponent} from '../../widget-modules/components/logo/logo.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-brand',
|
selector: 'app-brand',
|
||||||
templateUrl: './brand.component.html',
|
templateUrl: './brand.component.html',
|
||||||
styleUrls: ['./brand.component.less'],
|
styleUrls: ['./brand.component.less'],
|
||||||
|
imports: [LogoComponent],
|
||||||
})
|
})
|
||||||
export class BrandComponent {}
|
export class BrandComponent {}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
|
|||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {BrandComponent} from './brand.component';
|
import {BrandComponent} from './brand.component';
|
||||||
import {RouterModule, Routes} from '@angular/router';
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
import {LogoModule} from '../../widget-modules/components/logo/logo.module';
|
|
||||||
import {NewUserComponent} from './new-user/new-user.component';
|
import {NewUserComponent} from './new-user/new-user.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
@@ -18,7 +18,6 @@ const routes: Routes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [BrandComponent, NewUserComponent],
|
imports: [CommonModule, RouterModule.forChild(routes), BrandComponent, NewUserComponent],
|
||||||
imports: [CommonModule, RouterModule.forChild(routes), LogoModule],
|
|
||||||
})
|
})
|
||||||
export class BrandModule {}
|
export class BrandModule {}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<div class="frame">
|
<div class="frame">
|
||||||
<app-brand class="brand"></app-brand>
|
<app-brand class="brand"></app-brand>
|
||||||
<div *ngIf="user$ | async as user" class="text">
|
@if (user$ | async; as user) {
|
||||||
<div class="welcome">WILLKOMMEN</div>
|
<div class="text">
|
||||||
<div class="name">{{ user.name }}</div>
|
<div class="welcome">WILLKOMMEN</div>
|
||||||
<div class="roles">
|
<div class="name">{{ user.name }}</div>
|
||||||
Es wurden noch keine Berechtigungen zugeteilt, bitte wende Dich an den
|
<div class="roles">
|
||||||
Administrator!
|
Es wurden noch keine Berechtigungen zugeteilt, bitte wende Dich an den
|
||||||
|
Administrator!
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
@animation-duration: 20s;
|
:host {
|
||||||
|
--animation-duration: 20s;
|
||||||
|
}
|
||||||
|
|
||||||
.frame {
|
.frame {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
@@ -11,10 +13,10 @@
|
|||||||
.brand {
|
.brand {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
animation: @animation-duration brand ease-in-out forwards;
|
animation: var(--animation-duration) brand ease-in-out forwards;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
@media screen and (max-width: 860px) {
|
@media screen and (max-width: 860px) {
|
||||||
animation: @animation-duration brand-mobile ease-in-out forwards;
|
animation: var(--animation-duration) brand-mobile ease-in-out forwards;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@
|
|||||||
@media screen and (max-width: 860px) {
|
@media screen and (max-width: 860px) {
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
}
|
}
|
||||||
animation: @animation-duration welcome ease-in-out forwards;
|
animation: var(--animation-duration) welcome ease-in-out forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
@@ -43,14 +45,14 @@
|
|||||||
@media screen and (max-width: 860px) {
|
@media screen and (max-width: 860px) {
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
}
|
}
|
||||||
animation: @animation-duration name ease-in-out forwards;
|
animation: var(--animation-duration) name ease-in-out forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
.roles {
|
.roles {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
animation: @animation-duration roles ease-in-out forwards;
|
animation: var(--animation-duration) roles ease-in-out forwards;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('NewUserComponent', () => {
|
|||||||
let component: NewUserComponent;
|
let component: NewUserComponent;
|
||||||
let fixture: ComponentFixture<NewUserComponent>;
|
let fixture: ComponentFixture<NewUserComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [NewUserComponent],
|
||||||
declarations: [NewUserComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(NewUserComponent);
|
fixture = TestBed.createComponent(NewUserComponent);
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component, inject} from '@angular/core';
|
||||||
import {UserService} from '../../../services/user/user.service';
|
import {UserService} from '../../../services/user/user.service';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {User} from '../../../services/user/user';
|
import {User} from '../../../services/user/user';
|
||||||
|
import {BrandComponent} from '../brand.component';
|
||||||
|
import {AsyncPipe} from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new-user',
|
selector: 'app-new-user',
|
||||||
templateUrl: './new-user.component.html',
|
templateUrl: './new-user.component.html',
|
||||||
styleUrls: ['./new-user.component.less'],
|
styleUrls: ['./new-user.component.less'],
|
||||||
|
imports: [BrandComponent, AsyncPipe],
|
||||||
})
|
})
|
||||||
export class NewUserComponent {
|
export class NewUserComponent {
|
||||||
|
private userService = inject(UserService);
|
||||||
|
|
||||||
public user$: Observable<User | null> | null = null;
|
public user$: Observable<User | null> | null = null;
|
||||||
|
|
||||||
public constructor(private userService: UserService) {
|
public constructor() {
|
||||||
|
const userService = this.userService;
|
||||||
|
|
||||||
this.user$ = userService.user$;
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
26
src/app/modules/guest/guest-show-data.service.ts
Normal file
26
src/app/modules/guest/guest-show-data.service.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import {Injectable, inject} from '@angular/core';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
import {shareReplay} from 'rxjs/operators';
|
||||||
|
import {DbService} from 'src/app/services/db.service';
|
||||||
|
import {GuestShow} from './guest-show';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class GuestShowDataService {
|
||||||
|
private dbService = inject(DbService);
|
||||||
|
|
||||||
|
private collection = 'guest';
|
||||||
|
public list$: Observable<GuestShow[]> = this.dbService.col$<GuestShow>(this.collection).pipe(
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
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);
|
||||||
|
public add: (data: Partial<GuestShow>) => Promise<string> = async (data: Partial<GuestShow>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
|
||||||
|
public delete: (id: string) => Promise<void> = async (id: string): Promise<void> => await this.dbService.doc(this.collection + '/' + id).delete();
|
||||||
|
}
|
||||||
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
31
src/app/modules/guest/guest-show.service.ts
Normal file
31
src/app/modules/guest/guest-show.service.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
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';
|
||||||
|
import {ShowService} from '../shows/services/show.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class GuestShowService {
|
||||||
|
private showService = inject(ShowService);
|
||||||
|
private guestShowDataService = inject(GuestShowDataService);
|
||||||
|
|
||||||
|
public async share(show: Show, songs: Song[]): Promise<string> {
|
||||||
|
const data = {
|
||||||
|
showType: show.showType,
|
||||||
|
date: show.date,
|
||||||
|
songs: songs,
|
||||||
|
};
|
||||||
|
let shareId = show.shareId;
|
||||||
|
|
||||||
|
if (!show.shareId) {
|
||||||
|
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/' + shareId;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/app/modules/guest/guest-show.ts
Normal file
9
src/app/modules/guest/guest-show.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import {Song} from '../songs/services/song';
|
||||||
|
import {Timestamp} from '@angular/fire/firestore';
|
||||||
|
|
||||||
|
export interface GuestShow {
|
||||||
|
id: string;
|
||||||
|
showType: string;
|
||||||
|
date: Timestamp;
|
||||||
|
songs: Song[];
|
||||||
|
}
|
||||||
@@ -1,11 +1,28 @@
|
|||||||
<div *ngIf="songs$ | async as songs" class="view">
|
@if (show$|async; as show) {
|
||||||
<!-- <swiper>-->
|
<div class="page">
|
||||||
<!-- <div *ngFor="let song of songs" class="song">-->
|
<div class="title">
|
||||||
<!-- <app-song-text-->
|
<div class="left">{{ show.showType|showType }}</div>
|
||||||
<!-- [showSwitch]="false"-->
|
<div class="right">{{ show.date.toDate() | date: 'dd.MM.yyyy' }}</div>
|
||||||
<!-- [text]="song"-->
|
</div>
|
||||||
<!-- chordMode="hide"-->
|
<div class="view">
|
||||||
<!-- ></app-song-text>-->
|
<swiper-container scrollbar="true">
|
||||||
<!-- </div>-->
|
@for (song of show.songs; track trackBy(i, song); let i = $index) {
|
||||||
<!-- </swiper>-->
|
<swiper-slide
|
||||||
</div>
|
class="song-swipe">
|
||||||
|
<div class="song-title">{{ song.title }}</div>
|
||||||
|
<div class="legal">
|
||||||
|
@if (song.artist) {
|
||||||
|
<p>{{ song.artist }}</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<app-song-text
|
||||||
|
[text]="song.text"
|
||||||
|
></app-song-text>
|
||||||
|
</swiper-slide>
|
||||||
|
}
|
||||||
|
</swiper-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,59 @@
|
|||||||
|
.page {
|
||||||
|
background: var(--overlay);
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
|
||||||
|
--swiper-scrollbar-bg-color: rgba(247, 251, 255, 0.2);
|
||||||
|
--swiper-scrollbar-drag-bg-color: rgba(247, 251, 255, 0.6);
|
||||||
|
--swiper-scrollbar-sides-offset: 20px;
|
||||||
|
--swiper-scrollbar-top: 100px;
|
||||||
|
--swiper-scrollbar-bottom: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
color: var(--text-inverse);
|
||||||
|
padding: 70px 20px 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.left {
|
||||||
|
font-size: 1.8em;
|
||||||
|
color: var(--text-inverse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-title {
|
||||||
|
padding: 20px 20px 0;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legal {
|
||||||
|
padding: 0 20px;
|
||||||
|
font-size: 0.6em;
|
||||||
|
color: rgba(247, 251, 255, 0.72);
|
||||||
|
}
|
||||||
|
|
||||||
.view {
|
.view {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
background: #0003;
|
color: var(--text-inverse);
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
z-index: 1;
|
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app-song-text {
|
app-song-text {
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.song-swipe {
|
||||||
|
margin-top: 100px;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
min-height: calc(100vh - 150px);
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('GuestComponent', () => {
|
|||||||
let component: GuestComponent;
|
let component: GuestComponent;
|
||||||
let fixture: ComponentFixture<GuestComponent>;
|
let fixture: ComponentFixture<GuestComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [GuestComponent],
|
||||||
declarations: [GuestComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(GuestComponent);
|
fixture = TestBed.createComponent(GuestComponent);
|
||||||
|
|||||||
@@ -1,32 +1,30 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component, CUSTOM_ELEMENTS_SCHEMA, inject} from '@angular/core';
|
||||||
import {SongService} from '../songs/services/song.service';
|
import {GuestShowDataService} from './guest-show-data.service';
|
||||||
import {GlobalSettingsService} from '../../services/global-settings.service';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {Observable} from 'rxjs';
|
import {map, switchMap} from 'rxjs/operators';
|
||||||
import {filter, map, switchMap} from 'rxjs/operators';
|
import {Song} from '../songs/services/song';
|
||||||
import {ShowSongService} from '../shows/services/show-song.service';
|
import {ConfigService} from '../../services/config.service';
|
||||||
import {GlobalSettings} from '../../services/global-settings';
|
import {AsyncPipe, DatePipe} from '@angular/common';
|
||||||
import {ShowService} from '../shows/services/show.service';
|
import {SongTextComponent} from '../../widget-modules/components/song-text/song-text.component';
|
||||||
|
import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-guest',
|
selector: 'app-guest',
|
||||||
templateUrl: './guest.component.html',
|
templateUrl: './guest.component.html',
|
||||||
styleUrls: ['./guest.component.less'],
|
styleUrls: ['./guest.component.less'],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
imports: [SongTextComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||||
})
|
})
|
||||||
export class GuestComponent {
|
export class GuestComponent {
|
||||||
public songs$: Observable<string[]> = this.globalSettingsService.get$.pipe(
|
private currentRoute = inject(ActivatedRoute);
|
||||||
filter(_ => !!_),
|
private service = inject(GuestShowDataService);
|
||||||
map(_ => _ as GlobalSettings),
|
private configService = inject(ConfigService);
|
||||||
map(_ => _.currentShow),
|
|
||||||
switchMap(_ => this.showSongService.list$(_).pipe(map(l => ({showSongs: l, currentShow: _})))),
|
|
||||||
switchMap(_ => this.showService.read$(_.currentShow).pipe(map(l => ({showSongs: _.showSongs, show: l})))),
|
|
||||||
filter(_ => !!_.showSongs),
|
|
||||||
map(_ => (_?.show ? _.show.order.map(o => _.showSongs.find(f => f.id === o) ?? _.showSongs[0]).map(m => m.text) : []))
|
|
||||||
);
|
|
||||||
|
|
||||||
public constructor(
|
public show$ = this.currentRoute.params.pipe(
|
||||||
private songService: SongService,
|
map(param => param.id as string),
|
||||||
private showService: ShowService,
|
switchMap(id => this.service.read$(id))
|
||||||
private globalSettingsService: GlobalSettingsService,
|
);
|
||||||
private showSongService: ShowSongService
|
public config$ = this.configService.get$();
|
||||||
) {}
|
|
||||||
|
public trackBy = (index: number, show: Song) => show.id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,23 @@
|
|||||||
import {NgModule} from '@angular/core';
|
import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {GuestComponent} from './guest.component';
|
import {GuestComponent} from './guest.component';
|
||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module';
|
import {SongTextComponent} from '../../widget-modules/components/song-text/song-text.component';
|
||||||
|
import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [GuestComponent],
|
imports: [
|
||||||
imports: [CommonModule, RouterModule.forChild([{path: '', component: GuestComponent}]), SongTextModule],
|
CommonModule,
|
||||||
|
RouterModule.forChild([
|
||||||
|
{
|
||||||
|
path: ':id',
|
||||||
|
component: GuestComponent,
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
SongTextComponent,
|
||||||
|
ShowTypePipe,
|
||||||
|
GuestComponent,
|
||||||
|
],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
})
|
})
|
||||||
export class GuestModule {}
|
export class GuestModule {}
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
<ng-container *ngIf="song">
|
@if (song) {
|
||||||
<p *ngIf="song.artist">{{ song.artist }}</p>
|
@if (song.artist) {
|
||||||
<p *ngIf="song.label">{{ song.label }}</p>
|
<p>{{ song.artist }}</p>
|
||||||
<p *ngIf="song.termsOfUse" class="terms-of-use">{{ song.termsOfUse }}</p>
|
}
|
||||||
<p *ngIf="song.origin">{{ song.origin }}</p>
|
@if (song.label) {
|
||||||
|
<p>{{ song.label }}</p>
|
||||||
<div *ngIf="song.legalOwnerId">
|
}
|
||||||
<p *ngIf="song.legalOwner === 'CCLI' && config">
|
@if (song.termsOfUse) {
|
||||||
CCLI-Liednummer {{ song.legalOwnerId }}, CCLI-Lizenznummer
|
<p class="terms-of-use">{{ song.termsOfUse }}</p>
|
||||||
{{ config.ccliLicenseId }}
|
}
|
||||||
</p>
|
@if (song.origin) {
|
||||||
<p *ngIf="song.legalOwner !== 'CCLI'">Liednummer {{ song.legalOwnerId }}</p>
|
<p>{{ song.origin }}</p>
|
||||||
</div>
|
}
|
||||||
</ng-container>
|
@if (song.legalOwnerId) {
|
||||||
|
<div>
|
||||||
|
@if (song.legalOwner === 'CCLI' && config) {
|
||||||
|
<p>
|
||||||
|
CCLI-Liednummer {{ song.legalOwnerId }}, CCLI-Lizenznummer
|
||||||
|
{{ config.ccliLicenseId }}
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
@if (song.legalOwner !== 'CCLI') {
|
||||||
|
<p>Liednummer {{ song.legalOwnerId }}</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('LegalComponent', () => {
|
|||||||
let component: LegalComponent;
|
let component: LegalComponent;
|
||||||
let fixture: ComponentFixture<LegalComponent>;
|
let fixture: ComponentFixture<LegalComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [LegalComponent],
|
||||||
declarations: [LegalComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(LegalComponent);
|
fixture = TestBed.createComponent(LegalComponent);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {Config} from '../../../../services/config';
|
|||||||
selector: 'app-legal',
|
selector: 'app-legal',
|
||||||
templateUrl: './legal.component.html',
|
templateUrl: './legal.component.html',
|
||||||
styleUrls: ['./legal.component.less'],
|
styleUrls: ['./legal.component.less'],
|
||||||
|
imports: [],
|
||||||
})
|
})
|
||||||
export class LegalComponent {
|
export class LegalComponent {
|
||||||
@Input() public song: Song | null = null;
|
@Input() public song: Song | null = null;
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('LogoComponent', () => {
|
|||||||
let component: LogoComponent;
|
let component: LogoComponent;
|
||||||
let fixture: ComponentFixture<LogoComponent>;
|
let fixture: ComponentFixture<LogoComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [LogoComponent],
|
||||||
declarations: [LogoComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(LogoComponent);
|
fixture = TestBed.createComponent(LogoComponent);
|
||||||
|
|||||||
@@ -1,47 +1,50 @@
|
|||||||
<div class="fullscreen background"></div>
|
<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="bg-blue fullscreen bg-image" [class.visible]="presentationBackground==='blue'"></div>
|
<div [class.visible]="presentationBackground==='blue'" class="bg-blue fullscreen bg-image"></div>
|
||||||
<div class="bg-green fullscreen bg-image" [class.visible]="presentationBackground==='green'"></div>
|
<div [class.visible]="presentationBackground==='green'" class="bg-green fullscreen bg-image"></div>
|
||||||
<div class="bg-leder fullscreen bg-image" [class.visible]="presentationBackground==='leder'"></div>
|
<div [class.visible]="presentationBackground==='leder'" class="bg-leder fullscreen bg-image"></div>
|
||||||
<div class="bg-praise fullscreen bg-image" [class.visible]="presentationBackground==='praise'"></div>
|
<div [class.visible]="presentationBackground==='praise'" class="bg-praise fullscreen bg-image"></div>
|
||||||
<div class="bg-bible fullscreen bg-image" [class.visible]="presentationBackground==='bible'"></div>
|
<div [class.visible]="presentationBackground==='bible'" class="bg-bible fullscreen bg-image"></div>
|
||||||
|
<div
|
||||||
|
[@songSwitch]="songId"
|
||||||
<div
|
[class.blur]="songId === 'title' || songId === 'dynamicText'"
|
||||||
[@songSwitch]="songId"
|
[class.hide]="songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText'"
|
||||||
[class.blur]="songId === 'title' || songId === 'dynamicText'"
|
[class.no-logo]="presentationBackground!=='none'"
|
||||||
[class.no-logo]="presentationBackground!=='none'"
|
class="start fullscreen logo"
|
||||||
[class.hide]="songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText'"
|
>
|
||||||
class="start fullscreen logo"
|
<app-logo></app-logo>
|
||||||
>
|
</div>
|
||||||
<app-logo></app-logo>
|
@if (songId === 'title') {
|
||||||
|
<div @songSwitch class="start fullscreen">
|
||||||
|
<div>{{ showType | showType }}</div>
|
||||||
|
<div class="date">{{ date | date: "dd.MM.yyyy" }}</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@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
|
||||||
|
[@songSwitch]="songId"
|
||||||
|
[fullscreen]="true"
|
||||||
|
[header]="song.title"
|
||||||
|
[index]="index??0"
|
||||||
|
[showComments]="false"
|
||||||
|
[showSwitch]="false"
|
||||||
|
[text]="song.text"
|
||||||
|
chordMode="hide"
|
||||||
|
></app-song-text>
|
||||||
|
}
|
||||||
|
@if (song && songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText') {
|
||||||
|
<app-legal
|
||||||
|
[@songSwitch]="songId"
|
||||||
|
[config]="config$ | async"
|
||||||
|
[song]="song"
|
||||||
|
></app-legal>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div *ngIf="songId === 'title'" @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">
|
|
||||||
<div>{{ presentationDynamicCaption }}</div>
|
|
||||||
<div class="date">{{ presentationDynamicText }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<app-song-text
|
|
||||||
[header]="song.title"
|
|
||||||
*ngIf="songId !== 'title' && songId !== 'empty'"
|
|
||||||
[@songSwitch]="songId"
|
|
||||||
[fullscreen]="true"
|
|
||||||
[index]="index??0"
|
|
||||||
[showSwitch]="false"
|
|
||||||
[text]="song.text"
|
|
||||||
chordMode="hide"
|
|
||||||
></app-song-text>
|
|
||||||
<app-legal
|
|
||||||
*ngIf="songId !== 'title' && songId !== 'empty' && songId !== 'dynamicText'"
|
|
||||||
[@songSwitch]="songId"
|
|
||||||
[config]="config$ | async"
|
|
||||||
[song]="song"
|
|
||||||
></app-legal>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
.bg-blue {
|
.bg-blue {
|
||||||
background-image: url("/assets/bg-dark-blue.jpg");
|
background-image: url("/assets/bg-dark-blue.jpg");
|
||||||
filter: blur(10px);
|
filter: blur(10px);
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
.bg-green {
|
.bg-green {
|
||||||
background-image: url("/assets/bg-dark-green.jpg");
|
background-image: url("/assets/bg-dark-green.jpg");
|
||||||
filter: blur(5px);
|
filter: blur(5px);
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
.bg-leder {
|
.bg-leder {
|
||||||
background-image: url("/assets/bg-leder.jpg");
|
background-image: url("/assets/bg-leder.jpg");
|
||||||
filter: blur(5px);
|
filter: blur(5px);
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
@@ -58,6 +61,7 @@
|
|||||||
.bg-praise {
|
.bg-praise {
|
||||||
background-image: url("/assets/bg-praise.jpg");
|
background-image: url("/assets/bg-praise.jpg");
|
||||||
filter: blur(8px);
|
filter: blur(8px);
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
@@ -66,6 +70,7 @@
|
|||||||
.bg-bible {
|
.bg-bible {
|
||||||
background-image: url("/assets/bg-bible.jpg");
|
background-image: url("/assets/bg-bible.jpg");
|
||||||
filter: blur(8px);
|
filter: blur(8px);
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('MonitorComponent', () => {
|
|||||||
let component: MonitorComponent;
|
let component: MonitorComponent;
|
||||||
let fixture: ComponentFixture<MonitorComponent>;
|
let fixture: ComponentFixture<MonitorComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [MonitorComponent],
|
||||||
declarations: [MonitorComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(MonitorComponent);
|
fixture = TestBed.createComponent(MonitorComponent);
|
||||||
|
|||||||
@@ -1,26 +1,36 @@
|
|||||||
import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
|
import {ChangeDetectorRef, Component, OnDestroy, OnInit, inject} from '@angular/core';
|
||||||
import {debounceTime, distinctUntilChanged, filter, map, switchMap, tap} from 'rxjs/operators';
|
import {distinctUntilChanged, filter, map, shareReplay, switchMap, takeUntil, tap} from 'rxjs/operators';
|
||||||
import {ShowService} from '../../shows/services/show.service';
|
import {ShowService} from '../../shows/services/show.service';
|
||||||
import {SongService} from '../../songs/services/song.service';
|
|
||||||
import {Song} from '../../songs/services/song';
|
import {Song} from '../../songs/services/song';
|
||||||
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
||||||
import {Config} from '../../../services/config';
|
import {Config} from '../../../services/config';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable, Subject} from 'rxjs';
|
||||||
import {ConfigService} from '../../../services/config.service';
|
import {ConfigService} from '../../../services/config.service';
|
||||||
import {songSwitch} from '../../../widget-modules/components/song-text/animation';
|
import {songSwitch} from '../../../widget-modules/components/song-text/animation';
|
||||||
import {TextRenderingService} from '../../songs/services/text-rendering.service';
|
|
||||||
import {PresentationBackground, Show} from '../../shows/services/show';
|
import {PresentationBackground, Show} from '../../shows/services/show';
|
||||||
import {GlobalSettings} from '../../../services/global-settings';
|
import {ShowSong} from '../../shows/services/show-song';
|
||||||
import {ShowSongService} from '../../shows/services/show-song.service';
|
import {ShowSongService} from '../../shows/services/show-song.service';
|
||||||
import {openFullscreen} from '../../../services/fullscreen';
|
import {openFullscreen} from '../../../services/fullscreen';
|
||||||
|
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';
|
||||||
|
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-monitor',
|
selector: 'app-monitor',
|
||||||
templateUrl: './monitor.component.html',
|
templateUrl: './monitor.component.html',
|
||||||
styleUrls: ['./monitor.component.less'],
|
styleUrls: ['./monitor.component.less'],
|
||||||
animations: [songSwitch],
|
animations: [songSwitch],
|
||||||
|
imports: [LogoComponent, SongTextComponent, LegalComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||||
})
|
})
|
||||||
export class MonitorComponent implements OnInit {
|
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 song: Song | null = null;
|
||||||
public zoom = 10;
|
public zoom = 10;
|
||||||
public currentShowId: string | null = null;
|
public currentShowId: string | null = null;
|
||||||
@@ -32,55 +42,78 @@ export class MonitorComponent implements OnInit {
|
|||||||
public date: Date | null = null;
|
public date: Date | null = null;
|
||||||
public config$: Observable<Config | null>;
|
public config$: Observable<Config | null>;
|
||||||
public presentationBackground: PresentationBackground = 'none';
|
public presentationBackground: PresentationBackground = 'none';
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
const configService = this.configService;
|
||||||
|
|
||||||
public constructor(
|
|
||||||
private showService: ShowService,
|
|
||||||
private showSongService: ShowSongService,
|
|
||||||
private songService: SongService,
|
|
||||||
private textRenderingService: TextRenderingService,
|
|
||||||
private globalSettingsService: GlobalSettingsService,
|
|
||||||
private configService: ConfigService,
|
|
||||||
private cRef: ChangeDetectorRef
|
|
||||||
) {
|
|
||||||
this.config$ = configService.get$();
|
this.config$ = configService.get$();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
openFullscreen();
|
openFullscreen();
|
||||||
this.globalSettingsService.get$
|
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(
|
||||||
|
switchMap(showId => this.showService.read$(showId)),
|
||||||
|
filter((show): show is Show => !!show),
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$)
|
||||||
|
);
|
||||||
|
|
||||||
|
show$
|
||||||
.pipe(
|
.pipe(
|
||||||
debounceTime(100),
|
tap(show => {
|
||||||
filter(_ => !!_),
|
this.showType = show.showType;
|
||||||
map(_ => _ as GlobalSettings),
|
this.date = show.date.toDate();
|
||||||
map(_ => _.currentShow),
|
this.index = show.presentationSection;
|
||||||
distinctUntilChanged(),
|
this.presentationBackground = show.presentationBackground;
|
||||||
tap(_ => (this.currentShowId = _))
|
this.presentationDynamicCaption = show.presentationDynamicCaption;
|
||||||
|
this.presentationDynamicText = show.presentationDynamicText;
|
||||||
|
this.zoom = show.presentationZoom ?? 30;
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$)
|
||||||
)
|
)
|
||||||
|
.subscribe(() => this.cRef.markForCheck());
|
||||||
|
|
||||||
|
show$
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(_ => this.showService.read$(_)),
|
map(show => ({showId: show.id, presentationSongId: show.presentationSongId})),
|
||||||
filter(_ => !!_),
|
distinctUntilChanged((a, b) => a.showId === b.showId && a.presentationSongId === b.presentationSongId),
|
||||||
map(_ => _ as Show),
|
tap(({presentationSongId}) => {
|
||||||
tap<Show>(_ => {
|
if (presentationSongId === 'title' || presentationSongId === 'dynamicText' || !presentationSongId) {
|
||||||
this.showType = _.showType;
|
this.song = null;
|
||||||
this.date = _.date.toDate();
|
}
|
||||||
this.index = _.presentationSection;
|
if (this.songId !== presentationSongId) {
|
||||||
this.presentationBackground = _.presentationBackground;
|
this.songId = 'empty';
|
||||||
this.presentationDynamicCaption = _.presentationDynamicCaption;
|
}
|
||||||
this.presentationDynamicText = _.presentationDynamicText;
|
|
||||||
this.zoom = _.presentationZoom ?? 30;
|
|
||||||
if (this.songId !== _.presentationSongId) this.songId = 'empty';
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.songId = _.presentationSongId;
|
this.songId = presentationSongId;
|
||||||
this.cRef.markForCheck();
|
this.cRef.markForCheck();
|
||||||
}, 600);
|
}, 600);
|
||||||
}),
|
}),
|
||||||
switchMap((_: Show) => this.showSongService.read$(_.id, _.presentationSongId)),
|
switchMap(({showId, presentationSongId}) => this.showSongService.read$(showId, presentationSongId)),
|
||||||
filter(_ => !!_),
|
filter((song): song is ShowSong => !!song),
|
||||||
map(_ => _ as Song)
|
takeUntil(this.destroy$)
|
||||||
)
|
)
|
||||||
.subscribe(_ => {
|
.subscribe(song => {
|
||||||
this.song = _;
|
this.song = song;
|
||||||
this.cRef.markForCheck();
|
this.cRef.markForCheck();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,43 +4,45 @@ import {CommonModule} from '@angular/common';
|
|||||||
import {PresentationRoutingModule} from './presentation-routing.module';
|
import {PresentationRoutingModule} from './presentation-routing.module';
|
||||||
import {MonitorComponent} from './monitor/monitor.component';
|
import {MonitorComponent} from './monitor/monitor.component';
|
||||||
import {RemoteComponent} from './remote/remote.component';
|
import {RemoteComponent} from './remote/remote.component';
|
||||||
import {CardModule} from '../../widget-modules/components/card/card.module';
|
|
||||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||||
import {MatSelectModule} from '@angular/material/select';
|
import {MatSelectModule} from '@angular/material/select';
|
||||||
import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module';
|
|
||||||
import {SectionTypeTranslatorModule} from '../../widget-modules/pipes/section-type-translator/section-type-translator.module';
|
|
||||||
import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module';
|
|
||||||
import {LegalComponent} from './monitor/legal/legal.component';
|
import {LegalComponent} from './monitor/legal/legal.component';
|
||||||
import {MatButtonModule} from '@angular/material/button';
|
import {MatButtonModule} from '@angular/material/button';
|
||||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||||
import {MatSliderModule} from '@angular/material/slider';
|
import {MatSliderModule} from '@angular/material/slider';
|
||||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
import {AddSongModule} from '../../widget-modules/components/add-song/add-song.module';
|
|
||||||
import {LogoComponent} from './monitor/logo/logo.component';
|
import {LogoComponent} from './monitor/logo/logo.component';
|
||||||
import {SelectComponent} from './select/select.component';
|
import {SelectComponent} from './select/select.component';
|
||||||
import {MatInputModule} from '@angular/material/input';
|
import {MatInputModule} from '@angular/material/input';
|
||||||
import {UserNameModule} from '../../services/user/user-name/user-name.module';
|
|
||||||
|
import {SongTextComponent} from '../../widget-modules/components/song-text/song-text.component';
|
||||||
|
import {AddSongComponent} from '../../widget-modules/components/add-song/add-song.component';
|
||||||
|
import {SectionTypePipe} from '../../widget-modules/pipes/section-type-translator/section-type.pipe';
|
||||||
|
import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [MonitorComponent, RemoteComponent, LegalComponent, LogoComponent, SelectComponent],
|
|
||||||
exports: [RemoteComponent],
|
exports: [RemoteComponent],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
PresentationRoutingModule,
|
PresentationRoutingModule,
|
||||||
CardModule,
|
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
ShowTypeTranslaterModule,
|
ShowTypePipe,
|
||||||
SectionTypeTranslatorModule,
|
SectionTypePipe,
|
||||||
SongTextModule,
|
SongTextComponent,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
FontAwesomeModule,
|
FontAwesomeModule,
|
||||||
MatSliderModule,
|
MatSliderModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
AddSongModule,
|
AddSongComponent,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
UserNameModule,
|
MonitorComponent,
|
||||||
|
RemoteComponent,
|
||||||
|
LegalComponent,
|
||||||
|
LogoComponent,
|
||||||
|
SelectComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class PresentationModule {}
|
export class PresentationModule {}
|
||||||
|
|||||||
@@ -1,123 +1,128 @@
|
|||||||
<div *ngIf="show" @fade>
|
@if (show) {
|
||||||
<app-card [heading]="show.showType | showType" [subheading]="show.date.toDate() | date:'dd.MM.yyyy'"
|
<div @fade>
|
||||||
closeLink="/presentation/select" [closeIcon]="faIcon">
|
<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 class="song">
|
||||||
<div *ngIf="show" class="song-parts">
|
@if (show) {
|
||||||
<div
|
<div class="song-parts">
|
||||||
(click)="onSectionClick('title', -1, show.id)"
|
<div
|
||||||
[class.active]="show.presentationSongId === 'title'"
|
(click)="onSectionClick('title', -1, show.id)"
|
||||||
class="song-part"
|
[class.active]="show.presentationSongId === 'title'"
|
||||||
>
|
class="song-part"
|
||||||
<div class="head">Veranstaltung</div>
|
>
|
||||||
</div>
|
<div class="head">Veranstaltung</div>
|
||||||
<div
|
</div>
|
||||||
(click)="onSectionClick('empty', -1, show.id)"
|
<div
|
||||||
[class.active]="show.presentationSongId === 'empty'"
|
(click)="onSectionClick('empty', -1, show.id)"
|
||||||
class="song-part"
|
[class.active]="show.presentationSongId === 'empty'"
|
||||||
>
|
class="song-part"
|
||||||
<div class="head">Leer</div>
|
>
|
||||||
</div>
|
<div class="head">Leer</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@for (song of presentationSongs; track trackBy($index, song)) {
|
||||||
|
<div class="song">
|
||||||
<div *ngFor="let song of presentationSongs; trackBy: trackBy" class="song">
|
@if (show) {
|
||||||
<div *ngIf="show"
|
<div
|
||||||
[class.active]="show.presentationSongId === song.id"
|
[class.active]="show.presentationSongId === song.id"
|
||||||
class="title song-part"
|
class="title song-part"
|
||||||
>
|
>
|
||||||
<div (click)="onSectionClick(song.id, -1, show.id)" class="head">
|
<div (click)="onSectionClick(song.id, -1, show.id)" class="head">
|
||||||
{{ song.title }}
|
{{ song.title }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="show" class="song-parts">
|
}
|
||||||
<div
|
@if (show) {
|
||||||
(click)="onSectionClick(song.id, i, show.id)"
|
<div class="song-parts">
|
||||||
*ngFor="let section of song.sections; index as i"
|
@for (section of song.sections; track section; let i = $index) {
|
||||||
|
<div
|
||||||
|
(click)="onSectionClick(song.id, i, show.id)"
|
||||||
[class.active]="
|
[class.active]="
|
||||||
show.presentationSongId === song.id &&
|
show.presentationSongId === song.id &&
|
||||||
show.presentationSection === i
|
show.presentationSection === i
|
||||||
"
|
"
|
||||||
class="song-part"
|
class="song-part"
|
||||||
>
|
>
|
||||||
<div class="head">
|
<div class="head">
|
||||||
{{ section.type | sectionType }} {{ section.number + 1 }}
|
{{ section.type | sectionType }} {{ section.number + 1 }}
|
||||||
|
</div>
|
||||||
|
<div class="fragment">{{ getFirstLine(section) }}</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="song">
|
||||||
|
@if (show) {
|
||||||
|
<div
|
||||||
|
[class.active]="show.presentationSongId === 'dynamicText'"
|
||||||
|
class="title song-part"
|
||||||
|
>
|
||||||
|
<div (click)="onSectionClick('dynamicText', -1, show.id)" class="head">
|
||||||
|
Freier Text
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fragment">{{ getFirstLine(section) }}</div>
|
}
|
||||||
</div>
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Überschrift</mat-label>
|
||||||
|
<input (ngModelChange)="onDynamicCaption($event, show.id)" [ngModel]="show.presentationDynamicCaption"
|
||||||
|
autocomplete="off" id="dynamic-caption"
|
||||||
|
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>
|
||||||
</div>
|
@if (show) {
|
||||||
|
<div class="div-bottom">
|
||||||
<div class="song">
|
<button class="btn-start-presentation" mat-button routerLink="/presentation/monitor">
|
||||||
<div *ngIf="show"
|
<fa-icon [icon]="faDesktop"></fa-icon>
|
||||||
[class.active]="show.presentationSongId === 'dynamicText'"
|
Präsentation starten
|
||||||
class="title song-part"
|
</button>
|
||||||
>
|
<mat-form-field appearance="outline">
|
||||||
<div (click)="onSectionClick('dynamicText', -1, show.id)" class="head">
|
<mat-label>Hintergrund</mat-label>
|
||||||
Freier Text
|
<mat-select
|
||||||
|
(ngModelChange)="onBackground($event, show.id)"
|
||||||
|
[ngModel]="show.presentationBackground">
|
||||||
|
<mat-option value="none">kein Hintergrund</mat-option>
|
||||||
|
<mat-option value="blue">Sternenhimmel</mat-option>
|
||||||
|
<mat-option value="green">Blätter</mat-option>
|
||||||
|
<mat-option value="leder">Leder</mat-option>
|
||||||
|
<mat-option value="praise">Lobpreis</mat-option>
|
||||||
|
<mat-option value="bible">Bibel</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-slider
|
||||||
|
#slider
|
||||||
|
[max]="100"
|
||||||
|
[min]="10"
|
||||||
|
[step]="2"
|
||||||
|
class="zoom-slider"
|
||||||
|
color="primary"
|
||||||
|
ngDefaultControl
|
||||||
|
><input (ngModelChange)="onZoom($event, show.id)"
|
||||||
|
[ngModel]="show.presentationZoom"
|
||||||
|
matSliderThumb>
|
||||||
|
</mat-slider>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
|
@if (show) {
|
||||||
<mat-form-field appearance="outline">
|
<app-add-song
|
||||||
<mat-label>Überschrift</mat-label>
|
[addedLive]="true"
|
||||||
<input (ngModelChange)="onDynamicCaption($event, show.id)" [ngModel]="show.presentationDynamicCaption" autocomplete="off" id="dynamic-caption"
|
[showSongs]="showSongs"
|
||||||
matInput
|
[show]="show"
|
||||||
type="text">
|
[songs]="songs$|async"
|
||||||
</mat-form-field>
|
></app-add-song>
|
||||||
|
}
|
||||||
<mat-form-field appearance="outline">
|
}
|
||||||
<mat-label>Text</mat-label>
|
</app-card>
|
||||||
<textarea (ngModelChange)="onDynamicText($event, show.id)" [ngModel]="show.presentationDynamicText"
|
</div>
|
||||||
autocomplete="off" id="dynamic-text"
|
}
|
||||||
matInput></textarea>
|
|
||||||
</mat-form-field>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="show" class="div-bottom">
|
|
||||||
|
|
||||||
<button routerLink="/presentation/monitor" mat-button>
|
|
||||||
<fa-icon [icon]="faDesktop"></fa-icon>
|
|
||||||
Präsentation starten
|
|
||||||
</button>
|
|
||||||
|
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
|
||||||
<mat-label>Hintergrund</mat-label>
|
|
||||||
<mat-select
|
|
||||||
[ngModel]="show.presentationBackground"
|
|
||||||
(ngModelChange)="onBackground($event, show.id)">
|
|
||||||
<mat-option value="none">kein Hintergrund</mat-option>
|
|
||||||
<mat-option value="blue">Sternenhimmel</mat-option>
|
|
||||||
<mat-option value="green">Blätter</mat-option>
|
|
||||||
<mat-option value="leder">Leder</mat-option>
|
|
||||||
<mat-option value="praise">Lobpreis</mat-option>
|
|
||||||
<mat-option value="bible">Bibel</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
|
|
||||||
<mat-slider
|
|
||||||
(ngModelChange)="onZoom($event, show.id)"
|
|
||||||
[max]="100"
|
|
||||||
[min]="10"
|
|
||||||
[ngModel]="show.presentationZoom"
|
|
||||||
[step]="2"
|
|
||||||
[thumbLabel]="true"
|
|
||||||
color="primary"
|
|
||||||
class="zoom-slider"
|
|
||||||
>
|
|
||||||
</mat-slider>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<app-add-song
|
|
||||||
*ngIf="show"
|
|
||||||
[addedLive]="true"
|
|
||||||
[showSongs]="showSongs"
|
|
||||||
[songs]="songs$|async"
|
|
||||||
[show]="show"
|
|
||||||
></app-add-song>
|
|
||||||
</ng-container>
|
|
||||||
</app-card>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
@import "../../../../styles/shadow";
|
@import "../../../../styles/shadow";
|
||||||
|
|
||||||
.song {
|
.song {
|
||||||
background: #fff;
|
background: var(--surface-strong);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
color: var(--text);
|
||||||
|
|
||||||
@media screen and (max-width: 860px) {
|
@media screen and (max-width: 860px) {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin: -11px -20px 10px;
|
margin: -11px -20px 10px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid var(--surface-border);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,35 +40,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.song-part {
|
.song-part {
|
||||||
background: #fff;
|
background: var(--surface-strong);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: 300ms all ease-in-out;
|
transition: var(--transition);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: 0.5px solid #eee;
|
outline: 1px solid var(--surface-muted);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.card-1;
|
outline: 1px solid var(--primary-hover);
|
||||||
outline: 0 solid transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
.card-2;
|
outline: 1px solid var(--primary-color);
|
||||||
outline: 0 solid transparent;
|
|
||||||
|
|
||||||
.head {
|
.head {
|
||||||
background: #4286f4;
|
background-color: var(--primary-color);
|
||||||
color: white;
|
color: var(--text-inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
.fragment {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.head {
|
.head {
|
||||||
transition: 300ms all ease-in-out;
|
transition: var(--transition);
|
||||||
background: #eee;
|
background: var(--surface-muted);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -79,7 +76,11 @@
|
|||||||
.div-bottom {
|
.div-bottom {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
grid-template-columns: min-content min-content auto;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
|
||||||
|
.btn-start-presentation {
|
||||||
|
height: 56px;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 860px) {
|
@media screen and (max-width: 860px) {
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
@@ -100,9 +101,9 @@
|
|||||||
a {
|
a {
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
transition: all 300ms ease-in-out;
|
transition: var(--transition);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #4286f4;
|
color: var(--link-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('RemoteComponent', () => {
|
|||||||
let component: RemoteComponent;
|
let component: RemoteComponent;
|
||||||
let fixture: ComponentFixture<RemoteComponent>;
|
let fixture: ComponentFixture<RemoteComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [RemoteComponent],
|
||||||
declarations: [RemoteComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(RemoteComponent);
|
fixture = TestBed.createComponent(RemoteComponent);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from '@angular/core';
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, inject} from '@angular/core';
|
||||||
import {combineLatest, Subject} from 'rxjs';
|
import {combineLatest, Subject} from 'rxjs';
|
||||||
import {PresentationBackground, Show} from '../../shows/services/show';
|
import {PresentationBackground, Show} from '../../shows/services/show';
|
||||||
import {ShowSongService} from '../../shows/services/show-song.service';
|
import {ShowSongService} from '../../shows/services/show-song.service';
|
||||||
@@ -7,11 +7,25 @@ import {faDesktop, faFolderOpen} from '@fortawesome/free-solid-svg-icons';
|
|||||||
import {ShowService} from '../../shows/services/show.service';
|
import {ShowService} from '../../shows/services/show.service';
|
||||||
import {ShowSong} from '../../shows/services/show-song';
|
import {ShowSong} from '../../shows/services/show-song';
|
||||||
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
||||||
import {debounceTime, filter, map} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged, filter, map, switchMap, takeUntil} from 'rxjs/operators';
|
||||||
import {fade} from '../../../animations';
|
import {fade} from '../../../animations';
|
||||||
import {TextRenderingService} from '../../songs/services/text-rendering.service';
|
import {TextRenderingService} from '../../songs/services/text-rendering.service';
|
||||||
import {Section} from '../../songs/services/section';
|
import {Section} from '../../songs/services/section';
|
||||||
import {GlobalSettings} from '../../../services/global-settings';
|
import {LineType} from '../../songs/services/line-type';
|
||||||
|
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';
|
||||||
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
import {MatButton} from '@angular/material/button';
|
||||||
|
import {RouterLink} from '@angular/router';
|
||||||
|
import {FaIconComponent} from '@fortawesome/angular-fontawesome';
|
||||||
|
import {MatSelect} from '@angular/material/select';
|
||||||
|
import {MatOption} from '@angular/material/core';
|
||||||
|
import {MatSlider, MatSliderThumb} from '@angular/material/slider';
|
||||||
|
import {AddSongComponent} from '../../../widget-modules/components/add-song/add-song.component';
|
||||||
|
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
import {SectionTypePipe} from '../../../widget-modules/pipes/section-type-translator/section-type.pipe';
|
||||||
|
|
||||||
export interface PresentationSong {
|
export interface PresentationSong {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -25,8 +39,34 @@ export interface PresentationSong {
|
|||||||
styleUrls: ['./remote.component.less'],
|
styleUrls: ['./remote.component.less'],
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
imports: [
|
||||||
|
CardComponent,
|
||||||
|
MatFormField,
|
||||||
|
MatLabel,
|
||||||
|
MatInput,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
FormsModule,
|
||||||
|
MatButton,
|
||||||
|
RouterLink,
|
||||||
|
FaIconComponent,
|
||||||
|
MatSelect,
|
||||||
|
MatOption,
|
||||||
|
MatSlider,
|
||||||
|
MatSliderThumb,
|
||||||
|
AddSongComponent,
|
||||||
|
AsyncPipe,
|
||||||
|
DatePipe,
|
||||||
|
ShowTypePipe,
|
||||||
|
SectionTypePipe,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class RemoteComponent {
|
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 show: Show | null = null;
|
||||||
public showSongs: ShowSong[] = [];
|
public showSongs: ShowSong[] = [];
|
||||||
public songs$ = this.songService.list$();
|
public songs$ = this.songService.list$();
|
||||||
@@ -35,29 +75,62 @@ export class RemoteComponent {
|
|||||||
public faIcon = faFolderOpen;
|
public faIcon = faFolderOpen;
|
||||||
|
|
||||||
public faDesktop = faDesktop;
|
public faDesktop = faDesktop;
|
||||||
|
public presentationDynamicCaptionChanged$ = new Subject<{presentationDynamicCaption: string; showId: string}>();
|
||||||
|
public presentationDynamicTextChanged$ = new Subject<{presentationDynamicText: string; showId: string}>();
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
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(),
|
||||||
|
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),
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
takeUntil(this.destroy$)
|
||||||
|
);
|
||||||
|
|
||||||
|
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(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();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.presentationDynamicCaptionChanged$
|
||||||
|
.pipe(debounceTime(1000))
|
||||||
|
.subscribe(_ => void this.showService.update$(_.showId, {presentationDynamicCaption: _.presentationDynamicCaption}));
|
||||||
|
this.presentationDynamicTextChanged$.pipe(debounceTime(1000)).subscribe(_ => void this.showService.update$(_.showId, {presentationDynamicText: _.presentationDynamicText}));
|
||||||
|
}
|
||||||
|
|
||||||
public trackBy(index: number, item: PresentationSong): string {
|
public trackBy(index: number, item: PresentationSong): string {
|
||||||
return item.id;
|
return item.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public presentationDynamicCaptionChanged$ = new Subject<{presentationDynamicCaption: string; showId: string}>();
|
|
||||||
|
|
||||||
public onShowChanged(change: string): void {
|
|
||||||
combineLatest([this.showService.read$(change), this.showSongService.list$(change)]).subscribe(([show, list]) => {
|
|
||||||
this.showSongs = list;
|
|
||||||
this.show = show;
|
|
||||||
const presentationSongs = list.map(song => ({
|
|
||||||
id: song.id,
|
|
||||||
title: song.title,
|
|
||||||
sections: this.textRenderingService.parse(song.text, null),
|
|
||||||
}));
|
|
||||||
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
|
|
||||||
this.cRef.markForCheck();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public getFirstLine(section: Section): string {
|
public getFirstLine(section: Section): string {
|
||||||
return section.lines.filter(_ => _.type === 1)[0].text;
|
return section.lines.filter(_ => _.type === LineType.text)[0].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onSectionClick(id: string, index: number, showId: string): Promise<void> {
|
public async onSectionClick(id: string, index: number, showId: string): Promise<void> {
|
||||||
@@ -74,32 +147,6 @@ export class RemoteComponent {
|
|||||||
public async onBackground(presentationBackground: PresentationBackground, showId: string): Promise<void> {
|
public async onBackground(presentationBackground: PresentationBackground, showId: string): Promise<void> {
|
||||||
await this.showService.update$(showId, {presentationBackground});
|
await this.showService.update$(showId, {presentationBackground});
|
||||||
}
|
}
|
||||||
public presentationDynamicTextChanged$ = new Subject<{presentationDynamicText: string; showId: string}>();
|
|
||||||
|
|
||||||
public constructor(
|
|
||||||
private showService: ShowService,
|
|
||||||
private showSongService: ShowSongService,
|
|
||||||
private songService: SongService,
|
|
||||||
private textRenderingService: TextRenderingService,
|
|
||||||
private globalSettingsService: GlobalSettingsService,
|
|
||||||
private cRef: ChangeDetectorRef
|
|
||||||
) {
|
|
||||||
globalSettingsService.get$
|
|
||||||
.pipe(
|
|
||||||
filter(_ => !!_),
|
|
||||||
map(_ => _ as GlobalSettings),
|
|
||||||
map(_ => _.currentShow)
|
|
||||||
)
|
|
||||||
.subscribe(_ => {
|
|
||||||
this.onShowChanged(_);
|
|
||||||
this.cRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.presentationDynamicCaptionChanged$
|
|
||||||
.pipe(debounceTime(1000))
|
|
||||||
.subscribe(_ => void this.showService.update$(_.showId, {presentationDynamicCaption: _.presentationDynamicCaption}));
|
|
||||||
this.presentationDynamicTextChanged$.pipe(debounceTime(1000)).subscribe(_ => void this.showService.update$(_.showId, {presentationDynamicText: _.presentationDynamicText}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public onDynamicCaption(presentationDynamicCaption: string, showId: string): void {
|
public onDynamicCaption(presentationDynamicCaption: string, showId: string): void {
|
||||||
this.presentationDynamicCaptionChanged$.next({presentationDynamicCaption, showId});
|
this.presentationDynamicCaptionChanged$.next({presentationDynamicCaption, showId});
|
||||||
@@ -108,4 +155,9 @@ export class RemoteComponent {
|
|||||||
public onDynamicText(presentationDynamicText: string, showId: string): void {
|
public onDynamicText(presentationDynamicText: string, showId: string): void {
|
||||||
this.presentationDynamicTextChanged$.next({presentationDynamicText, showId});
|
this.presentationDynamicTextChanged$.next({presentationDynamicText, showId});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
<div *ngIf="shows$ | async as shows" @fade>
|
@if (shows$ | async; as shows) {
|
||||||
<app-card heading="Bitte eine Veranstaltung auswählen" *ngIf="visible">
|
<div @fade>
|
||||||
<p *ngIf="!shows.length">
|
@if (visible) {
|
||||||
Es ist derzeit keine Veranstaltung vorhanden
|
<app-card heading="Bitte eine Veranstaltung auswählen">
|
||||||
</p>
|
@if (!shows.length) {
|
||||||
|
<p>
|
||||||
<div *ngIf="shows.length>0" class="list">
|
Es ist derzeit keine Veranstaltung vorhanden
|
||||||
<button mat-stroked-button *ngFor="let show of shows" (click)="selectShow(show)">
|
</p>
|
||||||
<app-user-name [userId]="show.owner"></app-user-name>
|
}
|
||||||
,
|
@if (shows.length>0) {
|
||||||
{{ show.showType | showType }},
|
<div class="list">
|
||||||
{{ show.date.toDate() | date: "dd.MM.yyyy" }}
|
@for (show of shows; track show) {
|
||||||
</button>
|
<button (click)="selectShow(show)" mat-stroked-button>
|
||||||
</div>
|
<app-user-name [userId]="show.owner"></app-user-name>
|
||||||
</app-card>
|
,
|
||||||
</div>
|
{{ show.showType | showType }},
|
||||||
|
{{ show.date.toDate() | date: "dd.MM.yyyy" }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</app-card>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit, inject} from '@angular/core';
|
||||||
import {map} from 'rxjs/operators';
|
import {map} from 'rxjs/operators';
|
||||||
import {ShowService} from '../../shows/services/show.service';
|
import {ShowService} from '../../shows/services/show.service';
|
||||||
import {Show} from '../../shows/services/show';
|
import {Show} from '../../shows/services/show';
|
||||||
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
import {GlobalSettingsService} from '../../../services/global-settings.service';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {fade} from '../../../animations';
|
import {fade} from '../../../animations';
|
||||||
|
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';
|
||||||
|
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-select',
|
selector: 'app-select',
|
||||||
templateUrl: './select.component.html',
|
templateUrl: './select.component.html',
|
||||||
styleUrls: ['./select.component.less'],
|
styleUrls: ['./select.component.less'],
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
|
imports: [CardComponent, MatButton, UserNameComponent, AsyncPipe, DatePipe, ShowTypePipe],
|
||||||
})
|
})
|
||||||
export class SelectComponent implements OnInit {
|
export class SelectComponent implements OnInit {
|
||||||
public constructor(private showService: ShowService, private globalSettingsService: GlobalSettingsService, private router: Router) {}
|
private showService = inject(ShowService);
|
||||||
public visible = false;
|
private globalSettingsService = inject(GlobalSettingsService);
|
||||||
|
private router = inject(Router);
|
||||||
|
|
||||||
|
public visible = false;
|
||||||
public shows$ = this.showService
|
public shows$ = this.showService
|
||||||
.list$(true)
|
.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))));
|
.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))));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe('ArchiveDialogComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ArchiveDialogComponent],
|
imports: [ArchiveDialogComponent],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ArchiveDialogComponent);
|
fixture = TestBed.createComponent(ArchiveDialogComponent);
|
||||||
@@ -17,6 +17,6 @@ describe('ArchiveDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
void expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
|
import {MatDialogActions, MatDialogClose, MatDialogContent} from '@angular/material/dialog';
|
||||||
|
import {MatButton} from '@angular/material/button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-archive-dialog',
|
selector: 'app-archive-dialog',
|
||||||
templateUrl: './archive-dialog.component.html',
|
templateUrl: './archive-dialog.component.html',
|
||||||
styleUrls: ['./archive-dialog.component.less'],
|
styleUrls: ['./archive-dialog.component.less'],
|
||||||
|
imports: [MatDialogContent, MatDialogActions, MatButton, MatDialogClose],
|
||||||
})
|
})
|
||||||
export class ArchiveDialogComponent {}
|
export class ArchiveDialogComponent {}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<div mat-dialog-content>
|
||||||
|
<a [href]="data.url">{{ data.url }}</a>
|
||||||
|
<div [style.background-image]="'url('+qrCode+')'" alt="qrcode" class="qrcode">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div mat-dialog-actions>
|
||||||
|
<button [mat-dialog-close]="true" cdkFocusInitial mat-button>
|
||||||
|
Schließen
|
||||||
|
</button>
|
||||||
|
<button (click)="share()" mat-button>
|
||||||
|
Teilen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.qrcode {
|
||||||
|
width: 300px;
|
||||||
|
height: 300px;
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ShareDialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
void expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import {Component, inject} from '@angular/core';
|
||||||
|
import {MAT_DIALOG_DATA, MatDialogActions, MatDialogClose, MatDialogContent} from '@angular/material/dialog';
|
||||||
|
import {MatButton} from '@angular/material/button';
|
||||||
|
import QRCode from 'qrcode';
|
||||||
|
import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
import {Show} from '../../services/show';
|
||||||
|
|
||||||
|
export interface ShareDialogData {
|
||||||
|
url: string;
|
||||||
|
show: Show;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-share-dialog',
|
||||||
|
imports: [MatButton, MatDialogActions, MatDialogContent, MatDialogClose],
|
||||||
|
templateUrl: './share-dialog.component.html',
|
||||||
|
styleUrl: './share-dialog.component.less',
|
||||||
|
})
|
||||||
|
export class ShareDialogComponent {
|
||||||
|
public data = inject<ShareDialogData>(MAT_DIALOG_DATA);
|
||||||
|
|
||||||
|
public qrCode: string;
|
||||||
|
|
||||||
|
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',
|
||||||
|
quality: 0.92,
|
||||||
|
width: 1280,
|
||||||
|
height: 1280,
|
||||||
|
color: {
|
||||||
|
dark: '#010414',
|
||||||
|
light: '#ffffff',
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return
|
||||||
|
}).then(_ => (this.qrCode = _));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async share() {
|
||||||
|
if (navigator.clipboard) await navigator.clipboard.writeText(this.data.url);
|
||||||
|
|
||||||
|
if (navigator.share)
|
||||||
|
await navigator.share({
|
||||||
|
title: new ShowTypePipe().transform(this.data.show.showType),
|
||||||
|
text: new ShowTypePipe().transform(this.data.show.showType) + ' am ' + this.data.show.date.toDate().toLocaleString('de'),
|
||||||
|
url: this.data.url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,20 +5,26 @@
|
|||||||
<mat-label>Art der Veranstaltung</mat-label>
|
<mat-label>Art der Veranstaltung</mat-label>
|
||||||
<mat-select formControlName="showType">
|
<mat-select formControlName="showType">
|
||||||
<mat-optgroup label="öffentlich">
|
<mat-optgroup label="öffentlich">
|
||||||
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
|
@for (key of showTypePublic; track key) {
|
||||||
key | showType
|
<mat-option [value]="key">{{
|
||||||
}}</mat-option>
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
</mat-optgroup>
|
</mat-optgroup>
|
||||||
<mat-optgroup label="privat">
|
<mat-optgroup label="privat">
|
||||||
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
|
@for (key of showTypePrivate; track key) {
|
||||||
key | showType
|
<mat-option [value]="key">{{
|
||||||
}}</mat-option>
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
</mat-optgroup>
|
</mat-optgroup>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Datum</mat-label>
|
<mat-label>Datum</mat-label>
|
||||||
<input [matDatepicker]="picker" formControlName="date" matInput/>
|
<input [matDatepicker]="picker" formControlName="date" matInput />
|
||||||
<mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
|
<mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
|
||||||
<mat-datepicker #picker touchUi></mat-datepicker>
|
<mat-datepicker #picker touchUi></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|||||||
@@ -1,19 +1,51 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit, inject} from '@angular/core';
|
||||||
import {ShowDataService} from '../services/show-data.service';
|
import {ShowDataService} from '../services/show-data.service';
|
||||||
import {Observable, take} from 'rxjs';
|
import {Observable, take} from 'rxjs';
|
||||||
import {Show} from '../services/show';
|
import {Show} from '../services/show';
|
||||||
import {ShowService} from '../services/show.service';
|
import {ShowService} from '../services/show.service';
|
||||||
import {FormControl, FormGroup, Validators} from '@angular/forms';
|
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
||||||
import {map, switchMap} from 'rxjs/operators';
|
import {map, switchMap} from 'rxjs/operators';
|
||||||
|
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 {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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-edit',
|
selector: 'app-edit',
|
||||||
templateUrl: './edit.component.html',
|
templateUrl: './edit.component.html',
|
||||||
styleUrls: ['./edit.component.less'],
|
styleUrls: ['./edit.component.less'],
|
||||||
|
imports: [
|
||||||
|
CardComponent,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
MatFormField,
|
||||||
|
MatLabel,
|
||||||
|
MatSelect,
|
||||||
|
MatOptgroup,
|
||||||
|
MatOption,
|
||||||
|
MatInput,
|
||||||
|
MatDatepickerInput,
|
||||||
|
MatDatepickerToggle,
|
||||||
|
MatSuffix,
|
||||||
|
MatDatepicker,
|
||||||
|
ButtonRowComponent,
|
||||||
|
ButtonComponent,
|
||||||
|
ShowTypePipe,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class EditComponent implements OnInit {
|
export class EditComponent implements OnInit {
|
||||||
|
private showService = inject(ShowService);
|
||||||
|
private router = inject(Router);
|
||||||
|
private activatedRoute = inject(ActivatedRoute);
|
||||||
|
|
||||||
public shows$: Observable<Show[]>;
|
public shows$: Observable<Show[]>;
|
||||||
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
||||||
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
||||||
@@ -24,7 +56,9 @@ export class EditComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
public faSave = faSave;
|
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$;
|
this.shows$ = showDataService.list$;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,13 +87,10 @@ export class EditComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.showService.update$(
|
await this.showService.update$(this.form.value.id, {
|
||||||
this.form.value.id as string,
|
date: Timestamp.fromDate(this.form.value.date),
|
||||||
{
|
showType: this.form.value.showType,
|
||||||
date: this.form.value.date,
|
} as Partial<Show>);
|
||||||
showType: this.form.value.showType,
|
|
||||||
} as Partial<Show>
|
|
||||||
);
|
|
||||||
await this.router.navigateByUrl(`/shows/${this.form.value.id ?? ''}`);
|
await this.router.navigateByUrl(`/shows/${this.form.value.id ?? ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
export interface FilterValues {
|
export interface FilterValues {
|
||||||
time: number;
|
time: number;
|
||||||
|
owner: string;
|
||||||
|
showType: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,52 @@
|
|||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Zeitraum</mat-label>
|
<mat-label>Zeitraum</mat-label>
|
||||||
<mat-select formControlName="time">
|
<mat-select formControlName="time">
|
||||||
<mat-option *ngFor="let time of times" [value]="time.key">{{
|
@for (time of times; track time) {
|
||||||
time.value
|
<mat-option [value]="time.key">{{
|
||||||
}}</mat-option>
|
time.value
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Ersteller</mat-label>
|
||||||
|
<mat-select formControlName="owner">
|
||||||
|
<mat-option [value]="null">Alle</mat-option>
|
||||||
|
@for (owner of owners; track owner) {
|
||||||
|
<mat-option [value]="owner.key">{{
|
||||||
|
owner.value
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Art der Veranstaltung</mat-label>
|
||||||
|
<mat-select formControlName="showType">
|
||||||
|
<mat-option [value]="null">Alle</mat-option>
|
||||||
|
<mat-optgroup label="öffentlich">
|
||||||
|
@for (key of showTypePublic; track key) {
|
||||||
|
<mat-option [value]="key">{{
|
||||||
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-optgroup>
|
||||||
|
<mat-optgroup label="privat">
|
||||||
|
@for (key of showTypePrivate; track key) {
|
||||||
|
<mat-option [value]="key">{{
|
||||||
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-optgroup>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<i>Anzahl der Suchergebnisse: {{ shows.length }}</i>
|
<i>Anzahl der Suchergebnisse: {{ shows?.length ?? 0 }}</i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.third {
|
.third {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
column-gap: 20px;
|
column-gap: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe('FilterComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [FilterComponent],
|
imports: [FilterComponent],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,6 +19,6 @@ describe('FilterComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
void expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input, inject} from '@angular/core';
|
||||||
import {KeyValue} from '@angular/common';
|
import {KeyValue} from '@angular/common';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
|
import {ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
|
||||||
import {FilterValues} from './filter-values';
|
import {FilterValues} from './filter-values';
|
||||||
import {Show} from '../../services/show';
|
import {Show} from '../../services/show';
|
||||||
|
import {ShowService} from '../../services/show.service';
|
||||||
|
import {distinctUntilChanged, map, 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 {MatFormField, MatLabel} from '@angular/material/form-field';
|
||||||
|
import {MatSelect} from '@angular/material/select';
|
||||||
|
import {MatOptgroup, MatOption} from '@angular/material/core';
|
||||||
|
import {ShowTypePipe} from '../../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-filter',
|
selector: 'app-filter',
|
||||||
templateUrl: './filter.component.html',
|
templateUrl: './filter.component.html',
|
||||||
styleUrls: ['./filter.component.less'],
|
styleUrls: ['./filter.component.less'],
|
||||||
|
imports: [ReactiveFormsModule, MatFormField, MatLabel, MatSelect, MatOption, MatOptgroup, ShowTypePipe],
|
||||||
})
|
})
|
||||||
export class FilterComponent {
|
export class FilterComponent {
|
||||||
|
private router = inject(Router);
|
||||||
|
private showService = inject(ShowService);
|
||||||
|
private userService = inject(UserService);
|
||||||
|
|
||||||
@Input() public route = '/shows/';
|
@Input() public route = '/shows/';
|
||||||
@Input() public shows: Show[] = [];
|
@Input() public shows: Show[] = [];
|
||||||
|
|
||||||
|
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
||||||
|
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
||||||
|
|
||||||
public filterFormGroup: UntypedFormGroup;
|
public filterFormGroup: UntypedFormGroup;
|
||||||
public times: KeyValue<number, string>[] = [
|
public times: KeyValue<number, string>[] = [
|
||||||
{key: 1, value: 'letzter Monat'},
|
{key: 1, value: 'letzter Monat'},
|
||||||
@@ -22,24 +39,77 @@ export class FilterComponent {
|
|||||||
{key: 99999, value: 'alle'},
|
{key: 99999, value: 'alle'},
|
||||||
];
|
];
|
||||||
|
|
||||||
public constructor(private router: Router, activatedRoute: ActivatedRoute, fb: UntypedFormBuilder) {
|
public owners: {key: string; value: string}[] = [];
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
const activatedRoute = inject(ActivatedRoute);
|
||||||
|
const fb = inject(UntypedFormBuilder);
|
||||||
|
|
||||||
this.filterFormGroup = fb.group({
|
this.filterFormGroup = fb.group({
|
||||||
time: 1,
|
time: 1,
|
||||||
|
owner: null,
|
||||||
|
showType: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
activatedRoute.queryParams.subscribe(params => {
|
activatedRoute.queryParams.subscribe(params => {
|
||||||
const filterValues = params as FilterValues;
|
const filterValues = params as FilterValues;
|
||||||
if (filterValues.time) this.filterFormGroup.controls.time.setValue(+filterValues.time);
|
if (filterValues.time) this.filterFormGroup.controls.time.setValue(+filterValues.time);
|
||||||
|
this.filterFormGroup.controls.owner.setValue(filterValues.owner ?? null, {emitEvent: false});
|
||||||
|
this.filterFormGroup.controls.showType.setValue(filterValues.showType ?? null, {emitEvent: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filterFormGroup.controls.time.valueChanges.subscribe(_ => void this.filerValueChanged('time', _ as number));
|
this.filterFormGroup.controls.time.valueChanges.subscribe(_ => void this.filerValueChanged('time', _ as number));
|
||||||
|
this.filterFormGroup.controls.owner.valueChanges.subscribe(_ => void this.filerValueChanged('owner', _ as string));
|
||||||
|
this.filterFormGroup.controls.showType.valueChanges.subscribe(_ => void this.filerValueChanged('showType', _ as string));
|
||||||
|
|
||||||
|
this.owners$().subscribe(owners => (this.owners = owners));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public owners$ = (): Observable<{key: string; value: string}[]> => {
|
||||||
|
return this.showService.list$().pipe(
|
||||||
|
map(shows =>
|
||||||
|
shows
|
||||||
|
.map(show => show.owner)
|
||||||
|
.filter(onlyUnique)
|
||||||
|
.filter((ownerId): ownerId is string => !!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: user?.name,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
map(owners => {
|
||||||
|
return owners.sort(dynamicSort('value'));
|
||||||
|
}),
|
||||||
|
distinctUntilChanged((left, right) => this.sameOwners(left, right)),
|
||||||
|
map(_ => _ as {key: string; value: string}[])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
private async filerValueChanged<T>(key: string, value: T): Promise<void> {
|
private async filerValueChanged<T>(key: string, value: T): Promise<void> {
|
||||||
const route = this.router.createUrlTree([this.route], {
|
const route = this.router.createUrlTree([this.route], {
|
||||||
queryParams: {[key]: value},
|
queryParams: {[key]: value || null},
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
});
|
});
|
||||||
await this.router.navigateByUrl(route);
|
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,5 +1,9 @@
|
|||||||
<div class="list-item" *ngIf="show">
|
@if (show) {
|
||||||
<div>{{ show.date.toDate() | date: "dd.MM.yyyy" }}</div>
|
<div class="list-item">
|
||||||
<div><app-user-name [userId]="show.owner"></app-user-name></div>
|
<div>{{ show.date.toDate() | date: "dd.MM.yyyy" }}</div>
|
||||||
<div>{{ show.showType | showType }}</div>
|
<div>
|
||||||
</div>
|
<app-user-name [userId]="show.owner"></app-user-name>
|
||||||
|
</div>
|
||||||
|
<div>{{ show.showType | showType }}</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
@import "../../../../../styles/styles";
|
|
||||||
|
|
||||||
.list-item {
|
.list-item {
|
||||||
padding: 5px 20px;
|
padding: 5px 20px;
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -12,10 +10,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: var(--transition);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: @primary-color;
|
background: var(--hover-background);
|
||||||
color: #fff;
|
color: var(--text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('ListItemComponent', () => {
|
|||||||
let component: ListItemComponent;
|
let component: ListItemComponent;
|
||||||
let fixture: ComponentFixture<ListItemComponent>;
|
let fixture: ComponentFixture<ListItemComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [ListItemComponent],
|
||||||
declarations: [ListItemComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ListItemComponent);
|
fixture = TestBed.createComponent(ListItemComponent);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {Show} from '../../services/show';
|
import {Show} from '../../services/show';
|
||||||
|
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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-list-item',
|
selector: 'app-list-item',
|
||||||
templateUrl: './list-item.component.html',
|
templateUrl: './list-item.component.html',
|
||||||
styleUrls: ['./list-item.component.less'],
|
styleUrls: ['./list-item.component.less'],
|
||||||
|
imports: [UserNameComponent, DatePipe, ShowTypePipe],
|
||||||
})
|
})
|
||||||
export class ListItemComponent {
|
export class ListItemComponent {
|
||||||
@Input() public show: Show | null = null;
|
@Input() public show: Show | null = null;
|
||||||
|
|||||||
@@ -1,36 +1,42 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- <app-list-header *appRole="['leader']"></app-list-header>-->
|
<!-- <app-list-header *appRole="['leader']"></app-list-header>-->
|
||||||
<app-list-header *appRole="['leader']">
|
<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>
|
</app-list-header>
|
||||||
|
|
||||||
<ng-container *appRole="['leader']">
|
<ng-container *appRole="['leader']">
|
||||||
<ng-container *ngIf="privateShows$ | async as shows">
|
@if (privateShows$ | async; as shows) {
|
||||||
<app-card
|
@if (shows.length > 0) {
|
||||||
*ngIf="shows.length > 0"
|
<app-card
|
||||||
[padding]="false"
|
[padding]="false"
|
||||||
heading="meine Veranstaltungen"
|
heading="Meine Veranstaltungen"
|
||||||
>
|
>
|
||||||
<app-list-item
|
@for (show of shows | sortBy: 'desc':'date'; track show) {
|
||||||
*ngFor="let show of shows | sortBy: 'desc':'date'"
|
<app-list-item
|
||||||
[routerLink]="show.id"
|
[routerLink]="show.id"
|
||||||
[show]="show"
|
[show]="show"
|
||||||
></app-list-item>
|
></app-list-item>
|
||||||
</app-card>
|
}
|
||||||
</ng-container>
|
</app-card>
|
||||||
|
}
|
||||||
|
}
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngIf="publicShows$ | async as shows">
|
@if (publicShows$ | async; as shows) {
|
||||||
<app-card
|
@if (shows.length > 0) {
|
||||||
*ngIf="shows.length > 0"
|
<app-card
|
||||||
[padding]="false"
|
[padding]="false"
|
||||||
heading="veröffentlichte Veranstaltungen"
|
heading="Veröffentlichte Veranstaltungen"
|
||||||
>
|
>
|
||||||
<app-list-item
|
@for (show of shows | sortBy: 'desc':'date'; track trackBy($index, show)) {
|
||||||
*ngFor="let show of shows | sortBy: 'desc':'date'; trackBy: trackBy"
|
<app-list-item
|
||||||
[routerLink]="show.id"
|
[routerLink]="show.id"
|
||||||
[show]="show"
|
[show]="show"
|
||||||
></app-list-item>
|
></app-list-item>
|
||||||
</app-card>
|
}
|
||||||
</ng-container>
|
</app-card>
|
||||||
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('ListComponent', () => {
|
|||||||
let component: ListComponent;
|
let component: ListComponent;
|
||||||
let fixture: ComponentFixture<ListComponent>;
|
let fixture: ComponentFixture<ListComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [ListComponent],
|
||||||
declarations: [ListComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ListComponent);
|
fixture = TestBed.createComponent(ListComponent);
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component, inject} from '@angular/core';
|
||||||
import {combineLatest} from 'rxjs';
|
import {combineLatest} from 'rxjs';
|
||||||
import {Show} from '../services/show';
|
import {Show} from '../services/show';
|
||||||
import {fade} from '../../../animations';
|
import {fade} from '../../../animations';
|
||||||
import {ShowService} from '../services/show.service';
|
import {ShowService} from '../services/show.service';
|
||||||
import {FilterValues} from './filter/filter-values';
|
import {FilterValues} from './filter/filter-values';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute, RouterLink} from '@angular/router';
|
||||||
import {map} from 'rxjs/operators';
|
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} 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';
|
||||||
|
import {SortByPipe} from '../../../widget-modules/pipes/sort-by/sort-by.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-list',
|
selector: 'app-list',
|
||||||
templateUrl: './list.component.html',
|
templateUrl: './list.component.html',
|
||||||
styleUrls: ['./list.component.less'],
|
styleUrls: ['./list.component.less'],
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
|
imports: [RoleDirective, ListHeaderComponent, FilterComponent, CardComponent, ListItemComponent, RouterLink, AsyncPipe, SortByPipe],
|
||||||
})
|
})
|
||||||
export class ListComponent {
|
export class ListComponent {
|
||||||
public shows$ = this.showService.list$();
|
private showService = inject(ShowService);
|
||||||
public privateShows$ = this.showService.list$().pipe(map(show => show.filter(_ => !_.published)));
|
private activatedRoute = inject(ActivatedRoute);
|
||||||
|
|
||||||
public lastMonths$ = this.activatedRoute.queryParams.pipe(
|
public lastMonths$ = this.activatedRoute.queryParams.pipe(
|
||||||
map(params => {
|
map(params => {
|
||||||
const filterValues = params as FilterValues;
|
const filterValues = params as FilterValues;
|
||||||
@@ -23,18 +32,37 @@ export class ListComponent {
|
|||||||
return +filterValues.time;
|
return +filterValues.time;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
public owner$ = this.activatedRoute.queryParams.pipe(
|
||||||
public publicShows$ = combineLatest([this.shows$, this.lastMonths$]).pipe(
|
map(params => {
|
||||||
map(_ =>
|
const filterValues = params as FilterValues;
|
||||||
_[0].filter(f => {
|
return filterValues?.owner;
|
||||||
const d = new Date();
|
})
|
||||||
d.setMonth(d.getMonth() - _[1]);
|
|
||||||
return f.published && f.date.toDate() >= d;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
public showType$ = this.activatedRoute.queryParams.pipe(
|
||||||
|
map(params => {
|
||||||
|
const filterValues = params as FilterValues;
|
||||||
|
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();
|
||||||
|
startDate.setHours(0, 0, 0, 0);
|
||||||
|
startDate.setDate(startDate.getDate() - lastMonths * 30);
|
||||||
|
|
||||||
public constructor(private showService: ShowService, private activatedRoute: ActivatedRoute) {}
|
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);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
public trackBy = (index: number, show: unknown) => (show as Show).id;
|
public trackBy = (index: number, show: unknown) => (show as Show).id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,20 +5,26 @@
|
|||||||
<mat-label>Art der Veranstaltung</mat-label>
|
<mat-label>Art der Veranstaltung</mat-label>
|
||||||
<mat-select formControlName="showType">
|
<mat-select formControlName="showType">
|
||||||
<mat-optgroup label="öffentlich">
|
<mat-optgroup label="öffentlich">
|
||||||
<mat-option *ngFor="let key of showTypePublic" [value]="key">{{
|
@for (key of showTypePublic; track key) {
|
||||||
key | showType
|
<mat-option [value]="key">{{
|
||||||
}}</mat-option>
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
</mat-optgroup>
|
</mat-optgroup>
|
||||||
<mat-optgroup label="privat">
|
<mat-optgroup label="privat">
|
||||||
<mat-option *ngFor="let key of showTypePrivate" [value]="key">{{
|
@for (key of showTypePrivate; track key) {
|
||||||
key | showType
|
<mat-option [value]="key">{{
|
||||||
}}</mat-option>
|
key | showType
|
||||||
|
}}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
</mat-optgroup>
|
</mat-optgroup>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Datum</mat-label>
|
<mat-label>Datum</mat-label>
|
||||||
<input [matDatepicker]="picker" formControlName="date" matInput/>
|
<input [matDatepicker]="picker" formControlName="date" matInput />
|
||||||
<mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
|
<mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
|
||||||
<mat-datepicker #picker touchUi></mat-datepicker>
|
<mat-datepicker #picker touchUi></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('NewComponent', () => {
|
|||||||
let component: NewComponent;
|
let component: NewComponent;
|
||||||
let fixture: ComponentFixture<NewComponent>;
|
let fixture: ComponentFixture<NewComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [NewComponent],
|
||||||
declarations: [NewComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(NewComponent);
|
fixture = TestBed.createComponent(NewComponent);
|
||||||
|
|||||||
@@ -1,18 +1,48 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit, inject} from '@angular/core';
|
||||||
import {ShowDataService} from '../services/show-data.service';
|
import {ShowDataService} from '../services/show-data.service';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {Show} from '../services/show';
|
import {Show} from '../services/show';
|
||||||
import {ShowService} from '../services/show.service';
|
import {ShowService} from '../services/show.service';
|
||||||
import {UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
import {ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
import {faSave} from '@fortawesome/free-solid-svg-icons';
|
||||||
|
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 {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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new',
|
selector: 'app-new',
|
||||||
templateUrl: './new.component.html',
|
templateUrl: './new.component.html',
|
||||||
styleUrls: ['./new.component.less'],
|
styleUrls: ['./new.component.less'],
|
||||||
|
imports: [
|
||||||
|
CardComponent,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
MatFormField,
|
||||||
|
MatLabel,
|
||||||
|
MatSelect,
|
||||||
|
MatOptgroup,
|
||||||
|
MatOption,
|
||||||
|
MatInput,
|
||||||
|
MatDatepickerInput,
|
||||||
|
MatDatepickerToggle,
|
||||||
|
MatSuffix,
|
||||||
|
MatDatepicker,
|
||||||
|
ButtonRowComponent,
|
||||||
|
ButtonComponent,
|
||||||
|
ShowTypePipe,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class NewComponent implements OnInit {
|
export class NewComponent implements OnInit {
|
||||||
|
private showService = inject(ShowService);
|
||||||
|
private router = inject(Router);
|
||||||
|
|
||||||
public shows$: Observable<Show[]>;
|
public shows$: Observable<Show[]>;
|
||||||
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
public showTypePublic = ShowService.SHOW_TYPE_PUBLIC;
|
||||||
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
public showTypePrivate = ShowService.SHOW_TYPE_PRIVATE;
|
||||||
@@ -22,7 +52,9 @@ export class NewComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
public faSave = faSave;
|
public faSave = faSave;
|
||||||
|
|
||||||
public constructor(private showService: ShowService, showDataService: ShowDataService, private router: Router) {
|
public constructor() {
|
||||||
|
const showDataService = inject(ShowDataService);
|
||||||
|
|
||||||
this.shows$ = showDataService.list$;
|
this.shows$ = showDataService.list$;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable, inject} from '@angular/core';
|
||||||
import {Document, HeadingLevel, ISectionOptions, Packer, Paragraph} from 'docx';
|
import {Document, HeadingLevel, ISectionOptions, Packer, Paragraph} from 'docx';
|
||||||
import {ShowService} from './show.service';
|
import {ShowService} from './show.service';
|
||||||
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
import {ShowSongService} from './show-song.service';
|
import {ShowSongService} from './show-song.service';
|
||||||
import {Song} from '../../songs/services/song';
|
import {Song} from '../../songs/services/song';
|
||||||
import {SongService} from '../../songs/services/song.service';
|
|
||||||
import {ShowSong} from './show-song';
|
import {ShowSong} from './show-song';
|
||||||
import {Show} from './show';
|
import {Show} from './show';
|
||||||
import {ChordMode} from '../../../widget-modules/components/song-text/song-text.component';
|
import {ChordMode} from '../../../widget-modules/components/song-text/song-text.component';
|
||||||
@@ -27,14 +26,11 @@ export interface DownloadOptions {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class DocxService {
|
export class DocxService {
|
||||||
public constructor(
|
private showService = inject(ShowService);
|
||||||
private showService: ShowService,
|
private showSongService = inject(ShowSongService);
|
||||||
private showSongService: ShowSongService,
|
private textRenderingService = inject(TextRenderingService);
|
||||||
private songService: SongService,
|
private userService = inject(UserService);
|
||||||
private textRenderingService: TextRenderingService,
|
private configService = inject(ConfigService);
|
||||||
private userService: UserService,
|
|
||||||
private configService: ConfigService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public async create(showId: string, options: DownloadOptions = {}): Promise<void> {
|
public async create(showId: string, options: DownloadOptions = {}): Promise<void> {
|
||||||
const data = await this.prepareData(showId);
|
const data = await this.prepareData(showId);
|
||||||
@@ -94,7 +90,14 @@ export class DocxService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderSongs(songs: {showSong: ShowSong; sections: Section[]}[], options: DownloadOptions, config: Config): Paragraph[] {
|
private renderSongs(
|
||||||
|
songs: {
|
||||||
|
showSong: ShowSong;
|
||||||
|
sections: Section[];
|
||||||
|
}[],
|
||||||
|
options: DownloadOptions,
|
||||||
|
config: Config
|
||||||
|
): Paragraph[] {
|
||||||
return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []);
|
return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,18 +192,26 @@ export class DocxService {
|
|||||||
if (!config) return null;
|
if (!config) return null;
|
||||||
|
|
||||||
const showSongs = await this.showSongService.list(showId);
|
const showSongs = await this.showSongService.list(showId);
|
||||||
const songsAsync = showSongs.map(showSong => {
|
const songsLoaded = showSongs
|
||||||
const sections = this.textRenderingService.parse(showSong.text, {
|
.map(showSong => {
|
||||||
baseKey: showSong.keyOriginal,
|
const sections = this.textRenderingService.parse(showSong.text, {
|
||||||
targetKey: showSong.key,
|
baseKey: showSong.keyOriginal,
|
||||||
});
|
targetKey: showSong.key,
|
||||||
return {
|
});
|
||||||
showSong,
|
return {
|
||||||
sections,
|
showSong,
|
||||||
};
|
sections,
|
||||||
});
|
};
|
||||||
const songsLoaded = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as {showSong: ShowSong; sections: Section[]});
|
})
|
||||||
const songs = show.order.map(_ => songsLoaded.filter(f => f.showSong.id === _)[0]);
|
.filter(_ => !!_)
|
||||||
|
.map(
|
||||||
|
_ =>
|
||||||
|
_ as {
|
||||||
|
showSong: ShowSong;
|
||||||
|
sections: Section[];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const songs = show.order.map(_ => songsLoaded.find(f => f.showSong.id === _)).filter(_ => !!_);
|
||||||
return {songs, show, user, config};
|
return {songs, show, user, config};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,115 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
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';
|
import {ShowDataService} from './show-data.service';
|
||||||
|
|
||||||
describe('ShowDataService', () => {
|
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', () => {
|
it('should be created', () => {
|
||||||
const service: ShowDataService = TestBed.inject(ShowDataService);
|
expect(service).toBeTruthy();
|
||||||
void 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,24 +1,47 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable, inject} from '@angular/core';
|
||||||
import {BehaviorSubject, Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {DbService} from '../../../services/db.service';
|
import {DbService} from '../../../services/db.service';
|
||||||
import {Show} from './show';
|
import {Show} from './show';
|
||||||
import {map} from 'rxjs/operators';
|
import {map, shareReplay} from 'rxjs/operators';
|
||||||
|
import {orderBy, QueryConstraint, Timestamp, where} from 'firebase/firestore';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ShowDataService {
|
export class ShowDataService {
|
||||||
private collection = 'shows';
|
private dbService = inject(DbService);
|
||||||
|
|
||||||
public constructor(private dbService: DbService) {
|
private collection = 'shows';
|
||||||
this.dbService.col$<Show>(this.collection).subscribe(_ => this.list$.next(_));
|
public list$: Observable<Show[]> = this.dbService.col$<Show>(this.collection).pipe(
|
||||||
|
// server-side ordering cuts client work and keeps stable order across subscribers
|
||||||
|
map(shows => [...shows].sort((a, b) => a.date.toMillis() - b.date.toMillis())),
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
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 = Timestamp.fromDate(startDate);
|
||||||
|
|
||||||
|
const queryConstraints: QueryConstraint[] = [where('published', '==', true), where('date', '>=', startTimestamp), orderBy('date', 'desc')];
|
||||||
|
|
||||||
|
return this.dbService.col$<Show>(this.collection, queryConstraints).pipe(
|
||||||
|
map(shows => shows.filter(show => !show.archived)),
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public list$ = new BehaviorSubject<Show[]>([]);
|
public read$ = (showId: string): Observable<Show | null> => this.dbService.doc$(`${this.collection}/${showId}`);
|
||||||
public read$ = (showId: string): Observable<Show | null> => this.list$.pipe(map(_ => _.find(s => s.id === showId) || null));
|
|
||||||
|
|
||||||
// public list$ = (): Observable<Show[]> => this.dbService.col$(this.collection);
|
|
||||||
// public read$ = (showId: string): Observable<Show | null> => this.dbService.doc$(`${this.collection}/${showId}`);
|
|
||||||
public update = async (showId: string, data: Partial<Show>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}`).update(data);
|
public update = async (showId: string, data: Partial<Show>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}`).update(data);
|
||||||
public add = async (data: Partial<Show>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
|
public add = async (data: Partial<Show>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,98 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {of} from 'rxjs';
|
||||||
|
import {DbService} from '../../../services/db.service';
|
||||||
import {ShowSongDataService} from './show-song-data.service';
|
import {ShowSongDataService} from './show-song-data.service';
|
||||||
|
|
||||||
describe('ShowSongDataService', () => {
|
describe('ShowSongDataService', () => {
|
||||||
let service: 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(() => {
|
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);
|
service = TestBed.inject(ShowSongDataService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be created', () => {
|
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,19 +1,41 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable, inject} from '@angular/core';
|
||||||
import {DbService} from '../../../services/db.service';
|
import {DbService} from '../../../services/db.service';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {ShowSong} from './show-song';
|
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({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ShowSongDataService {
|
export class ShowSongDataService {
|
||||||
|
private dbService = inject(DbService);
|
||||||
|
|
||||||
private collection = 'shows';
|
private collection = 'shows';
|
||||||
private subCollection = 'songs';
|
private subCollection = 'songs';
|
||||||
|
private listCache = new Map<string, Observable<ShowSong[]>>();
|
||||||
|
|
||||||
public constructor(private dbService: DbService) {}
|
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);
|
||||||
|
if (cached) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream$ = this.dbService.col$<ShowSong>(`${this.collection}/${showId}/${this.subCollection}`).pipe(
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.listCache.set(showId, stream$);
|
||||||
|
return stream$;
|
||||||
|
};
|
||||||
|
|
||||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
|
||||||
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
||||||
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> =>
|
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> =>
|
||||||
await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).update(data);
|
await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).update(data);
|
||||||
|
|||||||
@@ -1,16 +1,131 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
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';
|
import {ShowSongService} from './show-song.service';
|
||||||
|
|
||||||
describe('ShowSongService', () => {
|
describe('ShowSongService', () => {
|
||||||
let service: 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(() => {
|
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);
|
service = TestBed.inject(ShowSongService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be created', () => {
|
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 {ShowSongDataService} from './show-song-data.service';
|
||||||
import {firstValueFrom, Observable} from 'rxjs';
|
import {firstValueFrom, Observable} from 'rxjs';
|
||||||
import {ShowSong} from './show-song';
|
import {ShowSong} from './show-song';
|
||||||
@@ -10,12 +10,10 @@ import {ShowService} from './show.service';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ShowSongService {
|
export class ShowSongService {
|
||||||
public constructor(
|
private showSongDataService = inject(ShowSongDataService);
|
||||||
private showSongDataService: ShowSongDataService,
|
private songDataService = inject(SongDataService);
|
||||||
private songDataService: SongDataService,
|
private userService = inject(UserService);
|
||||||
private userService: UserService,
|
private showService = inject(ShowService);
|
||||||
private showService: ShowService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public async new$(showId: string, songId: string, addedLive = false): Promise<string | null> {
|
public async new$(showId: string, songId: string, addedLive = false): Promise<string | null> {
|
||||||
const song = await firstValueFrom(this.songDataService.read$(songId));
|
const song = await firstValueFrom(this.songDataService.read$(songId));
|
||||||
@@ -29,6 +27,7 @@ export class ShowSongService {
|
|||||||
chordMode: user.chordMode,
|
chordMode: user.chordMode,
|
||||||
addedLive,
|
addedLive,
|
||||||
};
|
};
|
||||||
|
await this.userService.incSongCount(songId);
|
||||||
return await this.showSongDataService.add(showId, data);
|
return await this.showSongDataService.add(showId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +37,15 @@ export class ShowSongService {
|
|||||||
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId);
|
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId);
|
||||||
public list = (showId: string): Promise<ShowSong[]> => firstValueFrom(this.list$(showId));
|
public list = (showId: string): Promise<ShowSong[]> => firstValueFrom(this.list$(showId));
|
||||||
|
|
||||||
public async delete$(showId: string, songId: string, index: number): Promise<void> {
|
public async delete$(showId: string, showSongId: string, index: number): Promise<void> {
|
||||||
await this.showSongDataService.delete(showId, songId);
|
const [showSong, show] = await Promise.all([this.read(showId, showSongId), firstValueFrom(this.showService.read$(showId))]);
|
||||||
const show = await firstValueFrom(this.showService.read$(showId));
|
|
||||||
if (!show) return;
|
if (!show) return;
|
||||||
const order = show.order;
|
if (!showSong) return;
|
||||||
|
|
||||||
|
const order = [...show.order];
|
||||||
order.splice(index, 1);
|
order.splice(index, 1);
|
||||||
await this.showService.update$(showId, {order});
|
|
||||||
|
await Promise.all([this.showSongDataService.delete(showId, showSongId), this.showService.update$(showId, {order}), this.userService.decSongCount(showSong.songId)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
|
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
|
||||||
|
|||||||
@@ -1,27 +1,102 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {BehaviorSubject, of} from 'rxjs';
|
||||||
import {ShowService} from './show.service';
|
|
||||||
import {ShowDataService} from './show-data.service';
|
import {ShowDataService} from './show-data.service';
|
||||||
|
import {ShowService} from './show.service';
|
||||||
|
import {UserService} from '../../../services/user/user.service';
|
||||||
|
|
||||||
describe('ShowService', () => {
|
describe('ShowService', () => {
|
||||||
const mockShowDataService = {add: Promise.resolve(null)};
|
let service: ShowService;
|
||||||
beforeEach(
|
let showDataServiceSpy: jasmine.SpyObj<ShowDataService>;
|
||||||
() =>
|
let user$: BehaviorSubject<unknown>;
|
||||||
void TestBed.configureTestingModule({
|
const shows = [
|
||||||
providers: [{provide: ShowDataService, useValue: mockShowDataService}],
|
{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: 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 => {
|
ShowService.SHOW_TYPE_PUBLIC.forEach(type => {
|
||||||
it('should calc public flag for ' + type, async () => {
|
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});
|
const id = await service.new$({showType: type});
|
||||||
|
|
||||||
void expect(id).toBe('id');
|
expect(id).toBe('new-show-id');
|
||||||
void expect(addSpy).toHaveBeenCalledWith({
|
expect(showDataServiceSpy.add).toHaveBeenCalledWith({
|
||||||
showType: type,
|
showType: type,
|
||||||
|
owner: 'user-1',
|
||||||
|
order: [],
|
||||||
public: true,
|
public: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -29,14 +104,13 @@ describe('ShowService', () => {
|
|||||||
|
|
||||||
ShowService.SHOW_TYPE_PRIVATE.forEach(type => {
|
ShowService.SHOW_TYPE_PRIVATE.forEach(type => {
|
||||||
it('should calc private flag for ' + type, async () => {
|
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});
|
const id = await service.new$({showType: type});
|
||||||
|
|
||||||
void expect(id).toBe('id');
|
expect(id).toBe('new-show-id');
|
||||||
void expect(addSpy).toHaveBeenCalledWith({
|
expect(showDataServiceSpy.add).toHaveBeenCalledWith({
|
||||||
showType: type,
|
showType: type,
|
||||||
|
owner: 'user-1',
|
||||||
|
order: [],
|
||||||
public: false,
|
public: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable, inject} from '@angular/core';
|
||||||
import {ShowDataService} from './show-data.service';
|
import {ShowDataService} from './show-data.service';
|
||||||
import {Show} from './show';
|
import {Show} from './show';
|
||||||
import {Observable} from 'rxjs';
|
import {firstValueFrom, Observable} from 'rxjs';
|
||||||
import {UserService} from '../../../services/user/user.service';
|
import {UserService} from '../../../services/user/user.service';
|
||||||
import {map, switchMap} from 'rxjs/operators';
|
import {map, switchMap} from 'rxjs/operators';
|
||||||
import {User} from '../../../services/user/user';
|
import {User} from '../../../services/user/user';
|
||||||
@@ -10,16 +10,15 @@ import {User} from '../../../services/user/user';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ShowService {
|
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 = ['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_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'];
|
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 read$ = (showId: string): Observable<Show | null> => this.showDataService.read$(showId);
|
||||||
|
public listPublicSince$ = (lastMonths: number): Observable<Show[]> => this.showDataService.listPublicSince$(lastMonths);
|
||||||
|
|
||||||
public list$(publishedOnly = false): Observable<Show[]> {
|
public list$(publishedOnly = false): Observable<Show[]> {
|
||||||
return this.userService.user$.pipe(
|
return this.userService.user$.pipe(
|
||||||
@@ -27,22 +26,18 @@ export class ShowService {
|
|||||||
() => this.showDataService.list$,
|
() => this.showDataService.list$,
|
||||||
(user: User | null, shows: Show[]) => ({user, shows})
|
(user: User | null, shows: Show[]) => ({user, shows})
|
||||||
),
|
),
|
||||||
map(s =>
|
map(s => s.shows.filter(show => !show.archived).filter(show => show.published || (show.owner === s.user?.id && !publishedOnly)))
|
||||||
s.shows
|
|
||||||
.sort((a, b) => a.date.toMillis() - b.date.toMillis())
|
|
||||||
.filter(_ => !_.archived)
|
|
||||||
.filter(show => show.published || (show.owner === s.user?.id && !publishedOnly))
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public update$ = async (showId: string, data: Partial<Show>): Promise<void> => this.showDataService.update(showId, data);
|
public update$ = async (showId: string, data: Partial<Show>): Promise<void> => this.showDataService.update(showId, data);
|
||||||
|
|
||||||
public async new$(data: Partial<Show>): Promise<string | null> {
|
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> = {
|
const calculatedData: Partial<Show> = {
|
||||||
...data,
|
...data,
|
||||||
owner: this.user.id,
|
owner: user.id,
|
||||||
order: [],
|
order: [],
|
||||||
public: ShowService.SHOW_TYPE_PUBLIC.indexOf(data.showType) !== -1,
|
public: ShowService.SHOW_TYPE_PUBLIC.indexOf(data.showType) !== -1,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import firebase from 'firebase/compat/app';
|
import {Timestamp} from '@angular/fire/firestore';
|
||||||
import Timestamp = firebase.firestore.Timestamp;
|
|
||||||
|
|
||||||
export type PresentationBackground = 'none' | 'blue' | 'green' | 'leder' | 'praise' | 'bible';
|
export type PresentationBackground = 'none' | 'blue' | 'green' | 'leder' | 'praise' | 'bible';
|
||||||
|
|
||||||
@@ -13,6 +12,7 @@ export interface Show {
|
|||||||
published: boolean;
|
published: boolean;
|
||||||
archived: boolean;
|
archived: boolean;
|
||||||
order: string[];
|
order: string[];
|
||||||
|
shareId: string;
|
||||||
|
|
||||||
presentationSongId: string;
|
presentationSongId: string;
|
||||||
presentationDynamicCaption: string;
|
presentationDynamicCaption: string;
|
||||||
|
|||||||
@@ -1,98 +1,136 @@
|
|||||||
<div *ngIf="show$ | async as show">
|
@if (show$ | async; as show) {
|
||||||
<app-card
|
<div>
|
||||||
[fullscreen]="useSwiper"
|
<app-card
|
||||||
closeLink="../"
|
[fullscreen]="useSwiper"
|
||||||
|
closeLink="../"
|
||||||
heading="{{ show.showType | showType }}, {{
|
heading="{{ show.showType | showType }}, {{
|
||||||
show.date.toDate() | date: 'dd.MM.yyyy'
|
show.date.toDate() | date: 'dd.MM.yyyy'
|
||||||
}} - {{ getStatus(show) }}"
|
}} - {{ getStatus(show) }}"
|
||||||
>
|
>
|
||||||
<p *ngIf="!useSwiper">{{show.public ? 'öffentliche' : 'geschlossene'}} Veranstaltung von
|
@if (!useSwiper) {
|
||||||
<app-user-name [userId]="show.owner"></app-user-name>
|
<p>{{ show.public ? 'öffentliche' : 'geschlossene' }} Veranstaltung von
|
||||||
</p>
|
<app-user-name [userId]="show.owner"></app-user-name>
|
||||||
<div class="head">
|
</p>
|
||||||
<div>
|
}
|
||||||
<mat-checkbox *ngIf="!useSwiper" [(ngModel)]="showText">Text anzeigen</mat-checkbox>
|
<div class="head">
|
||||||
|
<div>
|
||||||
|
@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"
|
||||||
|
matTooltip="Verkleinern"></app-menu-button>
|
||||||
|
<app-menu-button (click)="onZoomIn()" @fade [icon]="faZoomIn" class="btn-delete btn-icon"
|
||||||
|
matTooltip="Vergrößern"></app-menu-button>
|
||||||
|
<app-menu-button (click)="useSwiper=!useSwiper;fullscreen(useSwiper)" @fade
|
||||||
|
[icon]="useSwiper ? faRestore : faMaximize" class="btn-delete btn-icon"
|
||||||
|
matTooltip="Vollbild"></app-menu-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div [class.floating]="useSwiper">
|
@if (showSongs && !useSwiper) {
|
||||||
<app-menu-button @fade (click)="onZoomOut()" [icon]="faZoomOut" class="btn-delete btn-icon"
|
<div (cdkDropListDropped)="drop($event, show)"
|
||||||
matTooltip="Verkleinern"></app-menu-button>
|
[cdkDropListDisabled]="show.published || showText"
|
||||||
<app-menu-button @fade (click)="onZoomIn()" [icon]="faZoomIn" class="btn-delete btn-icon"
|
[style.cursor]="!(show.published || showText) ? 'drag' : 'inherit'"
|
||||||
matTooltip="Vergrößern"></app-menu-button>
|
[style.font-size]="textSize + 'em'"
|
||||||
<app-menu-button (click)="useSwiper=!useSwiper;fullscreen(useSwiper)" @fade
|
cdkDropList
|
||||||
[icon]="useSwiper ? faFileLines : faFile" class="btn-delete btn-icon"
|
class="song-list">
|
||||||
matTooltip="Swiper umschalten"></app-menu-button>
|
@for (song of orderedShowSongs(show); track trackBy(i, song); let i = $index) {
|
||||||
</div>
|
<div cdkDrag class="song-row">
|
||||||
</div>
|
<app-song
|
||||||
<div *ngIf="showSongs && !useSwiper" [cdkDropListDisabled]="show.published || showText" cdkDropList
|
[fullscreen]="useSwiper"
|
||||||
class="song-list"
|
[index]="i"
|
||||||
[style.cursor]="!(show.published || showText) ? 'drag' : 'inherit'"
|
[showId]="showId"
|
||||||
[style.font-size]="textSize + 'em'"
|
[showSong]="song"
|
||||||
(cdkDropListDropped)="drop($event, show)">
|
[showText]="showText"
|
||||||
<div *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy" class="song-row" cdkDrag>
|
[show]="show"
|
||||||
<app-song
|
></app-song>
|
||||||
[showSong]="song"
|
</div>
|
||||||
[showId]="showId"
|
}
|
||||||
[showText]="showText"
|
</div>
|
||||||
[show]="show"
|
}
|
||||||
[fullscreen]="useSwiper"
|
@if (useSwiper) {
|
||||||
[index]="i"
|
<swiper-container scrollbar="true">
|
||||||
></app-song>
|
@for (song of orderedShowSongs(show); track trackBy(i, song); let i = $index) {
|
||||||
</div>
|
<swiper-slide
|
||||||
</div>
|
[style.font-size]="textSize + 'em'"
|
||||||
|
class="song-swipe">
|
||||||
<swiper-container *ngIf="useSwiper" scrollbar="true">
|
<app-song
|
||||||
<swiper-slide *ngFor="let song of orderedShowSongs(show); let i = index; trackBy: trackBy" [style.font-size]="textSize + 'em'"
|
[fullscreen]="true"
|
||||||
class="song-swipe">
|
[index]="i"
|
||||||
<app-song
|
[showId]="showId"
|
||||||
[fullscreen]="true"
|
[showSong]="song"
|
||||||
[index]="i"
|
[showText]="true"
|
||||||
[showId]="showId"
|
[show]="show"
|
||||||
[showSong]="song"
|
></app-song>
|
||||||
[showText]="true"
|
<div class="time">{{ currentTime | date: 'HH:mm' }}</div>
|
||||||
[show]="show"
|
@if (getNextSong(orderedShowSongs(show), i); as next) {
|
||||||
></app-song>
|
<div class="next-song">{{ next }}
|
||||||
</swiper-slide>
|
<fa-icon [icon]="faNextSong"></fa-icon>
|
||||||
</swiper-container>
|
</div>
|
||||||
|
}
|
||||||
<app-add-song
|
</swiper-slide>
|
||||||
*ngIf="songs && !show.published && !useSwiper"
|
}
|
||||||
[show]="show"
|
</swiper-container>
|
||||||
[showSongs]="showSongs"
|
}
|
||||||
[songs]="songs"
|
@if (songs$ | async; as songs) {
|
||||||
></app-add-song>
|
@if (songs && !show.published && !useSwiper) {
|
||||||
|
<app-add-song
|
||||||
<app-button-row *ngIf="!useSwiper">
|
[showSongs]="showSongs"
|
||||||
<ng-container *appRole="['leader']">
|
[show]="show"
|
||||||
<ng-container *appOwner="show.owner">
|
[songs]="songs"
|
||||||
<app-button (click)="onArchive(true)" *ngIf="!show.archived" [icon]="faBox">
|
></app-add-song>
|
||||||
Archivieren
|
}
|
||||||
|
}
|
||||||
|
@if (!useSwiper) {
|
||||||
|
<app-button-row>
|
||||||
|
<ng-container *appRole="['leader']">
|
||||||
|
<ng-container *appOwner="show.owner">
|
||||||
|
@if (!show.archived) {
|
||||||
|
<app-button (click)="onArchive(true)" [icon]="faBox">
|
||||||
|
Archivieren
|
||||||
|
</app-button>
|
||||||
|
}
|
||||||
|
@if (show.archived) {
|
||||||
|
<app-button (click)="onArchive(false)" [icon]="faBoxOpen">
|
||||||
|
Wiederherstellen
|
||||||
|
</app-button>
|
||||||
|
}
|
||||||
|
@if (!show.published) {
|
||||||
|
<app-button (click)="onPublish(true)" [icon]="faPublish">
|
||||||
|
Veröffentlichen
|
||||||
|
</app-button>
|
||||||
|
}
|
||||||
|
@if (show.published) {
|
||||||
|
<app-button (click)="onPublish(false)" [icon]="faUnpublish">
|
||||||
|
Veröffentlichung zurückziehen
|
||||||
|
</app-button>
|
||||||
|
}
|
||||||
|
@if (show.published) {
|
||||||
|
<app-button (click)="onShare(show)" [icon]="faShare">
|
||||||
|
Teilen
|
||||||
|
</app-button>
|
||||||
|
}
|
||||||
|
@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>
|
</app-button>
|
||||||
<app-button (click)="onArchive(false)" *ngIf="show.archived" [icon]="faBoxOpen">
|
<mat-menu #menu="matMenu">
|
||||||
Wiederherstellen
|
<app-button (click)="onDownload()" [icon]="faUser">
|
||||||
</app-button>
|
Ablauf für Lobpreisgruppe
|
||||||
<app-button (click)="onPublish(true)" *ngIf="!show.published" [icon]="faPublish">
|
</app-button>
|
||||||
Veröffentlichen
|
<app-button (click)="onDownloadHandout()" [icon]="faUsers">
|
||||||
</app-button>
|
Handout mit Copyright Infos
|
||||||
<app-button (click)="onPublish(false)" *ngIf="show.published" [icon]="faUnpublish">
|
</app-button>
|
||||||
Veröffentlichung zurückziehen
|
</mat-menu>
|
||||||
</app-button>
|
</app-button-row>
|
||||||
<app-button (click)="onChange(show.id)" [icon]="faSliders" *ngIf="!show.published">
|
}
|
||||||
Ändern
|
</app-card>
|
||||||
</app-button>
|
</div>
|
||||||
</ng-container>
|
}
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<app-button [icon]="faDownload" [matMenuTriggerFor]="menu">
|
|
||||||
Herunterladen
|
|
||||||
</app-button>
|
|
||||||
<mat-menu #menu="matMenu">
|
|
||||||
<app-button (click)="onDownload()" [icon]="faUser">
|
|
||||||
Ablauf für Lobpreisgruppe
|
|
||||||
</app-button>
|
|
||||||
<app-button (click)="onDownloadHandout()" [icon]="faUsers">
|
|
||||||
Handout mit Copyright Infos
|
|
||||||
</app-button>
|
|
||||||
</mat-menu>
|
|
||||||
</app-button-row>
|
|
||||||
</app-card>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
.song-row:not(:last-child) {
|
.song-row:not(:last-child) {
|
||||||
display: block;
|
display: block;
|
||||||
border-bottom: 1px solid #0002;
|
border-bottom: 1px solid var(--divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
.song-swipe {
|
.song-swipe {
|
||||||
@@ -21,9 +21,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cdk-drag-preview {
|
.cdk-drag-preview {
|
||||||
background-color: white;
|
background-color: var(--surface-strong);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
|
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,3 +50,21 @@
|
|||||||
top: 12px;
|
top: 12px;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.next-song {
|
||||||
|
color: var(--text-muted);
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
right: 10px;
|
||||||
|
|
||||||
|
fa-icon {
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
color: var(--text-muted);
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('ShowComponent', () => {
|
|||||||
let component: ShowComponent;
|
let component: ShowComponent;
|
||||||
let fixture: ComponentFixture<ShowComponent>;
|
let fixture: ComponentFixture<ShowComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [ShowComponent],
|
||||||
declarations: [ShowComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ShowComponent);
|
fixture = TestBed.createComponent(ShowComponent);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from '@angular/core';
|
import {ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, HostListener, OnDestroy, OnInit, inject} from '@angular/core';
|
||||||
import {filter, map, switchMap, tap} from 'rxjs/operators';
|
import {filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {ShowService} from '../services/show.service';
|
import {ShowService} from '../services/show.service';
|
||||||
import {Observable, Subscription} from 'rxjs';
|
import {Observable, of, Subscription} from 'rxjs';
|
||||||
import {Show} from '../services/show';
|
import {Show} from '../services/show';
|
||||||
import {SongService} from '../../songs/services/song.service';
|
import {SongService} from '../../songs/services/song.service';
|
||||||
import {Song} from '../../songs/services/song';
|
import {Song} from '../../songs/services/song';
|
||||||
@@ -10,70 +10,125 @@ import {ShowSongService} from '../services/show-song.service';
|
|||||||
import {ShowSong} from '../services/show-song';
|
import {ShowSong} from '../services/show-song';
|
||||||
import {DocxService} from '../services/docx.service';
|
import {DocxService} from '../services/docx.service';
|
||||||
import {
|
import {
|
||||||
|
faArrowUpRightFromSquare,
|
||||||
faBox,
|
faBox,
|
||||||
faBoxOpen,
|
faBoxOpen,
|
||||||
faExternalLinkAlt,
|
faChevronRight,
|
||||||
faFile,
|
|
||||||
faFileDownload,
|
faFileDownload,
|
||||||
faFileLines,
|
|
||||||
faLock,
|
faLock,
|
||||||
faMagnifyingGlassMinus,
|
faMagnifyingGlassMinus,
|
||||||
faMagnifyingGlassPlus,
|
faMagnifyingGlassPlus,
|
||||||
|
faMaximize,
|
||||||
|
faMinimize,
|
||||||
faSliders,
|
faSliders,
|
||||||
|
faUnlock,
|
||||||
faUser,
|
faUser,
|
||||||
faUsers,
|
faUsers,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop';
|
import {CdkDrag, CdkDragDrop, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||||
import {fade} from '../../../animations';
|
import {fade} from '../../../animations';
|
||||||
import {MatDialog} from '@angular/material/dialog';
|
import {MatDialog} from '@angular/material/dialog';
|
||||||
import {ArchiveDialogComponent} from '../dialog/archive-dialog/archive-dialog.component';
|
import {ArchiveDialogComponent} from '../dialog/archive-dialog/archive-dialog.component';
|
||||||
import {closeFullscreen, openFullscreen} from '../../../services/fullscreen';
|
import {closeFullscreen, openFullscreen} from '../../../services/fullscreen';
|
||||||
|
import {GuestShowService} from '../../guest/guest-show.service';
|
||||||
|
import {ShareDialogComponent} from '../dialog/share-dialog/share-dialog.component';
|
||||||
|
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';
|
||||||
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
import {MenuButtonComponent} from '../../../widget-modules/components/menu-button/menu-button.component';
|
||||||
|
import {MatTooltip} from '@angular/material/tooltip';
|
||||||
|
import {SongComponent} from './song/song.component';
|
||||||
|
import {FaIconComponent} from '@fortawesome/angular-fontawesome';
|
||||||
|
import {AddSongComponent} from '../../../widget-modules/components/add-song/add-song.component';
|
||||||
|
import {ButtonRowComponent} from '../../../widget-modules/components/button-row/button-row.component';
|
||||||
|
import {RoleDirective} from '../../../services/user/role.directive';
|
||||||
|
import {OwnerDirective} from '../../../services/user/owner.directive';
|
||||||
|
import {ButtonComponent} from '../../../widget-modules/components/button/button.component';
|
||||||
|
import {MatMenu, MatMenuTrigger} from '@angular/material/menu';
|
||||||
|
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-show',
|
selector: 'app-show',
|
||||||
templateUrl: './show.component.html',
|
templateUrl: './show.component.html',
|
||||||
styleUrls: ['./show.component.less'],
|
styleUrls: ['./show.component.less'],
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
imports: [
|
||||||
|
CardComponent,
|
||||||
|
UserNameComponent,
|
||||||
|
MatCheckbox,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
FormsModule,
|
||||||
|
MenuButtonComponent,
|
||||||
|
MatTooltip,
|
||||||
|
CdkDropList,
|
||||||
|
CdkDrag,
|
||||||
|
SongComponent,
|
||||||
|
FaIconComponent,
|
||||||
|
AddSongComponent,
|
||||||
|
ButtonRowComponent,
|
||||||
|
RoleDirective,
|
||||||
|
OwnerDirective,
|
||||||
|
ButtonComponent,
|
||||||
|
MatMenuTrigger,
|
||||||
|
MatMenu,
|
||||||
|
AsyncPipe,
|
||||||
|
DatePipe,
|
||||||
|
ShowTypePipe,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class ShowComponent implements OnInit, OnDestroy {
|
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 show$: Observable<Show | null> | null = null;
|
||||||
public songs: Song[] | null = null;
|
public songs$: Observable<Song[] | null> | null = null;
|
||||||
public showSongs: ShowSong[] | null = null;
|
public showSongs: ShowSong[] | null = null;
|
||||||
public showId: string | null = null;
|
public showId: string | null = null;
|
||||||
public showText = false;
|
public showText = false;
|
||||||
|
|
||||||
public faBox = faBox;
|
public faBox = faBox;
|
||||||
public faBoxOpen = faBoxOpen;
|
public faBoxOpen = faBoxOpen;
|
||||||
public faPublish = faExternalLinkAlt;
|
public faPublish = faUnlock;
|
||||||
public faUnpublish = faLock;
|
public faUnpublish = faLock;
|
||||||
|
public faShare = faArrowUpRightFromSquare;
|
||||||
public faDownload = faFileDownload;
|
public faDownload = faFileDownload;
|
||||||
public faSliders = faSliders;
|
public faSliders = faSliders;
|
||||||
public faUser = faUser;
|
public faUser = faUser;
|
||||||
public faUsers = faUsers;
|
public faUsers = faUsers;
|
||||||
public faZoomIn = faMagnifyingGlassPlus;
|
public faZoomIn = faMagnifyingGlassPlus;
|
||||||
public faZoomOut = faMagnifyingGlassMinus;
|
public faZoomOut = faMagnifyingGlassMinus;
|
||||||
public faPage = faFile;
|
|
||||||
public faLines = faFileLines;
|
|
||||||
private subs: Subscription[] = [];
|
|
||||||
public useSwiper = false;
|
public useSwiper = false;
|
||||||
|
public textSize = 1;
|
||||||
public constructor(
|
public faRestore = faMinimize;
|
||||||
private activatedRoute: ActivatedRoute,
|
public faMaximize = faMaximize;
|
||||||
private showService: ShowService,
|
public faNextSong = faChevronRight;
|
||||||
private songService: SongService,
|
public currentTime: Date;
|
||||||
private showSongService: ShowSongService,
|
private subs: Subscription[] = [];
|
||||||
private docxService: DocxService,
|
|
||||||
private router: Router,
|
|
||||||
private cRef: ChangeDetectorRef,
|
|
||||||
public dialog: MatDialog
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
|
this.currentTime = new Date();
|
||||||
|
setInterval(() => {
|
||||||
|
this.currentTime = new Date();
|
||||||
|
}, 10000);
|
||||||
this.show$ = this.activatedRoute.params.pipe(
|
this.show$ = this.activatedRoute.params.pipe(
|
||||||
map(param => param as {showId: string}),
|
map(param => param as {showId: string}),
|
||||||
map(param => param.showId),
|
map(param => param.showId),
|
||||||
tap((_: string) => (this.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.subs.push(
|
||||||
this.activatedRoute.params
|
this.activatedRoute.params
|
||||||
@@ -86,23 +141,22 @@ export class ShowComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe(_ => {
|
.subscribe(_ => {
|
||||||
this.showSongs = _;
|
this.showSongs = _;
|
||||||
this.cRef.markForCheck();
|
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,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy(): void {
|
public ngOnDestroy(): void {
|
||||||
this.subs.forEach(_ => _.unsubscribe());
|
this.subs.forEach(_ => _.unsubscribe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public textSize = 1;
|
|
||||||
|
|
||||||
public onZoomIn() {
|
public onZoomIn() {
|
||||||
this.textSize += 0.1;
|
this.textSize += 0.1;
|
||||||
}
|
}
|
||||||
@@ -128,6 +182,11 @@ export class ShowComponent implements OnInit, OnDestroy {
|
|||||||
if (this.showId != null) await this.showService.update$(this.showId, {published});
|
if (this.showId != null) await this.showService.update$(this.showId, {published});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onShare = async (show: Show): Promise<void> => {
|
||||||
|
const url = await this.guestShowService.share(show, this.orderedShowSongs(show));
|
||||||
|
this.dialog.open(ShareDialogComponent, {data: {url, show}});
|
||||||
|
};
|
||||||
|
|
||||||
public getStatus(show: Show): string {
|
public getStatus(show: Show): string {
|
||||||
if (show.published) {
|
if (show.published) {
|
||||||
return 'veröffentlicht';
|
return 'veröffentlicht';
|
||||||
@@ -159,20 +218,19 @@ export class ShowComponent implements OnInit, OnDestroy {
|
|||||||
public orderedShowSongs(show: Show): ShowSong[] {
|
public orderedShowSongs(show: Show): ShowSong[] {
|
||||||
const list = this.showSongs;
|
const list = this.showSongs;
|
||||||
if (!list) return [];
|
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 = (index: number, show: ShowSong) => show.id;
|
public trackBy = (_: number, show: ShowSong) => show?.id;
|
||||||
|
|
||||||
public async onChange(showId: string) {
|
public async onChange(showId: string) {
|
||||||
await this.router.navigateByUrl('/shows/' + showId + '/edit');
|
await this.router.navigateByUrl('/shows/' + showId + '/edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
public faFileLines = faFileLines;
|
|
||||||
public faFile = faFile;
|
|
||||||
|
|
||||||
@HostListener('document:keydown', ['$event'])
|
@HostListener('document:keydown', ['$event'])
|
||||||
public handleKeyboardEvent(event: KeyboardEvent) {
|
public handleKeyboardEvent(event: KeyboardEvent) {
|
||||||
|
if (!this.useSwiper) return;
|
||||||
const swiperEl = document.querySelector('swiper-container') as unknown as Swiper;
|
const swiperEl = document.querySelector('swiper-container') as unknown as Swiper;
|
||||||
switch (event.code) {
|
switch (event.code) {
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
@@ -187,9 +245,16 @@ export class ShowComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fullscreen(useSwiper: boolean) {
|
public fullscreen(useSwiper: boolean) {
|
||||||
|
this.textSize = useSwiper ? 2 : 1;
|
||||||
if (useSwiper) openFullscreen();
|
if (useSwiper) openFullscreen();
|
||||||
else closeFullscreen();
|
else closeFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNextSong(showSongs: ShowSong[], i: number): string {
|
||||||
|
if (!showSongs || showSongs.length === 0) return '';
|
||||||
|
const song = showSongs[i + 1];
|
||||||
|
return song?.title ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Swiper {
|
export interface Swiper {
|
||||||
|
|||||||
@@ -1,45 +1,69 @@
|
|||||||
<div *ngIf="iSong && iSong && show">
|
@if (iSong && iSong && show) {
|
||||||
<div *ngIf="show.published || fullscreen" class="title published">
|
<div>
|
||||||
<div class="key">{{ iSong.key }}</div>
|
@if (show.published || fullscreen) {
|
||||||
<div>{{ iSong.title }}</div>
|
<div class="title published">
|
||||||
</div>
|
<div class="key">{{ iSong.key }}</div>
|
||||||
|
<div>{{ iSong.title }}</div>
|
||||||
<div *ngIf="!show.published && !fullscreen" class="song">
|
</div>
|
||||||
<span class="title">{{ iSong.title }}</span>
|
}
|
||||||
<span *ngIf="!edit" class="keys">
|
@if (!show.published && !fullscreen) {
|
||||||
<span *ngIf="iSong.keyOriginal !== iSong.key">{{ iSong.keyOriginal }} → </span>
|
<div class="song">
|
||||||
<mat-form-field *ngIf="keys" appearance="standard" class="keys">
|
<span class="title">{{ iSong.title }}</span>
|
||||||
<mat-select [formControl]="keyFormControl">
|
@if (!edit) {
|
||||||
<mat-option *ngFor="let key of keys" [value]="key">{{ key }}</mat-option>
|
<span class="keys">
|
||||||
</mat-select>
|
@if (iSong.keyOriginal !== iSong.key) {
|
||||||
|
<span>{{ iSong.keyOriginal }} → </span>
|
||||||
|
}<span
|
||||||
|
(click)="openKeySelect()">{{ iSong.key }}</span>
|
||||||
|
@if (keys) {
|
||||||
|
<mat-form-field (click)="option.open()" class="transpose">
|
||||||
|
<mat-select #option [formControl]="keyFormControl">
|
||||||
|
@for (key of keys; track key) {
|
||||||
|
<mat-option [value]="key">{{ key }}</mat-option>
|
||||||
|
}
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
@if (!edit) {
|
||||||
|
<app-menu-button (click)="onEdit()" [icon]="faEdit" class="btn-edit btn-icon"
|
||||||
|
matTooltip="Lied für diese Veranstaltung bearbeiten"></app-menu-button>
|
||||||
|
}
|
||||||
|
@if (!edit) {
|
||||||
|
<app-menu-button (click)="onDelete()" [icon]="faDelete" class="btn-delete btn-icon"
|
||||||
|
matTooltip="Lied aus Veranstaltung entfernen"></app-menu-button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (edit) {
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Songtext</mat-label>
|
||||||
|
<textarea [cdkTextareaAutosize]="true"
|
||||||
|
[formControl]="editSongControl"
|
||||||
|
class="edit"
|
||||||
|
matInput
|
||||||
|
matTooltip="Tonart ändern"
|
||||||
|
></textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</span>
|
}
|
||||||
<app-menu-button (click)="onEdit()" *ngIf="!edit" [icon]="faEdit" class="btn-edit btn-icon"
|
@if (edit) {
|
||||||
matTooltip="Lied für diese Veranstaltung bearbeiten"></app-menu-button>
|
<div>Es wird nur der Liedtext für dieser Veranstaltung geändert.</div>
|
||||||
<app-menu-button (click)="onDelete()" *ngIf="!edit" [icon]="faDelete" class="btn-delete btn-icon"
|
}
|
||||||
matTooltip="Lied aus Veranstaltung entfernen"></app-menu-button>
|
@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)"
|
||||||
|
[chordMode]="iSong.chordMode"
|
||||||
|
[showSwitch]="!show.published"
|
||||||
|
[text]="iSong.text"
|
||||||
|
[transpose]="{ baseKey: iSong.keyOriginal, targetKey: iSong.key }"
|
||||||
|
></app-song-text>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<mat-form-field *ngIf="edit" appearance="outline">
|
|
||||||
<mat-label>Songtext</mat-label>
|
|
||||||
<textarea matTooltip="Tonart ändern"
|
|
||||||
[cdkTextareaAutosize]="true"
|
|
||||||
[formControl]="editSongControl"
|
|
||||||
matInput
|
|
||||||
></textarea>
|
|
||||||
</mat-form-field>
|
|
||||||
<div *ngIf="edit">Es wird nur der Liedtext für dieser Veranstaltung geändert.</div>
|
|
||||||
<app-button-row *ngIf="edit">
|
|
||||||
<app-button (click)="onSave()" [icon]="faSave">Speichern</app-button>
|
|
||||||
<app-button (click)="onDiscard()" [icon]="faEraser">Verwerfen</app-button>
|
|
||||||
</app-button-row>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|||||||
@@ -17,8 +17,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.keys {
|
.keys {
|
||||||
width: 40px;
|
position: relative;
|
||||||
margin: -24px 0 -20px 0;
|
margin-right: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.transpose {
|
||||||
|
height: 0;
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-up {
|
.btn-up {
|
||||||
@@ -39,8 +49,8 @@
|
|||||||
grid-template-columns: 1em auto;
|
grid-template-columns: 1em auto;
|
||||||
|
|
||||||
.key {
|
.key {
|
||||||
color: #00b;
|
color: var(--primary-active);
|
||||||
text-shadow: 0 0 1px #00b;
|
text-shadow: 0 0 1px var(--primary-hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +64,7 @@
|
|||||||
grid-area: delete;
|
grid-area: delete;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-edit {
|
.btn-edit {
|
||||||
grid-area: edit;
|
grid-area: edit;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
@@ -67,6 +78,6 @@ button {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea {
|
textarea.edit {
|
||||||
font-family: 'Ubuntu Mono', monospace;
|
font-family: 'Ubuntu Mono', monospace;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ describe('SongComponent', () => {
|
|||||||
let component: SongComponent;
|
let component: SongComponent;
|
||||||
let fixture: ComponentFixture<SongComponent>;
|
let fixture: ComponentFixture<SongComponent>;
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(waitForAsync(() => {
|
||||||
waitForAsync(() => {
|
void TestBed.configureTestingModule({
|
||||||
void TestBed.configureTestingModule({
|
imports: [SongComponent],
|
||||||
declarations: [SongComponent],
|
}).compileComponents();
|
||||||
}).compileComponents();
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(SongComponent);
|
fixture = TestBed.createComponent(SongComponent);
|
||||||
|
|||||||
@@ -1,26 +1,51 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit, ViewChild, inject} from '@angular/core';
|
||||||
import {ShowSongService} from '../../services/show-song.service';
|
import {ShowSongService} from '../../services/show-song.service';
|
||||||
import {ShowSong} from '../../services/show-song';
|
import {ShowSong} from '../../services/show-song';
|
||||||
import {getScale} from '../../../songs/services/key.helper';
|
import {getScale} from '../../../songs/services/key.helper';
|
||||||
import {UntypedFormControl} from '@angular/forms';
|
import {ReactiveFormsModule, UntypedFormControl} from '@angular/forms';
|
||||||
import {ChordMode} from '../../../../widget-modules/components/song-text/song-text.component';
|
import {ChordMode, SongTextComponent} from '../../../../widget-modules/components/song-text/song-text.component';
|
||||||
import {Show} from '../../services/show';
|
import {Show} from '../../services/show';
|
||||||
import {faEraser, faPenToSquare, faSave, faTrash} from '@fortawesome/free-solid-svg-icons';
|
import {faEraser, faPenToSquare, faSave, faTrash} from '@fortawesome/free-solid-svg-icons';
|
||||||
import {fade} from '../../../../animations';
|
import {fade} from '../../../../animations';
|
||||||
|
import {MatSelect} from '@angular/material/select';
|
||||||
|
|
||||||
|
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';
|
||||||
|
import {MatTooltip} from '@angular/material/tooltip';
|
||||||
|
import {MatInput} from '@angular/material/input';
|
||||||
|
import {CdkTextareaAutosize} from '@angular/cdk/text-field';
|
||||||
|
import {ButtonRowComponent} from '../../../../widget-modules/components/button-row/button-row.component';
|
||||||
|
import {ButtonComponent} from '../../../../widget-modules/components/button/button.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-song',
|
selector: 'app-song',
|
||||||
templateUrl: './song.component.html',
|
templateUrl: './song.component.html',
|
||||||
styleUrls: ['./song.component.less'],
|
styleUrls: ['./song.component.less'],
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
|
imports: [
|
||||||
|
MatFormField,
|
||||||
|
MatSelect,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
MatOption,
|
||||||
|
MenuButtonComponent,
|
||||||
|
MatTooltip,
|
||||||
|
MatLabel,
|
||||||
|
MatInput,
|
||||||
|
CdkTextareaAutosize,
|
||||||
|
ButtonRowComponent,
|
||||||
|
ButtonComponent,
|
||||||
|
SongTextComponent,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class SongComponent implements OnInit {
|
export class SongComponent implements OnInit {
|
||||||
|
private showSongService = inject(ShowSongService);
|
||||||
|
|
||||||
@Input() public show: Show | null = null;
|
@Input() public show: Show | null = null;
|
||||||
@Input() public showId: string | null = null;
|
@Input() public showId: string | null = null;
|
||||||
@Input() public showText: boolean | null = null;
|
@Input() public showText: boolean | null = null;
|
||||||
@Input() public index = -1;
|
@Input() public index = -1;
|
||||||
@Input() public fullscreen = false;
|
@Input() public fullscreen = false;
|
||||||
|
|
||||||
public keys: string[] = [];
|
public keys: string[] = [];
|
||||||
public faDelete = faTrash;
|
public faDelete = faTrash;
|
||||||
public faEdit = faPenToSquare;
|
public faEdit = faPenToSquare;
|
||||||
@@ -30,8 +55,7 @@ export class SongComponent implements OnInit {
|
|||||||
public iSong: ShowSong | null = null;
|
public iSong: ShowSong | null = null;
|
||||||
public edit = false;
|
public edit = false;
|
||||||
public editSongControl = new UntypedFormControl();
|
public editSongControl = new UntypedFormControl();
|
||||||
|
@ViewChild('option') private keyOptions: MatSelect;
|
||||||
public constructor(private showSongService: ShowSongService) {}
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
public set showSong(song: ShowSong) {
|
public set showSong(song: ShowSong) {
|
||||||
@@ -75,4 +99,8 @@ export class SongComponent implements OnInit {
|
|||||||
chordMode: value,
|
chordMode: value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public openKeySelect(): void {
|
||||||
|
this.keyOptions.open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,72 +3,69 @@ import {CommonModule} from '@angular/common';
|
|||||||
|
|
||||||
import {ShowsRoutingModule} from './shows-routing.module';
|
import {ShowsRoutingModule} from './shows-routing.module';
|
||||||
import {NewComponent} from './new/new.component';
|
import {NewComponent} from './new/new.component';
|
||||||
import {CardModule} from '../../widget-modules/components/card/card.module';
|
|
||||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
import {MatInputModule} from '@angular/material/input';
|
import {MatInputModule} from '@angular/material/input';
|
||||||
import {ListComponent} from './list/list.component';
|
import {ListComponent} from './list/list.component';
|
||||||
import {ListItemComponent} from './list/list-item/list-item.component';
|
import {ListItemComponent} from './list/list-item/list-item.component';
|
||||||
import {ListHeaderModule} from '../../widget-modules/components/list-header/list-header.module';
|
|
||||||
import {MatCheckboxModule} from '@angular/material/checkbox';
|
import {MatCheckboxModule} from '@angular/material/checkbox';
|
||||||
import {ButtonRowModule} from '../../widget-modules/components/button-row/button-row.module';
|
|
||||||
import {MatButtonModule} from '@angular/material/button';
|
import {MatButtonModule} from '@angular/material/button';
|
||||||
import {MatDatepickerModule} from '@angular/material/datepicker';
|
import {MatDatepickerModule} from '@angular/material/datepicker';
|
||||||
import {MatSelectModule} from '@angular/material/select';
|
import {MatSelectModule} from '@angular/material/select';
|
||||||
import {ShowTypeTranslaterModule} from '../../widget-modules/pipes/show-type-translater/show-type-translater.module';
|
|
||||||
import {MatNativeDateModule} from '@angular/material/core';
|
import {MatNativeDateModule} from '@angular/material/core';
|
||||||
import {ShowComponent} from './show/show.component';
|
import {ShowComponent} from './show/show.component';
|
||||||
import {SongComponent} from './show/song/song.component';
|
import {SongComponent} from './show/song/song.component';
|
||||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||||
import {MenuButtonModule} from '../../widget-modules/components/menu-button/menu-button.module';
|
|
||||||
import {SongTextModule} from '../../widget-modules/components/song-text/song-text.module';
|
|
||||||
import {NgxMatSelectSearchModule} from 'ngx-mat-select-search';
|
import {NgxMatSelectSearchModule} from 'ngx-mat-select-search';
|
||||||
import {AddSongModule} from '../../widget-modules/components/add-song/add-song.module';
|
|
||||||
import {ButtonModule} from '../../widget-modules/components/button/button.module';
|
|
||||||
import {OwnerModule} from '../../services/user/owner.module';
|
|
||||||
import {UserNameModule} from '../../services/user/user-name/user-name.module';
|
|
||||||
import {MatMenuModule} from '@angular/material/menu';
|
import {MatMenuModule} from '@angular/material/menu';
|
||||||
import {DragDropModule} from '@angular/cdk/drag-drop';
|
import {DragDropModule} from '@angular/cdk/drag-drop';
|
||||||
import {RoleModule} from '../../services/user/role.module';
|
|
||||||
import {SortByModule} from '../../widget-modules/pipes/sort-by/sort-by.module';
|
|
||||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||||
import {FilterComponent} from './list/filter/filter.component';
|
import {FilterComponent} from './list/filter/filter.component';
|
||||||
import {EditComponent} from './edit/edit.component';
|
import {EditComponent} from './edit/edit.component';
|
||||||
import {ArchiveDialogComponent} from './dialog/archive-dialog/archive-dialog.component';
|
import {ArchiveDialogComponent} from './dialog/archive-dialog/archive-dialog.component';
|
||||||
import {MatDialogModule} from '@angular/material/dialog';
|
import {MatDialogModule} from '@angular/material/dialog';
|
||||||
|
import {SongTextComponent} from '../../widget-modules/components/song-text/song-text.component';
|
||||||
|
import {AddSongComponent} from '../../widget-modules/components/add-song/add-song.component';
|
||||||
|
import {ShowTypePipe} from '../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||||
|
import {SortByPipe} from '../../widget-modules/pipes/sort-by/sort-by.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [NewComponent, ListComponent, ListItemComponent, ShowComponent, SongComponent, FilterComponent, EditComponent, ArchiveDialogComponent],
|
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ShowsRoutingModule,
|
ShowsRoutingModule,
|
||||||
CardModule,
|
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
ListHeaderModule,
|
|
||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
ButtonRowModule,
|
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatDatepickerModule,
|
MatDatepickerModule,
|
||||||
MatNativeDateModule,
|
MatNativeDateModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
ShowTypeTranslaterModule,
|
ShowTypePipe,
|
||||||
FontAwesomeModule,
|
FontAwesomeModule,
|
||||||
MenuButtonModule,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
SongTextModule,
|
SongTextComponent,
|
||||||
NgxMatSelectSearchModule,
|
NgxMatSelectSearchModule,
|
||||||
AddSongModule,
|
AddSongComponent,
|
||||||
ButtonModule,
|
|
||||||
OwnerModule,
|
|
||||||
UserNameModule,
|
|
||||||
MatMenuModule,
|
MatMenuModule,
|
||||||
DragDropModule,
|
DragDropModule,
|
||||||
RoleModule,
|
SortByPipe,
|
||||||
SortByModule,
|
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
|
NewComponent,
|
||||||
|
ListComponent,
|
||||||
|
ListItemComponent,
|
||||||
|
ShowComponent,
|
||||||
|
SongComponent,
|
||||||
|
FilterComponent,
|
||||||
|
EditComponent,
|
||||||
|
ArchiveDialogComponent,
|
||||||
],
|
],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,12 +1,68 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {of} from 'rxjs';
|
||||||
|
import {DbService} from '../../../services/db.service';
|
||||||
import {FileDataService} from './file-data.service';
|
import {FileDataService} from './file-data.service';
|
||||||
|
|
||||||
describe('FileDataService', () => {
|
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', () => {
|
it('should be created', () => {
|
||||||
const service: FileDataService = TestBed.inject(FileDataService);
|
expect(service).toBeTruthy();
|
||||||
void 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 {File} from './file';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {FileServer} from './fileServer';
|
import {FileServer} from './fileServer';
|
||||||
@@ -8,7 +8,7 @@ import {DbService} from '../../../services/db.service';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class FileDataService {
|
export class FileDataService {
|
||||||
public constructor(private db: DbService) {}
|
private db = inject(DbService);
|
||||||
|
|
||||||
public async set(songId: string, file: FileServer): Promise<string> {
|
public async set(songId: string, file: FileServer): Promise<string> {
|
||||||
const songRef = this.db.doc('songs/' + songId);
|
const songRef = this.db.doc('songs/' + songId);
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {Storage} from '@angular/fire/storage';
|
||||||
|
|
||||||
import {FileService} from './file.service';
|
import {FileService} from './file.service';
|
||||||
|
import {FileDataService} from './file-data.service';
|
||||||
|
|
||||||
describe('FileService', () => {
|
describe('FileService', () => {
|
||||||
let service: FileService;
|
let service: FileService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
void TestBed.configureTestingModule({});
|
void TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
{provide: Storage, useValue: {}},
|
||||||
|
{provide: FileDataService, useValue: {delete: () => Promise.resolve()}},
|
||||||
|
],
|
||||||
|
});
|
||||||
service = TestBed.inject(FileService);
|
service = TestBed.inject(FileService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {EnvironmentInjector, Injectable, inject, runInInjectionContext} from '@angular/core';
|
||||||
import {AngularFireStorage} from '@angular/fire/compat/storage';
|
import {deleteObject, getDownloadURL, ref, Storage} from '@angular/fire/storage';
|
||||||
import {firstValueFrom, Observable} from 'rxjs';
|
import {from, Observable} from 'rxjs';
|
||||||
import {FileDataService} from './file-data.service';
|
import {FileDataService} from './file-data.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class FileService {
|
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> {
|
public getDownloadUrl(path: string): Observable<string> {
|
||||||
const ref = this.storage.ref(path);
|
return from(runInInjectionContext(this.environmentInjector, () => getDownloadURL(ref(this.storage, path))));
|
||||||
return ref.getDownloadURL() as Observable<string>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete(path: string, songId: string, fileId: string): void {
|
public delete(path: string, songId: string, fileId: string): void {
|
||||||
const ref = this.storage.ref(path);
|
void runInInjectionContext(this.environmentInjector, () => deleteObject(ref(this.storage, path)));
|
||||||
void firstValueFrom(ref.delete());
|
|
||||||
void this.fileDataService.delete(songId, fileId);
|
void this.fileDataService.delete(songId, fileId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/app/modules/songs/services/key.helper.spec.ts
Normal file
15
src/app/modules/songs/services/key.helper.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import {getScale, scaleMapping} from './key.helper';
|
||||||
|
|
||||||
|
describe('key.helper', () => {
|
||||||
|
it('should render Gb correctly', () => {
|
||||||
|
void expect(scaleMapping['Gb']).toBe('G♭');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should expose a sharp-based scale for D', () => {
|
||||||
|
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', () => {
|
||||||
|
void expect(getScale('Db')).toEqual(['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'B', 'H']);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -82,7 +82,7 @@ const scaleAssignment: {[key: string]: string[]} = {
|
|||||||
C: KEYS_MAJOR_FLAT,
|
C: KEYS_MAJOR_FLAT,
|
||||||
'C#': KEYS_MAJOR_FLAT,
|
'C#': KEYS_MAJOR_FLAT,
|
||||||
Db: KEYS_MAJOR_B,
|
Db: KEYS_MAJOR_B,
|
||||||
D: KEYS_MAJOR_B,
|
D: KEYS_MAJOR_FLAT,
|
||||||
'D#': KEYS_MAJOR_FLAT,
|
'D#': KEYS_MAJOR_FLAT,
|
||||||
Eb: KEYS_MAJOR_B,
|
Eb: KEYS_MAJOR_B,
|
||||||
E: KEYS_MAJOR_FLAT,
|
E: KEYS_MAJOR_FLAT,
|
||||||
@@ -125,7 +125,7 @@ export const scaleMapping: {[key: string]: string} = {
|
|||||||
E: 'E',
|
E: 'E',
|
||||||
F: 'F',
|
F: 'F',
|
||||||
'F#': 'F♯',
|
'F#': 'F♯',
|
||||||
Gb: 'D♭',
|
Gb: 'G♭',
|
||||||
G: 'G',
|
G: 'G',
|
||||||
'G#': 'G♯',
|
'G#': 'G♯',
|
||||||
Ab: 'A♭',
|
Ab: 'A♭',
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ export enum SectionType {
|
|||||||
Verse,
|
Verse,
|
||||||
Chorus,
|
Chorus,
|
||||||
Bridge,
|
Bridge,
|
||||||
|
Comment,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,104 @@
|
|||||||
import {TestBed, waitForAsync} from '@angular/core/testing';
|
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 {SongDataService} from './song-data.service';
|
||||||
import {AngularFirestore} from '@angular/fire/compat/firestore';
|
|
||||||
import {of} from 'rxjs';
|
|
||||||
|
|
||||||
describe('SongDataService', () => {
|
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 = {
|
beforeEach(() => {
|
||||||
valueChanges: () => of(songs),
|
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 = {
|
void TestBed.configureTestingModule({
|
||||||
collection: () => angularFirestoreCollection,
|
providers: [{provide: DbService, useValue: dbServiceSpy}],
|
||||||
};
|
});
|
||||||
|
|
||||||
beforeEach(
|
service = TestBed.inject(SongDataService);
|
||||||
() =>
|
|
||||||
void TestBed.configureTestingModule({
|
|
||||||
providers: [{provide: AngularFirestore, useValue: mockAngularFirestore}],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
const service: SongDataService = TestBed.inject(SongDataService);
|
|
||||||
void expect(service).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(
|
it('should be created', () => {
|
||||||
'should list songs',
|
expect(service).toBeTruthy();
|
||||||
waitForAsync(() => {
|
});
|
||||||
const service: SongDataService = TestBed.inject(SongDataService);
|
|
||||||
service.list$().subscribe(s => {
|
it('should load songs from the songs collection once on creation', () => {
|
||||||
void expect(s[0].title).toEqual('title1');
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user