odata expand for files
This commit is contained in:
@@ -56,7 +56,8 @@ export class EditSongService {
|
|||||||
SongType: null,
|
SongType: null,
|
||||||
Key: null,
|
Key: null,
|
||||||
Comments: null,
|
Comments: null,
|
||||||
Final: false
|
Final: false,
|
||||||
|
Files: []
|
||||||
};
|
};
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Song } from 'src/app/models/song.model';
|
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 { Observable } from 'rxjs';
|
||||||
import { map, tap } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
import { base } from './urls';
|
import { base } from './urls';
|
||||||
@@ -21,11 +21,13 @@ export class OdataService {
|
|||||||
|
|
||||||
public get$<TResponse>(
|
public get$<TResponse>(
|
||||||
id: number,
|
id: number,
|
||||||
properties: string[]
|
properties: string[],
|
||||||
|
expands: string[]
|
||||||
): Observable<TResponse> {
|
): Observable<TResponse> {
|
||||||
const query = new ODataQuery(this.odataService, this.url)
|
const query = new ODataQuery(this.odataService, this.url)
|
||||||
.entitySet(this.entity)
|
.entitySet(this.entity)
|
||||||
.entityKey(id)
|
.entityKey(id)
|
||||||
|
.expand(expands.map(_ => new Expand(_)))
|
||||||
.select(properties);
|
.select(properties);
|
||||||
const get = query.get().pipe(map(_ => _.toEntity<TResponse>()));
|
const get = query.get().pipe(map(_ => _.toEntity<TResponse>()));
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,10 @@ export class SongsService extends OdataService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get$<Song>(id, ['Text', 'Comments']).subscribe(_ => {
|
this.get$<Song>(id, ['Text', 'Comments'], ['Files']).subscribe(_ => {
|
||||||
song.Text = _.Text;
|
song.Text = _.Text;
|
||||||
song.Comments = _.Comments;
|
song.Comments = _.Comments;
|
||||||
|
song.Files = _.Files;
|
||||||
this.selectedSong.next(song);
|
this.selectedSong.next(song);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
6
WEB/src/app/models/file.model.ts
Normal file
6
WEB/src/app/models/file.model.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { FileType } from './files-types.model.ts';
|
||||||
|
export interface File {
|
||||||
|
ID: number;
|
||||||
|
Name: string;
|
||||||
|
FileType: FileType;
|
||||||
|
}
|
||||||
6
WEB/src/app/models/files-types.model.ts.ts
Normal file
6
WEB/src/app/models/files-types.model.ts.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export enum FileType {
|
||||||
|
None = 'None',
|
||||||
|
Sheet = 'Sheet',
|
||||||
|
Chords = 'Chords',
|
||||||
|
MuseScore = 'MuseScore'
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { File } from './file.model';
|
||||||
|
|
||||||
export interface Song {
|
export interface Song {
|
||||||
ID: number;
|
ID: number;
|
||||||
Number: number;
|
Number: number;
|
||||||
@@ -8,4 +10,5 @@ export interface Song {
|
|||||||
Tempo: number;
|
Tempo: number;
|
||||||
SongType: string;
|
SongType: string;
|
||||||
Final: boolean;
|
Final: boolean;
|
||||||
|
Files: File[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user