From f5d9350e53cce079c457ca1d985765863d918fed Mon Sep 17 00:00:00 2001 From: smuddyx Date: Mon, 2 Mar 2020 16:27:31 +0100 Subject: [PATCH] =?UTF-8?q?Zus=C3=A4tzliche=20Felder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular.json | 7 ++- src/app/app.module.ts | 2 +- src/app/songs/models/song.ts | 11 ++++ .../songs/services/file-data.service.spec.ts | 4 +- src/app/songs/services/file-data.service.ts | 17 +++++- src/app/songs/services/file.ts | 8 +-- src/app/songs/services/fileBase.ts | 5 ++ src/app/songs/services/fileServer.ts | 5 ++ .../songs/services/song-data.service.spec.ts | 4 +- src/app/songs/services/song.service.ts | 35 +++++++++++- .../services/text-rendering.service.spec.ts | 12 ++++ .../songs/services/text-rendering.service.ts | 44 +++++++++++++++ src/app/songs/services/upload.service.spec.ts | 4 +- src/app/songs/services/upload.service.ts | 15 +++-- .../list-item/list-item.component.html | 2 +- .../songs/song-list/song-list.component.ts | 3 +- src/app/songs/song-list/song-list.module.ts | 14 ++--- .../edit/edit-file/edit-file.component.html | 8 +-- .../edit-file/edit-file.component.spec.ts | 8 +-- .../edit-file/file/file.component.spec.ts | 8 +-- .../edit/edit-file/file/file.component.ts | 5 +- .../edit/edit-song/edit-song.component.html | 55 +++++++++++++++++++ .../edit/edit-song/edit-song.component.less | 4 ++ .../edit-song/edit-song.component.spec.ts | 8 +-- .../edit/edit-song/edit-song.component.ts | 4 +- src/app/songs/song/edit/edit.module.ts | 10 +++- src/app/songs/song/edit/edit.service.ts | 13 ++++- src/app/songs/song/song.component.html | 25 ++++++--- src/app/songs/song/song.component.less | 8 ++- src/app/songs/song/song.component.ts | 15 ++++- src/app/songs/song/song.module.ts | 18 +++--- .../legal-type-translator.module.ts | 16 ++++++ .../legal-type.pipe.spec.ts | 8 +++ .../legal-type-translator/legal-type.pipe.ts | 19 +++++++ src/index.html | 4 +- tsconfig.json | 3 +- 36 files changed, 357 insertions(+), 74 deletions(-) create mode 100644 src/app/songs/services/fileBase.ts create mode 100644 src/app/songs/services/fileServer.ts create mode 100644 src/app/songs/services/text-rendering.service.spec.ts create mode 100644 src/app/songs/services/text-rendering.service.ts create mode 100644 src/app/widget-modules/pipes/legal-type-translator/legal-type-translator.module.ts create mode 100644 src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.spec.ts create mode 100644 src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.ts diff --git a/angular.json b/angular.json index cc8e88a..4351415 100644 --- a/angular.json +++ b/angular.json @@ -130,5 +130,8 @@ } } }, - "defaultProject": "wgenerator" -} + "defaultProject": "wgenerator", + "cli": { + "analytics": "4047dcd7-89f4-402f-958e-e365a5505c55" + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6ff18eb..afb671d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -27,7 +27,7 @@ import {AngularFireDatabaseModule} from '@angular/fire/database'; AngularFireModule.initializeApp(environment.firebase), - AngularFirestoreModule.enablePersistence(), + AngularFirestoreModule.enablePersistence({synchronizeTabs: true}), AngularFireStorageModule, AngularFireDatabaseModule diff --git a/src/app/songs/models/song.ts b/src/app/songs/models/song.ts index 57d2244..eafe951 100644 --- a/src/app/songs/models/song.ts +++ b/src/app/songs/models/song.ts @@ -8,4 +8,15 @@ export interface Song { text: string; title: string; type: string; + + legalType: string; + legalLink: string; + legalOwner: string; + legalOwnerId: string; + legalLicenseId: string; + + artist: string; + label: string; + termsOfUse: string; + origin: string; } diff --git a/src/app/songs/services/file-data.service.spec.ts b/src/app/songs/services/file-data.service.spec.ts index c74eeb3..3c6ca8b 100644 --- a/src/app/songs/services/file-data.service.spec.ts +++ b/src/app/songs/services/file-data.service.spec.ts @@ -1,6 +1,6 @@ -import { TestBed } from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; -import { FileDataService } from './file-data.service'; +import {FileDataService} from './file-data.service'; describe('FileDataService', () => { beforeEach(() => TestBed.configureTestingModule({})); diff --git a/src/app/songs/services/file-data.service.ts b/src/app/songs/services/file-data.service.ts index bd18261..deb0023 100644 --- a/src/app/songs/services/file-data.service.ts +++ b/src/app/songs/services/file-data.service.ts @@ -1,6 +1,9 @@ import {Injectable} from '@angular/core'; import {SongDataService} from './song-data.service'; import {File} from './file'; +import {Observable} from 'rxjs'; +import {map} from 'rxjs/operators'; +import {FileServer} from './fileServer'; @Injectable({ providedIn: 'root' @@ -10,10 +13,22 @@ export class FileDataService { constructor(private songDataService: SongDataService) { } - public async put(songId: string, file: File): Promise { + public async put(songId: string, file: FileServer): Promise { const songRef = this.songDataService.getSongRef(songId); const fileCollection = songRef.collection('files'); const id = await fileCollection.add(file); return id.id; } + + public get$(songId: string): Observable { + const songRef = this.songDataService.getSongRef(songId); + return songRef.collection('files').snapshotChanges().pipe(map(actions => { + return actions.map(a => ({ + ...a.payload.doc.data(), + id: a.payload.doc.id + })); + })); + } + + } diff --git a/src/app/songs/services/file.ts b/src/app/songs/services/file.ts index 69485f5..bf8c014 100644 --- a/src/app/songs/services/file.ts +++ b/src/app/songs/services/file.ts @@ -1,5 +1,5 @@ -export interface File { - name: string; - path: string; - createdAt: Date; +import {FileServer} from './fileServer'; + +export interface File extends FileServer { + id: string; } diff --git a/src/app/songs/services/fileBase.ts b/src/app/songs/services/fileBase.ts new file mode 100644 index 0000000..2423848 --- /dev/null +++ b/src/app/songs/services/fileBase.ts @@ -0,0 +1,5 @@ +export class FileBase { + + protected basePath = '/attachments'; + protected directory = (songId: string) => `${this.basePath}/${songId}`; +} diff --git a/src/app/songs/services/fileServer.ts b/src/app/songs/services/fileServer.ts new file mode 100644 index 0000000..bd7cc3d --- /dev/null +++ b/src/app/songs/services/fileServer.ts @@ -0,0 +1,5 @@ +export interface FileServer { + name: string; + path: string; + createdAt: Date; +} diff --git a/src/app/songs/services/song-data.service.spec.ts b/src/app/songs/services/song-data.service.spec.ts index 9e764be..a17a0a3 100644 --- a/src/app/songs/services/song-data.service.spec.ts +++ b/src/app/songs/services/song-data.service.spec.ts @@ -32,9 +32,9 @@ describe('SongDataService', () => { it('should list songs', async(() => { const service: SongDataService = TestBed.get(SongDataService); service.list().subscribe(s => { - expect(s).toEqual([ + expect(s).toEqual([ {title: 'title1'} - ] as any); + ] as any); } ); })); diff --git a/src/app/songs/services/song.service.ts b/src/app/songs/services/song.service.ts index c0d6c5a..881e82f 100644 --- a/src/app/songs/services/song.service.ts +++ b/src/app/songs/services/song.service.ts @@ -2,6 +2,9 @@ import {Injectable} from '@angular/core'; import {Observable} from 'rxjs'; import {Song} from '../models/song'; import {SongDataService} from './song-data.service'; +import {tap} from 'rxjs/operators'; + +declare var importCCLI: any; @Injectable({ providedIn: 'root' @@ -10,19 +13,49 @@ export class SongService { public TYPES = ['Praise', 'Worship']; + public LEGAL_OWNER = ['CCLI', 'other']; + public LEGAL_TYPE = ['open', 'allowed']; + public KEYS = [ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'B', 'H', 'c', 'c#', 'db', 'd', 'd#', 'eb', 'e', 'f', 'f#', 'gb', 'g', 'g#', 'ab', 'a', 'a#', 'b', 'h' ]; + private list: Song[]; constructor(private songDataService: SongDataService) { + importCCLI = (songs: Song[]) => this.updateFromCLI(songs); } - public list$ = (): Observable => this.songDataService.list(); + public list$ = (): Observable => this.songDataService.list().pipe(tap(_ => this.list = _)); public read = (songId: string): Observable => this.songDataService.read(songId); public async update(songId: string, data: any): Promise { await this.songDataService.update(songId, data); } +// https://www.csvjson.com/csv2json + private async updateFromCLI(songs: Song[]) { + const mapped = songs.map(_ => ({ + number: _.number, + legalType: _.legalType === 'ja' ? 'allowed' : 'open', + legalOwner: _.legalOwner === 'ja' ? 'CCLI' : 'other', + title: _.title, + legalOwnerId: _.legalOwnerId, + origin: _.origin, + artist: _.artist, + comment: _.comment + })); + const promises = this.list.map(async _ => { + // tslint:disable-next-line:triple-equals + const mappedSongs = mapped.filter(f => f.number == _.number); + if (mappedSongs.length === 1) { + const mappedSong = mappedSongs[0]; + const id = _.id; + return await this.update(id, mappedSong); + } + }); + + await Promise.all(promises); + } + } diff --git a/src/app/songs/services/text-rendering.service.spec.ts b/src/app/songs/services/text-rendering.service.spec.ts new file mode 100644 index 0000000..9dd6063 --- /dev/null +++ b/src/app/songs/services/text-rendering.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { TextRenderingService } from './text-rendering.service'; + +describe('TextRenderingService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: TextRenderingService = TestBed.get(TextRenderingService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/songs/services/text-rendering.service.ts b/src/app/songs/services/text-rendering.service.ts new file mode 100644 index 0000000..5a26ef2 --- /dev/null +++ b/src/app/songs/services/text-rendering.service.ts @@ -0,0 +1,44 @@ +import { Injectable } from '@angular/core'; + +export enum SectionType { + Verse, + Chorus, + Bridge, +} + +export enum LineType { + title, + chrod, + text, +} + +export interface Line { + type: LineType; + text: string; +} + + +export interface Section { + type: SectionType; + number: number; + lines: Line[]; +} + +@Injectable({ + providedIn: 'root' +}) +export class TextRenderingService { + + constructor() { } + + public render(text: string): Section[] { + const lines = text.match(/[^\r\n]+/g); + + + } + + private findSection(line: string) { + + } + +} diff --git a/src/app/songs/services/upload.service.spec.ts b/src/app/songs/services/upload.service.spec.ts index 70bfa6b..087c665 100644 --- a/src/app/songs/services/upload.service.spec.ts +++ b/src/app/songs/services/upload.service.spec.ts @@ -1,6 +1,6 @@ -import { TestBed } from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; -import { UploadService } from './upload.service'; +import {UploadService} from './upload.service'; describe('UploadServiceService', () => { beforeEach(() => TestBed.configureTestingModule({})); diff --git a/src/app/songs/services/upload.service.ts b/src/app/songs/services/upload.service.ts index 67fc682..27e1243 100644 --- a/src/app/songs/services/upload.service.ts +++ b/src/app/songs/services/upload.service.ts @@ -4,20 +4,23 @@ import {FileDataService} from './file-data.service'; import {AngularFireStorage} from '@angular/fire/storage'; import {finalize} from 'rxjs/operators'; import {File} from './file'; +import {FileBase} from './fileBase'; +import {FileServer} from './fileServer'; + @Injectable({ providedIn: 'root' }) -export class UploadService { - private basePath = '/attachments'; +export class UploadService extends FileBase { constructor(private fileDataService: FileDataService, private angularFireStorage: AngularFireStorage) { + super(); } public async pushUpload(songId: string, upload: Upload) { - const path = `${this.basePath}/${songId}`; - const filePath = `${path}/${upload.file.name}`; - upload.path = path; + const directory = this.directory(songId); + const filePath = `${directory}/${upload.file.name}`; + upload.path = directory; const ref = this.angularFireStorage.ref(filePath); const task = ref.put(upload.file); @@ -48,7 +51,7 @@ export class UploadService { } private async saveFileData(songId: string, upload: Upload) { - const file: File = { + const file: FileServer = { name: upload.file.name, path: upload.path, createdAt: new Date() diff --git a/src/app/songs/song-list/list-item/list-item.component.html b/src/app/songs/song-list/list-item/list-item.component.html index 09aae97..a74ca53 100644 --- a/src/app/songs/song-list/list-item/list-item.component.html +++ b/src/app/songs/song-list/list-item/list-item.component.html @@ -2,5 +2,5 @@
{{song.number}}
{{song.title}}
{{song.key}}
-
{{song.type | songType}}
+
{{song.legalType | legalType}}
diff --git a/src/app/songs/song-list/song-list.component.ts b/src/app/songs/song-list/song-list.component.ts index 54e2306..1e223dc 100644 --- a/src/app/songs/song-list/song-list.component.ts +++ b/src/app/songs/song-list/song-list.component.ts @@ -14,9 +14,10 @@ import {ActivatedRoute} from '@angular/router'; }) export class SongListComponent implements OnInit { + public songs$: Observable; + constructor(private songService: SongService, private activatedRoute: ActivatedRoute) { } - public songs$: Observable; private static filter(song: Song, filterValue: string): boolean { if (!filterValue) { diff --git a/src/app/songs/song-list/song-list.module.ts b/src/app/songs/song-list/song-list.module.ts index 5ef072a..f5e796a 100644 --- a/src/app/songs/song-list/song-list.module.ts +++ b/src/app/songs/song-list/song-list.module.ts @@ -3,20 +3,20 @@ import {CommonModule} from '@angular/common'; import {SongListComponent} from './song-list.component'; import {ListItemComponent} from './list-item/list-item.component'; import {CardModule} from '../../widget-modules/components/card/card.module'; -import {SongTypeTranslaterModule} from '../../widget-modules/pipes/song-type-translater/song-type-translater.module'; import {RouterModule} from '@angular/router'; +import {LegalTypeTranslatorModule} from '../../widget-modules/pipes/legal-type-translator/legal-type-translator.module'; @NgModule({ declarations: [SongListComponent, ListItemComponent], exports: [SongListComponent], - imports: [ - CommonModule, - RouterModule, + imports: [ + CommonModule, + RouterModule, - CardModule, - SongTypeTranslaterModule - ] + CardModule, + LegalTypeTranslatorModule + ] }) export class SongListModule { } diff --git a/src/app/songs/song/edit/edit-file/edit-file.component.html b/src/app/songs/song/edit/edit-file/edit-file.component.html index b5eac0c..e2e1136 100644 --- a/src/app/songs/song/edit/edit-file/edit-file.component.html +++ b/src/app/songs/song/edit/edit-file/edit-file.component.html @@ -3,18 +3,18 @@
-
+
Progress: {{currentUpload?.name}} | {{currentUpload?.progress}}% Complete
-
diff --git a/src/app/songs/song/edit/edit-file/edit-file.component.spec.ts b/src/app/songs/song/edit/edit-file/edit-file.component.spec.ts index 38640bf..f948d04 100644 --- a/src/app/songs/song/edit/edit-file/edit-file.component.spec.ts +++ b/src/app/songs/song/edit/edit-file/edit-file.component.spec.ts @@ -1,6 +1,6 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import { EditFileComponent } from './edit-file.component'; +import {EditFileComponent} from './edit-file.component'; describe('EditFileComponent', () => { let component: EditFileComponent; @@ -8,9 +8,9 @@ describe('EditFileComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ EditFileComponent ] + declarations: [EditFileComponent] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/songs/song/edit/edit-file/file/file.component.spec.ts b/src/app/songs/song/edit/edit-file/file/file.component.spec.ts index 851d631..0543dff 100644 --- a/src/app/songs/song/edit/edit-file/file/file.component.spec.ts +++ b/src/app/songs/song/edit/edit-file/file/file.component.spec.ts @@ -1,6 +1,6 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import { FileComponent } from './file.component'; +import {FileComponent} from './file.component'; describe('FileComponent', () => { let component: FileComponent; @@ -8,9 +8,9 @@ describe('FileComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ FileComponent ] + declarations: [FileComponent] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/songs/song/edit/edit-file/file/file.component.ts b/src/app/songs/song/edit/edit-file/file/file.component.ts index 65c4f7e..4178708 100644 --- a/src/app/songs/song/edit/edit-file/file/file.component.ts +++ b/src/app/songs/song/edit/edit-file/file/file.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; @Component({ selector: 'app-file', @@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core'; }) export class FileComponent implements OnInit { - constructor() { } + constructor() { + } ngOnInit() { } diff --git a/src/app/songs/song/edit/edit-song/edit-song.component.html b/src/app/songs/song/edit/edit-song/edit-song.component.html index 7c5f095..82ecd5a 100644 --- a/src/app/songs/song/edit/edit-song/edit-song.component.html +++ b/src/app/songs/song/edit/edit-song/edit-song.component.html @@ -30,6 +30,61 @@ + + Kommentar + + + + + + + Rechtlicher Status + + {{key|legalType}} + + + + + Rechteinhaber + + {{key|legalOwner}} + + + + + Rechteinhaber Link + + + + + Rechteinhaber ID (z.B. CCLI Liednummer) + + + + + Lizenznummer + + + + + Künstler + + + + + Verlag + + + + + Nutzungsbedingungen + + + + + abweichende Quelle + + diff --git a/src/app/songs/song/edit/edit-song/edit-song.component.less b/src/app/songs/song/edit/edit-song/edit-song.component.less index e02befa..4fbdacc 100644 --- a/src/app/songs/song/edit/edit-song/edit-song.component.less +++ b/src/app/songs/song/edit/edit-song/edit-song.component.less @@ -11,4 +11,8 @@ grid-template-columns: 1fr 1fr 1fr; column-gap: 20px; } + + textarea { + font-family: 'Ubuntu Mono', monospace; + } } diff --git a/src/app/songs/song/edit/edit-song/edit-song.component.spec.ts b/src/app/songs/song/edit/edit-song/edit-song.component.spec.ts index 89c603a..5ae86f2 100644 --- a/src/app/songs/song/edit/edit-song/edit-song.component.spec.ts +++ b/src/app/songs/song/edit/edit-song/edit-song.component.spec.ts @@ -1,6 +1,6 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import { EditSongComponent } from './edit-song.component'; +import {EditSongComponent} from './edit-song.component'; describe('EditSongComponent', () => { let component: EditSongComponent; @@ -8,9 +8,9 @@ describe('EditSongComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ EditSongComponent ] + declarations: [EditSongComponent] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/songs/song/edit/edit-song/edit-song.component.ts b/src/app/songs/song/edit/edit-song/edit-song.component.ts index 60c9b1c..e7381f2 100644 --- a/src/app/songs/song/edit/edit-song/edit-song.component.ts +++ b/src/app/songs/song/edit/edit-song/edit-song.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {Song} from '../../../models/song'; import {FormGroup} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; @@ -16,6 +16,8 @@ export class EditSongComponent implements OnInit { public form: FormGroup; public keys = this.songService.KEYS; public types = this.songService.TYPES; + public legalOwner = this.songService.LEGAL_OWNER; + public legalType = this.songService.LEGAL_TYPE; constructor( private activatedRoute: ActivatedRoute, diff --git a/src/app/songs/song/edit/edit.module.ts b/src/app/songs/song/edit/edit.module.ts index f2d3516..9aa658e 100644 --- a/src/app/songs/song/edit/edit.module.ts +++ b/src/app/songs/song/edit/edit.module.ts @@ -10,10 +10,12 @@ import {MatSelectModule} from '@angular/material/select'; import {MatButtonModule} from '@angular/material/button'; import {ButtonRowModule} from '../../../widget-modules/components/button-row/button-row.module'; import {RouterModule} from '@angular/router'; -import { EditSongComponent } from './edit-song/edit-song.component'; -import { EditFileComponent } from './edit-file/edit-file.component'; +import {EditSongComponent} from './edit-song/edit-song.component'; +import {EditFileComponent} from './edit-file/edit-file.component'; import {MatIconModule} from '@angular/material/icon'; -import { FileComponent } from './edit-file/file/file.component'; +import {FileComponent} from './edit-file/file/file.component'; +import {LegalOwnerTranslatorModule} from '../../../widget-modules/pipes/legal-owner-translator/legal-owner-translator.module'; +import {LegalTypeTranslatorModule} from '../../../widget-modules/pipes/legal-type-translator/legal-type-translator.module'; @NgModule({ @@ -33,6 +35,8 @@ import { FileComponent } from './edit-file/file/file.component'; ButtonRowModule, MatIconModule, + LegalOwnerTranslatorModule, + LegalTypeTranslatorModule, ] }) diff --git a/src/app/songs/song/edit/edit.service.ts b/src/app/songs/song/edit/edit.service.ts index 253de96..3bef42e 100644 --- a/src/app/songs/song/edit/edit.service.ts +++ b/src/app/songs/song/edit/edit.service.ts @@ -17,7 +17,18 @@ export class EditService { comment: new FormControl(song.comment), key: new FormControl(song.key), tempo: new FormControl(song.tempo), - type: new FormControl(song.type) + type: new FormControl(song.type), + + legalType: new FormControl(song.legalType), + legalLink: new FormControl(song.legalLink), + legalOwner: new FormControl(song.legalOwner), + legalOwnerId: new FormControl(song.legalOwnerId), + legalLicenseId: new FormControl(song.legalLicenseId), + + artist: new FormControl(song.artist), + label: new FormControl(song.label), + termsOfUse: new FormControl(song.termsOfUse), + origin: new FormControl(song.origin), }); } } diff --git a/src/app/songs/song/song.component.html b/src/app/songs/song/song.component.html index a0f4274..66d51fd 100644 --- a/src/app/songs/song/song.component.html +++ b/src/app/songs/song/song.component.html @@ -1,18 +1,29 @@
-
{{song.text}}
-
Typ
-
{{song.type | songType}}
-
Tonart
-
{{song.key}}
-
Tempo
-
{{song.tempo}}
+
Typ: {{song.type | songType}}
+
Tonart: {{song.key}}
+
Tempo: {{song.tempo}}
+
Rechteinhaber: {{song.legalOwner|legalOwner}}
+
Rechteinhaber ID: {{song.legalOwnerId}}
+
Lizenznummer: {{song.legalLicenseId}}
+
Künstler: {{song.artist}}
+
Verlag: {{song.label}}
+
Quelle: {{song.origin}}
+ +
{{song.text}}
+
{{song.comment}}
+
+

Anhänge

+
{{file.name}}
+
+ +
diff --git a/src/app/songs/song/song.component.less b/src/app/songs/song/song.component.less index 5dac69e..9e4a9bf 100644 --- a/src/app/songs/song/song.component.less +++ b/src/app/songs/song/song.component.less @@ -1,15 +1,17 @@ .song { display: grid; - grid-template-columns: 2fr 1fr; - column-gap: 20px; + grid-template-columns: 1fr; margin-top: 20px; + grid-gap: 20px; } .text { white-space: pre-wrap; + font-family: 'Ubuntu Mono', monospace; + } .detail { display: grid; - grid-template-columns: 1fr 2fr; + grid-template-columns: 1fr 1fr 1fr; } diff --git a/src/app/songs/song/song.component.ts b/src/app/songs/song/song.component.ts index cabdc30..b760f27 100644 --- a/src/app/songs/song/song.component.ts +++ b/src/app/songs/song/song.component.ts @@ -4,6 +4,8 @@ import {SongService} from '../services/song.service'; import {map, switchMap} from 'rxjs/operators'; import {Song} from '../models/song'; import {Observable} from 'rxjs'; +import {FileDataService} from '../services/file-data.service'; +import {File} from '../services/file'; @Component({ selector: 'app-song', @@ -12,8 +14,13 @@ import {Observable} from 'rxjs'; }) export class SongComponent implements OnInit { public song$: Observable; + public files$: Observable; - constructor(private activatedRoute: ActivatedRoute, private songService: SongService) { + constructor( + private activatedRoute: ActivatedRoute, + private songService: SongService, + private fileService: FileDataService, + ) { } public ngOnInit(): void { @@ -21,6 +28,12 @@ export class SongComponent implements OnInit { map(param => param.songId), switchMap(songId => this.songService.read(songId)) ); + + this.files$ = this.activatedRoute.params.pipe( + map(param => param.songId), + switchMap(songId => this.fileService.get$(songId)) + ); + } } diff --git a/src/app/songs/song/song.module.ts b/src/app/songs/song/song.module.ts index ddaae3a..6e92a7d 100644 --- a/src/app/songs/song/song.module.ts +++ b/src/app/songs/song/song.module.ts @@ -6,20 +6,22 @@ import {SongTypeTranslaterModule} from '../../widget-modules/pipes/song-type-tra import {MatButtonModule} from '@angular/material/button'; import {ButtonRowModule} from '../../widget-modules/components/button-row/button-row.module'; import {RouterModule} from '@angular/router'; +import {LegalOwnerTranslatorModule} from '../../widget-modules/pipes/legal-owner-translator/legal-owner-translator.module'; @NgModule({ declarations: [SongComponent], exports: [SongComponent], - imports: [ - CommonModule, - CardModule, - RouterModule, + imports: [ + CommonModule, + CardModule, + RouterModule, - SongTypeTranslaterModule, - MatButtonModule, - ButtonRowModule, - ] + SongTypeTranslaterModule, + MatButtonModule, + ButtonRowModule, + LegalOwnerTranslatorModule, + ] }) export class SongModule { } diff --git a/src/app/widget-modules/pipes/legal-type-translator/legal-type-translator.module.ts b/src/app/widget-modules/pipes/legal-type-translator/legal-type-translator.module.ts new file mode 100644 index 0000000..97a07a1 --- /dev/null +++ b/src/app/widget-modules/pipes/legal-type-translator/legal-type-translator.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { LegalTypePipe } from './legal-type.pipe'; + + + +@NgModule({ + declarations: [LegalTypePipe], + exports: [ + LegalTypePipe + ], + imports: [ + CommonModule + ] +}) +export class LegalTypeTranslatorModule { } diff --git a/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.spec.ts b/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.spec.ts new file mode 100644 index 0000000..e5f5c45 --- /dev/null +++ b/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.spec.ts @@ -0,0 +1,8 @@ +import { LegalTypePipe } from './legal-type.pipe'; + +describe('LegalTypePipe', () => { + it('create an instance', () => { + const pipe = new LegalTypePipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.ts b/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.ts new file mode 100644 index 0000000..0dd33a2 --- /dev/null +++ b/src/app/widget-modules/pipes/legal-type-translator/legal-type.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'legalType' +}) +export class LegalTypePipe implements PipeTransform { + + transform(legalTypeKey: string): string { + switch (legalTypeKey) { + case 'open': + return 'Klärung erforderlich '; + case 'allowed': + return 'OK'; + default: + return ''; + } + } + +} diff --git a/src/index.html b/src/index.html index a692bb9..1f37cae 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - Wgenerator + Worship Generator @@ -10,9 +10,11 @@ + + diff --git a/tsconfig.json b/tsconfig.json index 88f7755..5e482b4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,7 @@ "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "enableIvy": false + "strictTemplate": true, + "enableIvy": true } }