[DEV] update new model

This commit is contained in:
Edouard DUPIN 2024-03-19 08:37:07 +01:00
parent cebf7d35fb
commit a1684f0fc0
11 changed files with 196 additions and 181 deletions

View File

@ -129,30 +129,30 @@ const routes: Routes = [
component: AlbumsScene, component: AlbumsScene,
canActivate: [OnlyUsersGuard], canActivate: [OnlyUsersGuard],
}, },
{
path: 'album/:albumId/edit',
component: AlbumEditScene,
canActivate: [OnlyAdminGuard],
},
{ {
path: 'album/:albumId', path: 'album/:albumId',
component: AlbumScene, component: AlbumScene,
canActivate: [OnlyUsersGuard], canActivate: [OnlyUsersGuard],
}, },
{
path: 'album-edit/:albumId',
component: AlbumEditScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------ // ------------------------------------
// -- Tracks: // -- Tracks:
// ------------------------------------ // ------------------------------------
{
path: 'track/:trackId/edit',
component: TrackEditScene,
canActivate: [OnlyAdminGuard],
},
{ {
path: 'track/:genderId/:artistId/:albumId/:trackId', path: 'track/:genderId/:artistId/:albumId/:trackId',
component: TrackScene, component: TrackScene,
canActivate: [OnlyUsersGuard], canActivate: [OnlyUsersGuard],
}, },
{
path: 'track-edit/:trackId',
component: TrackEditScene,
canActivate: [OnlyAdminGuard],
},
// ------------------------------------ // ------------------------------------
// -- setting: // -- setting:

View File

@ -2,7 +2,7 @@
* API of the server (auto-generated code) * API of the server (auto-generated code)
*/ */
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" 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 { export namespace AlbumResource {
/** /**
@ -18,6 +18,7 @@ export namespace AlbumResource {
restModel: { restModel: {
endPoint: "/album/{id}", endPoint: "/album/{id}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -83,6 +84,42 @@ export namespace AlbumResource {
data, data,
}, isAlbum); }, isAlbum);
}; };
/**
* Get all the available Albums
*/
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Album[]> {
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<Album> {
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 * Remove a Track on a specific album
*/ */
@ -97,6 +134,7 @@ export namespace AlbumResource {
restModel: { restModel: {
endPoint: "/album/{id}/track/{trackId}", endPoint: "/album/{id}/track/{trackId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -142,42 +180,7 @@ export namespace AlbumResource {
restModel: { restModel: {
endPoint: "/album/{id}/cover/{coverId}", endPoint: "/album/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
accept: HTTPMimeType.JSON, contentType: HTTPMimeType.TEXT_PLAIN,
},
restConfig,
params,
}, isAlbum);
};
/**
* Get all the available Albums
*/
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Album[]> {
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<Album> {
return RESTRequestJson({
restModel: {
endPoint: "/album/{id}/track/{trackId}",
requestType: HTTPRequestModel.POST,
contentType: HTTPMimeType.MULTIPART,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,

View File

@ -2,7 +2,7 @@
* API of the server (auto-generated code) * API of the server (auto-generated code)
*/ */
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" 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 namespace ArtistResource {
export function remove({ restConfig, params, }: { export function remove({ restConfig, params, }: {
@ -15,6 +15,7 @@ export namespace ArtistResource {
restModel: { restModel: {
endPoint: "/artist/{id}", endPoint: "/artist/{id}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -71,6 +72,18 @@ export namespace ArtistResource {
data, data,
}, isArtist); }, isArtist);
}; };
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Artist[]> {
return RESTRequestJsonArray({
restModel: {
endPoint: "/artist",
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
},
restConfig,
}, isArtist);
};
export function uploadCover({ restConfig, params, data, }: { export function uploadCover({ restConfig, params, data, }: {
restConfig: RESTConfig, restConfig: RESTConfig,
params: { params: {
@ -104,22 +117,11 @@ export namespace ArtistResource {
restModel: { restModel: {
endPoint: "/artist/{id}/cover/{coverId}", endPoint: "/artist/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
params, params,
}, isArtist); }, isArtist);
}; };
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Artist[]> {
return RESTRequestJsonArray({
restModel: {
endPoint: "/artist",
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
},
restConfig,
}, isArtist);
};
} }

View File

@ -2,7 +2,7 @@
* API of the server (auto-generated code) * API of the server (auto-generated code)
*/ */
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" 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 namespace GenderResource {
export function remove({ restConfig, params, }: { export function remove({ restConfig, params, }: {
@ -15,6 +15,7 @@ export namespace GenderResource {
restModel: { restModel: {
endPoint: "/gender/{id}", endPoint: "/gender/{id}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -71,6 +72,18 @@ export namespace GenderResource {
data, data,
}, isGender); }, isGender);
}; };
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Gender[]> {
return RESTRequestJsonArray({
restModel: {
endPoint: "/gender",
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
},
restConfig,
}, isGender);
};
export function uploadCover({ restConfig, params, data, }: { export function uploadCover({ restConfig, params, data, }: {
restConfig: RESTConfig, restConfig: RESTConfig,
params: { params: {
@ -104,22 +117,11 @@ export namespace GenderResource {
restModel: { restModel: {
endPoint: "/gender/{id}/cover/{coverId}", endPoint: "/gender/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
params, params,
}, isGender); }, isGender);
}; };
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Gender[]> {
return RESTRequestJsonArray({
restModel: {
endPoint: "/gender",
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
},
restConfig,
}, isGender);
};
} }

View File

@ -2,7 +2,7 @@
* API of the server (auto-generated code) * API of the server (auto-generated code)
*/ */
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" 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 namespace PlaylistResource {
export function remove({ restConfig, params, }: { export function remove({ restConfig, params, }: {
@ -15,6 +15,7 @@ export namespace PlaylistResource {
restModel: { restModel: {
endPoint: "/playlist/{id}", endPoint: "/playlist/{id}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -71,6 +72,36 @@ export namespace PlaylistResource {
data, data,
}, isPlaylist); }, isPlaylist);
}; };
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Playlist[]> {
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<Playlist> {
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, }: { export function removeTrack({ restConfig, params, }: {
restConfig: RESTConfig, restConfig: RESTConfig,
params: { params: {
@ -82,6 +113,7 @@ export namespace PlaylistResource {
restModel: { restModel: {
endPoint: "/playlist/{id}/track/{trackId}", endPoint: "/playlist/{id}/track/{trackId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -121,36 +153,7 @@ export namespace PlaylistResource {
restModel: { restModel: {
endPoint: "/playlist/{id}/cover/{coverId}", endPoint: "/playlist/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
accept: HTTPMimeType.JSON, contentType: HTTPMimeType.TEXT_PLAIN,
},
restConfig,
params,
}, isPlaylist);
};
export function gets({ restConfig, }: {
restConfig: RESTConfig,
}): Promise<Playlist[]> {
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<Playlist> {
return RESTRequestJson({
restModel: {
endPoint: "/playlist/{id}/track/{trackId}",
requestType: HTTPRequestModel.POST,
contentType: HTTPMimeType.MULTIPART,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,

View File

@ -15,13 +15,14 @@ export enum HTTPRequestModel {
} }
export enum HTTPMimeType { export enum HTTPMimeType {
ALL = '*/*', ALL = '*/*',
CSV = 'text/csv',
IMAGE = 'image/*', IMAGE = 'image/*',
IMAGE_JPEG = 'image/jpeg', IMAGE_JPEG = 'image/jpeg',
IMAGE_PNG = 'image/png', IMAGE_PNG = 'image/png',
JSON = 'application/json', JSON = 'application/json',
OCTET_STREAM = 'application/octet-stream',
MULTIPART = 'multipart/form-data', MULTIPART = 'multipart/form-data',
CSV = 'text/csv', OCTET_STREAM = 'application/octet-stream',
TEXT_PLAIN = 'text/plain',
} }
export interface RESTConfig { export interface RESTConfig {

View File

@ -2,7 +2,7 @@
* API of the server (auto-generated code) * API of the server (auto-generated code)
*/ */
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools" 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 namespace TrackResource {
export function remove({ restConfig, params, }: { export function remove({ restConfig, params, }: {
@ -15,6 +15,7 @@ export namespace TrackResource {
restModel: { restModel: {
endPoint: "/track/{id}", endPoint: "/track/{id}",
requestType: HTTPRequestModel.DELETE, requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
}, },
restConfig, restConfig,
@ -71,62 +72,6 @@ export namespace TrackResource {
data, data,
}, isTrack); }, isTrack);
}; };
export function removeTrack({ restConfig, params, }: {
restConfig: RESTConfig,
params: {
artistId: Long,
id: Long,
},
}): Promise<Track> {
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<Track> {
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<Track> {
return RESTRequestJson({
restModel: {
endPoint: "/track/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE,
accept: HTTPMimeType.JSON,
},
restConfig,
params,
}, isTrack);
};
export function uploadTrack({ restConfig, data, }: { export function uploadTrack({ restConfig, data, }: {
restConfig: RESTConfig, restConfig: RESTConfig,
data: { data: {
@ -180,4 +125,62 @@ export namespace TrackResource {
params, params,
}, isTrack); }, isTrack);
}; };
export function removeTrack({ restConfig, params, }: {
restConfig: RESTConfig,
params: {
artistId: Long,
id: Long,
},
}): Promise<Track> {
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<Track> {
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<Track> {
return RESTRequestJson({
restModel: {
endPoint: "/track/{id}/cover/{coverId}",
requestType: HTTPRequestModel.DELETE,
contentType: HTTPMimeType.TEXT_PLAIN,
accept: HTTPMimeType.JSON,
},
restConfig,
params,
}, isTrack);
};
} }

View File

@ -22,19 +22,6 @@ export namespace UserResource {
params, params,
}, isUserKarusic); }, isUserKarusic);
}; };
export function getMe({ restConfig, produce, }: {
restConfig: RESTConfig,
produce: HTTPMimeType.JSON,
}): Promise<UserOut> {
return RESTRequestJson({
restModel: {
endPoint: "/users/me",
requestType: HTTPRequestModel.GET,
accept: produce,
},
restConfig,
}, isUserOut);
};
export function gets({ restConfig, produce, }: { export function gets({ restConfig, produce, }: {
restConfig: RESTConfig, restConfig: RESTConfig,
produce: HTTPMimeType.JSON, produce: HTTPMimeType.JSON,
@ -48,4 +35,17 @@ export namespace UserResource {
restConfig, restConfig,
}, isUserKarusic); }, isUserKarusic);
}; };
export function getMe({ restConfig, produce, }: {
restConfig: RESTConfig,
produce: HTTPMimeType.JSON,
}): Promise<UserOut> {
return RESTRequestJson({
restModel: {
endPoint: "/users/me",
requestType: HTTPRequestModel.GET,
accept: produce,
},
restConfig,
}, isUserOut);
};
} }

View File

@ -43,6 +43,7 @@ export class ElementSeasonComponent implements OnInit {
this.prefix = this.prefixName ?? ""; this.prefix = this.prefixName ?? "";
this.count = undefined; this.count = undefined;
this.count2 = undefined; this.count2 = undefined;
console.log(`element: ${JSON.stringify(this.element, null, 2)}`);
if (isNullOrUndefined(this.element)) { if (isNullOrUndefined(this.element)) {
this.numberAlbum = undefined; this.numberAlbum = undefined;
@ -51,7 +52,9 @@ export class ElementSeasonComponent implements OnInit {
} }
this.numberAlbum = this.element.name; this.numberAlbum = this.element.name;
this.description = this.element.description; this.description = this.element.description;
console.log(`covers: ${this.element.covers}`);
this.covers = this.dataService.getListThumbnailUrl(this.element.covers); this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
console.log(`covers >> : ${this.covers}`);
let self = this; let self = this;
if (!isNullOrUndefined(this.countSubTypeCallBack)) { if (!isNullOrUndefined(this.countSubTypeCallBack)) {
this.countSubTypeCallBack(this.element.id) this.countSubTypeCallBack(this.element.id)

View File

@ -45,8 +45,7 @@ export class GenericDataService<TYPE> {
key: 'id', key: 'id',
value: ids, value: ids,
}, },
], ]);
['name', 'id']);
resolve(data); resolve(data);
return; return;
}).catch((response) => { }).catch((response) => {
@ -85,8 +84,7 @@ export class GenericDataService<TYPE> {
key: 'id', key: 'id',
value: [undefined, null], value: [undefined, null],
}, },
], ]);
['name', 'id']);
resolve(data); resolve(data);
}).catch((response) => { }).catch((response) => {
console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`); console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);

@ -1 +1 @@
Subproject commit ae86abe8ca367b91d36c48683fda8cfd82f3ec48 Subproject commit 0fd7c540ea5cdce19533338b3125e88d4ef442ef