From a1684f0fc0c3e5ba84d3d56b0439251109b78808 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 19 Mar 2024 08:37:07 +0100 Subject: [PATCH] [DEV] update new model --- front/src/app/app-routing.module.ts | 20 +-- front/src/app/back-api/album-resource.ts | 77 ++++++------ front/src/app/back-api/artist-resource.ts | 28 +++-- front/src/app/back-api/gender-resource.ts | 28 +++-- front/src/app/back-api/playlist-resource.ts | 65 +++++----- front/src/app/back-api/rest-tools.ts | 5 +- front/src/app/back-api/track-resource.ts | 117 +++++++++--------- front/src/app/back-api/user-resource.ts | 26 ++-- .../element-season/element-season.ts | 3 + front/src/app/service/GenericDataService.ts | 6 +- front/src/common | 2 +- 11 files changed, 196 insertions(+), 181 deletions(-) diff --git a/front/src/app/app-routing.module.ts b/front/src/app/app-routing.module.ts index ac6774c..00ecb98 100644 --- a/front/src/app/app-routing.module.ts +++ b/front/src/app/app-routing.module.ts @@ -129,30 +129,30 @@ const routes: Routes = [ component: AlbumsScene, canActivate: [OnlyUsersGuard], }, + { + path: 'album/:albumId/edit', + component: AlbumEditScene, + canActivate: [OnlyAdminGuard], + }, { path: 'album/:albumId', component: AlbumScene, canActivate: [OnlyUsersGuard], }, - { - path: 'album-edit/:albumId', - component: AlbumEditScene, - canActivate: [OnlyAdminGuard], - }, // ------------------------------------ // -- Tracks: // ------------------------------------ + { + path: 'track/:trackId/edit', + component: TrackEditScene, + canActivate: [OnlyAdminGuard], + }, { path: 'track/:genderId/:artistId/:albumId/:trackId', component: TrackScene, canActivate: [OnlyUsersGuard], }, - { - path: 'track-edit/:trackId', - component: TrackEditScene, - canActivate: [OnlyAdminGuard], - }, // ------------------------------------ // -- setting: diff --git a/front/src/app/back-api/album-resource.ts b/front/src/app/back-api/album-resource.ts index abcbf8e..dfe2c5e 100644 --- a/front/src/app/back-api/album-resource.ts +++ b/front/src/app/back-api/album-resource.ts @@ -2,7 +2,7 @@ * API of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" -import {Long, UUID, Album, isAlbum, } from "./model" +import {UUID, Long, Album, isAlbum, } from "./model" export namespace AlbumResource { /** @@ -18,6 +18,7 @@ export namespace AlbumResource { restModel: { endPoint: "/album/{id}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -83,6 +84,42 @@ export namespace AlbumResource { data, }, isAlbum); }; + /** + * Get all the available Albums + */ + export function gets({ restConfig, }: { + restConfig: RESTConfig, + }): Promise { + return RESTRequestJsonArray({ + restModel: { + endPoint: "/album", + requestType: HTTPRequestModel.GET, + accept: HTTPMimeType.JSON, + }, + restConfig, + }, isAlbum); + }; + /** + * Add a Track on a specific album + */ + export function addTrack({ restConfig, params, }: { + restConfig: RESTConfig, + params: { + trackId: Long, + id: Long, + }, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/album/{id}/track/{trackId}", + requestType: HTTPRequestModel.POST, + contentType: HTTPMimeType.MULTIPART, + accept: HTTPMimeType.JSON, + }, + restConfig, + params, + }, isAlbum); + }; /** * Remove a Track on a specific album */ @@ -97,6 +134,7 @@ export namespace AlbumResource { restModel: { endPoint: "/album/{id}/track/{trackId}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -142,42 +180,7 @@ export namespace AlbumResource { restModel: { endPoint: "/album/{id}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, - accept: HTTPMimeType.JSON, - }, - restConfig, - params, - }, isAlbum); - }; - /** - * Get all the available Albums - */ - export function gets({ restConfig, }: { - restConfig: RESTConfig, - }): Promise { - return RESTRequestJsonArray({ - restModel: { - endPoint: "/album", - requestType: HTTPRequestModel.GET, - accept: HTTPMimeType.JSON, - }, - restConfig, - }, isAlbum); - }; - /** - * Add a Track on a specific album - */ - export function addTrack({ restConfig, params, }: { - restConfig: RESTConfig, - params: { - trackId: Long, - id: Long, - }, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/album/{id}/track/{trackId}", - requestType: HTTPRequestModel.POST, - contentType: HTTPMimeType.MULTIPART, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, diff --git a/front/src/app/back-api/artist-resource.ts b/front/src/app/back-api/artist-resource.ts index 6d35366..1bdf61d 100644 --- a/front/src/app/back-api/artist-resource.ts +++ b/front/src/app/back-api/artist-resource.ts @@ -2,7 +2,7 @@ * API of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" -import {Artist, Long, UUID, isArtist, } from "./model" +import {Artist, UUID, Long, isArtist, } from "./model" export namespace ArtistResource { export function remove({ restConfig, params, }: { @@ -15,6 +15,7 @@ export namespace ArtistResource { restModel: { endPoint: "/artist/{id}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -71,6 +72,18 @@ export namespace ArtistResource { data, }, isArtist); }; + export function gets({ restConfig, }: { + restConfig: RESTConfig, + }): Promise { + return RESTRequestJsonArray({ + restModel: { + endPoint: "/artist", + requestType: HTTPRequestModel.GET, + accept: HTTPMimeType.JSON, + }, + restConfig, + }, isArtist); + }; export function uploadCover({ restConfig, params, data, }: { restConfig: RESTConfig, params: { @@ -104,22 +117,11 @@ export namespace ArtistResource { restModel: { endPoint: "/artist/{id}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, params, }, isArtist); }; - export function gets({ restConfig, }: { - restConfig: RESTConfig, - }): Promise { - return RESTRequestJsonArray({ - restModel: { - endPoint: "/artist", - requestType: HTTPRequestModel.GET, - accept: HTTPMimeType.JSON, - }, - restConfig, - }, isArtist); - }; } diff --git a/front/src/app/back-api/gender-resource.ts b/front/src/app/back-api/gender-resource.ts index 9e6702b..8e635bd 100644 --- a/front/src/app/back-api/gender-resource.ts +++ b/front/src/app/back-api/gender-resource.ts @@ -2,7 +2,7 @@ * API of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" -import {Long, Gender, UUID, isGender, } from "./model" +import {UUID, Long, Gender, isGender, } from "./model" export namespace GenderResource { export function remove({ restConfig, params, }: { @@ -15,6 +15,7 @@ export namespace GenderResource { restModel: { endPoint: "/gender/{id}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -71,6 +72,18 @@ export namespace GenderResource { data, }, isGender); }; + export function gets({ restConfig, }: { + restConfig: RESTConfig, + }): Promise { + return RESTRequestJsonArray({ + restModel: { + endPoint: "/gender", + requestType: HTTPRequestModel.GET, + accept: HTTPMimeType.JSON, + }, + restConfig, + }, isGender); + }; export function uploadCover({ restConfig, params, data, }: { restConfig: RESTConfig, params: { @@ -104,22 +117,11 @@ export namespace GenderResource { restModel: { endPoint: "/gender/{id}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, params, }, isGender); }; - export function gets({ restConfig, }: { - restConfig: RESTConfig, - }): Promise { - return RESTRequestJsonArray({ - restModel: { - endPoint: "/gender", - requestType: HTTPRequestModel.GET, - accept: HTTPMimeType.JSON, - }, - restConfig, - }, isGender); - }; } diff --git a/front/src/app/back-api/playlist-resource.ts b/front/src/app/back-api/playlist-resource.ts index 388e8b7..0f2ee07 100644 --- a/front/src/app/back-api/playlist-resource.ts +++ b/front/src/app/back-api/playlist-resource.ts @@ -2,7 +2,7 @@ * API of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" -import {Long, UUID, Playlist, isPlaylist, } from "./model" +import {UUID, Long, Playlist, isPlaylist, } from "./model" export namespace PlaylistResource { export function remove({ restConfig, params, }: { @@ -15,6 +15,7 @@ export namespace PlaylistResource { restModel: { endPoint: "/playlist/{id}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -71,6 +72,36 @@ export namespace PlaylistResource { data, }, isPlaylist); }; + export function gets({ restConfig, }: { + restConfig: RESTConfig, + }): Promise { + return RESTRequestJsonArray({ + restModel: { + endPoint: "/playlist", + requestType: HTTPRequestModel.GET, + accept: HTTPMimeType.JSON, + }, + restConfig, + }, isPlaylist); + }; + export function addTrack({ restConfig, params, }: { + restConfig: RESTConfig, + params: { + trackId: Long, + id: Long, + }, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/playlist/{id}/track/{trackId}", + requestType: HTTPRequestModel.POST, + contentType: HTTPMimeType.MULTIPART, + accept: HTTPMimeType.JSON, + }, + restConfig, + params, + }, isPlaylist); + }; export function removeTrack({ restConfig, params, }: { restConfig: RESTConfig, params: { @@ -82,6 +113,7 @@ export namespace PlaylistResource { restModel: { endPoint: "/playlist/{id}/track/{trackId}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -121,36 +153,7 @@ export namespace PlaylistResource { restModel: { endPoint: "/playlist/{id}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, - accept: HTTPMimeType.JSON, - }, - restConfig, - params, - }, isPlaylist); - }; - export function gets({ restConfig, }: { - restConfig: RESTConfig, - }): Promise { - return RESTRequestJsonArray({ - restModel: { - endPoint: "/playlist", - requestType: HTTPRequestModel.GET, - accept: HTTPMimeType.JSON, - }, - restConfig, - }, isPlaylist); - }; - export function addTrack({ restConfig, params, }: { - restConfig: RESTConfig, - params: { - trackId: Long, - id: Long, - }, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/playlist/{id}/track/{trackId}", - requestType: HTTPRequestModel.POST, - contentType: HTTPMimeType.MULTIPART, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, diff --git a/front/src/app/back-api/rest-tools.ts b/front/src/app/back-api/rest-tools.ts index 2cc5a81..0879a22 100644 --- a/front/src/app/back-api/rest-tools.ts +++ b/front/src/app/back-api/rest-tools.ts @@ -15,13 +15,14 @@ export enum HTTPRequestModel { } export enum HTTPMimeType { ALL = '*/*', + CSV = 'text/csv', IMAGE = 'image/*', IMAGE_JPEG = 'image/jpeg', IMAGE_PNG = 'image/png', JSON = 'application/json', - OCTET_STREAM = 'application/octet-stream', MULTIPART = 'multipart/form-data', - CSV = 'text/csv', + OCTET_STREAM = 'application/octet-stream', + TEXT_PLAIN = 'text/plain', } export interface RESTConfig { diff --git a/front/src/app/back-api/track-resource.ts b/front/src/app/back-api/track-resource.ts index f8811d3..bf7dd40 100644 --- a/front/src/app/back-api/track-resource.ts +++ b/front/src/app/back-api/track-resource.ts @@ -2,7 +2,7 @@ * API of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" -import {Long, Track, UUID, isTrack, } from "./model" +import {UUID, Long, Track, isTrack, } from "./model" export namespace TrackResource { export function remove({ restConfig, params, }: { @@ -15,6 +15,7 @@ export namespace TrackResource { restModel: { endPoint: "/track/{id}", requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, @@ -71,62 +72,6 @@ export namespace TrackResource { data, }, isTrack); }; - export function removeTrack({ restConfig, params, }: { - restConfig: RESTConfig, - params: { - artistId: Long, - id: Long, - }, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/track/{id}/artist/{trackId}", - requestType: HTTPRequestModel.DELETE, - accept: HTTPMimeType.JSON, - }, - restConfig, - params, - }, isTrack); - }; - export function uploadCover({ restConfig, params, data, }: { - restConfig: RESTConfig, - params: { - id: Long, - }, - data: { - fileName: string, - file: File, - }, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/track/{id}/cover", - requestType: HTTPRequestModel.POST, - contentType: HTTPMimeType.MULTIPART, - accept: HTTPMimeType.JSON, - }, - restConfig, - params, - data, - }, isTrack); - }; - export function removeCover({ restConfig, params, }: { - restConfig: RESTConfig, - params: { - coverId: UUID, - id: Long, - }, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/track/{id}/cover/{coverId}", - requestType: HTTPRequestModel.DELETE, - accept: HTTPMimeType.JSON, - }, - restConfig, - params, - }, isTrack); - }; export function uploadTrack({ restConfig, data, }: { restConfig: RESTConfig, data: { @@ -180,4 +125,62 @@ export namespace TrackResource { params, }, isTrack); }; + export function removeTrack({ restConfig, params, }: { + restConfig: RESTConfig, + params: { + artistId: Long, + id: Long, + }, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/track/{id}/artist/{trackId}", + requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, + accept: HTTPMimeType.JSON, + }, + restConfig, + params, + }, isTrack); + }; + export function uploadCover({ restConfig, params, data, }: { + restConfig: RESTConfig, + params: { + id: Long, + }, + data: { + fileName: string, + file: File, + }, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/track/{id}/cover", + requestType: HTTPRequestModel.POST, + contentType: HTTPMimeType.MULTIPART, + accept: HTTPMimeType.JSON, + }, + restConfig, + params, + data, + }, isTrack); + }; + export function removeCover({ restConfig, params, }: { + restConfig: RESTConfig, + params: { + coverId: UUID, + id: Long, + }, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/track/{id}/cover/{coverId}", + requestType: HTTPRequestModel.DELETE, + contentType: HTTPMimeType.TEXT_PLAIN, + accept: HTTPMimeType.JSON, + }, + restConfig, + params, + }, isTrack); + }; } diff --git a/front/src/app/back-api/user-resource.ts b/front/src/app/back-api/user-resource.ts index 7954e37..4d214c6 100644 --- a/front/src/app/back-api/user-resource.ts +++ b/front/src/app/back-api/user-resource.ts @@ -22,19 +22,6 @@ export namespace UserResource { params, }, isUserKarusic); }; - export function getMe({ restConfig, produce, }: { - restConfig: RESTConfig, - produce: HTTPMimeType.JSON, - }): Promise { - return RESTRequestJson({ - restModel: { - endPoint: "/users/me", - requestType: HTTPRequestModel.GET, - accept: produce, - }, - restConfig, - }, isUserOut); - }; export function gets({ restConfig, produce, }: { restConfig: RESTConfig, produce: HTTPMimeType.JSON, @@ -48,4 +35,17 @@ export namespace UserResource { restConfig, }, isUserKarusic); }; + export function getMe({ restConfig, produce, }: { + restConfig: RESTConfig, + produce: HTTPMimeType.JSON, + }): Promise { + return RESTRequestJson({ + restModel: { + endPoint: "/users/me", + requestType: HTTPRequestModel.GET, + accept: produce, + }, + restConfig, + }, isUserOut); + }; } diff --git a/front/src/app/component/element-season/element-season.ts b/front/src/app/component/element-season/element-season.ts index c34c7b4..cafd606 100644 --- a/front/src/app/component/element-season/element-season.ts +++ b/front/src/app/component/element-season/element-season.ts @@ -43,6 +43,7 @@ export class ElementSeasonComponent implements OnInit { this.prefix = this.prefixName ?? ""; this.count = undefined; this.count2 = undefined; + console.log(`element: ${JSON.stringify(this.element, null, 2)}`); if (isNullOrUndefined(this.element)) { this.numberAlbum = undefined; @@ -51,7 +52,9 @@ export class ElementSeasonComponent implements OnInit { } this.numberAlbum = this.element.name; this.description = this.element.description; + console.log(`covers: ${this.element.covers}`); this.covers = this.dataService.getListThumbnailUrl(this.element.covers); + console.log(`covers >> : ${this.covers}`); let self = this; if (!isNullOrUndefined(this.countSubTypeCallBack)) { this.countSubTypeCallBack(this.element.id) diff --git a/front/src/app/service/GenericDataService.ts b/front/src/app/service/GenericDataService.ts index 41227aa..aa0c82f 100644 --- a/front/src/app/service/GenericDataService.ts +++ b/front/src/app/service/GenericDataService.ts @@ -45,8 +45,7 @@ export class GenericDataService { key: 'id', value: ids, }, - ], - ['name', 'id']); + ]); resolve(data); return; }).catch((response) => { @@ -85,8 +84,7 @@ export class GenericDataService { key: 'id', value: [undefined, null], }, - ], - ['name', 'id']); + ]); resolve(data); }).catch((response) => { console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`); diff --git a/front/src/common b/front/src/common index ae86abe..0fd7c54 160000 --- a/front/src/common +++ b/front/src/common @@ -1 +1 @@ -Subproject commit ae86abe8ca367b91d36c48683fda8cfd82f3ec48 +Subproject commit 0fd7c540ea5cdce19533338b3125e88d4ef442ef