From 2377c0a722a1e664e2e0eb7e29b20e9b58a2a7b6 Mon Sep 17 00:00:00 2001 From: Benjamin Ifland Date: Tue, 26 Mar 2019 22:00:43 +0100 Subject: [PATCH] odata expand for files --- WEB/src/app/data/edit-song.service.ts | 3 ++- WEB/src/app/data/odata.service.ts | 6 ++++-- WEB/src/app/data/songs.service.ts | 3 ++- WEB/src/app/models/file.model.ts | 6 ++++++ WEB/src/app/models/files-types.model.ts.ts | 6 ++++++ WEB/src/app/models/song.model.ts | 3 +++ 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 WEB/src/app/models/file.model.ts create mode 100644 WEB/src/app/models/files-types.model.ts.ts diff --git a/WEB/src/app/data/edit-song.service.ts b/WEB/src/app/data/edit-song.service.ts index b7f6ea0..0bea8cc 100644 --- a/WEB/src/app/data/edit-song.service.ts +++ b/WEB/src/app/data/edit-song.service.ts @@ -56,7 +56,8 @@ export class EditSongService { SongType: null, Key: null, Comments: null, - Final: false + Final: false, + Files: [] }; return song; diff --git a/WEB/src/app/data/odata.service.ts b/WEB/src/app/data/odata.service.ts index 3681335..8cd27de 100644 --- a/WEB/src/app/data/odata.service.ts +++ b/WEB/src/app/data/odata.service.ts @@ -1,5 +1,5 @@ import { Song } from 'src/app/models/song.model'; -import { ODataService, ODataQuery } from 'odata-v4-ng'; +import { ODataService, ODataQuery, Expand } from 'odata-v4-ng'; import { Observable } from 'rxjs'; import { map, tap } from 'rxjs/operators'; import { base } from './urls'; @@ -21,11 +21,13 @@ export class OdataService { public get$( id: number, - properties: string[] + properties: string[], + expands: string[] ): Observable { const query = new ODataQuery(this.odataService, this.url) .entitySet(this.entity) .entityKey(id) + .expand(expands.map(_ => new Expand(_))) .select(properties); const get = query.get().pipe(map(_ => _.toEntity())); diff --git a/WEB/src/app/data/songs.service.ts b/WEB/src/app/data/songs.service.ts index 0de8207..d63a8d8 100644 --- a/WEB/src/app/data/songs.service.ts +++ b/WEB/src/app/data/songs.service.ts @@ -45,9 +45,10 @@ export class SongsService extends OdataService { return; } - this.get$(id, ['Text', 'Comments']).subscribe(_ => { + this.get$(id, ['Text', 'Comments'], ['Files']).subscribe(_ => { song.Text = _.Text; song.Comments = _.Comments; + song.Files = _.Files; this.selectedSong.next(song); }); } diff --git a/WEB/src/app/models/file.model.ts b/WEB/src/app/models/file.model.ts new file mode 100644 index 0000000..24076d7 --- /dev/null +++ b/WEB/src/app/models/file.model.ts @@ -0,0 +1,6 @@ +import { FileType } from './files-types.model.ts'; +export interface File { + ID: number; + Name: string; + FileType: FileType; +} diff --git a/WEB/src/app/models/files-types.model.ts.ts b/WEB/src/app/models/files-types.model.ts.ts new file mode 100644 index 0000000..5f6ba36 --- /dev/null +++ b/WEB/src/app/models/files-types.model.ts.ts @@ -0,0 +1,6 @@ +export enum FileType { + None = 'None', + Sheet = 'Sheet', + Chords = 'Chords', + MuseScore = 'MuseScore' +} diff --git a/WEB/src/app/models/song.model.ts b/WEB/src/app/models/song.model.ts index e045575..c64deee 100644 --- a/WEB/src/app/models/song.model.ts +++ b/WEB/src/app/models/song.model.ts @@ -1,3 +1,5 @@ +import { File } from './file.model'; + export interface Song { ID: number; Number: number; @@ -8,4 +10,5 @@ export interface Song { Tempo: number; SongType: string; Final: boolean; + Files: File[]; }