From 473672ac33d2cb3be8ac88affc8a12b510a11b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 22 Feb 2023 14:08:04 +0100 Subject: [PATCH] fixed the getSong of the API.ts but modifications of the backend must be done --- front/API.ts | 69 ++++++++++++++++--------------------- front/models/Song.ts | 2 ++ front/models/SongDetails.ts | 17 +++++++++ 3 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 front/models/SongDetails.ts diff --git a/front/API.ts b/front/API.ts index c3623ed..2304a35 100644 --- a/front/API.ts +++ b/front/API.ts @@ -148,9 +148,21 @@ export default class API { * @param songId the id to find the song */ public static async getSong(songId: number): Promise { - return API.fetch({ + let song = await API.fetch({ route: `/song/${songId}` }); + + // this is a dummy illustration, we will need to fetch the real one from the API + return { + id: song.id as number, + name : song.name as string, + artistId: song.artistId as number, + albumId: song.albumId as number, + genreId: song.genreId as number, + details: song.difficulties, + cover: dummyIllustration, + metrics: {} + } as Song; } /** * Retrive a song's midi partition @@ -158,8 +170,17 @@ export default class API { */ public static async getSongMidi(songId: number): Promise { return API.fetch({ - route: `/song/${songId}/midi`, - raw: true, + route: `/song/${songId}/midi` + }); + } + + /** + * Retrive a song's musicXML partition + * @param songId the id to find the song + */ + public static async getSongMusicXML(songId: number): Promise { + return API.fetch({ + route: `/song/${songId}/musicXml` }); } @@ -195,7 +216,7 @@ export default class API { * @param songId the id to find the song */ public static async getSongHistory(songId: number): Promise { - return [6, 1, 2, 3, 4, 5].map((value) => ({ + return [].map((value) => ({ songId: songId, userId: 1, score: value @@ -207,15 +228,7 @@ export default class API { * @param query the string used to find the songs */ public static async searchSongs(query: string): Promise { - return Array.of(4).map((i) => ({ - id: i, - name: `Searched Song ${i}`, - artistId: i, - genreId: i, - albumId: i, - cover: dummyIllustration, - metrics: {} - })); + return []; } /** @@ -237,45 +250,21 @@ export default class API { * @param lessonId the id to find the lesson */ public static async getSearchHistory(): Promise { - return Array.of(4).map((i) => ({ - id: i, - name: `Song in history ${i}`, - artistId: i, - genreId: i, - albumId: i, - cover: dummyIllustration, - metrics: {} - })); + return []; } /** * Retrieve the authenticated user's recommendations */ public static async getUserRecommendations(): Promise { - return Array.of(4).map((i) => ({ - id: 1, - name: `Recommended Song ${i}`, - artistId: i, - genreId: i, - albumId: i, - cover: dummyIllustration, - metrics: {} - })); + return []; } /** * Retrieve the authenticated user's play history */ public static async getUserPlayHistory(): Promise { - return Array.of(4).map((i) => ({ - id: i, - name: `played Song ${i}`, - artistId: i, - genreId: i, - albumId: i, - cover: dummyIllustration, - metrics: {} - })); + return []; } /** diff --git a/front/models/Song.ts b/front/models/Song.ts index 11b30d7..8adfb0e 100644 --- a/front/models/Song.ts +++ b/front/models/Song.ts @@ -1,5 +1,6 @@ import Metrics from "./Metrics"; import Model from "./Model"; +import SongDetails from "./SongDetails"; interface Song extends Model { name: string @@ -8,6 +9,7 @@ interface Song extends Model { genreId: number | null; cover: string; metrics: Metrics; + details: SongDetails; } export default Song; \ No newline at end of file diff --git a/front/models/SongDetails.ts b/front/models/SongDetails.ts new file mode 100644 index 0000000..bdf0282 --- /dev/null +++ b/front/models/SongDetails.ts @@ -0,0 +1,17 @@ +interface SongDetails { + length: number, + rhythm: number, + arppegio: number, + distance: number, + lefthand: number, + righthand: number, + twohands: number, + notecombo: number, + precision: number, + pedalpoint: number, + chordtiming: number, + leadheadchange: number, + chordcomplexity: number, +} + +export default SongDetails; \ No newline at end of file