[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,
|
||||
TrackResource.class,
|
||||
DataResource.class),
|
||||
Initialization.CLASSES_BASE, "../front/src/app/model/");
|
||||
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
|
||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||
launcher.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.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
@ -68,9 +69,8 @@ public class AlbumResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@ -97,7 +97,8 @@ public class AlbumResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@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) {
|
||||
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
||||
}
|
||||
@ -106,8 +107,8 @@ public class AlbumResource {
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Operation(description = "Remove a cover on a specific album")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Album.class, id)).build();
|
||||
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
//AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
|
||||
return DataAccess.get(Album.class, id);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package org.kar.karusic.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
import org.kar.karusic.model.Artist;
|
||||
import org.slf4j.Logger;
|
||||
@ -62,15 +62,15 @@ public class ArtistResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@ -79,8 +79,8 @@ public class ArtistResource {
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Artist.class, id)).build();
|
||||
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
//AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
|
||||
return DataAccess.get(Artist.class, id);
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,12 @@ package org.kar.karusic.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
import org.kar.karusic.model.Gender;
|
||||
import org.slf4j.Logger;
|
||||
@ -32,20 +33,20 @@ public class GenderResource {
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@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);
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Gender> get() throws Exception {
|
||||
public List<Gender> gets() throws Exception {
|
||||
return DataAccess.gets(Gender.class);
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -53,7 +54,7 @@ public class GenderResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Gender.class, id);
|
||||
}
|
||||
@ -61,15 +62,15 @@ public class GenderResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@ -78,8 +79,8 @@ public class GenderResource {
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Gender.class, id)).build();
|
||||
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
//AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
|
||||
return DataAccess.get(Gender.class, id);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package org.kar.karusic.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
@ -45,7 +47,7 @@ public class PlaylistResource {
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -61,16 +63,15 @@ public class PlaylistResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/track/{trackId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
@ -87,6 +88,7 @@ public class PlaylistResource {
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@ -95,8 +97,8 @@ public class PlaylistResource {
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Playlist.class, id)).build();
|
||||
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
//AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
@ -41,20 +43,20 @@ public class TrackResource {
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@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);
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Track> get() throws Exception {
|
||||
public List<Track> gets() throws Exception {
|
||||
return DataAccess.gets(Track.class);
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ public class TrackResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Track.class, id);
|
||||
}
|
||||
@ -70,9 +72,8 @@ public class TrackResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@ -96,6 +97,7 @@ public class TrackResource {
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@ -104,9 +106,9 @@ public class TrackResource {
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Track.class, id)).build();
|
||||
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
//AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
|
||||
return DataAccess.get(Track.class, id);
|
||||
}
|
||||
|
||||
@POST
|
||||
@ -114,13 +116,14 @@ public class TrackResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
// Formatter:off
|
||||
public Response uploadFile(
|
||||
@AsyncType(Track.class)
|
||||
public Response uploadTrack(
|
||||
@FormDataParam("fileName") String fileName,
|
||||
@FormDataParam("gender") String gender,
|
||||
@FormDataParam("artist") String artist,
|
||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||
@FormDataParam("album") String album,
|
||||
@FormDataParam("trackId") String trackId,
|
||||
@AsyncType(Long.class) @FormDataParam("trackId") String trackId,
|
||||
@FormDataParam("title") String title,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@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',
|
||||
`parent_id` bigint
|
||||
) AUTO_INCREMENT=10;
|
||||
*/
|
||||
*/
|
||||
|
||||
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.GenericDataSoftDelete;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class NodeSmall extends GenericDataSoftDelete {
|
||||
@ -29,6 +30,7 @@ public class NodeSmall extends GenericDataSoftDelete {
|
||||
public String name = null;
|
||||
@Column(length = 0)
|
||||
public String description = null;
|
||||
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||
public List<Long> covers = null;
|
||||
@Schema(description = "List of Id of the specific covers")
|
||||
@DataJson(targetEntity = Data.class)
|
||||
public List<UUID> covers = null;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, isResponse, InputStream, isAlbum, Long, RestErrorResponse, Album, FormDataContentDisposition, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {UUID, Long, Album, isAlbum, } from "./model"
|
||||
export namespace AlbumResource {
|
||||
|
||||
/**
|
||||
@ -13,8 +13,8 @@ export namespace AlbumResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/album/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
@ -22,7 +22,7 @@ export namespace AlbumResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Get a specific Album with his ID
|
||||
@ -83,70 +83,6 @@ export namespace AlbumResource {
|
||||
data,
|
||||
}, 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
|
||||
*/
|
||||
@ -176,6 +112,72 @@ export namespace AlbumResource {
|
||||
restModel: {
|
||||
endPoint: "/album/{id}/track/{trackId}",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isAlbum);
|
||||
};
|
||||
/**
|
||||
* Remove a Track on a specific album
|
||||
*/
|
||||
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,
|
||||
},
|
||||
restConfig,
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, Artist, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, isArtist, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {Artist, UUID, Long, isArtist, } from "./model"
|
||||
export namespace ArtistResource {
|
||||
|
||||
export function remove({ restConfig, params, }: {
|
||||
@ -10,8 +10,8 @@ export namespace ArtistResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/artist/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
@ -19,7 +19,7 @@ export namespace ArtistResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
@ -71,44 +71,6 @@ export namespace ArtistResource {
|
||||
data,
|
||||
}, 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, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Artist[]> {
|
||||
@ -121,4 +83,43 @@ export namespace ArtistResource {
|
||||
restConfig,
|
||||
}, 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)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {Long, } from "./model"
|
||||
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
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataId({ restConfig, queries, params, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
@ -17,8 +38,8 @@ export namespace DataResource {
|
||||
id: Long,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -27,11 +48,12 @@ export namespace DataResource {
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 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, }: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
@ -41,8 +63,8 @@ export namespace DataResource {
|
||||
id: Long,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/thumbnail/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -51,11 +73,12 @@ export namespace DataResource {
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 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, }: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
@ -66,8 +89,8 @@ export namespace DataResource {
|
||||
id: Long,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/{id}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -76,25 +99,6 @@ export namespace DataResource {
|
||||
params,
|
||||
queries,
|
||||
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)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {RestErrorResponse, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {} from "./model"
|
||||
export namespace Front {
|
||||
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, isResponse, InputStream, Long, RestErrorResponse, isGender, Gender, FormDataContentDisposition, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {UUID, Long, Gender, isGender, } from "./model"
|
||||
export namespace GenderResource {
|
||||
|
||||
export function remove({ restConfig, params, }: {
|
||||
@ -10,8 +10,8 @@ export namespace GenderResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/gender/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
@ -19,21 +19,25 @@ export namespace GenderResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, }: {
|
||||
export function get({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Gender[]> {
|
||||
return RESTRequestJsonArray({
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/gender",
|
||||
endPoint: "/gender/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isGender);
|
||||
};
|
||||
export function put({ restConfig, params, data, }: {
|
||||
export function patch({ restConfig, params, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
@ -54,7 +58,7 @@ export namespace GenderResource {
|
||||
};
|
||||
export function post({ restConfig, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
data: string,
|
||||
data: Gender,
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -67,6 +71,18 @@ export namespace GenderResource {
|
||||
data,
|
||||
}, 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, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
@ -74,27 +90,28 @@ export namespace GenderResource {
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: FormDataContentDisposition,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/gender/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isResponse);
|
||||
}, isGender);
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: Long,
|
||||
coverId: UUID,
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/gender/{id}/cover/{coverId}",
|
||||
@ -103,22 +120,6 @@ export namespace GenderResource {
|
||||
},
|
||||
restConfig,
|
||||
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);
|
||||
};
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {RestErrorResponse, isHealthResult, HealthResult, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {HealthResult, isHealthResult, } from "./model"
|
||||
export namespace HealthCheck {
|
||||
|
||||
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({
|
||||
// Create time of the object
|
||||
createdAt: ZodDate.readonly().optional(),
|
||||
@ -207,7 +193,8 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
||||
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
||||
name: zod.string().max(256).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 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({
|
||||
firstName: zod.string().max(256).optional(),
|
||||
surname: zod.string().max(256).optional(),
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, Playlist, isPlaylist, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {UUID, Long, Playlist, isPlaylist, } from "./model"
|
||||
export namespace PlaylistResource {
|
||||
|
||||
export function remove({ restConfig, params, }: {
|
||||
@ -10,8 +10,8 @@ export namespace PlaylistResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
@ -19,7 +19,7 @@ export namespace PlaylistResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, }: {
|
||||
restConfig: RESTConfig,
|
||||
@ -54,7 +54,7 @@ export namespace PlaylistResource {
|
||||
};
|
||||
export function post({ restConfig, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
data: string,
|
||||
data: Playlist,
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -91,27 +91,28 @@ export namespace PlaylistResource {
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: FormDataContentDisposition,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isResponse);
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: Long,
|
||||
coverId: UUID,
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}/cover/{coverId}",
|
||||
@ -120,7 +121,7 @@ export namespace PlaylistResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function getWithId({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
@ -138,7 +139,7 @@ export namespace PlaylistResource {
|
||||
params,
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function addTrack({ restConfig, params, }: {
|
||||
export function uploadTrack({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
trackId: Long,
|
||||
@ -149,6 +150,7 @@ export namespace PlaylistResource {
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}/track/{trackId}",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2024, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (Generate file)
|
||||
* @license MPL-2
|
||||
*/
|
||||
|
||||
import { RestErrorResponse } from "./model"
|
||||
@ -20,6 +20,8 @@ export enum HTTPMimeType {
|
||||
IMAGE_PNG = 'image/png',
|
||||
JSON = 'application/json',
|
||||
OCTET_STREAM = 'application/octet-stream',
|
||||
MULTIPART = 'multipart/form-data',
|
||||
CSV = 'text/csv',
|
||||
}
|
||||
|
||||
export interface RESTConfig {
|
||||
@ -42,11 +44,6 @@ export interface RESTModel {
|
||||
tokenInUrl?: boolean;
|
||||
}
|
||||
|
||||
export interface RESTRequest {
|
||||
params?: object;
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface ModelResponseHttp {
|
||||
status: number;
|
||||
data: any;
|
||||
@ -119,6 +116,12 @@ export function RESTRequest({ restModel, restConfig, data, params, queries }: RE
|
||||
let body = data;
|
||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||
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}`)
|
||||
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)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {Response, isTrack, isResponse, InputStream, Long, RestErrorResponse, FormDataContentDisposition, Track, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {UUID, Long, Track, isTrack, } from "./model"
|
||||
export namespace TrackResource {
|
||||
|
||||
export function remove({ restConfig, params, }: {
|
||||
@ -10,8 +10,8 @@ export namespace TrackResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/track/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
@ -19,26 +19,30 @@ export namespace TrackResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Track[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/track",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isTrack);
|
||||
};
|
||||
export function put({ restConfig, params, data, }: {
|
||||
export function get({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
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> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -52,9 +56,9 @@ export namespace TrackResource {
|
||||
data,
|
||||
}, isTrack);
|
||||
};
|
||||
export function create({ restConfig, data, }: {
|
||||
export function post({ restConfig, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
data: string,
|
||||
data: Track,
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -67,6 +71,36 @@ export namespace TrackResource {
|
||||
data,
|
||||
}, 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, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
@ -91,27 +125,28 @@ export namespace TrackResource {
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: FormDataContentDisposition,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/track/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isResponse);
|
||||
}, isTrack);
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: Long,
|
||||
coverId: UUID,
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/track/{id}/cover/{coverId}",
|
||||
@ -120,61 +155,29 @@ export namespace TrackResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isResponse);
|
||||
}, isTrack);
|
||||
};
|
||||
export function uploadFile({ restConfig, data, }: {
|
||||
export function uploadTrack({ restConfig, data, }: {
|
||||
restConfig: RESTConfig,
|
||||
data: {
|
||||
fileName: string,
|
||||
file: FormDataContentDisposition,
|
||||
file: File,
|
||||
gender: string,
|
||||
artist: string,
|
||||
album: string,
|
||||
trackId: string,
|
||||
trackId: Long,
|
||||
title: string,
|
||||
},
|
||||
}): Promise<Response> {
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/track//upload/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
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);
|
||||
};
|
||||
}
|
@ -1,48 +1,51 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
||||
import {UserKarusic, UserOut, isUserOut, Long, RestErrorResponse, isUserKarusic, } from "./model"
|
||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||
import {UserOut, Long, UserKarusic, isUserOut, isUserKarusic, } from "./model"
|
||||
export namespace UserResource {
|
||||
|
||||
export function get({ restConfig, params, }: {
|
||||
export function get({ restConfig, params, produce, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
produce: HTTPMimeType.JSON,
|
||||
}): Promise<UserKarusic> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
accept: produce,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isUserKarusic);
|
||||
};
|
||||
export function getMe({ restConfig, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<UserOut> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/me",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isUserOut);
|
||||
};
|
||||
export function gets({ restConfig, }: {
|
||||
export function gets({ restConfig, produce, }: {
|
||||
restConfig: RESTConfig,
|
||||
produce: HTTPMimeType.JSON,
|
||||
}): Promise<UserKarusic[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/users",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
accept: produce,
|
||||
},
|
||||
restConfig,
|
||||
}, 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,13 +10,13 @@ import { DataService } from 'app/service/data';
|
||||
@Component({
|
||||
selector: 'data-image',
|
||||
templateUrl: './data-image.html',
|
||||
styleUrls: [ './data-image.less' ]
|
||||
styleUrls: ['./data-image.less']
|
||||
})
|
||||
export class ElementDataImageComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id:number = -1;
|
||||
@Input() id: string = "0";
|
||||
cover: string = '';
|
||||
/*
|
||||
/*
|
||||
imageCanvas:any;
|
||||
@ViewChild('imageCanvas')
|
||||
set mainDivEl(el: ElementRef) {
|
||||
@ -24,16 +24,16 @@ export class ElementDataImageComponent implements OnInit {
|
||||
this.imageCanvas = el.nativeElement;
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
constructor(private dataService: DataService) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.cover = this.dataService.getCoverThumbnailUrl(this.id);
|
||||
this.cover = this.dataService.getThumbnailUrl(this.id);
|
||||
/*
|
||||
let canvas = this.imageCanvas.nativeElement;
|
||||
let ctx = canvas.getContext("2d");
|
||||
console.log(`Request thumnail for ---> ${this.id}`);
|
||||
console.log(`Request thumbnail for ---> ${this.id}`);
|
||||
this.dataService.getImageThumbnail(this.id)
|
||||
.then((result:ModelResponseHttp) => {
|
||||
console.log(`plop ---> ${result.status}`);
|
||||
|
@ -3,11 +3,8 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
||||
import { NodeData } from 'common/model';
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
|
||||
import { GenderService, DataService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'description-area',
|
||||
|
@ -5,14 +5,13 @@
|
||||
*/
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { isArray, isNullOrUndefined } from 'common/utils';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
import { DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service';
|
||||
import { PlaylistCurrent } from 'app/service/player';
|
||||
import { HttpWrapperService } from 'common/service';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { environment } from 'environments/environment';
|
||||
import { Track } from 'app/model/server-karusic-api';
|
||||
import { Album, Artist, Track } from 'app/back-api';
|
||||
|
||||
|
||||
export enum PlayMode {
|
||||
@ -74,10 +73,9 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
constructor(
|
||||
private playerService: PlayerService,
|
||||
private trackService: TrackService,
|
||||
private dataService: DataService,
|
||||
private albumService: AlbumService,
|
||||
private artistService: ArtistService,
|
||||
private httpService: HttpWrapperService,
|
||||
private dataService: DataService,
|
||||
private titleService: Title) {
|
||||
// nothing to do...
|
||||
}
|
||||
@ -113,7 +111,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
self.dataTitle = response.name;
|
||||
if (!isNullOrUndefined(response.albumId)) {
|
||||
this.albumService.get(response.albumId)
|
||||
.then((response2: NodeData) => {
|
||||
.then((response2: Album) => {
|
||||
self.dataAlbum = response2.name;
|
||||
self.updateTitle();
|
||||
})
|
||||
@ -121,7 +119,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
}
|
||||
if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) {
|
||||
this.artistService.get(response.artists[0])
|
||||
.then((response2: NodeData) => {
|
||||
.then((response2: Artist) => {
|
||||
self.dataAuthor = response2.name;
|
||||
})
|
||||
.catch(() => { });
|
||||
@ -134,10 +132,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
console.log("Can not retrieve the media ... null or undefined data ID")
|
||||
return;
|
||||
}
|
||||
self.mediaSource = self.httpService.createRESTCall2({
|
||||
api: `data/${self.currentLMedia.dataId}/unknowMediaName.webm`, //${self.generatedName}`,
|
||||
addURLToken: true,
|
||||
}).replace("http://localhost:19080", "https://atria-soft.org");
|
||||
self.mediaSource = self.dataService.getUrl(self.currentLMedia.dataId, "unknownMediaName.webm");
|
||||
}).catch(() => {
|
||||
console.error("error not unmanaged in audio player ... 111");
|
||||
})
|
||||
@ -195,7 +190,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
this.isPlaying = false;
|
||||
}
|
||||
|
||||
convertIndisplayTime(time: number): string {
|
||||
convertInDisplayTime(time: number): string {
|
||||
let temporaryValue = parseInt(`${time}`, 10);
|
||||
let hours = parseInt(`${temporaryValue / 3600}`, 10);
|
||||
temporaryValue = temporaryValue - hours * 3600;
|
||||
@ -222,14 +217,14 @@ export class ElementPlayerAudioComponent implements OnInit {
|
||||
// console.log("time change ");
|
||||
// console.log(" ==> " + this.audioPlayer.currentTime);
|
||||
this.currentTime = this.mediaPlayer.currentTime;
|
||||
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
|
||||
this.currentTimeDisplay = this.convertInDisplayTime(this.currentTime);
|
||||
// console.log(" ==> " + this.currentTimeDisplay);
|
||||
}
|
||||
changeDurationchange(duration: any) {
|
||||
console.log('duration change ');
|
||||
console.log(` ==> ${this.mediaPlayer.duration}`);
|
||||
this.duration = this.mediaPlayer.duration;
|
||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
||||
this.durationDisplay = this.convertInDisplayTime(this.duration);
|
||||
}
|
||||
|
||||
onPlay() {
|
||||
|
@ -3,21 +3,22 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @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 { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-season',
|
||||
templateUrl: './element-season.html',
|
||||
styleUrls: [ './element-season.less' ]
|
||||
styleUrls: ['./element-season.less']
|
||||
})
|
||||
export class ElementSeasonComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
@Input() prefix:String;
|
||||
@Input() element: NodeSmall;
|
||||
@Input() prefix: String;
|
||||
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
||||
@Input() countSubType: String;
|
||||
@Input() countSubType2CallBack: (arg0: number) => Promise<number>;
|
||||
@ -39,7 +40,7 @@ export class ElementSeasonComponent implements OnInit {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.prefix = this.prefixName??"";
|
||||
this.prefix = this.prefixName ?? "";
|
||||
this.count = undefined;
|
||||
this.count2 = undefined;
|
||||
|
||||
@ -50,7 +51,7 @@ export class ElementSeasonComponent implements OnInit {
|
||||
}
|
||||
this.numberAlbum = this.element.name;
|
||||
this.description = this.element.description;
|
||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||
let self = this;
|
||||
if (!isNullOrUndefined(this.countSubTypeCallBack)) {
|
||||
this.countSubTypeCallBack(this.element.id)
|
||||
@ -75,7 +76,7 @@ export class ElementSeasonComponent implements OnInit {
|
||||
this.subValuesCallBack(this.element.id)
|
||||
.then((response: string[]) => {
|
||||
this.subValueData = "";
|
||||
for (let kkk=0; kkk<response.length; kkk++) {
|
||||
for (let kkk = 0; kkk < response.length; kkk++) {
|
||||
if (kkk != 0) {
|
||||
this.subValueData += ", ";
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<div>
|
||||
<div class="count-base">
|
||||
@if(counttrack) {
|
||||
@if(countTrack) {
|
||||
<div class="count">
|
||||
{{counttrack}}
|
||||
{{countTrack}}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
@ -4,28 +4,28 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
import { ArtistService, DataService } from 'app/service';
|
||||
import { DataService, TrackService } from 'app/service';
|
||||
import { NodeSmall } from 'app/back-api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-series',
|
||||
templateUrl: './element-series.html',
|
||||
styleUrls: [ './element-series.less' ]
|
||||
styleUrls: ['./element-series.less']
|
||||
})
|
||||
export class ElementSeriesComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
@Input() element: NodeSmall;
|
||||
|
||||
name:string = 'plouf';
|
||||
description:string = '';
|
||||
counttrack:number = null;
|
||||
name: string = 'plouf';
|
||||
description: string = '';
|
||||
countTrack: number = null;
|
||||
|
||||
covers:string[];
|
||||
covers: string[];
|
||||
|
||||
constructor(
|
||||
private artistService: ArtistService,
|
||||
private trackService: TrackService,
|
||||
private dataService: DataService) {
|
||||
|
||||
}
|
||||
@ -35,16 +35,15 @@ export class ElementSeriesComponent implements OnInit {
|
||||
this.description = undefined;
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
self.name = this.element.name;
|
||||
self.description = this.element.description;
|
||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
this.name = this.element.name;
|
||||
this.description = this.element.description;
|
||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||
|
||||
this.artistService.countTrack(this.element.id)
|
||||
this.trackService.countTracksOfAnArtist(this.element.id)
|
||||
.then((response) => {
|
||||
self.counttrack = response;
|
||||
this.countTrack = response;
|
||||
}).catch((response) => {
|
||||
self.counttrack = 0;
|
||||
this.countTrack = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -3,21 +3,21 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @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 { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-track',
|
||||
templateUrl: './element-track.html',
|
||||
styleUrls: [ './element-track.less' ]
|
||||
styleUrls: ['./element-track.less']
|
||||
})
|
||||
export class ElementTrackComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
@Input() prefix:String;
|
||||
@Input() element: NodeSmall;
|
||||
@Input() prefix: String;
|
||||
|
||||
prefixName: string = "";
|
||||
name: string;
|
||||
@ -31,7 +31,7 @@ export class ElementTrackComponent implements OnInit {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.prefix = this.prefixName??"";
|
||||
this.prefix = this.prefixName ?? "";
|
||||
if (isNullOrUndefined(this.element)) {
|
||||
this.name = undefined;
|
||||
this.covers = undefined;
|
||||
@ -40,7 +40,6 @@ export class ElementTrackComponent implements OnInit {
|
||||
this.name = this.element.name;
|
||||
this.description = this.element.description;
|
||||
this.track = this.element["track"];
|
||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
let self = this;
|
||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<div>
|
||||
@if(counttrack) {
|
||||
@if(countTrack) {
|
||||
<div class="count-base">
|
||||
<span class="count">{{counttrack}}</span>
|
||||
<span class="count">{{countTrack}}</span>
|
||||
</div>
|
||||
}
|
||||
<div class="imgContainer-small">
|
||||
|
@ -4,30 +4,30 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
import { DataService } from 'app/service';
|
||||
import { NodeSmall } from 'app/back-api';
|
||||
|
||||
import { GenderService, DataService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-type',
|
||||
templateUrl: './element-type.html',
|
||||
styleUrls: [ './element-type.less' ]
|
||||
styleUrls: ['./element-type.less']
|
||||
})
|
||||
export class ElementTypeComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
@Input() functionVignette:(number) => Promise<Number>;
|
||||
@Input() element: NodeSmall;
|
||||
@Input() functionVignette: (number) => Promise<Number>;
|
||||
|
||||
public name: string = 'rr';
|
||||
public description: string;
|
||||
|
||||
public counttrack: number;
|
||||
public countTrack: number;
|
||||
|
||||
public covers: string[];
|
||||
|
||||
constructor(
|
||||
private typeService: GenderService,
|
||||
private dataService: DataService) {
|
||||
|
||||
}
|
||||
@ -35,7 +35,7 @@ export class ElementTypeComponent implements OnInit {
|
||||
if (isNullOrUndefined(this.element)) {
|
||||
this.name = 'Not a media';
|
||||
this.description = undefined;
|
||||
this.counttrack = undefined;
|
||||
this.countTrack = undefined;
|
||||
this.covers = undefined;
|
||||
return;
|
||||
}
|
||||
@ -43,14 +43,14 @@ export class ElementTypeComponent implements OnInit {
|
||||
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
||||
self.name = this.element.name;
|
||||
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)) {
|
||||
this.functionVignette(this.element.id)
|
||||
.then((response: number) => {
|
||||
self.counttrack = response;
|
||||
self.countTrack = response;
|
||||
}).catch(() => {
|
||||
self.counttrack = 0;
|
||||
self.countTrack = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,9 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
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 { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-video',
|
||||
@ -19,9 +17,7 @@ import { isNullOrUndefined } from 'common/utils';
|
||||
@Injectable()
|
||||
export class ElementVideoComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element: NodeData;
|
||||
data: Track;
|
||||
|
||||
@Input() element: Track;
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
episodeDisplay: string = '';
|
||||
@ -34,15 +30,8 @@ export class ElementVideoComponent implements OnInit {
|
||||
// nothing to do.
|
||||
}
|
||||
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.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 { Album } from 'app/back-api';
|
||||
|
||||
import { AlbumService, ArianeService, DataService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
import { AlbumService, ArianeService, DataService, TrackService } from 'app/service';
|
||||
|
||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { PopInService } from 'common/service';
|
||||
@ -45,7 +45,7 @@ export class AlbumEditScene implements OnInit {
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteCoverId: string = null;
|
||||
private deleteItemId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
@ -67,6 +67,7 @@ export class AlbumEditScene implements OnInit {
|
||||
|
||||
constructor(
|
||||
private albumService: AlbumService,
|
||||
private trackService: TrackService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService,
|
||||
private dataService: DataService) {
|
||||
@ -77,7 +78,7 @@ export class AlbumEditScene implements OnInit {
|
||||
this.idAlbum = this.arianeService.getAlbumId();
|
||||
let self = this;
|
||||
this.albumService.get(this.idAlbum)
|
||||
.then((response: NodeData) => {
|
||||
.then((response: Album) => {
|
||||
console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
|
||||
self.nameAlbum = response.name;
|
||||
self.description = response.description;
|
||||
@ -91,7 +92,7 @@ export class AlbumEditScene implements OnInit {
|
||||
self.itemIsNotFound = true;
|
||||
self.itemIsLoading = false;
|
||||
});
|
||||
this.albumService.getTrack(this.idAlbum)
|
||||
this.trackService.getTracksWithAlbumId(this.idAlbum)
|
||||
.then((response: any) => {
|
||||
self.trackCount = response.length;
|
||||
}).catch((response: any) => {
|
||||
@ -105,7 +106,7 @@ export class AlbumEditScene implements OnInit {
|
||||
for (let iii = 0; iii < covers.length; iii++) {
|
||||
this.coversDisplay.push({
|
||||
id: covers[iii],
|
||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
||||
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -165,7 +166,7 @@ export class AlbumEditScene implements OnInit {
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
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.mediaSize = total;
|
||||
})
|
||||
@ -179,10 +180,10 @@ export class AlbumEditScene implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
removeCover(id: number) {
|
||||
removeCover(id: string) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
||||
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
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 { arrayUnique } from 'common/utils/arrayTools';
|
||||
@ -26,7 +26,7 @@ export class AlbumScene implements OnInit {
|
||||
public albumCovers: string[] = undefined;
|
||||
|
||||
public tracksIds: number[] = undefined;
|
||||
public tracks: Media[] = undefined;
|
||||
public tracks: Track[] = undefined;
|
||||
|
||||
constructor(
|
||||
private artistService: ArtistService,
|
||||
@ -45,7 +45,7 @@ export class AlbumScene implements OnInit {
|
||||
.then((response) => {
|
||||
self.albumName = response.name;
|
||||
self.albumDescription = response.description;
|
||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
||||
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||
}).catch((response) => {
|
||||
self.albumDescription = undefined;
|
||||
self.albumName = '???';
|
||||
@ -54,8 +54,8 @@ export class AlbumScene implements OnInit {
|
||||
});
|
||||
|
||||
//console.log("all the tracks: " + self.tracksIds);
|
||||
this.trackService.getWithAlbum(self.idAlbum)
|
||||
.then((response2: Media[]) => {
|
||||
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||
.then((response2: Track[]) => {
|
||||
self.tracks = response2;
|
||||
self.artistIds = []
|
||||
self.tracks.forEach(element => {
|
||||
@ -73,8 +73,8 @@ export class AlbumScene implements OnInit {
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.artistCovers = self.dataService.getCoverListUrl(response.covers);
|
||||
}).catch((response) => {
|
||||
self.artistCovers = self.dataService.getListUrl(response.covers);
|
||||
}).catch((error) => {
|
||||
self.description = undefined;
|
||||
self.name = '???';
|
||||
self.artistCovers = undefined;
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Album, Track } from 'app/back-api';
|
||||
|
||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
@ -19,8 +20,8 @@ export class AlbumsScene implements OnInit {
|
||||
public name: string = '';
|
||||
public description: string = undefined;
|
||||
public covers: string[] = undefined;
|
||||
public albums: NodeData[] = undefined;
|
||||
public albumsSave: NodeData[] = undefined;
|
||||
public albums: Album[] = undefined;
|
||||
public albumsSave: Album[] = undefined;
|
||||
public tracks: any[] = undefined;
|
||||
public countSubElement: number = undefined;
|
||||
countTrack: (id: number) => Promise<Number>;
|
||||
@ -37,12 +38,13 @@ export class AlbumsScene implements OnInit {
|
||||
}
|
||||
|
||||
countTrackCallback(albumId: number): Promise<Number> {
|
||||
return this.albumService.countTrack(albumId);
|
||||
return this.trackService.countTracksWithAlbumId(albumId);
|
||||
}
|
||||
|
||||
getArtistsStringCallback(albumId: number): Promise<String[]> {
|
||||
//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() {
|
||||
const self = this;
|
||||
@ -60,7 +62,7 @@ export class AlbumsScene implements OnInit {
|
||||
}).catch((response) => {
|
||||
self.albums = undefined;
|
||||
});
|
||||
// TODO later: get all orfan tracks ...
|
||||
// TODO later: get all orfans tracks ...
|
||||
/*
|
||||
this.artistService.getTrack(this.idArtist)
|
||||
.then((response: NodeData[]) => {
|
||||
@ -97,8 +99,8 @@ export class AlbumsScene implements OnInit {
|
||||
playAll(): void {
|
||||
this.playerService.clear();
|
||||
let self = this;
|
||||
this.trackService.getData()
|
||||
.then((response: NodeData[]) => {
|
||||
this.trackService.gets()
|
||||
.then((response: Track[]) => {
|
||||
let ids = [];
|
||||
response.forEach(element => {
|
||||
ids.push(element.id);
|
||||
@ -112,8 +114,8 @@ export class AlbumsScene implements OnInit {
|
||||
playShuffle(): void {
|
||||
this.playerService.clear();
|
||||
let self = this;
|
||||
this.trackService.getData()
|
||||
.then((response: NodeData[]) => {
|
||||
this.trackService.gets()
|
||||
.then((response: Track[]) => {
|
||||
let ids = [];
|
||||
response.forEach(element => {
|
||||
ids.push(element.id);
|
||||
|
@ -32,19 +32,6 @@
|
||||
}
|
||||
@else {
|
||||
<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="label">
|
||||
Name:
|
||||
|
@ -5,8 +5,9 @@
|
||||
*/
|
||||
|
||||
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 { PopInService } from 'common/service';
|
||||
|
||||
@ -31,7 +32,6 @@ export class ArtistEditScene implements OnInit {
|
||||
|
||||
error: string = '';
|
||||
|
||||
typeId: number = null;
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
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
|
||||
public upload: UploadProgress = new UploadProgress();
|
||||
|
||||
|
||||
listType: ElementList[] = [
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteCoverId: string = null;
|
||||
private deleteItemId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
@ -74,8 +69,9 @@ export class ArtistEditScene implements OnInit {
|
||||
|
||||
|
||||
constructor(private dataService: DataService,
|
||||
private typeService: GenderService,
|
||||
private genderService: GenderService,
|
||||
private artistService: ArtistService,
|
||||
private trackService: TrackService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService) {
|
||||
|
||||
@ -84,22 +80,11 @@ export class ArtistEditScene implements OnInit {
|
||||
ngOnInit() {
|
||||
this.idArtist = this.arianeService.getArtistId();
|
||||
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)
|
||||
.then((response) => {
|
||||
.then((response: Artist) => {
|
||||
// console.log("get response of track : " + JSON.stringify(response, null, 2));
|
||||
self.name = response.name;
|
||||
self.typeId = response.parentId;
|
||||
self.description = response.description;
|
||||
self.updateCoverList(response.covers);
|
||||
// console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
|
||||
@ -113,14 +98,14 @@ export class ArtistEditScene implements OnInit {
|
||||
self.itemIsLoading = false;
|
||||
});
|
||||
console.log(`get parameter id: ${this.idArtist}`);
|
||||
this.artistService.getAlbum(this.idArtist)
|
||||
.then((response) => {
|
||||
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||
.then((response: number[]) => {
|
||||
self.albumsCount = "" + response.length;
|
||||
}).catch((response) => {
|
||||
self.albumsCount = '---';
|
||||
});
|
||||
this.artistService.getAllTracks(this.idArtist)
|
||||
.then((response) => {
|
||||
this.trackService.getTracksOfAnArtist(this.idArtist)
|
||||
.then((response: Track[]) => {
|
||||
self.trackCount = "" + response.length;
|
||||
}).catch((response) => {
|
||||
self.trackCount = '---';
|
||||
@ -133,7 +118,7 @@ export class ArtistEditScene implements OnInit {
|
||||
for (let iii = 0; iii < covers.length; iii++) {
|
||||
this.coversDisplay.push({
|
||||
id: covers[iii],
|
||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
||||
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -149,18 +134,9 @@ export class ArtistEditScene implements OnInit {
|
||||
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 {
|
||||
console.log('send new values....');
|
||||
let data = {
|
||||
parentId: this.typeId,
|
||||
name: this.name,
|
||||
description: this.description
|
||||
};
|
||||
@ -203,7 +179,7 @@ export class ArtistEditScene implements OnInit {
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
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.mediaSize = total;
|
||||
})
|
||||
@ -216,14 +192,14 @@ export class ArtistEditScene implements OnInit {
|
||||
console.log('Can not add the cover in the track...');
|
||||
});
|
||||
}
|
||||
removeCover(id: number) {
|
||||
removeCover(id: string) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
||||
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(id: number) {
|
||||
removeCoverAfterConfirm(id: string) {
|
||||
console.log(`Request remove cover: ${id}`);
|
||||
let self = this;
|
||||
this.artistService.deleteCover(this.idArtist, id)
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
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';
|
||||
|
||||
@ -25,7 +25,7 @@ export class ArtistAlbumScene implements OnInit {
|
||||
public albumCovers: string[] = undefined;
|
||||
|
||||
public tracksIds: number[] = undefined;
|
||||
public tracks: Media[] = undefined;
|
||||
public tracks: Track[] = undefined;
|
||||
|
||||
constructor(
|
||||
private artistService: ArtistService,
|
||||
@ -38,8 +38,6 @@ export class ArtistAlbumScene implements OnInit {
|
||||
}
|
||||
|
||||
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.idAlbum = this.arianeService.getAlbumId();
|
||||
let self = this;
|
||||
@ -47,7 +45,7 @@ export class ArtistAlbumScene implements OnInit {
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.artistCovers = this.dataService.getCoverListUrl(response.covers);
|
||||
self.artistCovers = this.dataService.getListUrl(response.covers);
|
||||
}).catch((response) => {
|
||||
self.description = undefined;
|
||||
self.name = '???';
|
||||
@ -58,7 +56,7 @@ export class ArtistAlbumScene implements OnInit {
|
||||
.then((response) => {
|
||||
self.albumName = response.name;
|
||||
self.albumDescription = response.description;
|
||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
||||
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||
}).catch((response) => {
|
||||
self.albumDescription = undefined;
|
||||
self.albumName = '???';
|
||||
@ -67,8 +65,8 @@ export class ArtistAlbumScene implements OnInit {
|
||||
});
|
||||
|
||||
//console.log("all the tracks: " + self.tracksIds);
|
||||
this.trackService.getWithAlbum(self.idAlbum)
|
||||
.then((response2: Media[]) => {
|
||||
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||
.then((response2: Track[]) => {
|
||||
self.tracks = response2;
|
||||
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||
}).catch((response) => {
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Album, Track } from 'app/back-api';
|
||||
|
||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-artist',
|
||||
@ -19,8 +19,8 @@ export class ArtistScene implements OnInit {
|
||||
public name: string = '';
|
||||
public description: string = undefined;
|
||||
public covers: string[] = undefined;
|
||||
public albums: NodeData[] = undefined;
|
||||
public tracks: any[] = undefined;
|
||||
public albums: Album[] = undefined;
|
||||
public tracks: Track[] = undefined;
|
||||
public countSubElement: number = undefined;
|
||||
countTrack: (id: number) => Promise<Number>;
|
||||
|
||||
@ -28,13 +28,14 @@ export class ArtistScene implements OnInit {
|
||||
private albumService: AlbumService,
|
||||
private artistService: ArtistService,
|
||||
private playerService: PlayerService,
|
||||
private trackService: TrackService,
|
||||
private arianeService: ArianeService,
|
||||
private dataService: DataService) {
|
||||
|
||||
}
|
||||
|
||||
countTrackCallback(albumId: number): Promise<Number> {
|
||||
return this.albumService.countTrack(albumId);
|
||||
return this.trackService.countTracksWithAlbumId(albumId);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -48,20 +49,25 @@ export class ArtistScene implements OnInit {
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.covers = this.dataService.getCoverListUrl(response.covers);
|
||||
self.covers = this.dataService.getListUrl(response.covers);
|
||||
}).catch((response) => {
|
||||
self.name = '???';
|
||||
self.description = undefined;
|
||||
self.covers = undefined;
|
||||
});
|
||||
//console.log(`get parameter id: ${ this.idArtist}`);
|
||||
this.artistService.getAlbum(this.idArtist)
|
||||
.then((response: NodeData[]) => {
|
||||
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||
.then((albumIds: number[]) => {
|
||||
this.albumService.getAll(albumIds)
|
||||
.then((response: Album[]) => {
|
||||
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
||||
self.albums = response;
|
||||
}).catch((response) => {
|
||||
self.albums = undefined;
|
||||
});
|
||||
}).catch((response) => {
|
||||
self.albums = undefined;
|
||||
});
|
||||
// TODO later: get all orfan tracks ...
|
||||
/*
|
||||
this.artistService.getTrack(this.idArtist)
|
||||
@ -97,7 +103,7 @@ export class ArtistScene implements OnInit {
|
||||
for (let iii = 0; iii < this.albums.length; iii++) {
|
||||
elements.push(this.albums[iii].id);
|
||||
}
|
||||
return this.albumService.getAllTracksForAlbums(elements);
|
||||
return this.trackService.getTracksIdsForAlbums(elements);
|
||||
}
|
||||
|
||||
playAll(): void {
|
||||
|
@ -5,10 +5,9 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Artist, Track } from 'app/back-api';
|
||||
|
||||
import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-artists',
|
||||
@ -20,14 +19,13 @@ export class ArtistsScene implements OnInit {
|
||||
covers: Array<string> = [];
|
||||
name: string = "Artists";
|
||||
description: string = "All available artists";
|
||||
artists: NodeData[];
|
||||
artistsSave: NodeData[];
|
||||
artists: Artist[];
|
||||
artistsSave: Artist[];
|
||||
countTrack: (id: number) => Promise<Number>;
|
||||
countAlbum: (id: number) => Promise<Number>;
|
||||
|
||||
constructor(
|
||||
private artistService: ArtistService,
|
||||
private albumService: AlbumService,
|
||||
private trackService: TrackService,
|
||||
private playerService: PlayerService,
|
||||
private arianeService: ArianeService) {
|
||||
@ -41,7 +39,7 @@ export class ArtistsScene implements OnInit {
|
||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||
this.artistService.getOrder()
|
||||
.then((response: NodeData[]) => {
|
||||
.then((response: Artist[]) => {
|
||||
self.artists = response;
|
||||
self.artistsSave = [...response];
|
||||
//console.log("get artists: " + JSON.stringify(self.artists));
|
||||
@ -66,16 +64,16 @@ export class ArtistsScene implements OnInit {
|
||||
}
|
||||
|
||||
countTrackCallback(artistId: number): Promise<Number> {
|
||||
return this.artistService.countTrack(artistId);
|
||||
return this.trackService.countTracksOfAnArtist(artistId);
|
||||
}
|
||||
countAlbumCallback(artistId: number): Promise<Number> {
|
||||
return this.artistService.countAlbum(artistId);
|
||||
return this.trackService.countAlbumOfAnArtist(artistId);
|
||||
}
|
||||
playAll(): void {
|
||||
this.playerService.clear();
|
||||
let self = this;
|
||||
this.trackService.getData()
|
||||
.then((response: NodeData[]) => {
|
||||
this.trackService.gets()
|
||||
.then((response: Track[]) => {
|
||||
let ids = [];
|
||||
response.forEach(element => {
|
||||
ids.push(element.id);
|
||||
@ -89,8 +87,8 @@ export class ArtistsScene implements OnInit {
|
||||
playShuffle(): void {
|
||||
this.playerService.clear();
|
||||
let self = this;
|
||||
this.trackService.getData()
|
||||
.then((response: NodeData[]) => {
|
||||
this.trackService.gets()
|
||||
.then((response: Track[]) => {
|
||||
let ids = [];
|
||||
response.forEach(element => {
|
||||
ids.push(element.id);
|
||||
@ -98,7 +96,7 @@ export class ArtistsScene implements OnInit {
|
||||
self.playerService.setNewPlaylistShuffle(ids);
|
||||
})
|
||||
.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 { GenderService, DataService, ArianeService } from 'app/service';
|
||||
import { GenderService, DataService, ArianeService, TrackService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-gender',
|
||||
templateUrl: './gender.html',
|
||||
styleUrls: [ './gender.less' ]
|
||||
styleUrls: ['./gender.less']
|
||||
})
|
||||
|
||||
export class GenderScene implements OnInit {
|
||||
genderId = -1;
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
cover:string = null;
|
||||
covers:string[] = [];
|
||||
cover: string = null;
|
||||
covers: string[] = [];
|
||||
artistsError = '';
|
||||
artists = [];
|
||||
tracksError = '';
|
||||
tracks = [];
|
||||
constructor(
|
||||
private genderService: GenderService,
|
||||
private trackService: TrackService,
|
||||
private arianeService: ArianeService,
|
||||
private dataService: DataService) {
|
||||
//NOTHING TO DO ...
|
||||
@ -34,19 +35,19 @@ export class GenderScene implements OnInit {
|
||||
ngOnInit() {
|
||||
this.genderId = this.arianeService.getTypeId();
|
||||
let self = this;
|
||||
console.log(`get gender global id: ${ this.genderId}`);
|
||||
console.log(`get gender global id: ${this.genderId}`);
|
||||
this.genderService.get(this.genderId)
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
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.covers = [];
|
||||
} else {
|
||||
self.cover = self.dataService.getCoverUrl(response.covers[0]);
|
||||
for(let iii = 0; iii < response.covers.length; iii++) {
|
||||
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
|
||||
self.cover = self.dataService.getUrl(response.covers[0]);
|
||||
for (let iii = 0; iii < response.covers.length; iii++) {
|
||||
self.covers.push(self.dataService.getUrl(response.covers[iii]));
|
||||
}
|
||||
}
|
||||
}).catch((response) => {
|
||||
@ -55,7 +56,9 @@ export class GenderScene implements OnInit {
|
||||
self.covers = [];
|
||||
self.cover = null;
|
||||
});
|
||||
this.genderService.getSubArtist(this.genderId)
|
||||
/*
|
||||
TODO ???
|
||||
this.trackService.getSubArtist(this.genderId)
|
||||
.then((response) => {
|
||||
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
|
||||
self.artistsError = '';
|
||||
@ -65,7 +68,8 @@ export class GenderScene implements OnInit {
|
||||
self.artistsError = 'Wrong e-mail/login or password';
|
||||
self.artists = [];
|
||||
});
|
||||
this.genderService.getSubTrack(this.genderId)
|
||||
*/
|
||||
this.trackService.getTracksForGender(this.genderId)
|
||||
.then((response) => {
|
||||
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
|
||||
self.tracksError = '';
|
||||
@ -76,19 +80,19 @@ export class GenderScene implements OnInit {
|
||||
self.tracks = [];
|
||||
});
|
||||
}
|
||||
onSelectArtist(event: any, idSelected: number):void {
|
||||
onSelectArtist(event: any, idSelected: number): void {
|
||||
if (event.ctrlKey === false) {
|
||||
this.arianeService.navigateArtist({ artistId: idSelected, newWindows:event.which === 2} );
|
||||
this.arianeService.navigateArtist({ artistId: idSelected, newWindows: event.which === 2 });
|
||||
} 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) {
|
||||
this.arianeService.navigateTrack({ trackId: idSelected, newWindows:event.which === 2} );
|
||||
this.arianeService.navigateTrack({ trackId: idSelected, newWindows: event.which === 2 });
|
||||
} 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 { Track } from 'app/back-api';
|
||||
|
||||
|
||||
import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { PopInService } from 'common/service';
|
||||
import { Media } from 'app/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
export interface ElementList {
|
||||
@ -25,7 +25,7 @@ class DataToSend {
|
||||
track?: number;
|
||||
artistId: number = null;
|
||||
albumId: number = null;
|
||||
dataId: number = -1;
|
||||
dataId: string = "";
|
||||
genderId: number = null;
|
||||
generatedName: string = '';
|
||||
clone() {
|
||||
@ -164,7 +164,7 @@ export class TrackEditScene implements OnInit {
|
||||
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
||||
});
|
||||
this.trackService.get(this.idTrack)
|
||||
.then((response: Media) => {
|
||||
.then((response: Track) => {
|
||||
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||
self.data.name = response.name;
|
||||
self.data.description = response.description;
|
||||
|
@ -12,64 +12,64 @@ import { isNullOrUndefined } from 'common/utils';
|
||||
@Component({
|
||||
selector: 'app-track',
|
||||
templateUrl: './track.html',
|
||||
styleUrls: [ './track.less' ]
|
||||
styleUrls: ['./track.less']
|
||||
})
|
||||
|
||||
export class TrackScene implements OnInit {
|
||||
trackGlobal:any;
|
||||
trackGlobal: any;
|
||||
@ViewChild('globalTrackElement')
|
||||
set mainDivEl(el: ElementRef) {
|
||||
if(el !== null && el !== undefined) {
|
||||
if (el !== null && el !== undefined) {
|
||||
this.trackGlobal = el.nativeElement;
|
||||
}
|
||||
}
|
||||
trackPlayer: HTMLVideoElement;
|
||||
@ViewChild('videoPlayer')
|
||||
set mainTrackEl(el: ElementRef) {
|
||||
if(el !== null && el !== undefined) {
|
||||
if (el !== null && el !== undefined) {
|
||||
this.trackPlayer = el.nativeElement;
|
||||
}
|
||||
}
|
||||
videoCanva: any;
|
||||
@ViewChild('canvascreenshoot')
|
||||
set mainCanvaEl(el: ElementRef) {
|
||||
if(el !== null && el !== undefined) {
|
||||
if (el !== null && el !== undefined) {
|
||||
this.videoCanva = el.nativeElement;
|
||||
}
|
||||
}
|
||||
haveNext = null;
|
||||
havePrevious = null;
|
||||
idTrack:number = -1;
|
||||
idTrack: number = -1;
|
||||
|
||||
mediaIsNotFound:boolean = false;
|
||||
mediaIsLoading:boolean = true;
|
||||
error:string = '';
|
||||
mediaIsNotFound: boolean = false;
|
||||
mediaIsLoading: boolean = true;
|
||||
error: string = '';
|
||||
|
||||
name:string = '';
|
||||
description:string = '';
|
||||
episode:number = undefined;
|
||||
artists:number[] = undefined;
|
||||
artistName:string = undefined;
|
||||
albumId:number = undefined;
|
||||
albumName:string = undefined;
|
||||
dataId:number = -1;
|
||||
time:number = undefined;
|
||||
typeId:number = undefined;
|
||||
generatedName:string = '';
|
||||
trackSource:string = '';
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
episode: number = undefined;
|
||||
artists: number[] = undefined;
|
||||
artistName: string = undefined;
|
||||
albumId: number = undefined;
|
||||
albumName: string = undefined;
|
||||
dataId: string = "";
|
||||
time: number = undefined;
|
||||
typeId: number = undefined;
|
||||
generatedName: string = '';
|
||||
trackSource: string = '';
|
||||
covers: string[];
|
||||
|
||||
playTrack:boolean = false;
|
||||
displayVolumeMenu:boolean = false;
|
||||
isPlaying:boolean = false;
|
||||
isFullScreen:boolean = false;
|
||||
currentTime:number = 0;
|
||||
currentTimeDisplay:string = '00';
|
||||
duration:number = 0;
|
||||
durationDisplay:string = '00';
|
||||
volumeValue:number = 100;
|
||||
playTrack: boolean = false;
|
||||
displayVolumeMenu: boolean = false;
|
||||
isPlaying: boolean = false;
|
||||
isFullScreen: boolean = false;
|
||||
currentTime: number = 0;
|
||||
currentTimeDisplay: string = '00';
|
||||
duration: number = 0;
|
||||
durationDisplay: string = '00';
|
||||
volumeValue: number = 100;
|
||||
|
||||
displayNeedHide:boolean = false;
|
||||
displayNeedHide: boolean = false;
|
||||
timeLeft: number = 10;
|
||||
interval = null;
|
||||
constructor(private trackService: TrackService,
|
||||
@ -84,13 +84,13 @@ export class TrackScene implements OnInit {
|
||||
startHideTimer() {
|
||||
this.displayNeedHide = false;
|
||||
this.timeLeft = 5;
|
||||
if(this.interval !== null) {
|
||||
if (this.interval !== null) {
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.interval = setInterval(() => {
|
||||
console.log(`periodic event: ${ self.timeLeft}`);
|
||||
if(self.timeLeft > 0) {
|
||||
console.log(`periodic event: ${self.timeLeft}`);
|
||||
if (self.timeLeft > 0) {
|
||||
self.timeLeft--;
|
||||
} else {
|
||||
clearInterval(self.interval);
|
||||
@ -105,40 +105,40 @@ export class TrackScene implements OnInit {
|
||||
this.interval = null;
|
||||
}
|
||||
onRequireNext(event: any) {
|
||||
console.log(`generate next : ${ this.haveNext.id}`);
|
||||
console.log(`generate next : ${this.haveNext.id}`);
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
onRequirePrevious(event: any) {
|
||||
console.log(`generate previous : ${ this.havePrevious.id}`);
|
||||
console.log(`generate previous : ${this.havePrevious.id}`);
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
generateName() {
|
||||
this.generatedName = '';
|
||||
if(this.artistName !== undefined) {
|
||||
this.generatedName = `${this.generatedName }${this.artistName }-`;
|
||||
if (this.artistName !== undefined) {
|
||||
this.generatedName = `${this.generatedName}${this.artistName}-`;
|
||||
}
|
||||
if(this.albumName !== undefined) {
|
||||
if(this.albumName.length < 2) {
|
||||
this.generatedName = `${this.generatedName }s0${ this.albumName }-`;
|
||||
if (this.albumName !== undefined) {
|
||||
if (this.albumName.length < 2) {
|
||||
this.generatedName = `${this.generatedName}s0${this.albumName}-`;
|
||||
} else {
|
||||
this.generatedName = `${this.generatedName }s${ this.albumName }-`;
|
||||
this.generatedName = `${this.generatedName}s${this.albumName}-`;
|
||||
}
|
||||
}
|
||||
if(this.episode !== undefined) {
|
||||
if(this.episode < 10) {
|
||||
this.generatedName = `${this.generatedName }e0${ this.episode }-`;
|
||||
if (this.episode !== undefined) {
|
||||
if (this.episode < 10) {
|
||||
this.generatedName = `${this.generatedName}e0${this.episode}-`;
|
||||
} else {
|
||||
this.generatedName = `${this.generatedName }e${ this.episode }-`;
|
||||
this.generatedName = `${this.generatedName}e${this.episode}-`;
|
||||
}
|
||||
}
|
||||
this.generatedName = this.generatedName + this.name;
|
||||
@ -146,7 +146,7 @@ export class TrackScene implements OnInit {
|
||||
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
||||
// update the path of the uri request
|
||||
this.trackSource = this.httpService.createRESTCall2({
|
||||
api: `data/${ this.dataId}/${this.generatedName}`,
|
||||
api: `data/${this.dataId}/${this.generatedName}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
}
|
||||
@ -170,7 +170,7 @@ export class TrackScene implements OnInit {
|
||||
*/
|
||||
}
|
||||
audioTracks(event) {
|
||||
console.log(`list of the stream:${ event}`);
|
||||
console.log(`list of the stream:${event}`);
|
||||
|
||||
/*
|
||||
let captureStream = this.trackPlayer.audioTracks;
|
||||
@ -190,40 +190,40 @@ export class TrackScene implements OnInit {
|
||||
this.startHideTimer();
|
||||
this.idTrack = this.arianeService.getTrackId();
|
||||
this.arianeService.trackChange.subscribe((trackId) => {
|
||||
console.log(`Detect trackId change...${ trackId}`);
|
||||
console.log(`Detect trackId change...${trackId}`);
|
||||
self.idTrack = trackId;
|
||||
self.updateDisplay();
|
||||
});
|
||||
self.updateDisplay();
|
||||
}
|
||||
updateDisplay():void {
|
||||
updateDisplay(): void {
|
||||
let self = this;
|
||||
self.haveNext = null;
|
||||
self.havePrevious = null;
|
||||
this.trackService.get(this.idTrack)
|
||||
.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.name = response.name;
|
||||
self.description = response.description;
|
||||
self.episode = response.episode;
|
||||
//self.episode = response.episode;
|
||||
self.artists = response.artists;
|
||||
self.albumId = response.albumId;
|
||||
self.dataId = response.dataId;
|
||||
self.time = response.time;
|
||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
||||
if(self.dataId !== -1) {
|
||||
if (self.dataId !== -1) {
|
||||
self.trackSource = self.httpService.createRESTCall2({
|
||||
api: `data/${ self.dataId}/${self.generatedName}`,
|
||||
api: `data/${self.dataId}/${self.generatedName}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
} else {
|
||||
self.trackSource = '';
|
||||
}
|
||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
||||
self.covers = self.dataService.(response.covers);
|
||||
|
||||
self.generateName();
|
||||
if(!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
||||
if (!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
||||
self.artistService.get(self.artists[0])
|
||||
.then((response2) => {
|
||||
self.artistName = response2.name;
|
||||
@ -232,7 +232,7 @@ export class TrackScene implements OnInit {
|
||||
// nothing to do ...
|
||||
});
|
||||
}
|
||||
if(!isNullOrUndefined(self.albumId)) {
|
||||
if (!isNullOrUndefined(self.albumId)) {
|
||||
self.albumService.get(self.albumId)
|
||||
.then((response4) => {
|
||||
self.albumName = response4.name;
|
||||
@ -241,30 +241,30 @@ export class TrackScene implements OnInit {
|
||||
// nothing to do ...
|
||||
});
|
||||
self.albumService.getTrack(self.albumId)
|
||||
.then((response6:any) => {
|
||||
.then((response6: any) => {
|
||||
// console.log("saison property: " + JSON.stringify(response, null, 2));
|
||||
self.haveNext = null;
|
||||
self.havePrevious = null;
|
||||
for(let iii = 0; iii < response6.length; iii++) {
|
||||
if(isNullOrUndefined(response6[iii].episode)) {
|
||||
for (let iii = 0; iii < response6.length; iii++) {
|
||||
if (isNullOrUndefined(response6[iii].episode)) {
|
||||
continue;
|
||||
}
|
||||
if(response6[iii].episode < self.episode) {
|
||||
if(self.havePrevious === null) {
|
||||
if (response6[iii].episode < self.episode) {
|
||||
if (self.havePrevious === null) {
|
||||
self.havePrevious = response6[iii];
|
||||
} else if(self.havePrevious.episode < response6[iii].episode) {
|
||||
} else if (self.havePrevious.episode < response6[iii].episode) {
|
||||
self.havePrevious = response6[iii];
|
||||
}
|
||||
} else if(response6[iii].episode > self.episode) {
|
||||
if(self.haveNext === null) {
|
||||
} else if (response6[iii].episode > self.episode) {
|
||||
if (self.haveNext === null) {
|
||||
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.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
||||
}
|
||||
}).catch((response7:any) => {
|
||||
}).catch((response7: any) => {
|
||||
|
||||
});
|
||||
}
|
||||
@ -313,7 +313,7 @@ export class TrackScene implements OnInit {
|
||||
|
||||
changeStateToPlay() {
|
||||
this.isPlaying = true;
|
||||
if(this.isFullScreen === true) {
|
||||
if (this.isFullScreen === true) {
|
||||
this.onFullscreen();
|
||||
}
|
||||
}
|
||||
@ -321,25 +321,25 @@ export class TrackScene implements OnInit {
|
||||
this.isPlaying = false;
|
||||
}
|
||||
|
||||
convertIndisplayTime(time:number) : string {
|
||||
let tmpp = parseInt(`${ time}`, 10);
|
||||
let heures = parseInt(`${ tmpp / 3600}`, 10);
|
||||
convertIndisplayTime(time: number): string {
|
||||
let tmpp = parseInt(`${time}`, 10);
|
||||
let heures = parseInt(`${tmpp / 3600}`, 10);
|
||||
tmpp = tmpp - heures * 3600;
|
||||
let minutes = parseInt(`${ tmpp / 60}`, 10);
|
||||
let minutes = parseInt(`${tmpp / 60}`, 10);
|
||||
let seconds = tmpp - minutes * 60;
|
||||
let out = '';
|
||||
if(heures !== 0) {
|
||||
out = `${out }${heures }:`;
|
||||
if (heures !== 0) {
|
||||
out = `${out}${heures}:`;
|
||||
}
|
||||
if(minutes >= 10) {
|
||||
out = `${out }${minutes }:`;
|
||||
if (minutes >= 10) {
|
||||
out = `${out}${minutes}:`;
|
||||
} else {
|
||||
out = `${out }0${ minutes }:`;
|
||||
out = `${out}0${minutes}:`;
|
||||
}
|
||||
if(seconds >= 10) {
|
||||
if (seconds >= 10) {
|
||||
out = out + seconds;
|
||||
} else {
|
||||
out = `${out }0${ seconds}`;
|
||||
out = `${out}0${seconds}`;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -353,7 +353,7 @@ export class TrackScene implements OnInit {
|
||||
}
|
||||
changeDurationchange(duration: any) {
|
||||
console.log('duration change ');
|
||||
console.log(` ==> ${ this.trackPlayer.duration}`);
|
||||
console.log(` ==> ${this.trackPlayer.duration}`);
|
||||
this.duration = this.trackPlayer.duration;
|
||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
||||
}
|
||||
@ -361,9 +361,9 @@ export class TrackScene implements OnInit {
|
||||
onPlay() {
|
||||
console.log('play');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.volume = this.volumeValue / 100;
|
||||
@ -373,9 +373,9 @@ export class TrackScene implements OnInit {
|
||||
onPause() {
|
||||
console.log('pause');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.pause();
|
||||
@ -383,7 +383,7 @@ export class TrackScene implements OnInit {
|
||||
|
||||
onPauseToggle() {
|
||||
console.log('pause toggle ...');
|
||||
if(this.isPlaying === true) {
|
||||
if (this.isPlaying === true) {
|
||||
this.onPause();
|
||||
} else {
|
||||
this.onPlay();
|
||||
@ -393,9 +393,9 @@ export class TrackScene implements OnInit {
|
||||
onStop() {
|
||||
console.log('stop');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.pause();
|
||||
@ -412,12 +412,12 @@ export class TrackScene implements OnInit {
|
||||
this.startHideTimer();
|
||||
}
|
||||
|
||||
seek(newValue:any) {
|
||||
console.log(`seek ${ newValue.value}`);
|
||||
seek(newValue: any) {
|
||||
console.log(`seek ${newValue.value}`);
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.currentTime = newValue.value;
|
||||
@ -426,9 +426,9 @@ export class TrackScene implements OnInit {
|
||||
onRewind() {
|
||||
console.log('rewind');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.currentTime = this.currentTime - 10;
|
||||
@ -437,9 +437,9 @@ export class TrackScene implements OnInit {
|
||||
onForward() {
|
||||
console.log('forward');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.currentTime = this.currentTime + 10;
|
||||
@ -448,27 +448,27 @@ export class TrackScene implements OnInit {
|
||||
onMore() {
|
||||
console.log('more');
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
onFullscreen() {
|
||||
console.log('fullscreen');
|
||||
this.startHideTimer();
|
||||
if(this.trackGlobal === null ||
|
||||
if (this.trackGlobal === null ||
|
||||
this.trackGlobal === undefined) {
|
||||
console.log(`error element: ${ this.trackGlobal}`);
|
||||
console.log(`error element: ${this.trackGlobal}`);
|
||||
return;
|
||||
}
|
||||
if(this.trackGlobal.requestFullscreen) {
|
||||
if (this.trackGlobal.requestFullscreen) {
|
||||
this.trackGlobal.requestFullscreen();
|
||||
} else if(this.trackGlobal.mozRequestFullScreen) {
|
||||
} else if (this.trackGlobal.mozRequestFullScreen) {
|
||||
this.trackGlobal.mozRequestFullScreen();
|
||||
} else if(this.trackGlobal.webkitRequestFullscreen) {
|
||||
} else if (this.trackGlobal.webkitRequestFullscreen) {
|
||||
this.trackGlobal.webkitRequestFullscreen();
|
||||
} else if(this.trackGlobal.msRequestFullscreen) {
|
||||
} else if (this.trackGlobal.msRequestFullscreen) {
|
||||
this.trackGlobal.msRequestFullscreen();
|
||||
}
|
||||
}
|
||||
@ -476,21 +476,21 @@ export class TrackScene implements OnInit {
|
||||
onFullscreenExit() {
|
||||
this.onFullscreenExit22(document);
|
||||
}
|
||||
onFullscreenExit22(docc:any) {
|
||||
onFullscreenExit22(docc: any) {
|
||||
console.log('fullscreen EXIT');
|
||||
this.startHideTimer();
|
||||
if(this.trackGlobal === null ||
|
||||
if (this.trackGlobal === null ||
|
||||
this.trackGlobal === undefined) {
|
||||
console.log(`error element: ${ this.trackGlobal}`);
|
||||
console.log(`error element: ${this.trackGlobal}`);
|
||||
return;
|
||||
}
|
||||
if(docc.exitFullscreen) {
|
||||
if (docc.exitFullscreen) {
|
||||
docc.exitFullscreen();
|
||||
} else if(docc.mozCancelFullScreen) {
|
||||
} else if (docc.mozCancelFullScreen) {
|
||||
docc.mozCancelFullScreen();
|
||||
} else if(docc.webkitExitFullscreen) {
|
||||
} else if (docc.webkitExitFullscreen) {
|
||||
docc.webkitExitFullscreen();
|
||||
} else if(docc.msExitFullscreen) {
|
||||
} else if (docc.msExitFullscreen) {
|
||||
docc.msExitFullscreen();
|
||||
}
|
||||
}
|
||||
@ -498,12 +498,12 @@ export class TrackScene implements OnInit {
|
||||
onFullscreenChange() {
|
||||
this.onFullscreenChange22(document);
|
||||
}
|
||||
onFullscreenChange22(element:any) {
|
||||
onFullscreenChange22(element: any) {
|
||||
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
||||
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
||||
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
||||
element.msFullscreenElement && element.msFullscreenElement !== null;
|
||||
console.log(`onFullscreenChange(${ isInFullScreen })`);
|
||||
console.log(`onFullscreenChange(${isInFullScreen})`);
|
||||
this.isFullScreen = isInFullScreen;
|
||||
}
|
||||
|
||||
@ -512,12 +512,12 @@ export class TrackScene implements OnInit {
|
||||
this.startHideTimer();
|
||||
}
|
||||
|
||||
onVolume(newValue:any) {
|
||||
console.log(`onVolume ${ newValue.value}`);
|
||||
onVolume(newValue: any) {
|
||||
console.log(`onVolume ${newValue.value}`);
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.volumeValue = newValue.value;
|
||||
@ -527,9 +527,9 @@ export class TrackScene implements OnInit {
|
||||
|
||||
onVolumeMute() {
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.muted = true;
|
||||
@ -537,9 +537,9 @@ export class TrackScene implements OnInit {
|
||||
|
||||
onVolumeUnMute() {
|
||||
this.startHideTimer();
|
||||
if(this.trackPlayer === null ||
|
||||
if (this.trackPlayer === null ||
|
||||
this.trackPlayer === undefined) {
|
||||
console.log(`error element: ${ this.trackPlayer}`);
|
||||
console.log(`error element: ${this.trackPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.trackPlayer.muted = false;
|
||||
|
@ -14,7 +14,7 @@ import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
export class ElementList {
|
||||
constructor(
|
||||
public value: bigint,
|
||||
public value: number,
|
||||
public label: string) {
|
||||
// nothing to do.
|
||||
}
|
||||
@ -27,14 +27,14 @@ export class FileParsedElement {
|
||||
public file: File,
|
||||
public artist: string,
|
||||
public album: string,
|
||||
public trackId: bigint,
|
||||
public trackId: number,
|
||||
public title: string) {
|
||||
// nothing to do.
|
||||
}
|
||||
}
|
||||
export class FileFailParsedElement {
|
||||
constructor(
|
||||
public id: bigint,
|
||||
public id: number,
|
||||
public file: File,
|
||||
public reason: string) {
|
||||
// nothing to do.
|
||||
@ -52,9 +52,9 @@ export class UploadScene implements OnInit {
|
||||
parsedFailedElement: FileFailParsedElement[] = [];
|
||||
uploadFileValue: string = '';
|
||||
selectedFiles: FileList;
|
||||
genderId: bigint = null;
|
||||
artistId: bigint = null;
|
||||
albumId: bigint = null;
|
||||
genderId: number = null;
|
||||
artistId: number = null;
|
||||
albumId: number = null;
|
||||
needSend: boolean = false;
|
||||
|
||||
// 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
|
||||
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,
|
||||
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
|
||||
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
|
||||
searchPlaceholder: 'Search', // label thats displayed in search input,
|
||||
@ -284,7 +284,7 @@ export class UploadScene implements OnInit {
|
||||
// parsedElement: FileParsedElement[] = [];
|
||||
let artist: string = undefined;
|
||||
let album: string | null = undefined;
|
||||
let trackIdbigint: bigint | null = undefined;
|
||||
let trackIdnumber: number | null = undefined;
|
||||
let title: string = '';
|
||||
|
||||
console.log(`select file ${file.name}`);
|
||||
@ -305,19 +305,19 @@ export class UploadScene implements OnInit {
|
||||
//console.log("ploppppp " + tmpName);
|
||||
const splitElement3 = tmpName.split('-');
|
||||
if (splitElement3.length > 1) {
|
||||
trackIdbigint = parseInt(splitElement3[0], 10);
|
||||
trackIdnumber = parseInt(splitElement3[0], 10);
|
||||
tmpName = tmpName.substring(splitElement3[0].length + 1);
|
||||
}
|
||||
//console.log("KKKppppp " + tmpName);
|
||||
//console.log(" ===> " + splitElement3[0]);
|
||||
title = tmpName;
|
||||
|
||||
if (isNaN(trackIdbigint)) {
|
||||
trackIdbigint = undefined;
|
||||
if (isNaN(trackIdnumber)) {
|
||||
trackIdnumber = undefined;
|
||||
}
|
||||
// remove extention
|
||||
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)}`);
|
||||
// add it in the list.
|
||||
this.parsedElement.push(tmp);
|
||||
@ -387,10 +387,10 @@ export class UploadScene implements OnInit {
|
||||
this.globalUpLoad(0, this.parsedElement.length);
|
||||
}
|
||||
|
||||
globalUpLoad(id: bigint, total: bigint): void {
|
||||
globalUpLoad(id: number, total: number): void {
|
||||
let self = this;
|
||||
this.uploadFile(this.parsedElement[id], id, total, () => {
|
||||
let id2 = id + BigInt(1);
|
||||
let id2 = id + 1;
|
||||
if (id2 < total) {
|
||||
self.globalUpLoad(id2, total);
|
||||
} else {
|
||||
@ -400,7 +400,7 @@ export class UploadScene implements OnInit {
|
||||
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;
|
||||
|
||||
self.upload.labelMediaTitle = '';
|
||||
@ -515,7 +515,7 @@ export class UploadScene implements OnInit {
|
||||
// no album check only the artist files.
|
||||
if (isNullOrUndefined(this.globalAlbum)) {
|
||||
console.error(`NO ALBUM ==> check artist ID...`);
|
||||
self.artistService.getAllTracks(self.artistId)
|
||||
self.trackService.getTracksOfAnArtist(self.artistId)
|
||||
.then((response: any[]) => {
|
||||
self.listFileInBdd = response;
|
||||
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,74 +7,134 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
import { HttpWrapperService, BddService } from 'common/service';
|
||||
import { DataInterface, TypeCheck } from 'common/utils';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
import { SessionService } from 'common/service';
|
||||
import { DataInterface, TypeCheck, isArrayOf, isNumber } from 'common/utils';
|
||||
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()
|
||||
export class AlbumService extends GenericInterfaceModelDB {
|
||||
export class AlbumService extends GenericDataService<Album> {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('album', http, bdd);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karusic,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
getAllTracksForAlbums(idAlbums: bigint[]): Promise<bigint[]> {
|
||||
}
|
||||
private lambdaGets(): Promise<Album[]> {
|
||||
return AlbumResource.gets({ restConfig: this.getRestConfig() });
|
||||
}
|
||||
|
||||
constructor(private session: SessionService) {
|
||||
super();
|
||||
this.setStore(new DataStore<Album>(this.lambdaGets, "id"));
|
||||
}
|
||||
|
||||
insert(data: Album): Promise<Album> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
AlbumResource.post({
|
||||
restConfig: this.getRestConfig(),
|
||||
data
|
||||
}).then((value: Album) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
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) => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
AlbumResource.removeCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
coverId
|
||||
}
|
||||
/**
|
||||
* Get all the track for a specific album
|
||||
* @param idAlbum - Id of the album.
|
||||
* @returns a promise on the list of track elements
|
||||
*/
|
||||
getTrack(idAlbum: bigint): Promise<NodeData[]> {
|
||||
}).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) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
value: idAlbum,
|
||||
AlbumResource.uploadCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
],
|
||||
['name']); // tODO : set the Id in the track ...
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
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
|
||||
* @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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
self.gets()
|
||||
.then((response: Album[]) => {
|
||||
let data = DataTools.getsWhere(response,
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
@ -84,50 +144,16 @@ export class AlbumService extends GenericInterfaceModelDB {
|
||||
['name']);
|
||||
// filter with artist- ID !!!
|
||||
const listArtistId = DataInterface.extractLimitOneList(data, "artists");
|
||||
//console.log(`${idAlbum} ==> List Of ids: ${JSON.stringify(listArtistId, null, 2)} `);
|
||||
self.bdd.get('artist')
|
||||
.then((response: DataInterface) => {
|
||||
let dataArtist = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'id',
|
||||
value: listArtistId,
|
||||
},
|
||||
], ['name']);
|
||||
const listArtistNames = DataInterface.extractLimitOne(dataArtist, "name");
|
||||
resolve(listArtistNames);
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
if (isArrayOf(listArtistId, isNumber)) {
|
||||
resolve(listArtistId);
|
||||
} else {
|
||||
reject("Fail to get the ids (impossible case)");
|
||||
}
|
||||
}).catch((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';
|
||||
|
||||
export class InputOrders {
|
||||
public genderId: bigint = undefined;
|
||||
public playlistId: bigint = undefined;
|
||||
public artistId: bigint = undefined;
|
||||
public albumId: bigint = undefined;
|
||||
public trackId: bigint = undefined;
|
||||
public genderId: number = undefined;
|
||||
public playlistId: number = undefined;
|
||||
public artistId: number = undefined;
|
||||
public albumId: number = undefined;
|
||||
public trackId: number = undefined;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ArianeService {
|
||||
public genderId: bigint = undefined;
|
||||
public genderId: number = 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;
|
||||
@Output() playlistChange: EventEmitter<bigint> = new EventEmitter();
|
||||
@Output() playlistChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public artistId: bigint = undefined;
|
||||
public artistId: number = 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;
|
||||
@Output() albumChange: EventEmitter<bigint> = new EventEmitter();
|
||||
@Output() albumChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public trackId: bigint = undefined;
|
||||
public trackId: number = undefined;
|
||||
public trackName: string = undefined;
|
||||
@Output() trackChange: EventEmitter<bigint> = new EventEmitter();
|
||||
@Output() trackChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
@Output() update: EventEmitter<InputOrders> = new EventEmitter();
|
||||
|
||||
@ -89,12 +89,12 @@ export class ArianeService {
|
||||
return this.segment;
|
||||
}
|
||||
|
||||
getIsParam(params: any, name: string): undefined | bigint {
|
||||
getIsParam(params: any, name: string): undefined | number {
|
||||
let valueStr = params.get(name);
|
||||
if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
||||
return undefined;
|
||||
}
|
||||
return BigInt(valueStr);
|
||||
return valueStr;
|
||||
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ export class ArianeService {
|
||||
this.trackChange.emit(this.trackId);
|
||||
}
|
||||
|
||||
setType(id: bigint): void {
|
||||
setType(id: number): void {
|
||||
if (this.genderId === id) {
|
||||
return;
|
||||
}
|
||||
@ -178,14 +178,14 @@ export class ArianeService {
|
||||
self.typeChange.emit(self.genderId);
|
||||
});
|
||||
}
|
||||
getTypeId(): bigint | undefined {
|
||||
getTypeId(): number | undefined {
|
||||
return this.genderId;
|
||||
}
|
||||
getTypeName(): string | undefined {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
setPlaylist(id: bigint | undefined) {
|
||||
setPlaylist(id: number | undefined) {
|
||||
if (this.playlistId === id) {
|
||||
return;
|
||||
}
|
||||
@ -204,14 +204,14 @@ export class ArianeService {
|
||||
self.playlistChange.emit(self.playlistId);
|
||||
});
|
||||
}
|
||||
getPlaylistId(): bigint | undefined {
|
||||
getPlaylistId(): number | undefined {
|
||||
return this.playlistId;
|
||||
}
|
||||
getPlaylistName(): string | undefined {
|
||||
return this.playlistName;
|
||||
}
|
||||
|
||||
setArtist(id: bigint | undefined): void {
|
||||
setArtist(id: number | undefined): void {
|
||||
if (this.artistId === id) {
|
||||
return;
|
||||
}
|
||||
@ -230,14 +230,14 @@ export class ArianeService {
|
||||
self.artistChange.emit(self.artistId);
|
||||
});
|
||||
}
|
||||
getArtistId(): bigint | undefined {
|
||||
getArtistId(): number | undefined {
|
||||
return this.artistId;
|
||||
}
|
||||
getArtistName(): string | undefined {
|
||||
return this.artistName;
|
||||
}
|
||||
|
||||
setAlbum(id: bigint | undefined): void {
|
||||
setAlbum(id: number | undefined): void {
|
||||
if (this.albumId === id) {
|
||||
return;
|
||||
}
|
||||
@ -257,14 +257,14 @@ export class ArianeService {
|
||||
self.albumChange.emit(self.albumId);
|
||||
});
|
||||
}
|
||||
getAlbumId(): bigint | undefined {
|
||||
getAlbumId(): number | undefined {
|
||||
return this.albumId;
|
||||
}
|
||||
getAlbumName(): string | undefined {
|
||||
return this.albumName;
|
||||
}
|
||||
|
||||
setTrack(id: bigint | undefined): void {
|
||||
setTrack(id: number | undefined): void {
|
||||
if (this.trackId === id) {
|
||||
return;
|
||||
}
|
||||
@ -285,7 +285,7 @@ export class ArianeService {
|
||||
self.trackChange.emit(self.trackId);
|
||||
});
|
||||
}
|
||||
getTrackId(): bigint | undefined {
|
||||
getTrackId(): number | undefined {
|
||||
return this.trackId;
|
||||
}
|
||||
getTrackName(): string | undefined {
|
||||
@ -301,7 +301,7 @@ export class ArianeService {
|
||||
*/
|
||||
genericNavigate(
|
||||
destination: string,
|
||||
ids: bigint[],
|
||||
ids: number[],
|
||||
newWindows?: boolean,
|
||||
replaceCurrentPage: boolean = false): void {
|
||||
let addressOffset = `${destination}`;
|
||||
@ -318,7 +318,7 @@ export class ArianeService {
|
||||
}
|
||||
genericNavigateEdit(
|
||||
destination: string,
|
||||
id: bigint,
|
||||
id: number,
|
||||
newWindows?: boolean,
|
||||
replaceCurrentPage: boolean = false): void {
|
||||
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);
|
||||
}
|
||||
navigatePlaylistEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
||||
navigatePlaylistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||
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);
|
||||
}
|
||||
navigateGenderEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
||||
navigateGenderEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||
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);
|
||||
}
|
||||
navigateAlbumEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
||||
navigateAlbumEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||
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);
|
||||
}
|
||||
navigateArtistEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
||||
navigateArtistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||
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);
|
||||
}
|
||||
navigateTrackEdit({ id, newWindows }: { id: bigint; newWindows?: boolean; }): void {
|
||||
navigateTrackEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||
this.genericNavigateEdit('track', id, newWindows);
|
||||
}
|
||||
|
||||
|
@ -6,164 +6,122 @@
|
||||
|
||||
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 { isNodeData, NodeData } from 'common/model';
|
||||
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()
|
||||
export class ArtistService extends GenericInterfaceModelDB {
|
||||
export class ArtistService extends GenericDataService<Artist> {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('artist', http, bdd);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karusic,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
private lambdaGets(): Promise<Artist[]> {
|
||||
return ArtistResource.gets({ restConfig: this.getRestConfig() });
|
||||
}
|
||||
|
||||
constructor(private session: SessionService) {
|
||||
super();
|
||||
this.setStore(new DataStore<Artist>(this.lambdaGets, "id"));
|
||||
}
|
||||
insert(data: Artist): Promise<Artist> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
ArtistResource.post({
|
||||
restConfig: this.getRestConfig(),
|
||||
data
|
||||
}).then((value: Artist) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
patch(id: number, data: Artist): Promise<Artist> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
ArtistResource.patch({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
},
|
||||
data
|
||||
}).then((value: Artist) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the track for a specific artist
|
||||
* @param idArtist - Id of the artist.
|
||||
* @returns a promise on the list of track elements
|
||||
*/
|
||||
getTrackNoAlbum(idArtist: bigint): Promise<NodeData[]> {
|
||||
delete(id: number): Promise<void> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
ArtistResource.remove({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
}
|
||||
}).then(() => {
|
||||
self.dataStore.delete(id);
|
||||
resolve();
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
deleteCover(id: number, coverId: UUID): Promise<Artist> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.CONTAINS,
|
||||
key: 'artists',
|
||||
value: idArtist,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'albumId',
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
['track', 'name']);
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
ArtistResource.removeCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
coverId
|
||||
}
|
||||
}).then((value) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get all the track for a specific artist
|
||||
* @param idArtist - Id of the artist.
|
||||
* @returns a promise on the list of track elements
|
||||
*/
|
||||
getAllTracks(idArtist: bigint): Promise<NodeData[]> {
|
||||
uploadCover(id: number,
|
||||
file: File,
|
||||
progress: any = null): Promise<Artist> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
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
|
||||
*/
|
||||
countTrack(artistId: bigint): Promise<number> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.CONTAINS,
|
||||
key: 'artists',
|
||||
value: artistId,
|
||||
ArtistResource.uploadCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
]);
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
data: {
|
||||
file,
|
||||
fileName: file.name
|
||||
}
|
||||
}).then((value) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
//console.log(" <<<========================================>>> " + idArtist);
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
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");
|
||||
//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> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
//console.log(" <<<========================================>>> " + idArtist);
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,97 +5,101 @@
|
||||
*/
|
||||
|
||||
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()
|
||||
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');
|
||||
}
|
||||
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverUrl(coverId: number): string {
|
||||
return this.http.createRESTCall2({
|
||||
api: `data/${coverId}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
getUrl(dataId: string, optionalName?: string): string {
|
||||
if (isNullOrUndefined(optionalName)) {
|
||||
return RESTUrl({
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverListUrl(coverIds?: number[]): string[] | undefined {
|
||||
if (!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
||||
getListUrl(dataIds?: string[]): string[] | undefined {
|
||||
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
let covers = [] as string[];
|
||||
for (let iii = 0; iii < coverIds.length; iii++) {
|
||||
covers.push(this.getCoverUrl(coverIds[iii]).replace("http://localhost:19080", "https://atria-soft.org"));
|
||||
let covers: string[] = [];
|
||||
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||
covers.push(this.getUrl(dataIds[iii]));
|
||||
}
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverThumbnailUrl(coverId: number): string {
|
||||
return this.http.createRESTCall2({
|
||||
api: `data/thumbnail/${coverId}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
getThumbnailUrl(coverId: string): string {
|
||||
return RESTUrl({
|
||||
restModel: {
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverListThumbnailUrl(coverIds?: number[]): string[] | undefined {
|
||||
if (!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
||||
getListThumbnailUrl(dataIds?: string[]): string[] | undefined {
|
||||
if (!isArrayOf(dataIds, isNumberFinite) || dataIds.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
let covers = [] as string[];
|
||||
for (let iii = 0; iii < coverIds.length; iii++) {
|
||||
covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
|
||||
let covers: string[] = [];
|
||||
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||
covers.push(this.getThumbnailUrl(dataIds[iii]));
|
||||
}
|
||||
return covers;
|
||||
}
|
||||
|
@ -6,10 +6,14 @@
|
||||
|
||||
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 { 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 {
|
||||
id: number;
|
||||
@ -18,109 +22,109 @@ export interface MessageLogIn {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class GenderService extends GenericInterfaceModelDB {
|
||||
export class GenderService extends GenericDataService<Gender> {
|
||||
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('gender', http, bdd);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karusic,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
private lambdaGets(): Promise<Gender[]> {
|
||||
return GenderResource.gets({ restConfig: this.getRestConfig() });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
countTrack(id:number): Promise<number> {
|
||||
let self = this;
|
||||
constructor(private session: SessionService) {
|
||||
super();
|
||||
this.setStore(new DataStore<Gender>(this.lambdaGets, "id"));
|
||||
}
|
||||
insert(data: Gender): Promise<Gender> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
} ] );
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
GenderResource.post({
|
||||
restConfig: this.getRestConfig(),
|
||||
data
|
||||
}).then((value: Gender) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getSubTrack(id:number): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
patch(id: number, data: Gender): Promise<Gender> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'artistId',
|
||||
value: undefined,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'playlistId',
|
||||
value: undefined,
|
||||
GenderResource.patch({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
},
|
||||
], [ 'name' ] );
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
data
|
||||
}).then((value: Gender) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getSubArtist(id:number): Promise<NodeData[]> {
|
||||
let self = this;
|
||||
delete(id: number): Promise<void> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('artist')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'parentId',
|
||||
value: id,
|
||||
} ],
|
||||
[ 'name' ]);
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
GenderResource.remove({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
}
|
||||
}).then(() => {
|
||||
self.dataStore.delete(id);
|
||||
resolve();
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getSubPlaylist(id:number): Promise<NodeData[]> {
|
||||
deleteCover(id: number, coverId: UUID): Promise<Gender> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('track')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'artistId',
|
||||
value: [undefined, null],
|
||||
}, {
|
||||
check: TypeCheck.NOT_EQUAL,
|
||||
key: 'playlistId',
|
||||
value: undefined,
|
||||
GenderResource.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<Gender> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
GenderResource.uploadCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
]);
|
||||
//, [ 'universId' ]);
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch((response: any) => {
|
||||
reject(response);
|
||||
data: {
|
||||
file,
|
||||
fileName: file.name
|
||||
}
|
||||
}).then((value) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,16 +7,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
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 { 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()
|
||||
export class PlaylistService extends GenericInterfaceModelDB {
|
||||
export class PlaylistService extends GenericDataService<Playlist> {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('playlist', http, bdd);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
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 {
|
||||
@ -25,25 +40,90 @@ export class PlaylistService extends GenericInterfaceModelDB {
|
||||
|
||||
getSubTrack(id: bigint, select: Array<string> = []): any {
|
||||
// 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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get(self.serviceName)
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'id',
|
||||
value: ids,
|
||||
PlaylistResource.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<Playlist> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
PlaylistResource.uploadCover({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
],
|
||||
['name', 'id']);
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
data: {
|
||||
file,
|
||||
fileName: file.name
|
||||
}
|
||||
}).then((value) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -5,40 +5,141 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
import { HttpWrapperService, BddService } from 'common/service';
|
||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
import { Track, isTrack } from 'app/model/server-karusic-api';
|
||||
import { SessionService } from 'common/service';
|
||||
import { DataInterface, isArrayOf, isNumber, TypeCheck } from 'common/utils';
|
||||
import { DataStore } from 'common/utils/data-store';
|
||||
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()
|
||||
export class TrackService extends GenericInterfaceModelDB {
|
||||
export class TrackService extends GenericDataService<Track> {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('track', http, bdd);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
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) => {
|
||||
super.get(id).then((data: NodeData) => {
|
||||
if (isTrack(data)) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
reject("model is wrong !!!")
|
||||
return
|
||||
}).catch((reason: any) => {
|
||||
reject(reason);
|
||||
TrackResource.post({
|
||||
restConfig: this.getRestConfig(),
|
||||
data
|
||||
}).then((value: Track) => {
|
||||
self.dataStore.updateValue(value);
|
||||
resolve(value);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get(self.serviceName)
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
self.dataStore.getData()
|
||||
.then((response: Track[]) => {
|
||||
let data = DataTools.getsWhere(response,
|
||||
[
|
||||
{
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
@ -46,44 +147,261 @@ export class TrackService extends GenericInterfaceModelDB {
|
||||
},
|
||||
],
|
||||
['track', 'name', 'id']);
|
||||
if (isArrayOf(data, isTrack)) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
reject("model is wrong !!!");
|
||||
return;
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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) => {
|
||||
super.getData().then((data: NodeData[]) => {
|
||||
if (isArrayOf(data, isTrack)) {
|
||||
self.gets()
|
||||
.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);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
reject("model is wrong !!!")
|
||||
return
|
||||
}).catch((reason: any) => {
|
||||
reject(reason);
|
||||
}).catch((response: any) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uploadFile(file: File,
|
||||
gender?: string,
|
||||
artist?: string,
|
||||
album?: string,
|
||||
trackId?: number,
|
||||
title?: string,
|
||||
progress: any = null) {
|
||||
progress: any = null): Promise<Track> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
TrackResource.uploadTrack({
|
||||
restConfig: this.getRestConfig(),
|
||||
data: {
|
||||
fileName: file.name,
|
||||
file,
|
||||
gender: gender ?? null,
|
||||
artist: artist ?? null,
|
||||
album: album ?? null,
|
||||
trackId: trackId ?? null,
|
||||
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 begining it will permit to abort the transmission
|
||||
// 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);
|
||||
@ -96,11 +414,53 @@ export class TrackService extends GenericInterfaceModelDB {
|
||||
formData.append('title', title ?? null);
|
||||
|
||||
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,
|
||||
TrackId: bigint,
|
||||
TrackId: number,
|
||||
progress: any = null) {
|
||||
/*
|
||||
const formData = new FormData();
|
||||
formData.append('fileName', 'take_screenshoot');
|
||||
formData.append('typeId', TrackId.toString());
|
||||
@ -111,7 +471,7 @@ export class TrackService extends GenericInterfaceModelDB {
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
reject('error retrieve data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, TrackId, data);
|
||||
@ -120,6 +480,7 @@ export class TrackService extends GenericInterfaceModelDB {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user