[DEV] finish base of port but not tested
This commit is contained in:
parent
9a3f28553d
commit
5d8dab3742
@ -33,7 +33,7 @@ public class WebLauncherLocal extends WebLauncher {
|
|||||||
UserResource.class,
|
UserResource.class,
|
||||||
TrackResource.class,
|
TrackResource.class,
|
||||||
DataResource.class),
|
DataResource.class),
|
||||||
Initialization.CLASSES_BASE, "../front/src/app/model/");
|
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||||
launcher.process();
|
launcher.process();
|
||||||
launcher.logger.info("end-configure the server & wait finish process:");
|
launcher.logger.info("end-configure the server & wait finish process:");
|
||||||
|
@ -2,6 +2,7 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
@ -68,9 +69,8 @@ public class AlbumResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a specific album")
|
@Operation(description = "Remove a specific album")
|
||||||
public Response remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Album.class, id);
|
DataAccess.delete(Album.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -97,7 +97,8 @@ public class AlbumResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@Operation(description = "Add a cover on a specific album")
|
@Operation(description = "Add a cover on a specific album")
|
||||||
public Response addCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
@AsyncType(Album.class)
|
||||||
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
@ -106,8 +107,8 @@ public class AlbumResource {
|
|||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a cover on a specific album")
|
@Operation(description = "Remove a cover on a specific album")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
|
//AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Album.class, id)).build();
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Artist;
|
import org.kar.karusic.model.Artist;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -62,15 +62,15 @@ public class ArtistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Artist.class, id);
|
DataAccess.delete(Artist.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Artist.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
@ -79,8 +79,8 @@ public class ArtistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
|
//AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Artist.class, id)).build();
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,12 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Gender;
|
import org.kar.karusic.model.Gender;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -32,20 +33,20 @@ public class GenderResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Gender getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Gender get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Gender> get() throws Exception {
|
public List<Gender> gets() throws Exception {
|
||||||
return DataAccess.gets(Gender.class);
|
return DataAccess.gets(Gender.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender post(final String jsonRequest) throws Exception {
|
public Gender post(@AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public class GenderResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Gender patch(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
@ -61,15 +62,15 @@ public class GenderResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Gender.class, id);
|
DataAccess.delete(Gender.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Gender.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
@ -78,8 +79,8 @@ public class GenderResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
|
//AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Gender.class, id)).build();
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
@ -45,7 +47,7 @@ public class PlaylistResource {
|
|||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Playlist post(final String jsonRequest) throws Exception {
|
public Playlist post(@AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,16 +63,15 @@ public class PlaylistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Playlist.class, id);
|
DataAccess.delete(Playlist.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Playlist uploadTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
@ -87,6 +88,7 @@ public class PlaylistResource {
|
|||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Playlist.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
@ -95,8 +97,8 @@ public class PlaylistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
|
//AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Playlist.class, id)).build();
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
@ -41,20 +43,20 @@ public class TrackResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Track getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Track get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Track> get() throws Exception {
|
public List<Track> gets() throws Exception {
|
||||||
return DataAccess.gets(Track.class);
|
return DataAccess.gets(Track.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Track create(final String jsonRequest) throws Exception {
|
public Track post(@AsyncType(Track.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Track.class, jsonRequest);
|
return DataAccess.insertWithJson(Track.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ public class TrackResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Track put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
@ -70,9 +72,8 @@ public class TrackResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Track.class, id);
|
DataAccess.delete(Track.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -96,6 +97,7 @@ public class TrackResource {
|
|||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Track.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
@ -104,9 +106,9 @@ public class TrackResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
|
//AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
|
||||||
return Response.ok(DataAccess.get(Track.class, id)).build();
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -114,13 +116,14 @@ public class TrackResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
// Formatter:off
|
// Formatter:off
|
||||||
public Response uploadFile(
|
@AsyncType(Track.class)
|
||||||
|
public Response uploadTrack(
|
||||||
@FormDataParam("fileName") String fileName,
|
@FormDataParam("fileName") String fileName,
|
||||||
@FormDataParam("gender") String gender,
|
@FormDataParam("gender") String gender,
|
||||||
@FormDataParam("artist") String artist,
|
@FormDataParam("artist") String artist,
|
||||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||||
@FormDataParam("album") String album,
|
@FormDataParam("album") String album,
|
||||||
@FormDataParam("trackId") String trackId,
|
@AsyncType(Long.class) @FormDataParam("trackId") String trackId,
|
||||||
@FormDataParam("title") String title,
|
@FormDataParam("title") String title,
|
||||||
@FormDataParam("file") final InputStream fileInputStream,
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package org.kar.karusic.model;
|
|
||||||
/*
|
|
||||||
CREATE TABLE `data` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
`create_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been update',
|
|
||||||
`sha512` varchar(129) COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`mime_type` varchar(128) COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`size` bigint,
|
|
||||||
`original_name` TEXT
|
|
||||||
) AUTO_INCREMENT=64;
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class DataSmall {
|
|
||||||
public Long id;
|
|
||||||
public String sha512;
|
|
||||||
public String mimeType;
|
|
||||||
public Long size;
|
|
||||||
|
|
||||||
public DataSmall() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataSmall(ResultSet rs) {
|
|
||||||
int iii = 1;
|
|
||||||
try {
|
|
||||||
this.id = rs.getLong(iii++);
|
|
||||||
this.sha512 = rs.getString(iii++);
|
|
||||||
this.mimeType = rs.getString(iii++);
|
|
||||||
this.size = rs.getLong(iii++);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String getTableSql() {
|
|
||||||
return """
|
|
||||||
DROP TABLE IF EXISTS `data`;
|
|
||||||
CREATE TABLE `data` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'table ID',
|
|
||||||
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
|
||||||
`create_date` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Time the element has been update',
|
|
||||||
`sha512` varchar(129) CHARACTER SET utf8mb3 COLLATE utf8_general_ci NOT NULL,
|
|
||||||
`mime_type` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8_general_ci NOT NULL,
|
|
||||||
`size` bigint DEFAULT NULL,
|
|
||||||
`original_name` text,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
package org.kar.karusic.model;
|
|
||||||
/*
|
|
||||||
CREATE TABLE `node` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
`create_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been update',
|
|
||||||
`type` enum("TYPE", "UNIVERSE", "SERIES", "SEASON") NOT NULL DEFAULT 'TYPE',
|
|
||||||
`name` TEXT COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
|
||||||
`parent_id` bigint
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class MediaSmall {
|
|
||||||
public class MediaStreamProperty {
|
|
||||||
public Long id;
|
|
||||||
public Long timeSecond;
|
|
||||||
public Long width;
|
|
||||||
public Long height;
|
|
||||||
public Map<String, Long> videos = new HashMap<>();
|
|
||||||
public Map<String, Long> audios = new HashMap<>();
|
|
||||||
public Map<String, Long> subtitles = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long id;
|
|
||||||
public String name;
|
|
||||||
public String description;
|
|
||||||
public Long dataId;
|
|
||||||
public Long typeId;
|
|
||||||
public Long universeId;
|
|
||||||
public Long seriesId;
|
|
||||||
public Long seasonId;
|
|
||||||
public Integer episode;
|
|
||||||
public Integer date;
|
|
||||||
public Integer time;
|
|
||||||
public String ageLimit;
|
|
||||||
public List<Long> covers = null;
|
|
||||||
public MediaStreamProperty media;
|
|
||||||
|
|
||||||
public MediaSmall(ResultSet rs) {
|
|
||||||
int iii = 1;
|
|
||||||
try {
|
|
||||||
this.id = rs.getLong(iii++);
|
|
||||||
this.name = rs.getString(iii++);
|
|
||||||
this.description = rs.getString(iii++);
|
|
||||||
this.dataId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.dataId = null;
|
|
||||||
}
|
|
||||||
this.typeId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.typeId = null;
|
|
||||||
}
|
|
||||||
this.universeId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.universeId = null;
|
|
||||||
}
|
|
||||||
this.seriesId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.seriesId = null;
|
|
||||||
}
|
|
||||||
this.seasonId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.seasonId = null;
|
|
||||||
}
|
|
||||||
this.episode = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.episode = null;
|
|
||||||
}
|
|
||||||
this.date = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.date = null;
|
|
||||||
}
|
|
||||||
this.time = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.time = null;
|
|
||||||
}
|
|
||||||
this.ageLimit = rs.getString(iii++);
|
|
||||||
String coversString = rs.getString(iii++);
|
|
||||||
if (!rs.wasNull()) {
|
|
||||||
covers = new ArrayList<>();
|
|
||||||
String[] elements = coversString.split("-");
|
|
||||||
for (String elem : elements) {
|
|
||||||
Long tmp = Long.parseLong(elem);
|
|
||||||
covers.add(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,18 +10,19 @@ CREATE TABLE `node` (
|
|||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
`description` TEXT COLLATE 'utf8_general_ci',
|
||||||
`parent_id` bigint
|
`parent_id` bigint
|
||||||
) AUTO_INCREMENT=10;
|
) AUTO_INCREMENT=10;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class NodeSmall extends GenericDataSoftDelete {
|
public class NodeSmall extends GenericDataSoftDelete {
|
||||||
@ -29,6 +30,7 @@ public class NodeSmall extends GenericDataSoftDelete {
|
|||||||
public String name = null;
|
public String name = null;
|
||||||
@Column(length = 0)
|
@Column(length = 0)
|
||||||
public String description = null;
|
public String description = null;
|
||||||
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
@Schema(description = "List of Id of the specific covers")
|
||||||
public List<Long> covers = null;
|
@DataJson(targetEntity = Data.class)
|
||||||
|
public List<UUID> covers = null;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, isResponse, InputStream, isAlbum, Long, RestErrorResponse, Album, FormDataContentDisposition, } from "./model"
|
import {UUID, Long, Album, isAlbum, } from "./model"
|
||||||
export namespace AlbumResource {
|
export namespace AlbumResource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,8 +13,8 @@ export namespace AlbumResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/album/{id}",
|
endPoint: "/album/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
@ -22,7 +22,7 @@ export namespace AlbumResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get a specific Album with his ID
|
* Get a specific Album with his ID
|
||||||
@ -83,70 +83,6 @@ export namespace AlbumResource {
|
|||||||
data,
|
data,
|
||||||
}, isAlbum);
|
}, isAlbum);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Remove a Track on a specific album
|
|
||||||
*/
|
|
||||||
export function removeTrack({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
trackId: Long,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Album> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}/track/{trackId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isAlbum);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Add a cover on a specific album
|
|
||||||
*/
|
|
||||||
export function addCover({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
fileName: string,
|
|
||||||
file: FormDataContentDisposition,
|
|
||||||
},
|
|
||||||
}): Promise<Response> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}/cover",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Remove a cover on a specific album
|
|
||||||
*/
|
|
||||||
export function removeCover({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: Long,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Response> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get all the available Albums
|
* Get all the available Albums
|
||||||
*/
|
*/
|
||||||
@ -176,6 +112,72 @@ export namespace AlbumResource {
|
|||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/album/{id}/track/{trackId}",
|
endPoint: "/album/{id}/track/{trackId}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a Track on a specific album
|
||||||
|
*/
|
||||||
|
export function removeTrack({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
trackId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}/track/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Add a cover on a specific album
|
||||||
|
*/
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a cover on a specific album
|
||||||
|
*/
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, Artist, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, 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, }: {
|
||||||
@ -10,8 +10,8 @@ export namespace ArtistResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/artist/{id}",
|
endPoint: "/artist/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
@ -19,7 +19,7 @@ export namespace ArtistResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
export function get({ restConfig, params, }: {
|
export function get({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
@ -71,44 +71,6 @@ export namespace ArtistResource {
|
|||||||
data,
|
data,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
fileName: string,
|
|
||||||
file: FormDataContentDisposition,
|
|
||||||
},
|
|
||||||
}): Promise<Response> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/artist/{id}/cover",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
export function removeCover({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: Long,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Response> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/artist/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
export function gets({ restConfig, }: {
|
export function gets({ restConfig, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Artist[]> {
|
}): Promise<Artist[]> {
|
||||||
@ -121,4 +83,43 @@ export namespace ArtistResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
}
|
}
|
@ -1,13 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, } from "./model"
|
import {Long, } from "./model"
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a new data in the data environment
|
||||||
|
*/
|
||||||
|
export function uploadFile({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data//upload/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment
|
* Get back some data from the data environment
|
||||||
*/
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
export function retrieveDataId({ restConfig, queries, params, data, }: {
|
export function retrieveDataId({ restConfig, queries, params, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
@ -17,8 +38,8 @@ export namespace DataResource {
|
|||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{id}",
|
endPoint: "/data/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
@ -27,11 +48,12 @@ export namespace DataResource {
|
|||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get a thumbnail of from the data environment (if resize is possible)
|
* Get a thumbnail of from the data environment (if resize is possible)
|
||||||
*/
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
export function retrieveDataThumbnailId({ restConfig, queries, params, data, }: {
|
export function retrieveDataThumbnailId({ restConfig, queries, params, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
@ -41,8 +63,8 @@ export namespace DataResource {
|
|||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/thumbnail/{id}",
|
endPoint: "/data/thumbnail/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
@ -51,11 +73,12 @@ export namespace DataResource {
|
|||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment (with a beautifull name (permit download with basic name)
|
* Get back some data from the data environment (with a beautifull name (permit download with basic name)
|
||||||
*/
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
export function retrieveDataFull({ restConfig, queries, params, data, }: {
|
export function retrieveDataFull({ restConfig, queries, params, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
@ -66,8 +89,8 @@ export namespace DataResource {
|
|||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{id}/{name}",
|
endPoint: "/data/{id}/{name}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
@ -76,25 +99,6 @@ export namespace DataResource {
|
|||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Insert a new data in the data environment
|
|
||||||
*/
|
|
||||||
export function uploadFile({ restConfig, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: {
|
|
||||||
file: FormDataContentDisposition,
|
|
||||||
},
|
|
||||||
}): Promise<Response> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data//upload/",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}, isResponse);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {RestErrorResponse, } from "./model"
|
import {} from "./model"
|
||||||
export namespace Front {
|
export namespace Front {
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, isResponse, InputStream, Long, RestErrorResponse, isGender, Gender, FormDataContentDisposition, } 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, }: {
|
||||||
@ -10,8 +10,8 @@ export namespace GenderResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender/{id}",
|
endPoint: "/gender/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
@ -19,21 +19,25 @@ export namespace GenderResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
export function get({ restConfig, }: {
|
export function get({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Gender[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender",
|
endPoint: "/gender/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
export function put({ restConfig, params, data, }: {
|
export function patch({ restConfig, params, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
@ -54,7 +58,7 @@ export namespace GenderResource {
|
|||||||
};
|
};
|
||||||
export function post({ restConfig, data, }: {
|
export function post({ restConfig, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: string,
|
data: Gender,
|
||||||
}): Promise<Gender> {
|
}): Promise<Gender> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -67,6 +71,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: {
|
||||||
@ -74,27 +90,28 @@ export namespace GenderResource {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
file: FormDataContentDisposition,
|
file: File,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Gender> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender/{id}/cover",
|
endPoint: "/gender/{id}/cover",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
}, isGender);
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function removeCover({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: Long,
|
coverId: UUID,
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Gender> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender/{id}/cover/{coverId}",
|
endPoint: "/gender/{id}/cover/{coverId}",
|
||||||
@ -103,22 +120,6 @@ export namespace GenderResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
export function getWithId({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Gender> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/gender/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {RestErrorResponse, isHealthResult, HealthResult, } from "./model"
|
import {HealthResult, isHealthResult, } from "./model"
|
||||||
export namespace HealthCheck {
|
export namespace HealthCheck {
|
||||||
|
|
||||||
export function getHealth({ restConfig, }: {
|
export function getHealth({ restConfig, }: {
|
@ -140,20 +140,6 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodResponse = zod.object({
|
|
||||||
});
|
|
||||||
export type Response = zod.infer<typeof ZodResponse>;
|
|
||||||
export function isResponse(data: any): data is Response {
|
|
||||||
try {
|
|
||||||
ZodResponse.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericTiming = zod.object({
|
export const ZodGenericTiming = zod.object({
|
||||||
// Create time of the object
|
// Create time of the object
|
||||||
createdAt: ZodDate.readonly().optional(),
|
createdAt: ZodDate.readonly().optional(),
|
||||||
@ -207,7 +193,8 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
|||||||
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
||||||
name: zod.string().max(256).optional(),
|
name: zod.string().max(256).optional(),
|
||||||
description: zod.string().optional(),
|
description: zod.string().optional(),
|
||||||
covers: zod.array(ZodLong).optional()
|
// List of Id of the specific covers
|
||||||
|
covers: zod.array(ZodUUID).optional()
|
||||||
});
|
});
|
||||||
export type NodeSmall = zod.infer<typeof ZodNodeSmall>;
|
export type NodeSmall = zod.infer<typeof ZodNodeSmall>;
|
||||||
export function isNodeSmall(data: any): data is NodeSmall {
|
export function isNodeSmall(data: any): data is NodeSmall {
|
||||||
@ -236,48 +223,6 @@ export function isAlbum(data: any): data is Album {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodInputStream = zod.object({
|
|
||||||
});
|
|
||||||
export type InputStream = zod.infer<typeof ZodInputStream>;
|
|
||||||
export function isInputStream(data: any): data is InputStream {
|
|
||||||
try {
|
|
||||||
ZodInputStream.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodContentDisposition = zod.object({
|
|
||||||
});
|
|
||||||
export type ContentDisposition = zod.infer<typeof ZodContentDisposition>;
|
|
||||||
export function isContentDisposition(data: any): data is ContentDisposition {
|
|
||||||
try {
|
|
||||||
ZodContentDisposition.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodFormDataContentDisposition = ZodContentDisposition.extend({
|
|
||||||
});
|
|
||||||
export type FormDataContentDisposition = zod.infer<typeof ZodFormDataContentDisposition>;
|
|
||||||
export function isFormDataContentDisposition(data: any): data is FormDataContentDisposition {
|
|
||||||
try {
|
|
||||||
ZodFormDataContentDisposition.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodArtist = ZodNodeSmall.extend({
|
export const ZodArtist = ZodNodeSmall.extend({
|
||||||
firstName: zod.string().max(256).optional(),
|
firstName: zod.string().max(256).optional(),
|
||||||
surname: zod.string().max(256).optional(),
|
surname: zod.string().max(256).optional(),
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, Playlist, isPlaylist, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, } 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, }: {
|
||||||
@ -10,8 +10,8 @@ export namespace PlaylistResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}",
|
endPoint: "/playlist/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
@ -19,7 +19,7 @@ export namespace PlaylistResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
export function get({ restConfig, }: {
|
export function get({ restConfig, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
@ -54,7 +54,7 @@ export namespace PlaylistResource {
|
|||||||
};
|
};
|
||||||
export function post({ restConfig, data, }: {
|
export function post({ restConfig, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: string,
|
data: Playlist,
|
||||||
}): Promise<Playlist> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -91,27 +91,28 @@ export namespace PlaylistResource {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
file: FormDataContentDisposition,
|
file: File,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}/cover",
|
endPoint: "/playlist/{id}/cover",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function removeCover({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: Long,
|
coverId: UUID,
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}/cover/{coverId}",
|
endPoint: "/playlist/{id}/cover/{coverId}",
|
||||||
@ -120,7 +121,7 @@ export namespace PlaylistResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function getWithId({ restConfig, params, }: {
|
export function getWithId({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
@ -138,7 +139,7 @@ export namespace PlaylistResource {
|
|||||||
params,
|
params,
|
||||||
}, isPlaylist);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function addTrack({ restConfig, params, }: {
|
export function uploadTrack({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
trackId: Long,
|
trackId: Long,
|
||||||
@ -149,6 +150,7 @@ export namespace PlaylistResource {
|
|||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}/track/{trackId}",
|
endPoint: "/playlist/{id}/track/{trackId}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @copyright 2024, Edouard DUPIN, all right reserved
|
* @copyright 2024, Edouard DUPIN, all right reserved
|
||||||
* @license MPL-2 (Generate file)
|
* @license MPL-2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RestErrorResponse } from "./model"
|
import { RestErrorResponse } from "./model"
|
||||||
@ -20,6 +20,8 @@ export enum HTTPMimeType {
|
|||||||
IMAGE_PNG = 'image/png',
|
IMAGE_PNG = 'image/png',
|
||||||
JSON = 'application/json',
|
JSON = 'application/json',
|
||||||
OCTET_STREAM = 'application/octet-stream',
|
OCTET_STREAM = 'application/octet-stream',
|
||||||
|
MULTIPART = 'multipart/form-data',
|
||||||
|
CSV = 'text/csv',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTConfig {
|
export interface RESTConfig {
|
||||||
@ -42,11 +44,6 @@ export interface RESTModel {
|
|||||||
tokenInUrl?: boolean;
|
tokenInUrl?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTRequest {
|
|
||||||
params?: object;
|
|
||||||
body?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModelResponseHttp {
|
export interface ModelResponseHttp {
|
||||||
status: number;
|
status: number;
|
||||||
data: any;
|
data: any;
|
||||||
@ -119,6 +116,12 @@ export function RESTRequest({ restModel, restConfig, data, params, queries }: RE
|
|||||||
let body = data;
|
let body = data;
|
||||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||||
body = JSON.stringify(data);
|
body = JSON.stringify(data);
|
||||||
|
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const name in data) {
|
||||||
|
formData.append(name, data[name]);
|
||||||
|
}
|
||||||
|
body = formData
|
||||||
}
|
}
|
||||||
console.log(`Call ${generateUrl}`)
|
console.log(`Call ${generateUrl}`)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -215,3 +218,13 @@ export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (d
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
resolve();
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {Response, isTrack, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, Track, } 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, }: {
|
||||||
@ -10,8 +10,8 @@ export namespace TrackResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track/{id}",
|
endPoint: "/track/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
@ -19,26 +19,30 @@ export namespace TrackResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
});
|
||||||
};
|
};
|
||||||
export function get({ restConfig, }: {
|
export function get({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Track[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function put({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: string,
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Track,
|
||||||
}): Promise<Track> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -52,9 +56,9 @@ export namespace TrackResource {
|
|||||||
data,
|
data,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function create({ restConfig, data, }: {
|
export function post({ restConfig, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: string,
|
data: Track,
|
||||||
}): Promise<Track> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -67,6 +71,36 @@ export namespace TrackResource {
|
|||||||
data,
|
data,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Track[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function addTrack({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
artistId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/artist/{artistId}",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
export function removeTrack({ restConfig, params, }: {
|
export function removeTrack({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
@ -91,27 +125,28 @@ export namespace TrackResource {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
file: FormDataContentDisposition,
|
file: File,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track/{id}/cover",
|
endPoint: "/track/{id}/cover",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function removeCover({ restConfig, params, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: Long,
|
coverId: UUID,
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track/{id}/cover/{coverId}",
|
endPoint: "/track/{id}/cover/{coverId}",
|
||||||
@ -120,61 +155,29 @@ export namespace TrackResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isResponse);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function uploadFile({ restConfig, data, }: {
|
export function uploadTrack({ restConfig, data, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
file: FormDataContentDisposition,
|
file: File,
|
||||||
gender: string,
|
gender: string,
|
||||||
artist: string,
|
artist: string,
|
||||||
album: string,
|
album: string,
|
||||||
trackId: string,
|
trackId: Long,
|
||||||
title: string,
|
title: string,
|
||||||
},
|
},
|
||||||
}): Promise<Response> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track//upload/",
|
endPoint: "/track//upload/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
}, isResponse);
|
|
||||||
};
|
|
||||||
export function getWithId({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Track> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function addTrack({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
artistId: Long,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Track> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track/{id}/artist/{artistId}",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,48 +1,51 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* API of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
import {UserKarusic, UserOut, isUserOut, Long, RestErrorResponse, isUserKarusic, } from "./model"
|
import {UserOut, Long, UserKarusic, isUserOut, isUserKarusic, } from "./model"
|
||||||
export namespace UserResource {
|
export namespace UserResource {
|
||||||
|
|
||||||
export function get({ restConfig, params, }: {
|
export function get({ restConfig, params, produce, }: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
}): Promise<UserKarusic> {
|
}): Promise<UserKarusic> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/users/{id}",
|
endPoint: "/users/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: produce,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isUserKarusic);
|
}, isUserKarusic);
|
||||||
};
|
};
|
||||||
export function getMe({ restConfig, }: {
|
export function gets({ restConfig, produce, }: {
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<UserOut> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/me",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isUserOut);
|
|
||||||
};
|
|
||||||
export function gets({ restConfig, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
}): Promise<UserKarusic[]> {
|
}): Promise<UserKarusic[]> {
|
||||||
return RESTRequestJsonArray({
|
return RESTRequestJsonArray({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/users",
|
endPoint: "/users",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: produce,
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
};
|
||||||
}
|
}
|
@ -10,30 +10,30 @@ import { DataService } from 'app/service/data';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'data-image',
|
selector: 'data-image',
|
||||||
templateUrl: './data-image.html',
|
templateUrl: './data-image.html',
|
||||||
styleUrls: [ './data-image.less' ]
|
styleUrls: ['./data-image.less']
|
||||||
})
|
})
|
||||||
export class ElementDataImageComponent implements OnInit {
|
export class ElementDataImageComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() id:number = -1;
|
@Input() id: string = "0";
|
||||||
cover: string = '';
|
cover: string = '';
|
||||||
/*
|
/*
|
||||||
imageCanvas:any;
|
imageCanvas:any;
|
||||||
@ViewChild('imageCanvas')
|
@ViewChild('imageCanvas')
|
||||||
set mainDivEl(el: ElementRef) {
|
set mainDivEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if(el !== null && el !== undefined) {
|
||||||
this.imageCanvas = el.nativeElement;
|
this.imageCanvas = el.nativeElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
constructor(private dataService: DataService) {
|
constructor(private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.cover = this.dataService.getCoverThumbnailUrl(this.id);
|
this.cover = this.dataService.getThumbnailUrl(this.id);
|
||||||
/*
|
/*
|
||||||
let canvas = this.imageCanvas.nativeElement;
|
let canvas = this.imageCanvas.nativeElement;
|
||||||
let ctx = canvas.getContext("2d");
|
let ctx = canvas.getContext("2d");
|
||||||
console.log(`Request thumnail for ---> ${this.id}`);
|
console.log(`Request thumbnail for ---> ${this.id}`);
|
||||||
this.dataService.getImageThumbnail(this.id)
|
this.dataService.getImageThumbnail(this.id)
|
||||||
.then((result:ModelResponseHttp) => {
|
.then((result:ModelResponseHttp) => {
|
||||||
console.log(`plop ---> ${result.status}`);
|
console.log(`plop ---> ${result.status}`);
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { GenderService, DataService } from 'app/service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'description-area',
|
selector: 'description-area',
|
||||||
|
@ -5,14 +5,13 @@
|
|||||||
*/
|
*/
|
||||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { isArray, isNullOrUndefined } from 'common/utils';
|
import { isArray, isNullOrUndefined } from 'common/utils';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service';
|
import { DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service';
|
||||||
import { PlaylistCurrent } from 'app/service/player';
|
import { PlaylistCurrent } from 'app/service/player';
|
||||||
import { HttpWrapperService } from 'common/service';
|
import { HttpWrapperService } from 'common/service';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { Track } from 'app/model/server-karusic-api';
|
import { Album, Artist, Track } from 'app/back-api';
|
||||||
|
|
||||||
|
|
||||||
export enum PlayMode {
|
export enum PlayMode {
|
||||||
@ -74,10 +73,9 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
private trackService: TrackService,
|
private trackService: TrackService,
|
||||||
|
private dataService: DataService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private httpService: HttpWrapperService,
|
|
||||||
private dataService: DataService,
|
|
||||||
private titleService: Title) {
|
private titleService: Title) {
|
||||||
// nothing to do...
|
// nothing to do...
|
||||||
}
|
}
|
||||||
@ -113,7 +111,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
self.dataTitle = response.name;
|
self.dataTitle = response.name;
|
||||||
if (!isNullOrUndefined(response.albumId)) {
|
if (!isNullOrUndefined(response.albumId)) {
|
||||||
this.albumService.get(response.albumId)
|
this.albumService.get(response.albumId)
|
||||||
.then((response2: NodeData) => {
|
.then((response2: Album) => {
|
||||||
self.dataAlbum = response2.name;
|
self.dataAlbum = response2.name;
|
||||||
self.updateTitle();
|
self.updateTitle();
|
||||||
})
|
})
|
||||||
@ -121,7 +119,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) {
|
if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) {
|
||||||
this.artistService.get(response.artists[0])
|
this.artistService.get(response.artists[0])
|
||||||
.then((response2: NodeData) => {
|
.then((response2: Artist) => {
|
||||||
self.dataAuthor = response2.name;
|
self.dataAuthor = response2.name;
|
||||||
})
|
})
|
||||||
.catch(() => { });
|
.catch(() => { });
|
||||||
@ -134,10 +132,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
console.log("Can not retrieve the media ... null or undefined data ID")
|
console.log("Can not retrieve the media ... null or undefined data ID")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.mediaSource = self.httpService.createRESTCall2({
|
self.mediaSource = self.dataService.getUrl(self.currentLMedia.dataId, "unknownMediaName.webm");
|
||||||
api: `data/${self.currentLMedia.dataId}/unknowMediaName.webm`, //${self.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
}).replace("http://localhost:19080", "https://atria-soft.org");
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.error("error not unmanaged in audio player ... 111");
|
console.error("error not unmanaged in audio player ... 111");
|
||||||
})
|
})
|
||||||
@ -195,7 +190,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertIndisplayTime(time: number): string {
|
convertInDisplayTime(time: number): string {
|
||||||
let temporaryValue = parseInt(`${time}`, 10);
|
let temporaryValue = parseInt(`${time}`, 10);
|
||||||
let hours = parseInt(`${temporaryValue / 3600}`, 10);
|
let hours = parseInt(`${temporaryValue / 3600}`, 10);
|
||||||
temporaryValue = temporaryValue - hours * 3600;
|
temporaryValue = temporaryValue - hours * 3600;
|
||||||
@ -222,14 +217,14 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
// console.log("time change ");
|
// console.log("time change ");
|
||||||
// console.log(" ==> " + this.audioPlayer.currentTime);
|
// console.log(" ==> " + this.audioPlayer.currentTime);
|
||||||
this.currentTime = this.mediaPlayer.currentTime;
|
this.currentTime = this.mediaPlayer.currentTime;
|
||||||
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
|
this.currentTimeDisplay = this.convertInDisplayTime(this.currentTime);
|
||||||
// console.log(" ==> " + this.currentTimeDisplay);
|
// console.log(" ==> " + this.currentTimeDisplay);
|
||||||
}
|
}
|
||||||
changeDurationchange(duration: any) {
|
changeDurationchange(duration: any) {
|
||||||
console.log('duration change ');
|
console.log('duration change ');
|
||||||
console.log(` ==> ${this.mediaPlayer.duration}`);
|
console.log(` ==> ${this.mediaPlayer.duration}`);
|
||||||
this.duration = this.mediaPlayer.duration;
|
this.duration = this.mediaPlayer.duration;
|
||||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
this.durationDisplay = this.convertInDisplayTime(this.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPlay() {
|
onPlay() {
|
||||||
|
@ -3,28 +3,29 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, DataService } from 'app/service';
|
import { AlbumService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { isNullOrUndefined } from 'common/utils';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-season',
|
selector: 'app-element-season',
|
||||||
templateUrl: './element-season.html',
|
templateUrl: './element-season.html',
|
||||||
styleUrls: [ './element-season.less' ]
|
styleUrls: ['./element-season.less']
|
||||||
})
|
})
|
||||||
export class ElementSeasonComponent implements OnInit {
|
export class ElementSeasonComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() prefix:String;
|
@Input() prefix: String;
|
||||||
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
||||||
@Input() countSubType: String;
|
@Input() countSubType: String;
|
||||||
@Input() countSubType2CallBack: (arg0: number) => Promise<number>;
|
@Input() countSubType2CallBack: (arg0: number) => Promise<number>;
|
||||||
@Input() countSubType2: String;
|
@Input() countSubType2: String;
|
||||||
@Input() subValuesCallBack: (arg0: number) => Promise<string[]>;
|
@Input() subValuesCallBack: (arg0: number) => Promise<string[]>;
|
||||||
@Input() subValues: String;
|
@Input() subValues: String;
|
||||||
|
|
||||||
prefixName: string = "";
|
prefixName: string = "";
|
||||||
numberAlbum: string;
|
numberAlbum: string;
|
||||||
count: number;
|
count: number;
|
||||||
@ -39,7 +40,7 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.prefix = this.prefixName??"";
|
this.prefix = this.prefixName ?? "";
|
||||||
this.count = undefined;
|
this.count = undefined;
|
||||||
this.count2 = undefined;
|
this.count2 = undefined;
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ 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;
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.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)
|
||||||
@ -75,7 +76,7 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
this.subValuesCallBack(this.element.id)
|
this.subValuesCallBack(this.element.id)
|
||||||
.then((response: string[]) => {
|
.then((response: string[]) => {
|
||||||
this.subValueData = "";
|
this.subValueData = "";
|
||||||
for (let kkk=0; kkk<response.length; kkk++) {
|
for (let kkk = 0; kkk < response.length; kkk++) {
|
||||||
if (kkk != 0) {
|
if (kkk != 0) {
|
||||||
this.subValueData += ", ";
|
this.subValueData += ", ";
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="count-base">
|
<div class="count-base">
|
||||||
@if(counttrack) {
|
@if(countTrack) {
|
||||||
<div class="count">
|
<div class="count">
|
||||||
{{counttrack}}
|
{{countTrack}}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,28 +4,28 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { isNullOrUndefined } from 'common/utils';
|
||||||
|
|
||||||
import { ArtistService, DataService } from 'app/service';
|
import { DataService, TrackService } from 'app/service';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-series',
|
selector: 'app-element-series',
|
||||||
templateUrl: './element-series.html',
|
templateUrl: './element-series.html',
|
||||||
styleUrls: [ './element-series.less' ]
|
styleUrls: ['./element-series.less']
|
||||||
})
|
})
|
||||||
export class ElementSeriesComponent implements OnInit {
|
export class ElementSeriesComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
|
|
||||||
name:string = 'plouf';
|
|
||||||
description:string = '';
|
|
||||||
counttrack:number = null;
|
|
||||||
|
|
||||||
covers:string[];
|
name: string = 'plouf';
|
||||||
|
description: string = '';
|
||||||
|
countTrack: number = null;
|
||||||
|
|
||||||
|
covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private trackService: TrackService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -35,16 +35,15 @@ export class ElementSeriesComponent implements OnInit {
|
|||||||
this.description = undefined;
|
this.description = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
this.name = this.element.name;
|
||||||
self.name = this.element.name;
|
this.description = this.element.description;
|
||||||
self.description = this.element.description;
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
|
||||||
|
|
||||||
this.artistService.countTrack(this.element.id)
|
this.trackService.countTracksOfAnArtist(this.element.id)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.counttrack = response;
|
this.countTrack = response;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.counttrack = 0;
|
this.countTrack = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,22 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, DataService } from 'app/service';
|
import { AlbumService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { isNullOrUndefined } from 'common/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-track',
|
selector: 'app-element-track',
|
||||||
templateUrl: './element-track.html',
|
templateUrl: './element-track.html',
|
||||||
styleUrls: [ './element-track.less' ]
|
styleUrls: ['./element-track.less']
|
||||||
})
|
})
|
||||||
export class ElementTrackComponent implements OnInit {
|
export class ElementTrackComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() prefix:String;
|
@Input() prefix: String;
|
||||||
|
|
||||||
prefixName: string = "";
|
prefixName: string = "";
|
||||||
name: string;
|
name: string;
|
||||||
track: number;
|
track: number;
|
||||||
@ -31,7 +31,7 @@ export class ElementTrackComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.prefix = this.prefixName??"";
|
this.prefix = this.prefixName ?? "";
|
||||||
if (isNullOrUndefined(this.element)) {
|
if (isNullOrUndefined(this.element)) {
|
||||||
this.name = undefined;
|
this.name = undefined;
|
||||||
this.covers = undefined;
|
this.covers = undefined;
|
||||||
@ -40,7 +40,6 @@ export class ElementTrackComponent implements OnInit {
|
|||||||
this.name = this.element.name;
|
this.name = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
this.track = this.element["track"];
|
this.track = this.element["track"];
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
let self = this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
@if(counttrack) {
|
@if(countTrack) {
|
||||||
<div class="count-base">
|
<div class="count-base">
|
||||||
<span class="count">{{counttrack}}</span>
|
<span class="count">{{countTrack}}</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div class="imgContainer-small">
|
<div class="imgContainer-small">
|
||||||
|
@ -4,30 +4,30 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
import { isNullOrUndefined } from 'common/utils';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
import { DataService } from 'app/service';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
import { GenderService, DataService } from 'app/service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-type',
|
selector: 'app-element-type',
|
||||||
templateUrl: './element-type.html',
|
templateUrl: './element-type.html',
|
||||||
styleUrls: [ './element-type.less' ]
|
styleUrls: ['./element-type.less']
|
||||||
})
|
})
|
||||||
export class ElementTypeComponent implements OnInit {
|
export class ElementTypeComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() functionVignette:(number) => Promise<Number>;
|
@Input() functionVignette: (number) => Promise<Number>;
|
||||||
|
|
||||||
public name: string = 'rr';
|
public name: string = 'rr';
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
public counttrack: number;
|
public countTrack: number;
|
||||||
|
|
||||||
public covers: string[];
|
public covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private typeService: GenderService,
|
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export class ElementTypeComponent implements OnInit {
|
|||||||
if (isNullOrUndefined(this.element)) {
|
if (isNullOrUndefined(this.element)) {
|
||||||
this.name = 'Not a media';
|
this.name = 'Not a media';
|
||||||
this.description = undefined;
|
this.description = undefined;
|
||||||
this.counttrack = undefined;
|
this.countTrack = undefined;
|
||||||
this.covers = undefined;
|
this.covers = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,14 +43,14 @@ export class ElementTypeComponent implements OnInit {
|
|||||||
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
||||||
self.name = this.element.name;
|
self.name = this.element.name;
|
||||||
self.description = this.element.description;
|
self.description = this.element.description;
|
||||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.functionVignette)) {
|
if (!isNullOrUndefined(this.functionVignette)) {
|
||||||
this.functionVignette(this.element.id)
|
this.functionVignette(this.element.id)
|
||||||
.then((response: number) => {
|
.then((response: number) => {
|
||||||
self.counttrack = response;
|
self.countTrack = response;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
self.counttrack = 0;
|
self.countTrack = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
||||||
import { Track, isTrack } from 'app/model/server-karusic-api';
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
import { DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-video',
|
selector: 'app-element-video',
|
||||||
@ -19,9 +17,7 @@ import { isNullOrUndefined } from 'common/utils';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ElementVideoComponent implements OnInit {
|
export class ElementVideoComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element: NodeData;
|
@Input() element: Track;
|
||||||
data: Track;
|
|
||||||
|
|
||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
episodeDisplay: string = '';
|
episodeDisplay: string = '';
|
||||||
@ -34,15 +30,8 @@ export class ElementVideoComponent implements OnInit {
|
|||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (!isTrack(this.element)) {
|
|
||||||
this.data = undefined;
|
|
||||||
this.name = 'Not a track';
|
|
||||||
this.description = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.data = this.element;
|
|
||||||
this.name = this.element.name;
|
this.name = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Album } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, ArianeService, DataService } from 'app/service';
|
import { AlbumService, ArianeService, DataService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||||
import { PopInService } from 'common/service';
|
import { PopInService } from 'common/service';
|
||||||
@ -45,7 +45,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
// --------------- confirm section ------------------
|
// --------------- confirm section ------------------
|
||||||
public confirmDeleteComment: string = null;
|
public confirmDeleteComment: string = null;
|
||||||
public confirmDeleteImageUrl: string = null;
|
public confirmDeleteImageUrl: string = null;
|
||||||
private deleteCoverId: number = null;
|
private deleteCoverId: string = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@ -67,6 +67,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService,
|
private popInService: PopInService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
@ -77,7 +78,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
this.idAlbum = this.arianeService.getAlbumId();
|
this.idAlbum = this.arianeService.getAlbumId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.albumService.get(this.idAlbum)
|
this.albumService.get(this.idAlbum)
|
||||||
.then((response: NodeData) => {
|
.then((response: Album) => {
|
||||||
console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.nameAlbum = response.name;
|
self.nameAlbum = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
@ -91,7 +92,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
self.itemIsNotFound = true;
|
self.itemIsNotFound = true;
|
||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
});
|
});
|
||||||
this.albumService.getTrack(this.idAlbum)
|
this.trackService.getTracksWithAlbumId(this.idAlbum)
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
self.trackCount = response.length;
|
self.trackCount = response.length;
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
@ -105,7 +106,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
for (let iii = 0; iii < covers.length; iii++) {
|
for (let iii = 0; iii < covers.length; iii++) {
|
||||||
this.coversDisplay.push({
|
this.coversDisplay.push({
|
||||||
id: covers[iii],
|
id: covers[iii],
|
||||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -165,7 +166,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
this.upload.clear();
|
this.upload.clear();
|
||||||
// display the upload pop-in
|
// display the upload pop-in
|
||||||
this.popInService.open('popin-upload-progress');
|
this.popInService.open('popin-upload-progress');
|
||||||
this.albumService.uploadCover(file, this.idAlbum, (count, total) => {
|
this.albumService.uploadCover(this.idAlbum, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@ -179,10 +180,10 @@ export class AlbumEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCover(id: number) {
|
removeCover(id: string) {
|
||||||
this.cleanConfirm();
|
this.cleanConfirm();
|
||||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||||
this.deleteCoverId = id;
|
this.deleteCoverId = id;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Media } from 'app/model';
|
import { Album, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
import { arrayUnique } from 'common/utils/arrayTools';
|
import { arrayUnique } from 'common/utils/arrayTools';
|
||||||
@ -26,7 +26,7 @@ export class AlbumScene implements OnInit {
|
|||||||
public albumCovers: string[] = undefined;
|
public albumCovers: string[] = undefined;
|
||||||
|
|
||||||
public tracksIds: number[] = undefined;
|
public tracksIds: number[] = undefined;
|
||||||
public tracks: Media[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
@ -45,7 +45,7 @@ export class AlbumScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.albumName = response.name;
|
self.albumName = response.name;
|
||||||
self.albumDescription = response.description;
|
self.albumDescription = response.description;
|
||||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albumDescription = undefined;
|
self.albumDescription = undefined;
|
||||||
self.albumName = '???';
|
self.albumName = '???';
|
||||||
@ -54,8 +54,8 @@ export class AlbumScene implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//console.log("all the tracks: " + self.tracksIds);
|
//console.log("all the tracks: " + self.tracksIds);
|
||||||
this.trackService.getWithAlbum(self.idAlbum)
|
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||||
.then((response2: Media[]) => {
|
.then((response2: Track[]) => {
|
||||||
self.tracks = response2;
|
self.tracks = response2;
|
||||||
self.artistIds = []
|
self.artistIds = []
|
||||||
self.tracks.forEach(element => {
|
self.tracks.forEach(element => {
|
||||||
@ -73,8 +73,8 @@ export class AlbumScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.artistCovers = self.dataService.getCoverListUrl(response.covers);
|
self.artistCovers = self.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((error) => {
|
||||||
self.description = undefined;
|
self.description = undefined;
|
||||||
self.name = '???';
|
self.name = '???';
|
||||||
self.artistCovers = undefined;
|
self.artistCovers = undefined;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Album, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
import { NodeData } from 'common/model';
|
||||||
@ -19,8 +20,8 @@ export class AlbumsScene implements OnInit {
|
|||||||
public name: string = '';
|
public name: string = '';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: string[] = undefined;
|
public covers: string[] = undefined;
|
||||||
public albums: NodeData[] = undefined;
|
public albums: Album[] = undefined;
|
||||||
public albumsSave: NodeData[] = undefined;
|
public albumsSave: Album[] = undefined;
|
||||||
public tracks: any[] = undefined;
|
public tracks: any[] = undefined;
|
||||||
public countSubElement: number = undefined;
|
public countSubElement: number = undefined;
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
@ -37,12 +38,13 @@ export class AlbumsScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(albumId: number): Promise<Number> {
|
countTrackCallback(albumId: number): Promise<Number> {
|
||||||
return this.albumService.countTrack(albumId);
|
return this.trackService.countTracksWithAlbumId(albumId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArtistsStringCallback(albumId: number): Promise<String[]> {
|
getArtistsStringCallback(albumId: number): Promise<String[]> {
|
||||||
//console.log(`request all artist for album: {albumId}`)
|
//console.log(`request all artist for album: {albumId}`)
|
||||||
return this.albumService.getArtists(albumId);
|
//return this.trackService.getAlbumIdsOfAnArtist(albumId);
|
||||||
|
return new Promise((resolve, reject) => { resolve(["a implementer pus tyar"]); });
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -60,7 +62,7 @@ export class AlbumsScene implements OnInit {
|
|||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albums = undefined;
|
self.albums = undefined;
|
||||||
});
|
});
|
||||||
// TODO later: get all orfan tracks ...
|
// TODO later: get all orfans tracks ...
|
||||||
/*
|
/*
|
||||||
this.artistService.getTrack(this.idArtist)
|
this.artistService.getTrack(this.idArtist)
|
||||||
.then((response: NodeData[]) => {
|
.then((response: NodeData[]) => {
|
||||||
@ -97,8 +99,8 @@ export class AlbumsScene implements OnInit {
|
|||||||
playAll(): void {
|
playAll(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@ -112,8 +114,8 @@ export class AlbumsScene implements OnInit {
|
|||||||
playShuffle(): void {
|
playShuffle(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
|
@ -32,19 +32,6 @@
|
|||||||
}
|
}
|
||||||
@else {
|
@else {
|
||||||
<div class="fill-all">
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
|
||||||
<div class="label">
|
|
||||||
Type:
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<select [ngModel]="typeId"
|
|
||||||
(ngModelChange)="onChangeType($event)">
|
|
||||||
@for (element of listType; track element.value;) {
|
|
||||||
<option [ngValue]="element.value">{{element.label}}</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
Name:
|
Name:
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Artist, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, GenderService, ArianeService } from 'app/service';
|
import { ArtistService, DataService, GenderService, ArianeService, TrackService } from 'app/service';
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||||
import { PopInService } from 'common/service';
|
import { PopInService } from 'common/service';
|
||||||
|
|
||||||
@ -31,7 +32,6 @@ export class ArtistEditScene implements OnInit {
|
|||||||
|
|
||||||
error: string = '';
|
error: string = '';
|
||||||
|
|
||||||
typeId: number = null;
|
|
||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
coverFile: File;
|
coverFile: File;
|
||||||
@ -45,15 +45,10 @@ export class ArtistEditScene implements OnInit {
|
|||||||
// section tha define the upload value to display in the pop-in of upload
|
// section tha define the upload value to display in the pop-in of upload
|
||||||
public upload: UploadProgress = new UploadProgress();
|
public upload: UploadProgress = new UploadProgress();
|
||||||
|
|
||||||
|
|
||||||
listType: ElementList[] = [
|
|
||||||
{ value: undefined, label: '---' },
|
|
||||||
];
|
|
||||||
|
|
||||||
// --------------- confirm section ------------------
|
// --------------- confirm section ------------------
|
||||||
public confirmDeleteComment: string = null;
|
public confirmDeleteComment: string = null;
|
||||||
public confirmDeleteImageUrl: string = null;
|
public confirmDeleteImageUrl: string = null;
|
||||||
private deleteCoverId: number = null;
|
private deleteCoverId: string = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@ -74,8 +69,9 @@ export class ArtistEditScene implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
constructor(private dataService: DataService,
|
constructor(private dataService: DataService,
|
||||||
private typeService: GenderService,
|
private genderService: GenderService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService) {
|
private popInService: PopInService) {
|
||||||
|
|
||||||
@ -84,22 +80,11 @@ export class ArtistEditScene implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
this.idArtist = this.arianeService.getArtistId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.listType = [{ value: null, label: '---' }];
|
|
||||||
|
|
||||||
this.typeService.getData()
|
|
||||||
.then((response2) => {
|
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
|
||||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
|
||||||
}
|
|
||||||
}).catch((response2) => {
|
|
||||||
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.artistService.get(this.idArtist)
|
this.artistService.get(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: Artist) => {
|
||||||
// console.log("get response of track : " + JSON.stringify(response, null, 2));
|
// console.log("get response of track : " + JSON.stringify(response, null, 2));
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.typeId = response.parentId;
|
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.updateCoverList(response.covers);
|
self.updateCoverList(response.covers);
|
||||||
// console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
|
// console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
|
||||||
@ -113,14 +98,14 @@ export class ArtistEditScene implements OnInit {
|
|||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
});
|
});
|
||||||
console.log(`get parameter id: ${this.idArtist}`);
|
console.log(`get parameter id: ${this.idArtist}`);
|
||||||
this.artistService.getAlbum(this.idArtist)
|
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: number[]) => {
|
||||||
self.albumsCount = "" + response.length;
|
self.albumsCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albumsCount = '---';
|
self.albumsCount = '---';
|
||||||
});
|
});
|
||||||
this.artistService.getAllTracks(this.idArtist)
|
this.trackService.getTracksOfAnArtist(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: Track[]) => {
|
||||||
self.trackCount = "" + response.length;
|
self.trackCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.trackCount = '---';
|
self.trackCount = '---';
|
||||||
@ -133,7 +118,7 @@ export class ArtistEditScene implements OnInit {
|
|||||||
for (let iii = 0; iii < covers.length; iii++) {
|
for (let iii = 0; iii < covers.length; iii++) {
|
||||||
this.coversDisplay.push({
|
this.coversDisplay.push({
|
||||||
id: covers[iii],
|
id: covers[iii],
|
||||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -149,18 +134,9 @@ export class ArtistEditScene implements OnInit {
|
|||||||
this.description = value;
|
this.description = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeType(value: any): void {
|
|
||||||
console.log(`Change requested of type ... ${value}`);
|
|
||||||
this.typeId = value;
|
|
||||||
if (this.typeId === undefined) {
|
|
||||||
this.typeId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendValues(): void {
|
sendValues(): void {
|
||||||
console.log('send new values....');
|
console.log('send new values....');
|
||||||
let data = {
|
let data = {
|
||||||
parentId: this.typeId,
|
|
||||||
name: this.name,
|
name: this.name,
|
||||||
description: this.description
|
description: this.description
|
||||||
};
|
};
|
||||||
@ -203,7 +179,7 @@ export class ArtistEditScene implements OnInit {
|
|||||||
this.upload.clear();
|
this.upload.clear();
|
||||||
// display the upload pop-in
|
// display the upload pop-in
|
||||||
this.popInService.open('popin-upload-progress');
|
this.popInService.open('popin-upload-progress');
|
||||||
this.artistService.uploadCover(file, this.idArtist, (count, total) => {
|
this.artistService.uploadCover(this.idArtist, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@ -216,14 +192,14 @@ export class ArtistEditScene implements OnInit {
|
|||||||
console.log('Can not add the cover in the track...');
|
console.log('Can not add the cover in the track...');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
removeCover(id: number) {
|
removeCover(id: string) {
|
||||||
this.cleanConfirm();
|
this.cleanConfirm();
|
||||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||||
this.deleteCoverId = id;
|
this.deleteCoverId = id;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
removeCoverAfterConfirm(id: number) {
|
removeCoverAfterConfirm(id: string) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.artistService.deleteCover(this.idArtist, id)
|
this.artistService.deleteCover(this.idArtist, id)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Media } from 'app/model';
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
public albumCovers: string[] = undefined;
|
public albumCovers: string[] = undefined;
|
||||||
|
|
||||||
public tracksIds: number[] = undefined;
|
public tracksIds: number[] = undefined;
|
||||||
public tracks: Media[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
@ -38,8 +38,6 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
this.idArtist = this.arianeService.getArtistId();
|
||||||
this.idAlbum = this.arianeService.getAlbumId();
|
this.idAlbum = this.arianeService.getAlbumId();
|
||||||
let self = this;
|
let self = this;
|
||||||
@ -47,7 +45,7 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.artistCovers = this.dataService.getCoverListUrl(response.covers);
|
self.artistCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.description = undefined;
|
self.description = undefined;
|
||||||
self.name = '???';
|
self.name = '???';
|
||||||
@ -58,7 +56,7 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.albumName = response.name;
|
self.albumName = response.name;
|
||||||
self.albumDescription = response.description;
|
self.albumDescription = response.description;
|
||||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albumDescription = undefined;
|
self.albumDescription = undefined;
|
||||||
self.albumName = '???';
|
self.albumName = '???';
|
||||||
@ -67,8 +65,8 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//console.log("all the tracks: " + self.tracksIds);
|
//console.log("all the tracks: " + self.tracksIds);
|
||||||
this.trackService.getWithAlbum(self.idAlbum)
|
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||||
.then((response2: Media[]) => {
|
.then((response2: Track[]) => {
|
||||||
self.tracks = response2;
|
self.tracks = response2;
|
||||||
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Album, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-artist',
|
selector: 'app-artist',
|
||||||
@ -19,8 +19,8 @@ export class ArtistScene implements OnInit {
|
|||||||
public name: string = '';
|
public name: string = '';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: string[] = undefined;
|
public covers: string[] = undefined;
|
||||||
public albums: NodeData[] = undefined;
|
public albums: Album[] = undefined;
|
||||||
public tracks: any[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
public countSubElement: number = undefined;
|
public countSubElement: number = undefined;
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
|
|
||||||
@ -28,13 +28,14 @@ export class ArtistScene implements OnInit {
|
|||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(albumId: number): Promise<Number> {
|
countTrackCallback(albumId: number): Promise<Number> {
|
||||||
return this.albumService.countTrack(albumId);
|
return this.trackService.countTracksWithAlbumId(albumId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -48,17 +49,22 @@ export class ArtistScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.covers = this.dataService.getCoverListUrl(response.covers);
|
self.covers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.name = '???';
|
self.name = '???';
|
||||||
self.description = undefined;
|
self.description = undefined;
|
||||||
self.covers = undefined;
|
self.covers = undefined;
|
||||||
});
|
});
|
||||||
//console.log(`get parameter id: ${ this.idArtist}`);
|
//console.log(`get parameter id: ${ this.idArtist}`);
|
||||||
this.artistService.getAlbum(this.idArtist)
|
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||||
.then((response: NodeData[]) => {
|
.then((albumIds: number[]) => {
|
||||||
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
this.albumService.getAll(albumIds)
|
||||||
self.albums = response;
|
.then((response: Album[]) => {
|
||||||
|
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
||||||
|
self.albums = response;
|
||||||
|
}).catch((response) => {
|
||||||
|
self.albums = undefined;
|
||||||
|
});
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albums = undefined;
|
self.albums = undefined;
|
||||||
});
|
});
|
||||||
@ -97,7 +103,7 @@ export class ArtistScene implements OnInit {
|
|||||||
for (let iii = 0; iii < this.albums.length; iii++) {
|
for (let iii = 0; iii < this.albums.length; iii++) {
|
||||||
elements.push(this.albums[iii].id);
|
elements.push(this.albums[iii].id);
|
||||||
}
|
}
|
||||||
return this.albumService.getAllTracksForAlbums(elements);
|
return this.trackService.getTracksIdsForAlbums(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
playAll(): void {
|
playAll(): void {
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Artist, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-artists',
|
selector: 'app-artists',
|
||||||
@ -20,14 +19,13 @@ export class ArtistsScene implements OnInit {
|
|||||||
covers: Array<string> = [];
|
covers: Array<string> = [];
|
||||||
name: string = "Artists";
|
name: string = "Artists";
|
||||||
description: string = "All available artists";
|
description: string = "All available artists";
|
||||||
artists: NodeData[];
|
artists: Artist[];
|
||||||
artistsSave: NodeData[];
|
artistsSave: Artist[];
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
countAlbum: (id: number) => Promise<Number>;
|
countAlbum: (id: number) => Promise<Number>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
|
||||||
private trackService: TrackService,
|
private trackService: TrackService,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
private arianeService: ArianeService) {
|
private arianeService: ArianeService) {
|
||||||
@ -41,7 +39,7 @@ export class ArtistsScene implements OnInit {
|
|||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||||
this.artistService.getOrder()
|
this.artistService.getOrder()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Artist[]) => {
|
||||||
self.artists = response;
|
self.artists = response;
|
||||||
self.artistsSave = [...response];
|
self.artistsSave = [...response];
|
||||||
//console.log("get artists: " + JSON.stringify(self.artists));
|
//console.log("get artists: " + JSON.stringify(self.artists));
|
||||||
@ -66,16 +64,16 @@ export class ArtistsScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(artistId: number): Promise<Number> {
|
countTrackCallback(artistId: number): Promise<Number> {
|
||||||
return this.artistService.countTrack(artistId);
|
return this.trackService.countTracksOfAnArtist(artistId);
|
||||||
}
|
}
|
||||||
countAlbumCallback(artistId: number): Promise<Number> {
|
countAlbumCallback(artistId: number): Promise<Number> {
|
||||||
return this.artistService.countAlbum(artistId);
|
return this.trackService.countAlbumOfAnArtist(artistId);
|
||||||
}
|
}
|
||||||
playAll(): void {
|
playAll(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@ -89,8 +87,8 @@ export class ArtistsScene implements OnInit {
|
|||||||
playShuffle(): void {
|
playShuffle(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@ -98,7 +96,7 @@ export class ArtistsScene implements OnInit {
|
|||||||
self.playerService.setNewPlaylistShuffle(ids);
|
self.playerService.setNewPlaylistShuffle(ids);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o track ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,26 +6,27 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { GenderService, DataService, ArianeService } from 'app/service';
|
import { GenderService, DataService, ArianeService, TrackService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gender',
|
selector: 'app-gender',
|
||||||
templateUrl: './gender.html',
|
templateUrl: './gender.html',
|
||||||
styleUrls: [ './gender.less' ]
|
styleUrls: ['./gender.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class GenderScene implements OnInit {
|
export class GenderScene implements OnInit {
|
||||||
genderId = -1;
|
genderId = -1;
|
||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
cover:string = null;
|
cover: string = null;
|
||||||
covers:string[] = [];
|
covers: string[] = [];
|
||||||
artistsError = '';
|
artistsError = '';
|
||||||
artists = [];
|
artists = [];
|
||||||
tracksError = '';
|
tracksError = '';
|
||||||
tracks = [];
|
tracks = [];
|
||||||
constructor(
|
constructor(
|
||||||
private genderService: GenderService,
|
private genderService: GenderService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
//NOTHING TO DO ...
|
//NOTHING TO DO ...
|
||||||
@ -34,19 +35,19 @@ export class GenderScene implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.genderId = this.arianeService.getTypeId();
|
this.genderId = this.arianeService.getTypeId();
|
||||||
let self = this;
|
let self = this;
|
||||||
console.log(`get gender global id: ${ this.genderId}`);
|
console.log(`get gender global id: ${this.genderId}`);
|
||||||
this.genderService.get(this.genderId)
|
this.genderService.get(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
console.log(` ==> get answer gender detail: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer gender detail: ${JSON.stringify(response)}`);
|
||||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
if (response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
||||||
self.cover = null;
|
self.cover = null;
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.dataService.getCoverUrl(response.covers[0]);
|
self.cover = self.dataService.getUrl(response.covers[0]);
|
||||||
for(let iii = 0; iii < response.covers.length; iii++) {
|
for (let iii = 0; iii < response.covers.length; iii++) {
|
||||||
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
|
self.covers.push(self.dataService.getUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@ -55,7 +56,9 @@ export class GenderScene implements OnInit {
|
|||||||
self.covers = [];
|
self.covers = [];
|
||||||
self.cover = null;
|
self.cover = null;
|
||||||
});
|
});
|
||||||
this.genderService.getSubArtist(this.genderId)
|
/*
|
||||||
|
TODO ???
|
||||||
|
this.trackService.getSubArtist(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
|
||||||
self.artistsError = '';
|
self.artistsError = '';
|
||||||
@ -65,7 +68,8 @@ export class GenderScene implements OnInit {
|
|||||||
self.artistsError = 'Wrong e-mail/login or password';
|
self.artistsError = 'Wrong e-mail/login or password';
|
||||||
self.artists = [];
|
self.artists = [];
|
||||||
});
|
});
|
||||||
this.genderService.getSubTrack(this.genderId)
|
*/
|
||||||
|
this.trackService.getTracksForGender(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
|
||||||
self.tracksError = '';
|
self.tracksError = '';
|
||||||
@ -76,19 +80,19 @@ export class GenderScene implements OnInit {
|
|||||||
self.tracks = [];
|
self.tracks = [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onSelectArtist(event: any, idSelected: number):void {
|
onSelectArtist(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateArtist({ artistId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtist({ artistId: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateArtistEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtistEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
|
|
||||||
import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||||
import { PopInService } from 'common/service';
|
import { PopInService } from 'common/service';
|
||||||
import { Media } from 'app/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { isNullOrUndefined } from 'common/utils';
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
@ -25,7 +25,7 @@ class DataToSend {
|
|||||||
track?: number;
|
track?: number;
|
||||||
artistId: number = null;
|
artistId: number = null;
|
||||||
albumId: number = null;
|
albumId: number = null;
|
||||||
dataId: number = -1;
|
dataId: string = "";
|
||||||
genderId: number = null;
|
genderId: number = null;
|
||||||
generatedName: string = '';
|
generatedName: string = '';
|
||||||
clone() {
|
clone() {
|
||||||
@ -164,7 +164,7 @@ export class TrackEditScene implements OnInit {
|
|||||||
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
||||||
});
|
});
|
||||||
this.trackService.get(this.idTrack)
|
this.trackService.get(this.idTrack)
|
||||||
.then((response: Media) => {
|
.then((response: Track) => {
|
||||||
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.data.name = response.name;
|
self.data.name = response.name;
|
||||||
self.data.description = response.description;
|
self.data.description = response.description;
|
||||||
|
@ -12,85 +12,85 @@ import { isNullOrUndefined } from 'common/utils';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-track',
|
selector: 'app-track',
|
||||||
templateUrl: './track.html',
|
templateUrl: './track.html',
|
||||||
styleUrls: [ './track.less' ]
|
styleUrls: ['./track.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class TrackScene implements OnInit {
|
export class TrackScene implements OnInit {
|
||||||
trackGlobal:any;
|
trackGlobal: any;
|
||||||
@ViewChild('globalTrackElement')
|
@ViewChild('globalTrackElement')
|
||||||
set mainDivEl(el: ElementRef) {
|
set mainDivEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.trackGlobal = el.nativeElement;
|
this.trackGlobal = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trackPlayer: HTMLVideoElement;
|
trackPlayer: HTMLVideoElement;
|
||||||
@ViewChild('videoPlayer')
|
@ViewChild('videoPlayer')
|
||||||
set mainTrackEl(el: ElementRef) {
|
set mainTrackEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.trackPlayer = el.nativeElement;
|
this.trackPlayer = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoCanva: any;
|
videoCanva: any;
|
||||||
@ViewChild('canvascreenshoot')
|
@ViewChild('canvascreenshoot')
|
||||||
set mainCanvaEl(el: ElementRef) {
|
set mainCanvaEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.videoCanva = el.nativeElement;
|
this.videoCanva = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
haveNext = null;
|
haveNext = null;
|
||||||
havePrevious = null;
|
havePrevious = null;
|
||||||
idTrack:number = -1;
|
idTrack: number = -1;
|
||||||
|
|
||||||
mediaIsNotFound:boolean = false;
|
mediaIsNotFound: boolean = false;
|
||||||
mediaIsLoading:boolean = true;
|
mediaIsLoading: boolean = true;
|
||||||
error:string = '';
|
error: string = '';
|
||||||
|
|
||||||
name:string = '';
|
name: string = '';
|
||||||
description:string = '';
|
description: string = '';
|
||||||
episode:number = undefined;
|
episode: number = undefined;
|
||||||
artists:number[] = undefined;
|
artists: number[] = undefined;
|
||||||
artistName:string = undefined;
|
artistName: string = undefined;
|
||||||
albumId:number = undefined;
|
albumId: number = undefined;
|
||||||
albumName:string = undefined;
|
albumName: string = undefined;
|
||||||
dataId:number = -1;
|
dataId: string = "";
|
||||||
time:number = undefined;
|
time: number = undefined;
|
||||||
typeId:number = undefined;
|
typeId: number = undefined;
|
||||||
generatedName:string = '';
|
generatedName: string = '';
|
||||||
trackSource:string = '';
|
trackSource: string = '';
|
||||||
covers: string[];
|
covers: string[];
|
||||||
|
|
||||||
playTrack:boolean = false;
|
playTrack: boolean = false;
|
||||||
displayVolumeMenu:boolean = false;
|
displayVolumeMenu: boolean = false;
|
||||||
isPlaying:boolean = false;
|
isPlaying: boolean = false;
|
||||||
isFullScreen:boolean = false;
|
isFullScreen: boolean = false;
|
||||||
currentTime:number = 0;
|
currentTime: number = 0;
|
||||||
currentTimeDisplay:string = '00';
|
currentTimeDisplay: string = '00';
|
||||||
duration:number = 0;
|
duration: number = 0;
|
||||||
durationDisplay:string = '00';
|
durationDisplay: string = '00';
|
||||||
volumeValue:number = 100;
|
volumeValue: number = 100;
|
||||||
|
|
||||||
displayNeedHide:boolean = false;
|
displayNeedHide: boolean = false;
|
||||||
timeLeft: number = 10;
|
timeLeft: number = 10;
|
||||||
interval = null;
|
interval = null;
|
||||||
constructor(private trackService: TrackService,
|
constructor(private trackService: TrackService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private httpService: HttpWrapperService,
|
private httpService: HttpWrapperService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startHideTimer() {
|
startHideTimer() {
|
||||||
this.displayNeedHide = false;
|
this.displayNeedHide = false;
|
||||||
this.timeLeft = 5;
|
this.timeLeft = 5;
|
||||||
if(this.interval !== null) {
|
if (this.interval !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
console.log(`periodic event: ${ self.timeLeft}`);
|
console.log(`periodic event: ${self.timeLeft}`);
|
||||||
if(self.timeLeft > 0) {
|
if (self.timeLeft > 0) {
|
||||||
self.timeLeft--;
|
self.timeLeft--;
|
||||||
} else {
|
} else {
|
||||||
clearInterval(self.interval);
|
clearInterval(self.interval);
|
||||||
@ -105,40 +105,40 @@ export class TrackScene implements OnInit {
|
|||||||
this.interval = null;
|
this.interval = null;
|
||||||
}
|
}
|
||||||
onRequireNext(event: any) {
|
onRequireNext(event: any) {
|
||||||
console.log(`generate next : ${ this.haveNext.id}`);
|
console.log(`generate next : ${this.haveNext.id}`);
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
this.arianeService.setTrack(this.haveNext.id);
|
this.arianeService.setTrack(this.haveNext.id);
|
||||||
}
|
}
|
||||||
onRequirePrevious(event: any) {
|
onRequirePrevious(event: any) {
|
||||||
console.log(`generate previous : ${ this.havePrevious.id}`);
|
console.log(`generate previous : ${this.havePrevious.id}`);
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
this.arianeService.setTrack(this.havePrevious.id);
|
this.arianeService.setTrack(this.havePrevious.id);
|
||||||
}
|
}
|
||||||
generateName() {
|
generateName() {
|
||||||
this.generatedName = '';
|
this.generatedName = '';
|
||||||
if(this.artistName !== undefined) {
|
if (this.artistName !== undefined) {
|
||||||
this.generatedName = `${this.generatedName }${this.artistName }-`;
|
this.generatedName = `${this.generatedName}${this.artistName}-`;
|
||||||
}
|
}
|
||||||
if(this.albumName !== undefined) {
|
if (this.albumName !== undefined) {
|
||||||
if(this.albumName.length < 2) {
|
if (this.albumName.length < 2) {
|
||||||
this.generatedName = `${this.generatedName }s0${ this.albumName }-`;
|
this.generatedName = `${this.generatedName}s0${this.albumName}-`;
|
||||||
} else {
|
} else {
|
||||||
this.generatedName = `${this.generatedName }s${ this.albumName }-`;
|
this.generatedName = `${this.generatedName}s${this.albumName}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.episode !== undefined) {
|
if (this.episode !== undefined) {
|
||||||
if(this.episode < 10) {
|
if (this.episode < 10) {
|
||||||
this.generatedName = `${this.generatedName }e0${ this.episode }-`;
|
this.generatedName = `${this.generatedName}e0${this.episode}-`;
|
||||||
} else {
|
} else {
|
||||||
this.generatedName = `${this.generatedName }e${ this.episode }-`;
|
this.generatedName = `${this.generatedName}e${this.episode}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.generatedName = this.generatedName + this.name;
|
this.generatedName = this.generatedName + this.name;
|
||||||
@ -146,7 +146,7 @@ export class TrackScene implements OnInit {
|
|||||||
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
||||||
// update the path of the uri request
|
// update the path of the uri request
|
||||||
this.trackSource = this.httpService.createRESTCall2({
|
this.trackSource = this.httpService.createRESTCall2({
|
||||||
api: `data/${ this.dataId}/${this.generatedName}`,
|
api: `data/${this.dataId}/${this.generatedName}`,
|
||||||
addURLToken: true,
|
addURLToken: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -160,27 +160,27 @@ export class TrackScene implements OnInit {
|
|||||||
/*
|
/*
|
||||||
let captureStream = this.trackPlayer.audioTracks;
|
let captureStream = this.trackPlayer.audioTracks;
|
||||||
for (let iii=0; iii < captureStream.length; iii++) {
|
for (let iii=0; iii < captureStream.length; iii++) {
|
||||||
console.log(" - " + captureStream[iii].language);
|
console.log(" - " + captureStream[iii].language);
|
||||||
if (captureStream[iii].language.substring(0,2) === "fr") {
|
if (captureStream[iii].language.substring(0,2) === "fr") {
|
||||||
captureStream[iii].enabled = true;
|
captureStream[iii].enabled = true;
|
||||||
} else {
|
} else {
|
||||||
captureStream[iii].enabled = false;
|
captureStream[iii].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
audioTracks(event) {
|
audioTracks(event) {
|
||||||
console.log(`list of the stream:${ event}`);
|
console.log(`list of the stream:${event}`);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
let captureStream = this.trackPlayer.audioTracks;
|
let captureStream = this.trackPlayer.audioTracks;
|
||||||
for (let iii=0; iii < captureStream.length; iii++) {
|
for (let iii=0; iii < captureStream.length; iii++) {
|
||||||
console.log(" - " + captureStream[iii].language);
|
console.log(" - " + captureStream[iii].language);
|
||||||
if (captureStream[iii].language.substring(0,2) === "fr") {
|
if (captureStream[iii].language.substring(0,2) === "fr") {
|
||||||
captureStream[iii].enabled = true;
|
captureStream[iii].enabled = true;
|
||||||
} else {
|
} else {
|
||||||
captureStream[iii].enabled = false;
|
captureStream[iii].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -190,40 +190,40 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
this.idTrack = this.arianeService.getTrackId();
|
this.idTrack = this.arianeService.getTrackId();
|
||||||
this.arianeService.trackChange.subscribe((trackId) => {
|
this.arianeService.trackChange.subscribe((trackId) => {
|
||||||
console.log(`Detect trackId change...${ trackId}`);
|
console.log(`Detect trackId change...${trackId}`);
|
||||||
self.idTrack = trackId;
|
self.idTrack = trackId;
|
||||||
self.updateDisplay();
|
self.updateDisplay();
|
||||||
});
|
});
|
||||||
self.updateDisplay();
|
self.updateDisplay();
|
||||||
}
|
}
|
||||||
updateDisplay():void {
|
updateDisplay(): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
this.trackService.get(this.idTrack)
|
this.trackService.get(this.idTrack)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
|
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.error = '';
|
self.error = '';
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.episode = response.episode;
|
//self.episode = response.episode;
|
||||||
self.artists = response.artists;
|
self.artists = response.artists;
|
||||||
self.albumId = response.albumId;
|
self.albumId = response.albumId;
|
||||||
self.dataId = response.dataId;
|
self.dataId = response.dataId;
|
||||||
self.time = response.time;
|
self.time = response.time;
|
||||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
||||||
if(self.dataId !== -1) {
|
if (self.dataId !== -1) {
|
||||||
self.trackSource = self.httpService.createRESTCall2({
|
self.trackSource = self.httpService.createRESTCall2({
|
||||||
api: `data/${ self.dataId}/${self.generatedName}`,
|
api: `data/${self.dataId}/${self.generatedName}`,
|
||||||
addURLToken: true,
|
addURLToken: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.trackSource = '';
|
self.trackSource = '';
|
||||||
}
|
}
|
||||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
self.covers = self.dataService.(response.covers);
|
||||||
|
|
||||||
self.generateName();
|
self.generateName();
|
||||||
if(!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
if (!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
||||||
self.artistService.get(self.artists[0])
|
self.artistService.get(self.artists[0])
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
self.artistName = response2.name;
|
self.artistName = response2.name;
|
||||||
@ -232,7 +232,7 @@ export class TrackScene implements OnInit {
|
|||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(!isNullOrUndefined(self.albumId)) {
|
if (!isNullOrUndefined(self.albumId)) {
|
||||||
self.albumService.get(self.albumId)
|
self.albumService.get(self.albumId)
|
||||||
.then((response4) => {
|
.then((response4) => {
|
||||||
self.albumName = response4.name;
|
self.albumName = response4.name;
|
||||||
@ -241,30 +241,30 @@ export class TrackScene implements OnInit {
|
|||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
});
|
});
|
||||||
self.albumService.getTrack(self.albumId)
|
self.albumService.getTrack(self.albumId)
|
||||||
.then((response6:any) => {
|
.then((response6: any) => {
|
||||||
// console.log("saison property: " + JSON.stringify(response, null, 2));
|
// console.log("saison property: " + JSON.stringify(response, null, 2));
|
||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
for(let iii = 0; iii < response6.length; iii++) {
|
for (let iii = 0; iii < response6.length; iii++) {
|
||||||
if(isNullOrUndefined(response6[iii].episode)) {
|
if (isNullOrUndefined(response6[iii].episode)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(response6[iii].episode < self.episode) {
|
if (response6[iii].episode < self.episode) {
|
||||||
if(self.havePrevious === null) {
|
if (self.havePrevious === null) {
|
||||||
self.havePrevious = response6[iii];
|
self.havePrevious = response6[iii];
|
||||||
} else if(self.havePrevious.episode < response6[iii].episode) {
|
} else if (self.havePrevious.episode < response6[iii].episode) {
|
||||||
self.havePrevious = response6[iii];
|
self.havePrevious = response6[iii];
|
||||||
}
|
}
|
||||||
} else if(response6[iii].episode > self.episode) {
|
} else if (response6[iii].episode > self.episode) {
|
||||||
if(self.haveNext === null) {
|
if (self.haveNext === null) {
|
||||||
self.haveNext = response6[iii];
|
self.haveNext = response6[iii];
|
||||||
} else if(self.haveNext.episode > response6[iii].episode) {
|
} else if (self.haveNext.episode > response6[iii].episode) {
|
||||||
self.haveNext = response6[iii];
|
self.haveNext = response6[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
||||||
}
|
}
|
||||||
}).catch((response7:any) => {
|
}).catch((response7: any) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
changeStateToPlay() {
|
changeStateToPlay() {
|
||||||
this.isPlaying = true;
|
this.isPlaying = true;
|
||||||
if(this.isFullScreen === true) {
|
if (this.isFullScreen === true) {
|
||||||
this.onFullscreen();
|
this.onFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,25 +321,25 @@ export class TrackScene implements OnInit {
|
|||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertIndisplayTime(time:number) : string {
|
convertIndisplayTime(time: number): string {
|
||||||
let tmpp = parseInt(`${ time}`, 10);
|
let tmpp = parseInt(`${time}`, 10);
|
||||||
let heures = parseInt(`${ tmpp / 3600}`, 10);
|
let heures = parseInt(`${tmpp / 3600}`, 10);
|
||||||
tmpp = tmpp - heures * 3600;
|
tmpp = tmpp - heures * 3600;
|
||||||
let minutes = parseInt(`${ tmpp / 60}`, 10);
|
let minutes = parseInt(`${tmpp / 60}`, 10);
|
||||||
let seconds = tmpp - minutes * 60;
|
let seconds = tmpp - minutes * 60;
|
||||||
let out = '';
|
let out = '';
|
||||||
if(heures !== 0) {
|
if (heures !== 0) {
|
||||||
out = `${out }${heures }:`;
|
out = `${out}${heures}:`;
|
||||||
}
|
}
|
||||||
if(minutes >= 10) {
|
if (minutes >= 10) {
|
||||||
out = `${out }${minutes }:`;
|
out = `${out}${minutes}:`;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ minutes }:`;
|
out = `${out}0${minutes}:`;
|
||||||
}
|
}
|
||||||
if(seconds >= 10) {
|
if (seconds >= 10) {
|
||||||
out = out + seconds;
|
out = out + seconds;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ seconds}`;
|
out = `${out}0${seconds}`;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ export class TrackScene implements OnInit {
|
|||||||
}
|
}
|
||||||
changeDurationchange(duration: any) {
|
changeDurationchange(duration: any) {
|
||||||
console.log('duration change ');
|
console.log('duration change ');
|
||||||
console.log(` ==> ${ this.trackPlayer.duration}`);
|
console.log(` ==> ${this.trackPlayer.duration}`);
|
||||||
this.duration = this.trackPlayer.duration;
|
this.duration = this.trackPlayer.duration;
|
||||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
||||||
}
|
}
|
||||||
@ -361,9 +361,9 @@ export class TrackScene implements OnInit {
|
|||||||
onPlay() {
|
onPlay() {
|
||||||
console.log('play');
|
console.log('play');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.volume = this.volumeValue / 100;
|
this.trackPlayer.volume = this.volumeValue / 100;
|
||||||
@ -373,9 +373,9 @@ export class TrackScene implements OnInit {
|
|||||||
onPause() {
|
onPause() {
|
||||||
console.log('pause');
|
console.log('pause');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.pause();
|
this.trackPlayer.pause();
|
||||||
@ -383,7 +383,7 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onPauseToggle() {
|
onPauseToggle() {
|
||||||
console.log('pause toggle ...');
|
console.log('pause toggle ...');
|
||||||
if(this.isPlaying === true) {
|
if (this.isPlaying === true) {
|
||||||
this.onPause();
|
this.onPause();
|
||||||
} else {
|
} else {
|
||||||
this.onPlay();
|
this.onPlay();
|
||||||
@ -393,9 +393,9 @@ export class TrackScene implements OnInit {
|
|||||||
onStop() {
|
onStop() {
|
||||||
console.log('stop');
|
console.log('stop');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.pause();
|
this.trackPlayer.pause();
|
||||||
@ -412,12 +412,12 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
seek(newValue:any) {
|
seek(newValue: any) {
|
||||||
console.log(`seek ${ newValue.value}`);
|
console.log(`seek ${newValue.value}`);
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = newValue.value;
|
this.trackPlayer.currentTime = newValue.value;
|
||||||
@ -426,9 +426,9 @@ export class TrackScene implements OnInit {
|
|||||||
onRewind() {
|
onRewind() {
|
||||||
console.log('rewind');
|
console.log('rewind');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = this.currentTime - 10;
|
this.trackPlayer.currentTime = this.currentTime - 10;
|
||||||
@ -437,9 +437,9 @@ export class TrackScene implements OnInit {
|
|||||||
onForward() {
|
onForward() {
|
||||||
console.log('forward');
|
console.log('forward');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = this.currentTime + 10;
|
this.trackPlayer.currentTime = this.currentTime + 10;
|
||||||
@ -448,27 +448,27 @@ export class TrackScene implements OnInit {
|
|||||||
onMore() {
|
onMore() {
|
||||||
console.log('more');
|
console.log('more');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onFullscreen() {
|
onFullscreen() {
|
||||||
console.log('fullscreen');
|
console.log('fullscreen');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackGlobal === null ||
|
if (this.trackGlobal === null ||
|
||||||
this.trackGlobal === undefined) {
|
this.trackGlobal === undefined) {
|
||||||
console.log(`error element: ${ this.trackGlobal}`);
|
console.log(`error element: ${this.trackGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.trackGlobal.requestFullscreen) {
|
if (this.trackGlobal.requestFullscreen) {
|
||||||
this.trackGlobal.requestFullscreen();
|
this.trackGlobal.requestFullscreen();
|
||||||
} else if(this.trackGlobal.mozRequestFullScreen) {
|
} else if (this.trackGlobal.mozRequestFullScreen) {
|
||||||
this.trackGlobal.mozRequestFullScreen();
|
this.trackGlobal.mozRequestFullScreen();
|
||||||
} else if(this.trackGlobal.webkitRequestFullscreen) {
|
} else if (this.trackGlobal.webkitRequestFullscreen) {
|
||||||
this.trackGlobal.webkitRequestFullscreen();
|
this.trackGlobal.webkitRequestFullscreen();
|
||||||
} else if(this.trackGlobal.msRequestFullscreen) {
|
} else if (this.trackGlobal.msRequestFullscreen) {
|
||||||
this.trackGlobal.msRequestFullscreen();
|
this.trackGlobal.msRequestFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,21 +476,21 @@ export class TrackScene implements OnInit {
|
|||||||
onFullscreenExit() {
|
onFullscreenExit() {
|
||||||
this.onFullscreenExit22(document);
|
this.onFullscreenExit22(document);
|
||||||
}
|
}
|
||||||
onFullscreenExit22(docc:any) {
|
onFullscreenExit22(docc: any) {
|
||||||
console.log('fullscreen EXIT');
|
console.log('fullscreen EXIT');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackGlobal === null ||
|
if (this.trackGlobal === null ||
|
||||||
this.trackGlobal === undefined) {
|
this.trackGlobal === undefined) {
|
||||||
console.log(`error element: ${ this.trackGlobal}`);
|
console.log(`error element: ${this.trackGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(docc.exitFullscreen) {
|
if (docc.exitFullscreen) {
|
||||||
docc.exitFullscreen();
|
docc.exitFullscreen();
|
||||||
} else if(docc.mozCancelFullScreen) {
|
} else if (docc.mozCancelFullScreen) {
|
||||||
docc.mozCancelFullScreen();
|
docc.mozCancelFullScreen();
|
||||||
} else if(docc.webkitExitFullscreen) {
|
} else if (docc.webkitExitFullscreen) {
|
||||||
docc.webkitExitFullscreen();
|
docc.webkitExitFullscreen();
|
||||||
} else if(docc.msExitFullscreen) {
|
} else if (docc.msExitFullscreen) {
|
||||||
docc.msExitFullscreen();
|
docc.msExitFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,12 +498,12 @@ export class TrackScene implements OnInit {
|
|||||||
onFullscreenChange() {
|
onFullscreenChange() {
|
||||||
this.onFullscreenChange22(document);
|
this.onFullscreenChange22(document);
|
||||||
}
|
}
|
||||||
onFullscreenChange22(element:any) {
|
onFullscreenChange22(element: any) {
|
||||||
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
||||||
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
||||||
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
||||||
element.msFullscreenElement && element.msFullscreenElement !== null;
|
element.msFullscreenElement && element.msFullscreenElement !== null;
|
||||||
console.log(`onFullscreenChange(${ isInFullScreen })`);
|
console.log(`onFullscreenChange(${isInFullScreen})`);
|
||||||
this.isFullScreen = isInFullScreen;
|
this.isFullScreen = isInFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,12 +512,12 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
onVolume(newValue:any) {
|
onVolume(newValue: any) {
|
||||||
console.log(`onVolume ${ newValue.value}`);
|
console.log(`onVolume ${newValue.value}`);
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.volumeValue = newValue.value;
|
this.volumeValue = newValue.value;
|
||||||
@ -527,9 +527,9 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onVolumeMute() {
|
onVolumeMute() {
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.muted = true;
|
this.trackPlayer.muted = true;
|
||||||
@ -537,9 +537,9 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onVolumeUnMute() {
|
onVolumeUnMute() {
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.muted = false;
|
this.trackPlayer.muted = false;
|
||||||
|
@ -14,7 +14,7 @@ import { isNullOrUndefined } from 'common/utils';
|
|||||||
|
|
||||||
export class ElementList {
|
export class ElementList {
|
||||||
constructor(
|
constructor(
|
||||||
public value: bigint,
|
public value: number,
|
||||||
public label: string) {
|
public label: string) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
@ -27,14 +27,14 @@ export class FileParsedElement {
|
|||||||
public file: File,
|
public file: File,
|
||||||
public artist: string,
|
public artist: string,
|
||||||
public album: string,
|
public album: string,
|
||||||
public trackId: bigint,
|
public trackId: number,
|
||||||
public title: string) {
|
public title: string) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class FileFailParsedElement {
|
export class FileFailParsedElement {
|
||||||
constructor(
|
constructor(
|
||||||
public id: bigint,
|
public id: number,
|
||||||
public file: File,
|
public file: File,
|
||||||
public reason: string) {
|
public reason: string) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
@ -52,9 +52,9 @@ export class UploadScene implements OnInit {
|
|||||||
parsedFailedElement: FileFailParsedElement[] = [];
|
parsedFailedElement: FileFailParsedElement[] = [];
|
||||||
uploadFileValue: string = '';
|
uploadFileValue: string = '';
|
||||||
selectedFiles: FileList;
|
selectedFiles: FileList;
|
||||||
genderId: bigint = null;
|
genderId: number = null;
|
||||||
artistId: bigint = null;
|
artistId: number = null;
|
||||||
albumId: bigint = null;
|
albumId: number = null;
|
||||||
needSend: boolean = false;
|
needSend: boolean = false;
|
||||||
|
|
||||||
// list of all files already registered in the bdd to compare with the current list of files.
|
// list of all files already registered in the bdd to compare with the current list of files.
|
||||||
@ -86,7 +86,7 @@ export class UploadScene implements OnInit {
|
|||||||
height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
|
height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
|
||||||
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
|
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
|
||||||
customComparator: () => { }, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
|
customComparator: () => { }, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
|
||||||
limitTo: 10, // bigint thats limits the no of options displayed in the UI (if zero, options will not be limited)
|
limitTo: 10, // number thats limits the no of options displayed in the UI (if zero, options will not be limited)
|
||||||
moreText: 'more', // text to be displayed when more than one items are selected like Option 1 + 5 more
|
moreText: 'more', // text to be displayed when more than one items are selected like Option 1 + 5 more
|
||||||
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
|
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
|
||||||
searchPlaceholder: 'Search', // label thats displayed in search input,
|
searchPlaceholder: 'Search', // label thats displayed in search input,
|
||||||
@ -284,7 +284,7 @@ export class UploadScene implements OnInit {
|
|||||||
// parsedElement: FileParsedElement[] = [];
|
// parsedElement: FileParsedElement[] = [];
|
||||||
let artist: string = undefined;
|
let artist: string = undefined;
|
||||||
let album: string | null = undefined;
|
let album: string | null = undefined;
|
||||||
let trackIdbigint: bigint | null = undefined;
|
let trackIdnumber: number | null = undefined;
|
||||||
let title: string = '';
|
let title: string = '';
|
||||||
|
|
||||||
console.log(`select file ${file.name}`);
|
console.log(`select file ${file.name}`);
|
||||||
@ -305,19 +305,19 @@ export class UploadScene implements OnInit {
|
|||||||
//console.log("ploppppp " + tmpName);
|
//console.log("ploppppp " + tmpName);
|
||||||
const splitElement3 = tmpName.split('-');
|
const splitElement3 = tmpName.split('-');
|
||||||
if (splitElement3.length > 1) {
|
if (splitElement3.length > 1) {
|
||||||
trackIdbigint = parseInt(splitElement3[0], 10);
|
trackIdnumber = parseInt(splitElement3[0], 10);
|
||||||
tmpName = tmpName.substring(splitElement3[0].length + 1);
|
tmpName = tmpName.substring(splitElement3[0].length + 1);
|
||||||
}
|
}
|
||||||
//console.log("KKKppppp " + tmpName);
|
//console.log("KKKppppp " + tmpName);
|
||||||
//console.log(" ===> " + splitElement3[0]);
|
//console.log(" ===> " + splitElement3[0]);
|
||||||
title = tmpName;
|
title = tmpName;
|
||||||
|
|
||||||
if (isNaN(trackIdbigint)) {
|
if (isNaN(trackIdnumber)) {
|
||||||
trackIdbigint = undefined;
|
trackIdnumber = undefined;
|
||||||
}
|
}
|
||||||
// remove extention
|
// remove extention
|
||||||
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
||||||
let tmp = new FileParsedElement(file, artist, album, trackIdbigint, title);
|
let tmp = new FileParsedElement(file, artist, album, trackIdnumber, title);
|
||||||
console.log(`==>${JSON.stringify(tmp)}`);
|
console.log(`==>${JSON.stringify(tmp)}`);
|
||||||
// add it in the list.
|
// add it in the list.
|
||||||
this.parsedElement.push(tmp);
|
this.parsedElement.push(tmp);
|
||||||
@ -387,10 +387,10 @@ export class UploadScene implements OnInit {
|
|||||||
this.globalUpLoad(0, this.parsedElement.length);
|
this.globalUpLoad(0, this.parsedElement.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
globalUpLoad(id: bigint, total: bigint): void {
|
globalUpLoad(id: number, total: number): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.uploadFile(this.parsedElement[id], id, total, () => {
|
this.uploadFile(this.parsedElement[id], id, total, () => {
|
||||||
let id2 = id + BigInt(1);
|
let id2 = id + 1;
|
||||||
if (id2 < total) {
|
if (id2 < total) {
|
||||||
self.globalUpLoad(id2, total);
|
self.globalUpLoad(id2, total);
|
||||||
} else {
|
} else {
|
||||||
@ -400,7 +400,7 @@ export class UploadScene implements OnInit {
|
|||||||
self.upload.error = `Error in the upload of the data...${value}`;
|
self.upload.error = `Error in the upload of the data...${value}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uploadFile(element: FileParsedElement, id: bigint, total: bigint, sendDone: any, errorOccurred: any): void {
|
uploadFile(element: FileParsedElement, id: number, total: number, sendDone: any, errorOccurred: any): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
self.upload.labelMediaTitle = '';
|
self.upload.labelMediaTitle = '';
|
||||||
@ -515,7 +515,7 @@ export class UploadScene implements OnInit {
|
|||||||
// no album check only the artist files.
|
// no album check only the artist files.
|
||||||
if (isNullOrUndefined(this.globalAlbum)) {
|
if (isNullOrUndefined(this.globalAlbum)) {
|
||||||
console.error(`NO ALBUM ==> check artist ID...`);
|
console.error(`NO ALBUM ==> check artist ID...`);
|
||||||
self.artistService.getAllTracks(self.artistId)
|
self.trackService.getTracksOfAnArtist(self.artistId)
|
||||||
.then((response: any[]) => {
|
.then((response: any[]) => {
|
||||||
self.listFileInBdd = response;
|
self.listFileInBdd = response;
|
||||||
console.error(`find track: ${JSON.stringify(response, null, 2)}`);
|
console.error(`find track: ${JSON.stringify(response, null, 2)}`);
|
||||||
|
98
front/src/app/service/GenericDataService.ts
Normal file
98
front/src/app/service/GenericDataService.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
|
||||||
|
import { DataStore } from "common/utils/data-store";
|
||||||
|
import { DataTools } from "common/utils/data-tools";
|
||||||
|
|
||||||
|
|
||||||
|
export class GenericDataService<TYPE> {
|
||||||
|
protected dataStore: DataStore<TYPE>;
|
||||||
|
|
||||||
|
setStore(dataStore: DataStore<TYPE>) {
|
||||||
|
this.dataStore = dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gets(): Promise<TYPE[]> {
|
||||||
|
return this.dataStore.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
get(id: number): Promise<TYPE> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.get(response, id);
|
||||||
|
if (isNullOrUndefined(data)) {
|
||||||
|
reject('Data does not exist in the local BDD');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll(ids: number[]): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'id',
|
||||||
|
value: ids,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['name', 'id']);
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getLike(value: string): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.getNameLike(response, value);
|
||||||
|
if (isNullOrUndefined(data) || data.length === 0) {
|
||||||
|
reject('Data does not exist in the local BDD');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getOrder(): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.NOT_EQUAL,
|
||||||
|
key: 'id',
|
||||||
|
value: [undefined, null],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['name', 'id']);
|
||||||
|
resolve(data);
|
||||||
|
}).catch((response) => {
|
||||||
|
console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,182 +0,0 @@
|
|||||||
import { isNodeData, NodeData } from "common/model";
|
|
||||||
import { HttpWrapperService, BddService } from "common/service";
|
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
|
|
||||||
|
|
||||||
|
|
||||||
export class GenericInterfaceModelDB {
|
|
||||||
constructor(
|
|
||||||
protected serviceName: string,
|
|
||||||
protected http: HttpWrapperService,
|
|
||||||
protected bdd: BddService) {
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
gets(): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.gets();
|
|
||||||
if (isNullOrUndefined(data)) {
|
|
||||||
reject('Data does not exist in the local BDD');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getLike(nameArtist: string): any {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getNameLike(nameArtist);
|
|
||||||
if (data === null || data === undefined || data.length === 0) {
|
|
||||||
reject('Data does not exist in the local BDD');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getOrder(): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
|
||||||
check: TypeCheck.NOT_EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: [undefined, null],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
['name', 'id']);
|
|
||||||
//data = response.gets();
|
|
||||||
if (isArrayOf(data, isNodeData)) {
|
|
||||||
resolve(data);
|
|
||||||
}
|
|
||||||
reject("The model is wrong ...");
|
|
||||||
}).catch((response) => {
|
|
||||||
console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(id: bigint): Promise<NodeData> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.get(id);
|
|
||||||
if (isNullOrUndefined(data)) {
|
|
||||||
reject('Data does not exist in the local BDD');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getAll(ids: bigint[]): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: ids,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
['name', 'id']);
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getData(): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get(self.serviceName)
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.gets();
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
console.log(`[E] ${self.constructor.name}: can not retrive BDD values`);
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
insert(data: any): any {
|
|
||||||
let ret = this.http.postSpecific([this.serviceName], data);
|
|
||||||
return this.bdd.addAfterPost(this.serviceName, ret);
|
|
||||||
|
|
||||||
}
|
|
||||||
patch(id: bigint, data: any): any {
|
|
||||||
let ret = this.http.patchSpecific([this.serviceName, id], data);
|
|
||||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: bigint): any {
|
|
||||||
let ret = this.http.deleteSpecific([this.serviceName, id]);
|
|
||||||
return this.bdd.delete(this.serviceName, id, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteCover(nodeId: bigint, coverId: number) {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
|
|
||||||
.then((response) => {
|
|
||||||
let data = response;
|
|
||||||
if (data === null || data === undefined) {
|
|
||||||
reject('error retrive data from server');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
uploadCover(file: File,
|
|
||||||
nodeId: bigint,
|
|
||||||
progress: any = null) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('fileName', file.name);
|
|
||||||
formData.append('id', nodeId.toString());
|
|
||||||
formData.append('file', file);
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.http.uploadMultipart(`${this.serviceName}/${nodeId}/add_cover/`, formData, progress)
|
|
||||||
.then((response) => {
|
|
||||||
let data = response;
|
|
||||||
if (data === null || data === undefined) {
|
|
||||||
reject('error retrieve data from server');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,127 +7,153 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
import { NodeData } from 'common/model';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { SessionService } from 'common/service';
|
||||||
import { DataInterface, TypeCheck } from 'common/utils';
|
import { DataInterface, TypeCheck, isArrayOf, isNumber } from 'common/utils';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { Album, AlbumResource, UUID } from 'app/back-api';
|
||||||
|
import { DataStore } from '../../common/utils/data-store';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { DataTools } from 'common/utils/data-tools';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlbumService extends GenericInterfaceModelDB {
|
export class AlbumService extends GenericDataService<Album> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('album', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Album[]> {
|
||||||
|
return AlbumResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
getAllTracksForAlbums(idAlbums: bigint[]): Promise<bigint[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get('track')
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'albumId',
|
|
||||||
value: idAlbums,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
['name']); // tODO : set the Id in the track ...
|
|
||||||
// filter with artist- ID !!!
|
|
||||||
const listId = DataInterface.extractLimitOne(data, "id");
|
|
||||||
resolve(listId);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
this.setStore(new DataStore<Album>(this.lambdaGets, "id"));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Get all the track for a specific album
|
insert(data: Album): Promise<Album> {
|
||||||
* @param idAlbum - Id of the album.
|
const self = this;
|
||||||
* @returns a promise on the list of track elements
|
|
||||||
*/
|
|
||||||
getTrack(idAlbum: bigint): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
AlbumResource.post({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
data
|
||||||
{
|
}).then((value: Album) => {
|
||||||
check: TypeCheck.EQUAL,
|
self.dataStore.updateValue(value);
|
||||||
key: 'albumId',
|
resolve(value);
|
||||||
value: idAlbum,
|
}).catch((error) => {
|
||||||
},
|
reject(error);
|
||||||
],
|
});
|
||||||
['name']); // tODO : set the Id in the track ...
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
patch(id: number, data: Album): Promise<Album> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
AlbumResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Album) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
AlbumResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Album> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
AlbumResource.removeCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
coverId
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Album> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
AlbumResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the artists for a specific album
|
* Get all the artists for a specific album
|
||||||
* @param idAlbum - Id of the album.
|
* @param idAlbum - Id of the album.
|
||||||
* @returns a promise on the list of Artist names for this album
|
* @returns a promise on the list of Artist ID for this album
|
||||||
*/
|
*/
|
||||||
getArtists(idAlbum: bigint): Promise<String[]> {
|
getArtists(idAlbum: number): Promise<number[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
self.gets()
|
||||||
.then((response: DataInterface) => {
|
.then((response: Album[]) => {
|
||||||
let data = response.getsWhere([
|
let data = DataTools.getsWhere(response,
|
||||||
{
|
[
|
||||||
check: TypeCheck.EQUAL,
|
{
|
||||||
key: 'albumId',
|
check: TypeCheck.EQUAL,
|
||||||
value: idAlbum,
|
key: 'albumId',
|
||||||
},
|
value: idAlbum,
|
||||||
],
|
},
|
||||||
|
],
|
||||||
['name']);
|
['name']);
|
||||||
// filter with artist- ID !!!
|
// filter with artist- ID !!!
|
||||||
const listArtistId = DataInterface.extractLimitOneList(data, "artists");
|
const listArtistId = DataInterface.extractLimitOneList(data, "artists");
|
||||||
//console.log(`${idAlbum} ==> List Of ids: ${JSON.stringify(listArtistId, null, 2)} `);
|
if (isArrayOf(listArtistId, isNumber)) {
|
||||||
self.bdd.get('artist')
|
resolve(listArtistId);
|
||||||
.then((response: DataInterface) => {
|
} else {
|
||||||
let dataArtist = response.getsWhere([
|
reject("Fail to get the ids (impossible case)");
|
||||||
{
|
}
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: listArtistId,
|
|
||||||
},
|
|
||||||
], ['name']);
|
|
||||||
const listArtistNames = DataInterface.extractLimitOne(dataArtist, "name");
|
|
||||||
resolve(listArtistNames);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the bigint of track in this saison ID
|
|
||||||
* @param AlbumId - Id of the album.
|
|
||||||
* @returns The bigint of element present in this saison
|
|
||||||
*/
|
|
||||||
countTrack(AlbumId: bigint): Promise<number> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.bdd.get('track')
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'albumId',
|
|
||||||
value: AlbumId,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
resolve(data.length);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,34 +18,34 @@ import { NodeData } from 'common/model';
|
|||||||
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
|
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
|
||||||
|
|
||||||
export class InputOrders {
|
export class InputOrders {
|
||||||
public genderId: bigint = undefined;
|
public genderId: number = undefined;
|
||||||
public playlistId: bigint = undefined;
|
public playlistId: number = undefined;
|
||||||
public artistId: bigint = undefined;
|
public artistId: number = undefined;
|
||||||
public albumId: bigint = undefined;
|
public albumId: number = undefined;
|
||||||
public trackId: bigint = undefined;
|
public trackId: number = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ArianeService {
|
export class ArianeService {
|
||||||
public genderId: bigint = undefined;
|
public genderId: number = undefined;
|
||||||
public typeName: string = undefined;
|
public typeName: string = undefined;
|
||||||
@Output() typeChange: EventEmitter<bigint> = new EventEmitter();
|
@Output() typeChange: EventEmitter<number> = new EventEmitter();
|
||||||
|
|
||||||
public playlistId: bigint = undefined;
|
public playlistId: number = undefined;
|
||||||
public playlistName: string = undefined;
|
public playlistName: string = undefined;
|
||||||
@Output() playlistChange: EventEmitter<bigint> = new EventEmitter();
|
@Output() playlistChange: EventEmitter<number> = new EventEmitter();
|
||||||
|
|
||||||
public artistId: bigint = undefined;
|
public artistId: number = undefined;
|
||||||
public artistName: string = undefined;
|
public artistName: string = undefined;
|
||||||
@Output() artistChange: EventEmitter<bigint> = new EventEmitter();
|
@Output() artistChange: EventEmitter<number> = new EventEmitter();
|
||||||
|
|
||||||
public albumId: bigint = undefined;
|
public albumId: number = undefined;
|
||||||
public albumName: string = undefined;
|
public albumName: string = undefined;
|
||||||
@Output() albumChange: EventEmitter<bigint> = new EventEmitter();
|
@Output() albumChange: EventEmitter<number> = new EventEmitter();
|
||||||
|
|
||||||
public trackId: bigint = undefined;
|
public trackId: number = undefined;
|
||||||
public trackName: string = undefined;
|
public trackName: string = undefined;
|
||||||
@Output() trackChange: EventEmitter<bigint> = new EventEmitter();
|
@Output() trackChange: EventEmitter<number> = new EventEmitter();
|
||||||
|
|
||||||
@Output() update: EventEmitter<InputOrders> = new EventEmitter();
|
@Output() update: EventEmitter<InputOrders> = new EventEmitter();
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ export class ArianeService {
|
|||||||
return this.segment;
|
return this.segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIsParam(params: any, name: string): undefined | bigint {
|
getIsParam(params: any, name: string): undefined | number {
|
||||||
let valueStr = params.get(name);
|
let valueStr = params.get(name);
|
||||||
if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return BigInt(valueStr);
|
return valueStr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ export class ArianeService {
|
|||||||
this.trackChange.emit(this.trackId);
|
this.trackChange.emit(this.trackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
setType(id: bigint): void {
|
setType(id: number): void {
|
||||||
if (this.genderId === id) {
|
if (this.genderId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,14 +178,14 @@ export class ArianeService {
|
|||||||
self.typeChange.emit(self.genderId);
|
self.typeChange.emit(self.genderId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getTypeId(): bigint | undefined {
|
getTypeId(): number | undefined {
|
||||||
return this.genderId;
|
return this.genderId;
|
||||||
}
|
}
|
||||||
getTypeName(): string | undefined {
|
getTypeName(): string | undefined {
|
||||||
return this.typeName;
|
return this.typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlaylist(id: bigint | undefined) {
|
setPlaylist(id: number | undefined) {
|
||||||
if (this.playlistId === id) {
|
if (this.playlistId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,14 +204,14 @@ export class ArianeService {
|
|||||||
self.playlistChange.emit(self.playlistId);
|
self.playlistChange.emit(self.playlistId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPlaylistId(): bigint | undefined {
|
getPlaylistId(): number | undefined {
|
||||||
return this.playlistId;
|
return this.playlistId;
|
||||||
}
|
}
|
||||||
getPlaylistName(): string | undefined {
|
getPlaylistName(): string | undefined {
|
||||||
return this.playlistName;
|
return this.playlistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setArtist(id: bigint | undefined): void {
|
setArtist(id: number | undefined): void {
|
||||||
if (this.artistId === id) {
|
if (this.artistId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,14 +230,14 @@ export class ArianeService {
|
|||||||
self.artistChange.emit(self.artistId);
|
self.artistChange.emit(self.artistId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getArtistId(): bigint | undefined {
|
getArtistId(): number | undefined {
|
||||||
return this.artistId;
|
return this.artistId;
|
||||||
}
|
}
|
||||||
getArtistName(): string | undefined {
|
getArtistName(): string | undefined {
|
||||||
return this.artistName;
|
return this.artistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlbum(id: bigint | undefined): void {
|
setAlbum(id: number | undefined): void {
|
||||||
if (this.albumId === id) {
|
if (this.albumId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -257,14 +257,14 @@ export class ArianeService {
|
|||||||
self.albumChange.emit(self.albumId);
|
self.albumChange.emit(self.albumId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getAlbumId(): bigint | undefined {
|
getAlbumId(): number | undefined {
|
||||||
return this.albumId;
|
return this.albumId;
|
||||||
}
|
}
|
||||||
getAlbumName(): string | undefined {
|
getAlbumName(): string | undefined {
|
||||||
return this.albumName;
|
return this.albumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTrack(id: bigint | undefined): void {
|
setTrack(id: number | undefined): void {
|
||||||
if (this.trackId === id) {
|
if (this.trackId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ export class ArianeService {
|
|||||||
self.trackChange.emit(self.trackId);
|
self.trackChange.emit(self.trackId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getTrackId(): bigint | undefined {
|
getTrackId(): number | undefined {
|
||||||
return this.trackId;
|
return this.trackId;
|
||||||
}
|
}
|
||||||
getTrackName(): string | undefined {
|
getTrackName(): string | undefined {
|
||||||
@ -301,7 +301,7 @@ export class ArianeService {
|
|||||||
*/
|
*/
|
||||||
genericNavigate(
|
genericNavigate(
|
||||||
destination: string,
|
destination: string,
|
||||||
ids: bigint[],
|
ids: number[],
|
||||||
newWindows?: boolean,
|
newWindows?: boolean,
|
||||||
replaceCurrentPage: boolean = false): void {
|
replaceCurrentPage: boolean = false): void {
|
||||||
let addressOffset = `${destination}`;
|
let addressOffset = `${destination}`;
|
||||||
@ -318,7 +318,7 @@ export class ArianeService {
|
|||||||
}
|
}
|
||||||
genericNavigateEdit(
|
genericNavigateEdit(
|
||||||
destination: string,
|
destination: string,
|
||||||
id: bigint,
|
id: number,
|
||||||
newWindows?: boolean,
|
newWindows?: boolean,
|
||||||
replaceCurrentPage: boolean = false): void {
|
replaceCurrentPage: boolean = false): void {
|
||||||
let addressOffset = `${destination}/${id}`;
|
let addressOffset = `${destination}/${id}`;
|
||||||
@ -329,39 +329,39 @@ export class ArianeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigatePlaylist({ id, newWindows }: { id?: bigint; newWindows?: boolean; }): void {
|
navigatePlaylist({ id, newWindows }: { id?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('playlist', [id], newWindows);
|
this.genericNavigate('playlist', [id], newWindows);
|
||||||
}
|
}
|
||||||
navigatePlaylistEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
navigatePlaylistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('playlist', id, newWindows);
|
this.genericNavigateEdit('playlist', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateGender({ genderId, newWindows }: { genderId?: bigint; newWindows?: boolean; }): void {
|
navigateGender({ genderId, newWindows }: { genderId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('gender', [genderId], newWindows);
|
this.genericNavigate('gender', [genderId], newWindows);
|
||||||
}
|
}
|
||||||
navigateGenderEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
navigateGenderEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('gender', id, newWindows);
|
this.genericNavigateEdit('gender', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateAlbum({ albumId, newWindows }: { albumId?: bigint; newWindows?: boolean; }): void {
|
navigateAlbum({ albumId, newWindows }: { albumId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('album', [albumId], newWindows);
|
this.genericNavigate('album', [albumId], newWindows);
|
||||||
}
|
}
|
||||||
navigateAlbumEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
navigateAlbumEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('album', id, newWindows);
|
this.genericNavigateEdit('album', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
navigateArtist({ artistId, albumId, newWindows }: { artistId?: bigint; albumId?: bigint, newWindows?: boolean; }): void {
|
navigateArtist({ artistId, albumId, newWindows }: { artistId?: number; albumId?: number, newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('artist', [artistId, albumId], newWindows);
|
this.genericNavigate('artist', [artistId, albumId], newWindows);
|
||||||
}
|
}
|
||||||
navigateArtistEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
navigateArtistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('artist', id, newWindows);
|
this.genericNavigateEdit('artist', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateTrack({ trackId, newWindows }: { trackId?: bigint; newWindows?: boolean; }): void {
|
navigateTrack({ trackId, newWindows }: { trackId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('track', [trackId], newWindows);
|
this.genericNavigate('track', [trackId], newWindows);
|
||||||
}
|
}
|
||||||
navigateTrackEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
navigateTrackEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('track', id, newWindows);
|
this.genericNavigateEdit('track', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,164 +6,122 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { HttpWrapperService, BddService, SessionService } from 'common/service';
|
||||||
import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
|
import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
|
||||||
import { isNodeData, NodeData } from 'common/model';
|
import { isNodeData, NodeData } from 'common/model';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||||
|
import { Artist, ArtistResource, UUID } from 'app/back-api';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { DataStore } from 'common/utils/data-store';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ArtistService extends GenericInterfaceModelDB {
|
export class ArtistService extends GenericDataService<Artist> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('artist', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Artist[]> {
|
||||||
|
return ArtistResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
/**
|
super();
|
||||||
* Get all the track for a specific artist
|
this.setStore(new DataStore<Artist>(this.lambdaGets, "id"));
|
||||||
* @param idArtist - Id of the artist.
|
}
|
||||||
* @returns a promise on the list of track elements
|
insert(data: Artist): Promise<Artist> {
|
||||||
*/
|
const self = this;
|
||||||
getTrackNoAlbum(idArtist: bigint): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.post({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
data
|
||||||
{
|
}).then((value: Artist) => {
|
||||||
check: TypeCheck.CONTAINS,
|
self.dataStore.updateValue(value);
|
||||||
key: 'artists',
|
resolve(value);
|
||||||
value: idArtist,
|
}).catch((error) => {
|
||||||
}, {
|
reject(error);
|
||||||
check: TypeCheck.EQUAL,
|
});
|
||||||
key: 'albumId',
|
|
||||||
value: undefined,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
['track', 'name']);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
patch(id: number, data: Artist): Promise<Artist> {
|
||||||
* Get all the track for a specific artist
|
const self = this;
|
||||||
* @param idArtist - Id of the artist.
|
|
||||||
* @returns a promise on the list of track elements
|
|
||||||
*/
|
|
||||||
getAllTracks(idArtist: bigint): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.patch({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id
|
||||||
check: TypeCheck.CONTAINS,
|
},
|
||||||
key: 'artists',
|
data
|
||||||
value: idArtist,
|
}).then((value: Artist) => {
|
||||||
}
|
self.dataStore.updateValue(value);
|
||||||
],
|
resolve(value);
|
||||||
['track', 'name']);
|
}).catch((error) => {
|
||||||
resolve(data);
|
reject(error);
|
||||||
}).catch((response) => {
|
});
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
delete(id: number): Promise<void> {
|
||||||
* Get the number of track in this artist ID
|
const self = this;
|
||||||
* @param id - Id of the artist.
|
|
||||||
* @returns The number of track present in this artist
|
|
||||||
*/
|
|
||||||
countTrack(artistId: bigint): Promise<number> {
|
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.remove({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id
|
||||||
check: TypeCheck.CONTAINS,
|
}
|
||||||
key: 'artists',
|
}).then(() => {
|
||||||
value: artistId,
|
self.dataStore.delete(id);
|
||||||
},
|
resolve();
|
||||||
]);
|
}).catch((error) => {
|
||||||
resolve(data.length);
|
reject(error);
|
||||||
}).catch((response) => {
|
});
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
deleteCover(id: number, coverId: UUID): Promise<Artist> {
|
||||||
* Get all the album of a specific artist
|
|
||||||
* @param idArtist - ID of the artist
|
|
||||||
* @returns the required List.
|
|
||||||
*/
|
|
||||||
getAlbum(idArtist: bigint): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
//console.log(" <<<========================================>>> " + idArtist);
|
params: {
|
||||||
let data = response.getsWhere([
|
id,
|
||||||
{
|
coverId
|
||||||
check: TypeCheck.CONTAINS, //< this is for array containing
|
}
|
||||||
key: 'artists',
|
}).then((value) => {
|
||||||
value: idArtist,
|
self.dataStore.updateValue(value);
|
||||||
},
|
resolve(value);
|
||||||
], ['id']);
|
}).catch((error) => {
|
||||||
//console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
reject(error);
|
||||||
// extract a single time all value "id" in an array
|
});
|
||||||
const listAlbumId = DataInterface.extractLimitOne(data, "albumId");
|
|
||||||
//console.log("==> List Of ids: " + JSON.stringify(listAlbumId, null, 2));
|
|
||||||
self.bdd.get('album')
|
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let dataAlbum = response.getsWhere([
|
|
||||||
{
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: listAlbumId,
|
|
||||||
},
|
|
||||||
], ['publication', 'name', 'id']);
|
|
||||||
resolve(dataAlbum);
|
|
||||||
//console.log("==> get all albums: " + JSON.stringify(dataAlbum, null, 2));
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
countAlbum(idArtist: bigint): Promise<number> {
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Artist> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.uploadCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
//console.log(" <<<========================================>>> " + idArtist);
|
params: {
|
||||||
let data = response.getsWhere([
|
id,
|
||||||
{
|
},
|
||||||
check: TypeCheck.CONTAINS, //< this is for array containing
|
data: {
|
||||||
key: 'artists',
|
file,
|
||||||
value: idArtist,
|
fileName: file.name
|
||||||
},
|
}
|
||||||
], ['id']);
|
}).then((value) => {
|
||||||
//console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
self.dataStore.updateValue(value);
|
||||||
// extract a single time all value "id" in an array
|
resolve(value);
|
||||||
const listAlbumId = DataInterface.extractLimitOne(data, "albumId");
|
}).catch((error) => {
|
||||||
resolve(listAlbumId.length);
|
reject(error);
|
||||||
}).catch((response) => {
|
});
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,97 +5,101 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { isArrayOf, isNumberFinite } from 'common/utils';
|
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
||||||
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
|
import { SessionService } from 'common/service';
|
||||||
|
import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataService {
|
export class DataService {
|
||||||
// 0: Not hide password; 1 hide password;
|
|
||||||
private serviceName: string = 'data';
|
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService) {
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
console.log('Start DataService');
|
console.log('Start DataService');
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(): any {
|
|
||||||
return this.http.getSpecific(this.serviceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
get(_id: number): any {
|
|
||||||
return this.http.getSpecific([this.serviceName, _id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadFile(_form: FormData, _progress: any = null) {
|
|
||||||
// return this.http.uploadFileMultipart(this.serviceName, null, _file);
|
|
||||||
return this.http.uploadMultipart(`${this.serviceName}/upload/`, _form, _progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
getImage(_id: number): Promise<ModelResponseHttp> {
|
|
||||||
return this.http.requestImage({
|
|
||||||
endPoint: this.serviceName,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.IMAGE,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getImageThumbnail(_id: number): Promise<ModelResponseHttp> {
|
|
||||||
return this.http.requestImage({
|
|
||||||
endPoint: this.serviceName + "/thumbnail/" + _id,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.ALL,//IMAGE,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Retreive the Cover URL of a specific data id
|
* Retrieve the Cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverUrl(coverId: number): string {
|
getUrl(dataId: string, optionalName?: string): string {
|
||||||
return this.http.createRESTCall2({
|
if (isNullOrUndefined(optionalName)) {
|
||||||
api: `data/${coverId}`,
|
return RESTUrl({
|
||||||
addURLToken: true,
|
restModel: {
|
||||||
});
|
endPoint: "data/{dataId}",
|
||||||
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
queries: {
|
||||||
|
dataId
|
||||||
|
}
|
||||||
|
}).replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
|
}
|
||||||
|
return RESTUrl({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "data/{dataId}/{optionalName}",
|
||||||
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
queries: {
|
||||||
|
dataId,
|
||||||
|
optionalName
|
||||||
|
}
|
||||||
|
}).replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the list Cover URL of a specific data id
|
* Retrieve the list Cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverListUrl(coverIds?: number[]): string[] | undefined {
|
getListUrl(dataIds?: string[]): string[] | undefined {
|
||||||
if (!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let covers = [] as string[];
|
let covers: string[] = [];
|
||||||
for (let iii = 0; iii < coverIds.length; iii++) {
|
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||||
covers.push(this.getCoverUrl(coverIds[iii]).replace("http://localhost:19080", "https://atria-soft.org"));
|
covers.push(this.getUrl(dataIds[iii]));
|
||||||
}
|
}
|
||||||
return covers;
|
return covers;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the thumbnail cover URL of a specific data id
|
* Retrieve the thumbnail cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverThumbnailUrl(coverId: number): string {
|
getThumbnailUrl(coverId: string): string {
|
||||||
return this.http.createRESTCall2({
|
return RESTUrl({
|
||||||
api: `data/thumbnail/${coverId}`,
|
restModel: {
|
||||||
addURLToken: true,
|
endPoint: "data/thumbnail/{coverId}",
|
||||||
});
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
queries: {
|
||||||
|
coverId
|
||||||
|
} +
|
||||||
|
}).replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the list thumbnail cover URL of a specific data id
|
* Retrieve the list thumbnail cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverListThumbnailUrl(coverIds?: number[]): string[] | undefined {
|
getListThumbnailUrl(dataIds?: string[]): string[] | undefined {
|
||||||
if (!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let covers = [] as string[];
|
let covers: string[] = [];
|
||||||
for (let iii = 0; iii < coverIds.length; iii++) {
|
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||||
covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
|
covers.push(this.getThumbnailUrl(dataIds[iii]));
|
||||||
}
|
}
|
||||||
return covers;
|
return covers;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,14 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { HttpWrapperService, BddService, SessionService } from 'common/service';
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
||||||
import { isNodeData, NodeData } from 'common/model';
|
import { isNodeData, NodeData } from 'common/model';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { GenderResource, Gender, GenderResource, UUID } from 'app/back-api';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { DataStore } from 'common/utils/data-store';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
export interface MessageLogIn {
|
export interface MessageLogIn {
|
||||||
id: number;
|
id: number;
|
||||||
@ -18,109 +22,109 @@ export interface MessageLogIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GenderService extends GenericInterfaceModelDB {
|
export class GenderService extends GenericDataService<Gender> {
|
||||||
|
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('gender', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Gender[]> {
|
||||||
|
return GenderResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
this.setStore(new DataStore<Gender>(this.lambdaGets, "id"));
|
||||||
countTrack(id:number): Promise<number> {
|
}
|
||||||
let self = this;
|
insert(data: Gender): Promise<Gender> {
|
||||||
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.post({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
data
|
||||||
{
|
}).then((value: Gender) => {
|
||||||
check: TypeCheck.EQUAL,
|
self.dataStore.updateValue(value);
|
||||||
key: 'typeId',
|
resolve(value);
|
||||||
value: id,
|
}).catch((error) => {
|
||||||
} ] );
|
reject(error);
|
||||||
resolve(data.length);
|
});
|
||||||
}).catch((response) => {
|
});
|
||||||
reject(response);
|
}
|
||||||
});
|
patch(id: number, data: Gender): Promise<Gender> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
GenderResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Gender) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubTrack(id:number): Promise<NodeData[]> {
|
delete(id: number): Promise<void> {
|
||||||
let self = this;
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.remove({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id
|
||||||
check: TypeCheck.EQUAL,
|
}
|
||||||
key: 'typeId',
|
}).then(() => {
|
||||||
value: id,
|
self.dataStore.delete(id);
|
||||||
}, {
|
resolve();
|
||||||
check: TypeCheck.EQUAL,
|
}).catch((error) => {
|
||||||
key: 'artistId',
|
reject(error);
|
||||||
value: undefined,
|
});
|
||||||
}, {
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'playlistId',
|
|
||||||
value: undefined,
|
|
||||||
},
|
|
||||||
], [ 'name' ] );
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubArtist(id:number): Promise<NodeData[]> {
|
deleteCover(id: number, coverId: UUID): Promise<Gender> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('artist')
|
GenderResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
coverId
|
||||||
key: 'parentId',
|
}
|
||||||
value: id,
|
}).then((value) => {
|
||||||
} ],
|
self.dataStore.updateValue(value);
|
||||||
[ 'name' ]);
|
resolve(value);
|
||||||
resolve(data);
|
}).catch((error) => {
|
||||||
}).catch((response) => {
|
reject(error);
|
||||||
reject(response);
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
getSubPlaylist(id:number): Promise<NodeData[]> {
|
file: File,
|
||||||
|
progress: any = null): Promise<Gender> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.uploadCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
},
|
||||||
key: 'typeId',
|
data: {
|
||||||
value: id,
|
file,
|
||||||
}, {
|
fileName: file.name
|
||||||
check: TypeCheck.EQUAL,
|
}
|
||||||
key: 'artistId',
|
}).then((value) => {
|
||||||
value: [undefined, null],
|
self.dataStore.updateValue(value);
|
||||||
}, {
|
resolve(value);
|
||||||
check: TypeCheck.NOT_EQUAL,
|
}).catch((error) => {
|
||||||
key: 'playlistId',
|
reject(error);
|
||||||
value: undefined,
|
});
|
||||||
},
|
|
||||||
]);
|
|
||||||
//, [ 'universId' ]);
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}).catch((response: any) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,16 +7,31 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
import { NodeData } from 'common/model';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { HttpWrapperService, BddService, SessionService } from 'common/service';
|
||||||
import { DataInterface, TypeCheck } from 'common/utils';
|
import { DataInterface, TypeCheck } from 'common/utils';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||||
|
import { Playlist, PlaylistResource, Playlist, UUID } from 'app/back-api';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { DataStore } from 'common/utils/data-store';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PlaylistService extends GenericInterfaceModelDB {
|
export class PlaylistService extends GenericDataService<Playlist> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('playlist', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Playlist[]> {
|
||||||
|
return PlaylistResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
this.setStore(new DataStore<Playlist>(this.lambdaGets, "id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubArtist(id: bigint, select: Array<string> = []): any {
|
getSubArtist(id: bigint, select: Array<string> = []): any {
|
||||||
@ -25,26 +40,91 @@ export class PlaylistService extends GenericInterfaceModelDB {
|
|||||||
|
|
||||||
getSubTrack(id: bigint, select: Array<string> = []): any {
|
getSubTrack(id: bigint, select: Array<string> = []): any {
|
||||||
// this.checkLocalBdd();
|
// this.checkLocalBdd();
|
||||||
|
} insert(data: Playlist): Promise<Playlist> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.post({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
data
|
||||||
|
}).then((value: Playlist) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
patch(id: number, data: Playlist): Promise<Playlist> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Playlist) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(ids: bigint[]): Promise<NodeData[]> {
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Playlist> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get(self.serviceName)
|
PlaylistResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
coverId
|
||||||
key: 'id',
|
}
|
||||||
value: ids,
|
}).then((value) => {
|
||||||
},
|
self.dataStore.updateValue(value);
|
||||||
],
|
resolve(value);
|
||||||
['name', 'id']);
|
}).catch((error) => {
|
||||||
resolve(data);
|
reject(error);
|
||||||
return;
|
});
|
||||||
}).catch((response) => {
|
});
|
||||||
reject(response);
|
}
|
||||||
});
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Playlist> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,52 +5,149 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { SessionService } from 'common/service';
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
import { DataInterface, isArrayOf, isNumber, TypeCheck } from 'common/utils';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { DataStore } from 'common/utils/data-store';
|
||||||
import { Track, isTrack } from 'app/model/server-karusic-api';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { Track, TrackResource, UUID } from 'app/back-api';
|
||||||
|
import { DataTools } from 'common/utils/data-tools';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TrackService extends GenericInterfaceModelDB {
|
export class TrackService extends GenericDataService<Track> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('track', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getTrack(id: bigint): Promise<Track> {
|
private lambdaGets(): Promise<Track[]> {
|
||||||
|
return TrackResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
this.setStore(new DataStore<Track>(this.lambdaGets, "id"));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
insert(data: Track): Promise<Track> {
|
||||||
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
super.get(id).then((data: NodeData) => {
|
TrackResource.post({
|
||||||
if (isTrack(data)) {
|
restConfig: this.getRestConfig(),
|
||||||
resolve(data);
|
data
|
||||||
return;
|
}).then((value: Track) => {
|
||||||
}
|
self.dataStore.updateValue(value);
|
||||||
reject("model is wrong !!!")
|
resolve(value);
|
||||||
return
|
}).catch((error) => {
|
||||||
}).catch((reason: any) => {
|
reject(error);
|
||||||
reject(reason);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getWithAlbum(idAlbum: number): Promise<Track[]> {
|
*/
|
||||||
|
patch(id: number, data: Track): Promise<Track> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
TrackResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Track) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
TrackResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getTracksIdsForAlbums(idAlbums: number[]): Promise<number[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get(self.serviceName)
|
self.dataStore.getData()
|
||||||
.then((response: DataInterface) => {
|
.then((response: Track[]) => {
|
||||||
let data = response.getsWhere([
|
let data = DataTools.getsWhere(response,
|
||||||
{
|
[
|
||||||
check: TypeCheck.EQUAL,
|
{
|
||||||
key: 'albumId',
|
check: TypeCheck.EQUAL,
|
||||||
value: idAlbum,
|
key: 'albumId',
|
||||||
},
|
value: idAlbums,
|
||||||
],
|
},
|
||||||
|
],
|
||||||
|
['name']); // tODO : set the Id in the track ...
|
||||||
|
// filter with artist- ID !!!
|
||||||
|
const listId = DataInterface.extractLimitOne(data, "id");
|
||||||
|
resolve(listId);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of track in this season ID
|
||||||
|
* @param AlbumId - Id of the album.
|
||||||
|
* @returns The number of element present in this season
|
||||||
|
*/
|
||||||
|
countTracksWithAlbumId(AlbumId: number): Promise<number> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'albumId',
|
||||||
|
value: AlbumId,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
resolve(data.length);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getTracksWithAlbumId(idAlbum: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'albumId',
|
||||||
|
value: idAlbum,
|
||||||
|
},
|
||||||
|
],
|
||||||
['track', 'name', 'id']);
|
['track', 'name', 'id']);
|
||||||
if (isArrayOf(data, isTrack)) {
|
resolve(data);
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reject("model is wrong !!!");
|
|
||||||
return;
|
return;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -58,49 +155,312 @@ export class TrackService extends GenericInterfaceModelDB {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
getTrackData(): Promise<Track[]> {
|
* Get all the track for a specific artist
|
||||||
|
* @param idArtist - Id of the artist.
|
||||||
|
* @returns a promise on the list of track elements
|
||||||
|
*/
|
||||||
|
getTracksOfArtistWithNoAlbum(idArtist: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
super.getData().then((data: NodeData[]) => {
|
self.gets()
|
||||||
if (isArrayOf(data, isTrack)) {
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response, [
|
||||||
|
{
|
||||||
|
check: TypeCheck.CONTAINS,
|
||||||
|
key: 'artists',
|
||||||
|
value: idArtist,
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'albumId',
|
||||||
|
value: undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['track', 'name']);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return;
|
}).catch((response) => {
|
||||||
}
|
reject(response);
|
||||||
reject("model is wrong !!!")
|
});
|
||||||
return
|
|
||||||
}).catch((reason: any) => {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the track for a specific artist
|
||||||
|
* @param idArtist - Id of the artist.
|
||||||
|
* @returns a promise on the list of track elements
|
||||||
|
*/
|
||||||
|
getTracksOfAnArtist(idArtist: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response, [
|
||||||
|
{
|
||||||
|
check: TypeCheck.CONTAINS,
|
||||||
|
key: 'artists',
|
||||||
|
value: idArtist,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
['track', 'name']);
|
||||||
|
resolve(data);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of track in this artist ID
|
||||||
|
* @param id - Id of the artist.
|
||||||
|
* @returns The number of track present in this artist
|
||||||
|
*/
|
||||||
|
countTracksOfAnArtist(artistId: number): Promise<number> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response, [
|
||||||
|
{
|
||||||
|
check: TypeCheck.CONTAINS,
|
||||||
|
key: 'artists',
|
||||||
|
value: artistId,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
resolve(data.length);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the album of a specific artist
|
||||||
|
* @param idArtist - ID of the artist
|
||||||
|
* @returns the required List.
|
||||||
|
*/
|
||||||
|
getAlbumIdsOfAnArtist(idArtist: number): Promise<number[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
//console.log(" <<<========================================>>> " + idArtist);
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.CONTAINS, //< this is for array containing
|
||||||
|
key: 'artists',
|
||||||
|
value: idArtist,
|
||||||
|
},
|
||||||
|
], ['id']);
|
||||||
|
//console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
||||||
|
// extract a single time all value "id" in an array
|
||||||
|
const listAlbumId = DataInterface.extractLimitOne(data, "albumId");
|
||||||
|
if (isArrayOf(listAlbumId, isNumber)) {
|
||||||
|
resolve(listAlbumId);
|
||||||
|
} else {
|
||||||
|
reject("Fail to get the ids (impossible case)");
|
||||||
|
}
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
countAlbumOfAnArtist(idArtist: number): Promise<number> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
//console.log(" <<<========================================>>> " + idArtist);
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.CONTAINS, //< this is for array containing
|
||||||
|
key: 'artists',
|
||||||
|
value: idArtist,
|
||||||
|
},
|
||||||
|
], ['id']);
|
||||||
|
//console.log("==> get all tracks of the artist: " + JSON.stringify(data, null, 2));
|
||||||
|
// extract a single time all value "id" in an array
|
||||||
|
const listAlbumId = DataInterface.extractLimitOne(data, "albumId");
|
||||||
|
resolve(listAlbumId.length);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
countTrackForGender(typeId: number): Promise<number> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'typeId',
|
||||||
|
value: typeId,
|
||||||
|
}]);
|
||||||
|
resolve(data.length);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getTracksForGender(id: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'genderId',
|
||||||
|
value: id,
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'artistId',
|
||||||
|
value: undefined,
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'playlistId',
|
||||||
|
value: undefined,
|
||||||
|
},
|
||||||
|
], ['name']);
|
||||||
|
resolve(data);
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getSubPlaylist(typeId: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'typeId',
|
||||||
|
value: typeId,
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'artistId',
|
||||||
|
value: [undefined, null],
|
||||||
|
}, {
|
||||||
|
check: TypeCheck.NOT_EQUAL,
|
||||||
|
key: 'playlistId',
|
||||||
|
value: undefined,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
//, [ 'universId' ]);
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response: any) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uploadFile(file: File,
|
uploadFile(file: File,
|
||||||
gender?: string,
|
gender?: string,
|
||||||
artist?: string,
|
artist?: string,
|
||||||
album?: string,
|
album?: string,
|
||||||
trackId?: number,
|
trackId?: number,
|
||||||
title?: string,
|
title?: string,
|
||||||
progress: any = null) {
|
progress: any = null): Promise<Track> {
|
||||||
const formData = new FormData();
|
const self = this;
|
||||||
formData.append('fileName', file.name);
|
return new Promise((resolve, reject) => {
|
||||||
// set the file at hte begining it will permit to abort the transmission
|
TrackResource.uploadTrack({
|
||||||
formData.append('file', file ?? null);
|
restConfig: this.getRestConfig(),
|
||||||
formData.append('gender', gender ?? null);
|
data: {
|
||||||
formData.append('artist', artist ?? null);
|
fileName: file.name,
|
||||||
formData.append('album', album ?? null);
|
file,
|
||||||
if (!isNullOrUndefined(trackId)) {
|
gender: gender ?? null,
|
||||||
formData.append('trackId', trackId.toString());
|
artist: artist ?? null,
|
||||||
} else {
|
album: album ?? null,
|
||||||
formData.append('trackId', null);
|
trackId: trackId ?? null,
|
||||||
}
|
title: title ?? null,
|
||||||
formData.append('title', title ?? null);
|
}
|
||||||
|
}).then((value: Track) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('fileName', file.name);
|
||||||
|
// set the file at hte beginning it will permit to abort the transmission
|
||||||
|
formData.append('file', file ?? null);
|
||||||
|
formData.append('gender', gender ?? null);
|
||||||
|
formData.append('artist', artist ?? null);
|
||||||
|
formData.append('album', album ?? null);
|
||||||
|
if (!isNullOrUndefined(trackId)) {
|
||||||
|
formData.append('trackId', trackId.toString());
|
||||||
|
} else {
|
||||||
|
formData.append('trackId', null);
|
||||||
|
}
|
||||||
|
formData.append('title', title ?? null);
|
||||||
|
|
||||||
return this.http.uploadMultipart(`${this.serviceName}/upload/`, formData, progress);
|
return this.http.uploadMultipart(`${this.serviceName}/upload/`, formData, progress);
|
||||||
|
*/
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Track> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
TrackResource.removeCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
coverId
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Track> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
TrackResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uploadCoverBlob(blob: Blob,
|
uploadCoverBlob(blob: Blob,
|
||||||
TrackId: bigint,
|
TrackId: number,
|
||||||
progress: any = null) {
|
progress: any = null) {
|
||||||
|
/*
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('fileName', 'take_screenshoot');
|
formData.append('fileName', 'take_screenshoot');
|
||||||
formData.append('typeId', TrackId.toString());
|
formData.append('typeId', TrackId.toString());
|
||||||
@ -111,7 +471,7 @@ export class TrackService extends GenericInterfaceModelDB {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
let data = response;
|
let data = response;
|
||||||
if (data === null || data === undefined) {
|
if (data === null || data === undefined) {
|
||||||
reject('error retrive data from server');
|
reject('error retrieve data from server');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.bdd.asyncSetInDB(self.serviceName, TrackId, data);
|
self.bdd.asyncSetInDB(self.serviceName, TrackId, data);
|
||||||
@ -120,6 +480,7 @@ export class TrackService extends GenericInterfaceModelDB {
|
|||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user