Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6155ca5c0b | |||
| 45eb56a6fe | |||
| 9e0a834b48 | |||
| d5f335e1e7 | |||
| df384cc8be | |||
| 4b545ebbe2 | |||
| eb3cd1b1fe | |||
| 95e2e03686 | |||
| 2402fc31ed | |||
| 763875fbdf | |||
| 4ff2b247b4 | |||
| e4246750c7 | |||
| 04633240b3 | |||
| c76a339caf | |||
| 8a5758af78 | |||
| e05fe70f80 | |||
| f6f9fa199a | |||
| a1684f0fc0 | |||
| cebf7d35fb | |||
| 5d8dab3742 | |||
| 9a3f28553d | |||
| 48e14212db | |||
| c3e2b7240b | |||
| 0af1bbfb52 | |||
| 619973459a | |||
| d37ce25621 | |||
| b4157877c3 | |||
| 883866d5f6 | |||
| 247064e412 | |||
| 70c63882e4 | |||
| 9da93a2831 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "front/src/common"]
|
|
||||||
path = front/src/common
|
|
||||||
url = ../common_web.git
|
|
||||||
@@ -1,7 +1,29 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
version_file="../version.txt"
|
||||||
|
|
||||||
|
# update new release dependency
|
||||||
cd back
|
cd back
|
||||||
mvn versions:set -DnewVersion=$(cat ../version.txt)
|
# update the Maven version number
|
||||||
|
mvn versions:set -DnewVersion=$(sed 's/DEV/SNAPSHOT/g' $version_file)
|
||||||
|
if grep -q "DEV" "$version_file"; then
|
||||||
|
# update all versions release of dependency
|
||||||
|
mvn versions:use-latest-releases
|
||||||
|
# update our manage dependency as snapshoot
|
||||||
|
mvn versions:use-latest-versions -Dincludes=kangaroo-and-rabbit
|
||||||
|
else
|
||||||
|
# update our manage dependency as release (must be done before)
|
||||||
|
mvn versions:use-latest-releases -Dincludes=kangaroo-and-rabbit
|
||||||
|
fi
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
|
||||||
|
cd front
|
||||||
|
if grep -q "DEV" "$version_file"; then
|
||||||
|
# update all dependency
|
||||||
|
pnpm install
|
||||||
|
pnpm run update_packages
|
||||||
|
else
|
||||||
|
# in case of release ==> can not do it automatically ...
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
FROM archlinux:base-devel AS builder
|
FROM archlinux:base-devel AS builder
|
||||||
# update system
|
# update system
|
||||||
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||||
&& pacman -S --noconfirm jdk-openjdk maven npm \
|
&& pacman -S --noconfirm jdk-openjdk maven npm pnpm \
|
||||||
&& pacman -Scc --noconfirm
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
ENV PATH /tmp/node_modules/.bin:$PATH
|
ENV PATH /tmp/node_modules/.bin:$PATH
|
||||||
@@ -29,14 +29,15 @@ RUN mvn clean compile assembly:single
|
|||||||
######################################################################################
|
######################################################################################
|
||||||
FROM builder AS buildFront
|
FROM builder AS buildFront
|
||||||
|
|
||||||
ADD front/package-lock.json \
|
RUN echo "@kangaroo-and-rabbit:registry=https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/npm/" > /root/.npmrc
|
||||||
front/package.json \
|
|
||||||
|
ADD front/package.json \
|
||||||
front/karma.conf.js \
|
front/karma.conf.js \
|
||||||
front/protractor.conf.js \
|
front/protractor.conf.js \
|
||||||
/tmp/
|
/tmp/
|
||||||
|
|
||||||
# install and cache app dependencies
|
# install and cache app dependencies
|
||||||
RUN npm install
|
RUN pnpm install
|
||||||
|
|
||||||
ADD front/e2e \
|
ADD front/e2e \
|
||||||
front/tsconfig.json \
|
front/tsconfig.json \
|
||||||
|
|||||||
@@ -20,13 +20,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.6.0</version>
|
<version>0.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>2.0.9</version>
|
<version>2.0.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>2.16.1</version>
|
||||||
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
************************************************************
|
************************************************************
|
||||||
** TEST dependency **
|
** TEST dependency **
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.kar.archidata.api.DataResource;
|
|||||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
import org.kar.archidata.catcher.FailExceptionCatcher;
|
||||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
import org.kar.archidata.catcher.InputExceptionCatcher;
|
||||||
|
import org.kar.archidata.catcher.JacksonCatcher;
|
||||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
||||||
import org.kar.archidata.filter.CORSFilter;
|
import org.kar.archidata.filter.CORSFilter;
|
||||||
import org.kar.archidata.filter.OptionFilter;
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
@@ -29,6 +30,8 @@ import org.kar.karusic.api.UserResource;
|
|||||||
import org.kar.karusic.filter.KarusicAuthenticationFilter;
|
import org.kar.karusic.filter.KarusicAuthenticationFilter;
|
||||||
import org.kar.karusic.migration.Initialization;
|
import org.kar.karusic.migration.Initialization;
|
||||||
import org.kar.karusic.migration.Migration20231126;
|
import org.kar.karusic.migration.Migration20231126;
|
||||||
|
import org.kar.karusic.migration.Migration20240225;
|
||||||
|
import org.kar.karusic.migration.Migration20240226;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -54,6 +57,8 @@ public class WebLauncher {
|
|||||||
migrationEngine.setInit(new Initialization());
|
migrationEngine.setInit(new Initialization());
|
||||||
WebLauncher.LOGGER.info("Add migration since last version");
|
WebLauncher.LOGGER.info("Add migration since last version");
|
||||||
migrationEngine.add(new Migration20231126());
|
migrationEngine.add(new Migration20231126());
|
||||||
|
migrationEngine.add(new Migration20240225());
|
||||||
|
migrationEngine.add(new Migration20240226());
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
@@ -87,6 +92,7 @@ public class WebLauncher {
|
|||||||
// global authentication system
|
// global authentication system
|
||||||
rc.register(KarusicAuthenticationFilter.class);
|
rc.register(KarusicAuthenticationFilter.class);
|
||||||
// register exception catcher
|
// register exception catcher
|
||||||
|
rc.register(JacksonCatcher.class);
|
||||||
rc.register(InputExceptionCatcher.class);
|
rc.register(InputExceptionCatcher.class);
|
||||||
rc.register(SystemExceptionCatcher.class);
|
rc.register(SystemExceptionCatcher.class);
|
||||||
rc.register(FailExceptionCatcher.class);
|
rc.register(FailExceptionCatcher.class);
|
||||||
|
|||||||
@@ -1,20 +1,44 @@
|
|||||||
package org.kar.karusic;
|
package org.kar.karusic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
|
import org.kar.karusic.api.AlbumResource;
|
||||||
|
import org.kar.karusic.api.ArtistResource;
|
||||||
|
import org.kar.karusic.api.Front;
|
||||||
|
import org.kar.karusic.api.GenderResource;
|
||||||
|
import org.kar.karusic.api.HealthCheck;
|
||||||
|
import org.kar.karusic.api.PlaylistResource;
|
||||||
|
import org.kar.karusic.api.TrackResource;
|
||||||
|
import org.kar.karusic.api.UserResource;
|
||||||
|
import org.kar.karusic.migration.Initialization;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class WebLauncherLocal extends WebLauncher {
|
public class WebLauncherLocal extends WebLauncher {
|
||||||
final Logger logger = LoggerFactory.getLogger(WebLauncherLocal.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
||||||
|
|
||||||
private WebLauncherLocal() {}
|
private WebLauncherLocal() {}
|
||||||
|
|
||||||
public static void main(final String[] args) throws InterruptedException {
|
public static void main(final String[] args) throws Exception {
|
||||||
|
DataFactoryTsApi.generatePackage(List.of(
|
||||||
|
AlbumResource.class,
|
||||||
|
ArtistResource.class,
|
||||||
|
Front.class,
|
||||||
|
GenderResource.class,
|
||||||
|
HealthCheck.class,
|
||||||
|
PlaylistResource.class,
|
||||||
|
UserResource.class,
|
||||||
|
TrackResource.class,
|
||||||
|
DataResource.class),
|
||||||
|
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||||
launcher.process();
|
launcher.process();
|
||||||
launcher.logger.info("end-configure the server & wait finish process:");
|
launcher.LOGGER.info("end-configure the server & wait finish process:");
|
||||||
Thread.currentThread().join();
|
Thread.currentThread().join();
|
||||||
launcher.logger.info("STOP the REST server:");
|
launcher.LOGGER.info("STOP the REST server:");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,14 +2,21 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Album;
|
import org.kar.karusic.model.Album;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
import jakarta.ws.rs.DELETE;
|
import jakarta.ws.rs.DELETE;
|
||||||
@@ -25,24 +32,28 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Path("/album")
|
@Path("/album")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class AlbumResource {
|
public class AlbumResource {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Album getWithId(@PathParam("id") final Long id) throws Exception {
|
@Operation(description = "Get a specific Album with his ID")
|
||||||
|
public static Album get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Album> get() throws Exception {
|
@Operation(description = "Get all the available Albums")
|
||||||
|
public List<Album> gets() throws Exception {
|
||||||
return DataAccess.gets(Album.class);
|
return DataAccess.gets(Album.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Album post(final String jsonRequest) throws Exception {
|
@Operation(description = "Add an album (when all the data already exist)")
|
||||||
|
public Album post(@AsyncType(Album.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Album.class, jsonRequest);
|
return DataAccess.insertWithJson(Album.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +61,8 @@ public class AlbumResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Album put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
@Operation(description = "Update a specific album")
|
||||||
|
public Album patch(@PathParam("id") final Long id, @AsyncType(Album.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Album.class, id, jsonRequest);
|
DataAccess.updateWithJson(Album.class, id, jsonRequest);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
@@ -58,42 +70,48 @@ public class AlbumResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
@Operation(description = "Remove a specific album")
|
||||||
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Album.class, id);
|
DataAccess.delete(Album.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@Operation(description = "Add a Track on a specific album")
|
||||||
public Album addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Album addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
|
@Operation(description = "Remove a Track on a specific album")
|
||||||
public Album removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Album removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@Operation(description = "Add a cover on a specific album")
|
||||||
|
@AsyncType(Album.class)
|
||||||
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
@Operation(description = "Remove a cover on a specific album")
|
||||||
AddOnManyToMany.removeLink(Album.class, id, "cover", coverId);
|
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
return Response.ok(DataAccess.get(Album.class, id)).build();
|
AddOnDataJson.removeLink(Album.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,18 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Artist;
|
import org.kar.karusic.model.Artist;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
@@ -25,24 +30,25 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Path("/artist")
|
@Path("/artist")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class ArtistResource {
|
public class ArtistResource {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Artist getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Artist get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Artist.class, id);
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Artist> get() throws Exception {
|
public List<Artist> gets() throws Exception {
|
||||||
return DataAccess.gets(Artist.class);
|
return DataAccess.gets(Artist.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Artist put(final String jsonRequest) throws Exception {
|
public Artist post(@AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Artist.class, jsonRequest);
|
return DataAccess.insertWithJson(Artist.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +56,7 @@ public class ArtistResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Artist put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Artist patch(@PathParam("id") final Long id, @AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Artist.class, id, jsonRequest);
|
DataAccess.updateWithJson(Artist.class, id, jsonRequest);
|
||||||
return DataAccess.get(Artist.class, id);
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
@@ -58,25 +64,27 @@ public class ArtistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Artist.class, id);
|
DataAccess.delete(Artist.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Artist.class)
|
||||||
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Artist.class, id, "cover", coverId);
|
LOGGER.error("klmlmkmlkmlklmklmk");
|
||||||
return Response.ok(DataAccess.get(Artist.class, id)).build();
|
AddOnDataJson.removeLink(Artist.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,18 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Gender;
|
import org.kar.karusic.model.Gender;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
@@ -25,24 +30,25 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Path("/gender")
|
@Path("/gender")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class GenderResource {
|
public class GenderResource {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Gender getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Gender get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Gender> get() throws Exception {
|
public List<Gender> gets() throws Exception {
|
||||||
return DataAccess.gets(Gender.class);
|
return DataAccess.gets(Gender.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender put(final String jsonRequest) throws Exception {
|
public Gender post(@AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +56,7 @@ public class GenderResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Gender patch(@PathParam("id") final Long id, @AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
@@ -58,25 +64,26 @@ public class GenderResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Gender.class, id);
|
DataAccess.delete(Gender.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Gender.class)
|
||||||
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Gender.class, id, "cover", coverId);
|
AddOnDataJson.removeLink(Gender.class, id, "covers", coverId);
|
||||||
return Response.ok(DataAccess.get(Gender.class, id)).build();
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,18 @@ package org.kar.karusic.api;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karusic.model.Playlist;
|
import org.kar.karusic.model.Playlist;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
@@ -25,24 +30,25 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Path("/playlist")
|
@Path("/playlist")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class PlaylistResource {
|
public class PlaylistResource {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Playlist getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Playlist get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Playlist> get() throws Exception {
|
public List<Playlist> gets() throws Exception {
|
||||||
return DataAccess.gets(Playlist.class);
|
return DataAccess.gets(Playlist.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Playlist put(final String jsonRequest) throws Exception {
|
public Playlist post(@AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +56,7 @@ public class PlaylistResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Playlist put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Playlist patch(@PathParam("id") final Long id, @AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Playlist.class, id, jsonRequest);
|
DataAccess.updateWithJson(Playlist.class, id, jsonRequest);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
@@ -58,13 +64,12 @@ public class PlaylistResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Playlist.class, id);
|
DataAccess.delete(Playlist.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
||||||
@@ -72,8 +77,8 @@ public class PlaylistResource {
|
|||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
||||||
@@ -81,19 +86,20 @@ public class PlaylistResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Playlist.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "cover", coverId);
|
AddOnDataJson.removeLink(Playlist.class, id, "covers", coverId);
|
||||||
return Response.ok(DataAccess.get(Playlist.class, id)).build();
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
@@ -18,6 +22,8 @@ import org.kar.karusic.model.Album;
|
|||||||
import org.kar.karusic.model.Artist;
|
import org.kar.karusic.model.Artist;
|
||||||
import org.kar.karusic.model.Gender;
|
import org.kar.karusic.model.Gender;
|
||||||
import org.kar.karusic.model.Track;
|
import org.kar.karusic.model.Track;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
@@ -34,24 +40,25 @@ import jakarta.ws.rs.core.Response;
|
|||||||
@Path("/track")
|
@Path("/track")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class TrackResource {
|
public class TrackResource {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(TrackResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Track getWithId(@PathParam("id") final Long id) throws Exception {
|
public static Track get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Track> get() throws Exception {
|
public List<Track> gets() throws Exception {
|
||||||
return DataAccess.gets(Track.class);
|
return DataAccess.gets(Track.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Track create(final String jsonRequest) throws Exception {
|
public Track post(@AsyncType(Track.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Track.class, jsonRequest);
|
return DataAccess.insertWithJson(Track.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +66,7 @@ public class TrackResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Track put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
@@ -67,13 +74,12 @@ public class TrackResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Track.class, id);
|
DataAccess.delete(Track.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_artist/{artistId}")
|
@Path("{id}/artist/{artistId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Track addTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
|
public Track addTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
|
||||||
@@ -81,8 +87,8 @@ public class TrackResource {
|
|||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_artist/{trackId}")
|
@Path("{id}/artist/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
|
public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
|
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
|
||||||
@@ -90,30 +96,43 @@ public class TrackResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@AsyncType(Track.class)
|
||||||
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||||
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
AddOnManyToMany.removeLink(Track.class, id, "cover", coverId);
|
AddOnDataJson.removeLink(Track.class, id, "covers", coverId);
|
||||||
return Response.ok(DataAccess.get(Track.class, id)).build();
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/upload/")
|
@Path("upload/")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadFile(@FormDataParam("fileName") String fileName, @FormDataParam("gender") String gender, @FormDataParam("artist") String artist,
|
// Formatter:off
|
||||||
|
@AsyncType(Track.class)
|
||||||
|
@TypeScriptProgress
|
||||||
|
public Response uploadTrack(
|
||||||
|
@FormDataParam("fileName") String fileName, //
|
||||||
|
@FormDataParam("gender") String gender, //
|
||||||
|
@FormDataParam("artist") String artist, //
|
||||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||||
@FormDataParam("album") String album, @FormDataParam("trackId") String trackId, @FormDataParam("title") String title, @FormDataParam("file") final InputStream fileInputStream,
|
@FormDataParam("album") String album, //
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@AsyncType(Long.class) @FormDataParam("trackId") String trackId, //
|
||||||
|
@FormDataParam("title") String title, //
|
||||||
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||||
|
) {
|
||||||
|
// Formatter:on
|
||||||
try {
|
try {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
fileName = DataTools.multipartCorrection(fileName);
|
fileName = DataTools.multipartCorrection(fileName);
|
||||||
@@ -124,16 +143,15 @@ public class TrackResource {
|
|||||||
title = DataTools.multipartCorrection(title);
|
title = DataTools.multipartCorrection(title);
|
||||||
|
|
||||||
//public NodeSmall uploadFile(final FormDataMultiPart form) {
|
//public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||||
System.out.println("Upload media file: " + fileMetaData);
|
LOGGER.info("Upload media file: " + fileMetaData);
|
||||||
System.out.println(" - fileName: " + fileName);
|
LOGGER.info(" > fileName: " + fileName);
|
||||||
System.out.println(" - gender: " + gender);
|
LOGGER.info(" > gender: " + gender);
|
||||||
System.out.println(" - artist: " + artist);
|
LOGGER.info(" > artist: " + artist);
|
||||||
System.out.println(" - album: " + album);
|
LOGGER.info(" > album: " + album);
|
||||||
System.out.println(" - trackId: " + trackId);
|
LOGGER.info(" > trackId: " + trackId);
|
||||||
System.out.println(" - title: " + title);
|
LOGGER.info(" > title: " + title);
|
||||||
System.out.println(" - fileInputStream: " + fileInputStream);
|
LOGGER.info(" > fileInputStream: " + fileInputStream);
|
||||||
System.out.println(" - fileMetaData: " + fileMetaData);
|
LOGGER.info(" > fileMetaData: " + fileMetaData);
|
||||||
System.out.flush();
|
|
||||||
/*
|
/*
|
||||||
if (typeId == null) {
|
if (typeId == null) {
|
||||||
return Response.status(406).
|
return Response.status(406).
|
||||||
@@ -147,8 +165,8 @@ public class TrackResource {
|
|||||||
final String sha512 = DataTools.saveTemporaryFile(fileInputStream, tmpUID);
|
final String sha512 = DataTools.saveTemporaryFile(fileInputStream, tmpUID);
|
||||||
Data data = DataTools.getWithSha512(sha512);
|
Data data = DataTools.getWithSha512(sha512);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
System.out.println("Need to add the data in the BDD ... ");
|
LOGGER.info("Need to add the data in the BDD ... ");
|
||||||
System.out.flush();
|
|
||||||
try {
|
try {
|
||||||
data = DataTools.createNewData(tmpUID, fileName, sha512);
|
data = DataTools.createNewData(tmpUID, fileName, sha512);
|
||||||
} catch (final IOException ex) {
|
} catch (final IOException ex) {
|
||||||
@@ -161,16 +179,14 @@ public class TrackResource {
|
|||||||
return Response.notModified("Error in SQL insertion ...").build();
|
return Response.notModified("Error in SQL insertion ...").build();
|
||||||
}
|
}
|
||||||
} else if (data.deleted) {
|
} else if (data.deleted) {
|
||||||
System.out.println("Data already exist but deleted");
|
LOGGER.info("Data already exist but deleted");
|
||||||
System.out.flush();
|
|
||||||
DataTools.undelete(data.id);
|
DataTools.undelete(data.id);
|
||||||
data.deleted = false;
|
data.deleted = false;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Data already exist ... all good");
|
LOGGER.info("Data already exist ... all good");
|
||||||
System.out.flush();
|
|
||||||
}
|
}
|
||||||
// Fist step: retrieve all the Id of each parents:...
|
// Fist step: retrieve all the Id of each parents:...
|
||||||
System.out.println("Find typeNode");
|
LOGGER.info("Find typeNode");
|
||||||
Gender genderElem = null;
|
Gender genderElem = null;
|
||||||
if (gender != null) {
|
if (gender != null) {
|
||||||
genderElem = DataAccess.getWhere(Gender.class, new Condition(new QueryCondition("name", "=", gender)));
|
genderElem = DataAccess.getWhere(Gender.class, new Condition(new QueryCondition("name", "=", gender)));
|
||||||
@@ -185,18 +201,20 @@ public class TrackResource {
|
|||||||
// DataTools.removeTemporaryFile(tmpUID);
|
// DataTools.removeTemporaryFile(tmpUID);
|
||||||
// return Response.notModified("TypeId does not exist ...").build();
|
// return Response.notModified("TypeId does not exist ...").build();
|
||||||
// }
|
// }
|
||||||
System.out.println(" ==> " + genderElem);
|
LOGGER.info(" ==> genderElem={}", genderElem);
|
||||||
|
|
||||||
Artist artistElem = null;
|
Artist artistElem = null;
|
||||||
if (artist != null) {
|
if (artist != null) {
|
||||||
|
LOGGER.info(" Try to find Artist: '{}'", artist);
|
||||||
artistElem = DataAccess.getWhere(Artist.class, new Condition(new QueryCondition("name", "=", artist)));
|
artistElem = DataAccess.getWhere(Artist.class, new Condition(new QueryCondition("name", "=", artist)));
|
||||||
if (artistElem == null) {
|
if (artistElem == null) {
|
||||||
|
LOGGER.info(" ** Create a new one...");
|
||||||
artistElem = new Artist();
|
artistElem = new Artist();
|
||||||
artistElem.name = artist;
|
artistElem.name = artist;
|
||||||
artistElem = DataAccess.insert(artistElem);
|
artistElem = DataAccess.insert(artistElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(" ==> " + artistElem);
|
LOGGER.info(" ==> artistElem={}", artistElem);
|
||||||
|
|
||||||
Album albumElem = null;
|
Album albumElem = null;
|
||||||
if (album != null) {
|
if (album != null) {
|
||||||
@@ -207,9 +225,9 @@ public class TrackResource {
|
|||||||
albumElem = DataAccess.insert(albumElem);
|
albumElem = DataAccess.insert(albumElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(" ==> " + album);
|
LOGGER.info(" ==> " + album);
|
||||||
|
|
||||||
System.out.println("add media");
|
LOGGER.info("add media");
|
||||||
|
|
||||||
Track trackElem = new Track();
|
Track trackElem = new Track();
|
||||||
trackElem.name = title;
|
trackElem.name = title;
|
||||||
@@ -217,7 +235,7 @@ public class TrackResource {
|
|||||||
trackElem.albumId = albumElem != null ? albumElem.id : null;
|
trackElem.albumId = albumElem != null ? albumElem.id : null;
|
||||||
trackElem.genderId = genderElem != null ? genderElem.id : null;
|
trackElem.genderId = genderElem != null ? genderElem.id : null;
|
||||||
trackElem.dataId = data.id;
|
trackElem.dataId = data.id;
|
||||||
// Now list of artis has an internal management:
|
// Now list of artist has an internal management:
|
||||||
if (artistElem != null) {
|
if (artistElem != null) {
|
||||||
trackElem.artists = new ArrayList<>();
|
trackElem.artists = new ArrayList<>();
|
||||||
trackElem.artists.add(artistElem.id);
|
trackElem.artists.add(artistElem.id);
|
||||||
@@ -231,7 +249,7 @@ public class TrackResource {
|
|||||||
*/
|
*/
|
||||||
return Response.ok(trackElem).build();
|
return Response.ok(trackElem).build();
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
System.out.println("Catch an unexpected error ... " + ex.getMessage());
|
LOGGER.info("Catch an unexpected error ... {}", ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return Response.status(417).entity("Back-end error : " + ex.getMessage()).type("text/plain").build();
|
return Response.status(417).entity("Back-end error : " + ex.getMessage()).type("text/plain").build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import jakarta.ws.rs.core.SecurityContext;
|
|||||||
@Path("/users")
|
@Path("/users")
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
final Logger logger = LoggerFactory.getLogger(UserResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class UserOut {
|
public class UserOut {
|
||||||
@@ -41,8 +41,8 @@ public class UserResource {
|
|||||||
// curl http://localhost:9993/api/users
|
// curl http://localhost:9993/api/users
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public List<UserKarusic> getUsers() {
|
public List<UserKarusic> gets() {
|
||||||
System.out.println("getUsers");
|
LOGGER.info("getUsers");
|
||||||
try {
|
try {
|
||||||
return DataAccess.gets(UserKarusic.class);
|
return DataAccess.gets(UserKarusic.class);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@@ -56,12 +56,12 @@ public class UserResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public UserKarusic getUsers(@Context final SecurityContext sc, @PathParam("id") final long userId) {
|
public UserKarusic get(@Context final SecurityContext sc, @PathParam("id") final long userId) {
|
||||||
System.out.println("getUser " + userId);
|
LOGGER.info("getUser {}", userId);
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
System.out.println("===================================================");
|
LOGGER.info("===================================================");
|
||||||
System.out.println("== USER ? " + gc.userByToken.name);
|
LOGGER.info("== USER {} ", gc.userByToken.name);
|
||||||
System.out.println("===================================================");
|
LOGGER.info("===================================================");
|
||||||
try {
|
try {
|
||||||
return DataAccess.get(UserKarusic.class, userId);
|
return DataAccess.get(UserKarusic.class, userId);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@@ -75,9 +75,9 @@ public class UserResource {
|
|||||||
@Path("me")
|
@Path("me")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public UserOut getMe(@Context final SecurityContext sc) {
|
public UserOut getMe(@Context final SecurityContext sc) {
|
||||||
this.logger.debug("getMe()");
|
LOGGER.debug("getMe()");
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
LOGGER.debug("== USER ? {}", gc.userByToken);
|
||||||
return new UserOut(gc.userByToken.id, gc.userByToken.name);
|
return new UserOut(gc.userByToken.id, gc.userByToken.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.kar.karusic.migration;
|
package org.kar.karusic.migration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
@@ -12,6 +14,7 @@ import org.kar.karusic.model.Track;
|
|||||||
public class Initialization extends MigrationSqlStep {
|
public class Initialization extends MigrationSqlStep {
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
public static final List<Class<?>> CLASSES_BASE = List.of(Album.class,Artist.class,Data.class,Gender.class,Playlist.class,Track.class,User.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -24,13 +27,9 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
addClass(Album.class);
|
for (final Class<?> elem : CLASSES_BASE) {
|
||||||
addClass(Artist.class);
|
addClass(elem);
|
||||||
addClass(Data.class);
|
}
|
||||||
addClass(Gender.class);
|
|
||||||
addClass(Playlist.class);
|
|
||||||
addClass(Track.class);
|
|
||||||
addClass(User.class);
|
|
||||||
|
|
||||||
addAction("""
|
addAction("""
|
||||||
INSERT INTO `gender` (`id`, `name`, `description`) VALUES
|
INSERT INTO `gender` (`id`, `name`, `description`) VALUES
|
||||||
@@ -68,9 +67,6 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `artist` AUTO_INCREMENT = 1000;
|
ALTER TABLE `artist` AUTO_INCREMENT = 1000;
|
||||||
""", "mysql");
|
""", "mysql");
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `gender` AUTO_INCREMENT = 1000;
|
ALTER TABLE `gender` AUTO_INCREMENT = 1000;
|
||||||
""", "mysql");
|
""", "mysql");
|
||||||
|
|||||||
26
back/src/org/kar/karusic/migration/Migration20240225.java
Normal file
26
back/src/org/kar/karusic/migration/Migration20240225.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package org.kar.karusic.migration;
|
||||||
|
|
||||||
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
|
|
||||||
|
public class Migration20240225 extends MigrationSqlStep {
|
||||||
|
|
||||||
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "migration-2024-02-25: change model of thrack to use real json";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Migration20240225() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateStep() throws Exception {
|
||||||
|
// update migration update (last one)
|
||||||
|
addAction("""
|
||||||
|
UPDATE `track` SET artists = CONCAT('[', artists, ']') WHERE artists IS NOT NULL
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
135
back/src/org/kar/karusic/migration/Migration20240226.java
Normal file
135
back/src/org/kar/karusic/migration/Migration20240226.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
package org.kar.karusic.migration;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
|
import org.kar.archidata.dataAccess.addOn.model.LinkTable;
|
||||||
|
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
||||||
|
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
||||||
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
|
import org.kar.archidata.tools.UuidUtils;
|
||||||
|
import org.kar.karusic.migration.model.CoverConversion;
|
||||||
|
import org.kar.karusic.migration.model.MediaConversion;
|
||||||
|
import org.kar.karusic.migration.model.UUIDConversion;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class Migration20240226 extends MigrationSqlStep {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
||||||
|
|
||||||
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "migration-2024-02-26: convert base with UUID";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Migration20240226() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateStep() throws Exception {
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
||||||
|
""");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion elem: datas) {
|
||||||
|
elem.uuid = UuidUtils.nextUUID();
|
||||||
|
}
|
||||||
|
for (final UUIDConversion elem: datas) {
|
||||||
|
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||||
|
""");
|
||||||
|
final List<String> tableToTransform = List.of("album", "artist", "gender", "playlist", "track", "user");
|
||||||
|
for (final String tableName : tableToTransform ) {
|
||||||
|
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||||
|
final List<LinkTable> links = DataAccess.gets(LinkTable.class, new OverrideTableName(tableName + "_link_cover"));
|
||||||
|
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||||
|
for (final CoverConversion media: medias) {
|
||||||
|
final List<UUID> values = new ArrayList<>();
|
||||||
|
for (final LinkTable link: links) {
|
||||||
|
if (link.object1Id.equals(media.id)) {
|
||||||
|
for (final UUIDConversion data: datas) {
|
||||||
|
if (data.id.equals(link.object2Id)) {
|
||||||
|
values.add(data.uuid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (values.size() != 0) {
|
||||||
|
media.covers = values;
|
||||||
|
LOGGER.info(" update: {} => {}", media.id, media.covers);
|
||||||
|
DataAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("DROP TABLE `" + tableName + "_link_cover`;");
|
||||||
|
}
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
||||||
|
""");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
||||||
|
for (final MediaConversion media: medias) {
|
||||||
|
for (final UUIDConversion data: datas) {
|
||||||
|
if (data.id.equals(media.dataId)) {
|
||||||
|
media.dataUUID = data.uuid;
|
||||||
|
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addAction("""
|
||||||
|
DROP TABLE `playlist`;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
DROP TABLE `playlist_link_track`;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `track` DROP `dataId`;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `track` CHANGE `dataUUID` `dataId` binary(16) NOT NULL;
|
||||||
|
""");
|
||||||
|
// Move the files...
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion data: datas) {
|
||||||
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
|
final String destination = DataResource.getFileData(data.uuid);
|
||||||
|
LOGGER.info("move file = {}", origin);
|
||||||
|
LOGGER.info(" ==> {}", destination);
|
||||||
|
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` DROP `id`;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` CHANGE `uuid` `id` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.kar.karusic.migration.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
public class CoverConversion {
|
||||||
|
@Id
|
||||||
|
public Long id = null;
|
||||||
|
@DataJson
|
||||||
|
public List<UUID> covers = null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.kar.karusic.migration.model;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
public class MediaConversion {
|
||||||
|
@Id
|
||||||
|
public Long id = null;
|
||||||
|
public Long dataId = null;
|
||||||
|
public UUID dataUUID = null;
|
||||||
|
}
|
||||||
11
back/src/org/kar/karusic/migration/model/UUIDConversion.java
Normal file
11
back/src/org/kar/karusic/migration/model/UUIDConversion.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package org.kar.karusic.migration.model;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
public class UUIDConversion {
|
||||||
|
@Id
|
||||||
|
public Long id = null;
|
||||||
|
public UUID uuid = null;
|
||||||
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package org.kar.karusic.model;
|
|
||||||
/*
|
|
||||||
CREATE TABLE `data` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
`create_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been update',
|
|
||||||
`sha512` varchar(129) COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`mime_type` varchar(128) COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`size` bigint,
|
|
||||||
`original_name` TEXT
|
|
||||||
) AUTO_INCREMENT=64;
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class DataSmall {
|
|
||||||
public Long id;
|
|
||||||
public String sha512;
|
|
||||||
public String mimeType;
|
|
||||||
public Long size;
|
|
||||||
|
|
||||||
public DataSmall() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataSmall(ResultSet rs) {
|
|
||||||
int iii = 1;
|
|
||||||
try {
|
|
||||||
this.id = rs.getLong(iii++);
|
|
||||||
this.sha512 = rs.getString(iii++);
|
|
||||||
this.mimeType = rs.getString(iii++);
|
|
||||||
this.size = rs.getLong(iii++);
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String getTableSql() {
|
|
||||||
return """
|
|
||||||
DROP TABLE IF EXISTS `data`;
|
|
||||||
CREATE TABLE `data` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'table ID',
|
|
||||||
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
|
||||||
`create_date` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Time the element has been update',
|
|
||||||
`sha512` varchar(129) CHARACTER SET utf8mb3 COLLATE utf8_general_ci NOT NULL,
|
|
||||||
`mime_type` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8_general_ci NOT NULL,
|
|
||||||
`size` bigint DEFAULT NULL,
|
|
||||||
`original_name` text,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package org.kar.karusic.model;
|
|
||||||
/*
|
|
||||||
CREATE TABLE `node` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
`create_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been update',
|
|
||||||
`type` enum("TYPE", "UNIVERSE", "SERIES", "SEASON") NOT NULL DEFAULT 'TYPE',
|
|
||||||
`name` TEXT COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
|
||||||
`parent_id` bigint
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class MediaSmall {
|
|
||||||
public class MediaStreamProperty {
|
|
||||||
public Long id;
|
|
||||||
public Long timeSecond;
|
|
||||||
public Long width;
|
|
||||||
public Long height;
|
|
||||||
public Map<String, Long> videos = new HashMap<>();
|
|
||||||
public Map<String, Long> audios = new HashMap<>();
|
|
||||||
public Map<String, Long> subtitles = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long id;
|
|
||||||
public String name;
|
|
||||||
public String description;
|
|
||||||
public Long dataId;
|
|
||||||
public Long typeId;
|
|
||||||
public Long universeId;
|
|
||||||
public Long seriesId;
|
|
||||||
public Long seasonId;
|
|
||||||
public Integer episode;
|
|
||||||
public Integer date;
|
|
||||||
public Integer time;
|
|
||||||
public String ageLimit;
|
|
||||||
public List<Long> covers = null;
|
|
||||||
public MediaStreamProperty media;
|
|
||||||
|
|
||||||
public MediaSmall(ResultSet rs) {
|
|
||||||
int iii = 1;
|
|
||||||
try {
|
|
||||||
this.id = rs.getLong(iii++);
|
|
||||||
this.name = rs.getString(iii++);
|
|
||||||
this.description = rs.getString(iii++);
|
|
||||||
this.dataId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.dataId = null;
|
|
||||||
}
|
|
||||||
this.typeId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.typeId = null;
|
|
||||||
}
|
|
||||||
this.universeId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.universeId = null;
|
|
||||||
}
|
|
||||||
this.seriesId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.seriesId = null;
|
|
||||||
}
|
|
||||||
this.seasonId = rs.getLong(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.seasonId = null;
|
|
||||||
}
|
|
||||||
this.episode = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.episode = null;
|
|
||||||
}
|
|
||||||
this.date = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.date = null;
|
|
||||||
}
|
|
||||||
this.time = rs.getInt(iii++);
|
|
||||||
if (rs.wasNull()) {
|
|
||||||
this.time = null;
|
|
||||||
}
|
|
||||||
this.ageLimit = rs.getString(iii++);
|
|
||||||
String coversString = rs.getString(iii++);
|
|
||||||
if (!rs.wasNull()) {
|
|
||||||
covers = new ArrayList<>();
|
|
||||||
String[] elements = coversString.split("-");
|
|
||||||
for (String elem : elements) {
|
|
||||||
Long tmp = Long.parseLong(elem);
|
|
||||||
covers.add(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,18 +10,19 @@ CREATE TABLE `node` (
|
|||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
`description` TEXT COLLATE 'utf8_general_ci',
|
||||||
`parent_id` bigint
|
`parent_id` bigint
|
||||||
) AUTO_INCREMENT=10;
|
) AUTO_INCREMENT=10;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class NodeSmall extends GenericDataSoftDelete {
|
public class NodeSmall extends GenericDataSoftDelete {
|
||||||
@@ -29,6 +30,7 @@ public class NodeSmall extends GenericDataSoftDelete {
|
|||||||
public String name = null;
|
public String name = null;
|
||||||
@Column(length = 0)
|
@Column(length = 0)
|
||||||
public String description = null;
|
public String description = null;
|
||||||
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
@Schema(description = "List of Id of the specific covers")
|
||||||
public List<Long> covers = null;
|
@DataJson(targetEntity = Data.class)
|
||||||
|
public List<UUID> covers = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ CREATE TABLE `node` (
|
|||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
`description` TEXT COLLATE 'utf8_general_ci',
|
||||||
`parent_id` bigint
|
`parent_id` bigint
|
||||||
) AUTO_INCREMENT=10;
|
) AUTO_INCREMENT=10;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.annotation.addOn.SQLTableExternalForeinKeyAsList;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
@@ -29,9 +30,9 @@ public class Track extends NodeSmall {
|
|||||||
public Long genderId = null;
|
public Long genderId = null;
|
||||||
public Long albumId = null;
|
public Long albumId = null;
|
||||||
public Long track = null;
|
public Long track = null;
|
||||||
public Long dataId = null;
|
public UUID dataId = null;
|
||||||
//@ManyToMany(fetch = FetchType.LAZY, targetEntity = Artist.class)
|
//@ManyToMany(fetch = FetchType.LAZY, targetEntity = Artist.class)
|
||||||
@SQLTableExternalForeinKeyAsList
|
@DataJson
|
||||||
@Column(length = 0)
|
@Column(length = 0)
|
||||||
public List<Long> artists = null;
|
public List<Long> artists = null;
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ WORKDIR /application/
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
ADD e2e /application/e2e
|
ADD e2e /application/e2e
|
||||||
ADD tsconfig.json /application/
|
ADD tsconfig.json tslint.json angular.json ./
|
||||||
ADD tslint.json /application/
|
|
||||||
ADD angular.json /application/
|
|
||||||
ADD src /application/src
|
ADD src /application/src
|
||||||
|
|
||||||
# generate build
|
# generate build
|
||||||
|
|||||||
@@ -1,88 +1,117 @@
|
|||||||
{
|
{
|
||||||
"$schema" : "./node_modules/@angular/cli/lib/config/schema.json",
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
"version" : 1,
|
"version": 1,
|
||||||
"newProjectRoot" : "projects",
|
"newProjectRoot": "projects",
|
||||||
"defaultProject" : "karusic",
|
"projects": {
|
||||||
"projects" : {
|
"karusic": {
|
||||||
"karusic" : {
|
"root": "",
|
||||||
"root" : "",
|
"sourceRoot": "src",
|
||||||
"sourceRoot" : "src",
|
"projectType": "application",
|
||||||
"projectType" : "application",
|
"architect": {
|
||||||
"architect" : {
|
"build": {
|
||||||
"build" : {
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"builder" : "@angular-devkit/build-angular:browser",
|
"options": {
|
||||||
"options" : {
|
"outputPath": "dist",
|
||||||
"outputPath" : "dist",
|
"index": "src/index.html",
|
||||||
"index" : "src/index.html",
|
"main": "src/main.ts",
|
||||||
"main" : "src/main.ts",
|
"tsConfig": "src/tsconfig.app.json",
|
||||||
"tsConfig" : "src/tsconfig.app.json",
|
"preserveSymlinks": true,
|
||||||
"polyfills" : "src/polyfills.ts",
|
"polyfills": [
|
||||||
"assets" : [ "src/assets", "src/favicon.ico" ],
|
"zone.js"
|
||||||
"styles" : [ "src/styles.less", "src/generic_page.less", "src/theme.color.blue.less", "src/theme.checkbox.less", "src/theme.modal.less" ],
|
],
|
||||||
"scripts" : [ ]
|
"assets": [
|
||||||
|
"src/assets",
|
||||||
|
"src/favicon.ico"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.less",
|
||||||
|
"src/generic_page.less",
|
||||||
|
"src/theme.color.blue.less",
|
||||||
|
"src/theme.checkbox.less",
|
||||||
|
"src/theme.modal.less"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
},
|
},
|
||||||
"configurations" : {
|
"configurations": {
|
||||||
"production" : {
|
"production": {
|
||||||
"optimization" : true,
|
"optimization": true,
|
||||||
"outputHashing" : "all",
|
"outputHashing": "all",
|
||||||
"sourceMap" : false,
|
"sourceMap": false,
|
||||||
"namedChunks" : false,
|
"namedChunks": false,
|
||||||
"aot" : true,
|
"aot": true,
|
||||||
"extractLicenses" : true,
|
"extractLicenses": true,
|
||||||
"vendorChunk" : false,
|
"vendorChunk": false,
|
||||||
"buildOptimizer" : true,
|
"buildOptimizer": true,
|
||||||
"fileReplacements" : [ {
|
"fileReplacements": [
|
||||||
"replace" : "src/environments/environment.ts",
|
{
|
||||||
"with" : "src/environments/environment.prod.ts"
|
"replace": "src/environments/environment.ts",
|
||||||
} ]
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"develop" : {
|
"develop": {
|
||||||
"optimization" : false,
|
"optimization": false,
|
||||||
"outputHashing" : "none",
|
"outputHashing": "none",
|
||||||
"sourceMap" : true,
|
"namedChunks": true,
|
||||||
"namedChunks" : true,
|
"aot": false,
|
||||||
"aot" : true,
|
"extractLicenses": true,
|
||||||
"extractLicenses" : true,
|
"vendorChunk": true,
|
||||||
"vendorChunk" : true,
|
"buildOptimizer": false,
|
||||||
"buildOptimizer" : false
|
"sourceMap": {
|
||||||
|
"scripts": true,
|
||||||
|
"styles": true,
|
||||||
|
"hidden": false,
|
||||||
|
"vendor": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"serve" : {
|
"serve": {
|
||||||
"builder" : "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"options" : {
|
"options": {
|
||||||
"browserTarget" : "karusic:build"
|
"buildTarget": "karusic:build"
|
||||||
},
|
},
|
||||||
"configurations" : {
|
"configurations": {
|
||||||
"production" : {
|
"production": {
|
||||||
"browserTarget" : "karusic:build:production"
|
"buildTarget": "karusic:build:production"
|
||||||
},
|
},
|
||||||
"develop" : {
|
"develop": {
|
||||||
"browserTarget" : "karusic:build:develop"
|
"buildTarget": "karusic:build:develop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extract-i18n" : {
|
"extract-i18n": {
|
||||||
"builder" : "@angular-devkit/build-angular:extract-i18n",
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
"options" : {
|
"options": {
|
||||||
"browserTarget" : "karusic:build"
|
"buildTarget": "karusic:build"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test" : {
|
"test": {
|
||||||
"builder" : "@angular-devkit/build-angular:karma",
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
"options" : {
|
"options": {
|
||||||
"main" : "src/test.ts",
|
"main": "src/test.ts",
|
||||||
"karmaConfig" : "./karma.conf.js",
|
"karmaConfig": "./karma.conf.js",
|
||||||
"polyfills" : "src/polyfills.ts",
|
"polyfills": [
|
||||||
"tsConfig" : "src/tsconfig.spec.json",
|
"zone.js"
|
||||||
"scripts" : [ ],
|
],
|
||||||
"styles" : [ "src/styles.less", "src/generic_page.less", "src/theme.color.blue.less", "src/theme.checkbox.less", "src/theme.modal.less" ],
|
"tsConfig": "src/tsconfig.spec.json",
|
||||||
"assets" : [ "src/assets", "src/favicon.ico" ]
|
"scripts": [],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.less",
|
||||||
|
"src/generic_page.less",
|
||||||
|
"src/theme.color.blue.less",
|
||||||
|
"src/theme.checkbox.less",
|
||||||
|
"src/theme.modal.less"
|
||||||
|
],
|
||||||
|
"assets": [
|
||||||
|
"src/assets",
|
||||||
|
"src/favicon.ico"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint" : {
|
"lint": {
|
||||||
"builder" : "@angular-eslint/builder:lint",
|
"builder": "@angular-eslint/builder:lint",
|
||||||
"options" : {
|
"options": {
|
||||||
"fix": true,
|
"fix": true,
|
||||||
"eslintConfig": ".eslintrc.js",
|
"eslintConfig": ".eslintrc.js",
|
||||||
"lintFilePatterns": [
|
"lintFilePatterns": [
|
||||||
@@ -91,44 +120,53 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TTTTTTlint" : {
|
"TTTTTTlint": {
|
||||||
"builder" : "@angular-devkit/build-angular:tslint",
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
"options" : {
|
"options": {
|
||||||
"tsConfig" : [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ],
|
"tsConfig": [
|
||||||
"exclude" : [ "**/node_modules/**" ]
|
"src/tsconfig.app.json",
|
||||||
|
"src/tsconfig.spec.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"karusic-e2e" : {
|
"karusic-e2e": {
|
||||||
"root" : "e2e",
|
"root": "e2e",
|
||||||
"sourceRoot" : "e2e",
|
"sourceRoot": "e2e",
|
||||||
"projectType" : "application",
|
"projectType": "application",
|
||||||
"architect" : {
|
"architect": {
|
||||||
"e2e" : {
|
"e2e": {
|
||||||
"builder" : "@angular-devkit/build-angular:protractor",
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
"options" : {
|
"options": {
|
||||||
"protractorConfig" : "./protractor.conf.js",
|
"protractorConfig": "./protractor.conf.js",
|
||||||
"devServerTarget" : "karusic:serve"
|
"devServerTarget": "karusic:serve"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint" : {
|
"lint": {
|
||||||
"builder" : "@angular-devkit/build-angular:tslint",
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
"options" : {
|
"options": {
|
||||||
"tsConfig" : [ "e2e/tsconfig.e2e.json" ],
|
"tsConfig": [
|
||||||
"exclude" : [ "**/node_modules/**" ]
|
"e2e/tsconfig.e2e.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schematics" : {
|
"schematics": {
|
||||||
"@schematics/angular:component" : {
|
"@schematics/angular:component": {
|
||||||
"prefix" : "app",
|
"prefix": "app",
|
||||||
"style" : "less"
|
"style": "less"
|
||||||
},
|
},
|
||||||
"@schematics/angular:directive" : {
|
"@schematics/angular:directive": {
|
||||||
"prefix" : "app"
|
"prefix": "app"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21733
front/package-lock.json
generated
21733
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,40 +1,49 @@
|
|||||||
{
|
{
|
||||||
"name": "karusic",
|
"name": "karusic",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MPL-2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"all": "npm run build && npm run test",
|
"all": "npm run build && pnpm run test",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve --configuration=develop --watch --port 4203",
|
"dev": "ng serve --configuration=develop --watch --port 4203",
|
||||||
"build": "ng build --prod",
|
"build": "ng build --prod",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e"
|
"style": "prettier --write .",
|
||||||
|
"e2e": "ng e2e",
|
||||||
|
"update_packages": "ncu --upgrade",
|
||||||
|
"install_dependency": "pnpm install --force",
|
||||||
|
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||||
|
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^14.2.10",
|
"@angular/animations": "^17.3.4",
|
||||||
"@angular/cdk": "^14.2.7",
|
"@angular/cdk": "^17.3.4",
|
||||||
"@angular/common": "^14.2.10",
|
"@angular/common": "^17.3.4",
|
||||||
"@angular/compiler": "^14.2.10",
|
"@angular/compiler": "^17.3.4",
|
||||||
"@angular/core": "^14.2.10",
|
"@angular/core": "^17.3.4",
|
||||||
"@angular/forms": "^14.2.10",
|
"@angular/forms": "^17.3.4",
|
||||||
"@angular/material": "^14.2.7",
|
"@angular/material": "^17.3.4",
|
||||||
"@angular/platform-browser": "^14.2.10",
|
"@angular/platform-browser": "^17.3.4",
|
||||||
"@angular/platform-browser-dynamic": "^14.2.10",
|
"@angular/platform-browser-dynamic": "^17.3.4",
|
||||||
"@angular/router": "^14.2.10",
|
"@angular/router": "^17.3.4",
|
||||||
"rxjs": "^7.5.7",
|
"rxjs": "^7.8.1",
|
||||||
"zone.js": "^0.12.0"
|
"zone.js": "^0.14.4",
|
||||||
|
"zod": "3.22.4",
|
||||||
|
"@kangaroo-and-rabbit/kar-cw": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^14.2.9",
|
"@angular-devkit/build-angular": "^17.3.4",
|
||||||
"@angular-eslint/builder": "14.2.0",
|
"@angular-eslint/builder": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin": "14.2.0",
|
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "14.2.0",
|
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||||
"@angular-eslint/schematics": "14.2.0",
|
"@angular-eslint/schematics": "17.3.0",
|
||||||
"@angular-eslint/template-parser": "14.2.0",
|
"@angular-eslint/template-parser": "17.3.0",
|
||||||
"@angular/cli": "^14.2.9",
|
"@angular/cli": "^17.3.4",
|
||||||
"@angular/compiler-cli": "^14.2.10",
|
"@angular/compiler-cli": "^17.3.4",
|
||||||
"@angular/language-service": "^14.2.10"
|
"@angular/language-service": "^17.3.4",
|
||||||
|
"npm-check-updates": "^16.14.18",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
9705
front/pnpm-lock.yaml
generated
Normal file
9705
front/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,11 +6,12 @@
|
|||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
||||||
import { ForbiddenScene, HomeOutScene, NotFound404Scene, SsoScene } from 'common/scene';
|
|
||||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service';
|
|
||||||
|
|
||||||
import { HelpScene, HomeScene, AlbumEditScene, AlbumsScene, ArtistEditScene, ArtistScene, SettingsScene,
|
import {
|
||||||
GenderScene, PlaylistScene, TrackEditScene, TrackScene, UploadScene, ArtistsScene, ArtistAlbumScene, AlbumScene } from './scene';
|
HelpScene, HomeScene, AlbumEditScene, AlbumsScene, ArtistEditScene, ArtistScene, SettingsScene,
|
||||||
|
GenderScene, PlaylistScene, TrackEditScene, TrackScene, UploadScene, ArtistsScene, ArtistAlbumScene, AlbumScene
|
||||||
|
} from './scene';
|
||||||
|
import { ForbiddenScene, OnlyUsersGuardHome, HomeOutScene, OnlyUnregisteredGuardHome, SsoScene, OnlyAdminGuard, OnlyUsersGuard, NotFound404Scene } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
// import { HelpComponent } from './help/help.component';
|
// import { HelpComponent } from './help/help.component';
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ const routes: Routes = [
|
|||||||
component: GenderScene,
|
component: GenderScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
// display all (artist | album | traks)
|
// display all (artist | album | tracks)
|
||||||
{
|
{
|
||||||
path: 'gender/:genderId',
|
path: 'gender/:genderId',
|
||||||
component: GenderScene,
|
component: GenderScene,
|
||||||
@@ -107,16 +108,16 @@ const routes: Routes = [
|
|||||||
component: ArtistScene,
|
component: ArtistScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'artist/:artistId/edit',
|
||||||
|
component: ArtistEditScene,
|
||||||
|
canActivate: [OnlyAdminGuard],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'artist/:artistId/:albumId',
|
path: 'artist/:artistId/:albumId',
|
||||||
component: ArtistAlbumScene,
|
component: ArtistAlbumScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'artist-edit/:artistId',
|
|
||||||
component: ArtistEditScene,
|
|
||||||
canActivate: [OnlyAdminGuard],
|
|
||||||
},
|
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// -- Album:
|
// -- Album:
|
||||||
@@ -127,30 +128,30 @@ const routes: Routes = [
|
|||||||
component: AlbumsScene,
|
component: AlbumsScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'album/:albumId/edit',
|
||||||
|
component: AlbumEditScene,
|
||||||
|
canActivate: [OnlyAdminGuard],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'album/:albumId',
|
path: 'album/:albumId',
|
||||||
component: AlbumScene,
|
component: AlbumScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'album-edit/:albumId',
|
|
||||||
component: AlbumEditScene,
|
|
||||||
canActivate: [OnlyAdminGuard],
|
|
||||||
},
|
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// -- Tracks:
|
// -- Tracks:
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
{
|
||||||
|
path: 'track/:trackId/edit',
|
||||||
|
component: TrackEditScene,
|
||||||
|
canActivate: [OnlyAdminGuard],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'track/:genderId/:artistId/:albumId/:trackId',
|
path: 'track/:genderId/:artistId/:albumId/:trackId',
|
||||||
component: TrackScene,
|
component: TrackScene,
|
||||||
canActivate: [OnlyUsersGuard],
|
canActivate: [OnlyUsersGuard],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'track-edit/:trackId',
|
|
||||||
component: TrackEditScene,
|
|
||||||
canActivate: [OnlyAdminGuard],
|
|
||||||
},
|
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// -- setting:
|
// -- setting:
|
||||||
@@ -164,7 +165,6 @@ const routes: Routes = [
|
|||||||
path: '**',
|
path: '**',
|
||||||
component: NotFound404Scene,
|
component: NotFound404Scene,
|
||||||
},
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -181,5 +181,4 @@ const routes: Routes = [
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule { }
|
export class AppRoutingModule { }
|
||||||
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
<!-- Generig global menu -->
|
<!-- Generic global menu -->
|
||||||
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
|
<karcw-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"/>
|
||||||
<!-- all interfaced pages -->
|
<!-- all interfaced pages -->
|
||||||
<div class="main-content" *ngIf="autoConnectedDone">
|
<div class="main-content">
|
||||||
|
@if(autoConnectedDone) {
|
||||||
<router-outlet ></router-outlet>
|
<router-outlet ></router-outlet>
|
||||||
</div>
|
}
|
||||||
<div class="main-content" *ngIf="!autoConnectedDone">
|
@else {
|
||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-all colomn_mutiple">
|
<div class="fill-all colomn_mutiple">
|
||||||
<b style="color:red;">Auto-connection in progress</b>
|
<b style="color:red;">Auto-connection in progress</b>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<app-element-player-audio></app-element-player-audio>
|
<app-element-player-audio></app-element-player-audio>
|
||||||
|
|||||||
@@ -5,12 +5,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
|
||||||
import { MenuItem, MenuPosition } from 'common/model';
|
|
||||||
import { UserService, SessionService, SSOService } from 'common/service';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
import { ArianeService } from './service';
|
import { ArianeService } from './service';
|
||||||
import { UserRoles222 } from 'common/service/session';
|
import {
|
||||||
|
MenuItem,
|
||||||
|
SSOService,
|
||||||
|
SessionService,
|
||||||
|
UserService,
|
||||||
|
UserRoles222,
|
||||||
|
EventOnMenu,
|
||||||
|
MenuPosition,
|
||||||
|
isNullOrUndefined,
|
||||||
|
} from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
enum MenuEventType {
|
enum MenuEventType {
|
||||||
SSO_LOGIN = "SSO_CALL_LOGIN",
|
SSO_LOGIN = "SSO_CALL_LOGIN",
|
||||||
@@ -40,10 +45,11 @@ export class AppComponent implements OnInit {
|
|||||||
location: string = "home";
|
location: string = "home";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
|
||||||
private sessionService: SessionService,
|
private sessionService: SessionService,
|
||||||
private ssoService: SSOService,
|
private ssoService: SSOService,
|
||||||
private arianeService: ArianeService) {
|
private arianeService: ArianeService,
|
||||||
|
private userService: UserService
|
||||||
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +59,7 @@ export class AppComponent implements OnInit {
|
|||||||
this.updateMainMenu();
|
this.updateMainMenu();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.sessionService.change.subscribe((isConnected) => {
|
this.sessionService.change.subscribe((isConnected) => {
|
||||||
console.log(`receive event from session ...${ isConnected}`);
|
console.log(`receive event from session ...${isConnected}`);
|
||||||
self.isConnected = isConnected;
|
self.isConnected = isConnected;
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
self.updateMainMenu();
|
self.updateMainMenu();
|
||||||
@@ -105,9 +111,8 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventOnMenu(data: EventOnMenu): void {
|
eventOnMenu(data: EventOnMenu): void {
|
||||||
//console.log(`plopppppppppp ${JSON.stringify(this.route.snapshot.url)}`);
|
console.log(`Get event on menu: ${JSON.stringify(data, null, 4)}`);
|
||||||
//console.log(`Get event on menu: ${JSON.stringify(data, null, 4)}`);
|
switch (data.menu.otherData) {
|
||||||
switch(data.menu.otherData) {
|
|
||||||
case MenuEventType.SSO_LOGIN:
|
case MenuEventType.SSO_LOGIN:
|
||||||
this.ssoService.requestSignIn();
|
this.ssoService.requestSignIn();
|
||||||
break;
|
break;
|
||||||
@@ -118,15 +123,15 @@ export class AppComponent implements OnInit {
|
|||||||
this.ssoService.requestSignUp();
|
this.ssoService.requestSignUp();
|
||||||
break;
|
break;
|
||||||
case MenuEventType.SEGMENT:
|
case MenuEventType.SEGMENT:
|
||||||
if(this.arianeService.getCurrrentSegment() === "artist") {
|
if (this.arianeService.getCurrrentSegment() === "artist") {
|
||||||
this.arianeService.navigateArtist({});
|
this.arianeService.navigateArtist({});
|
||||||
} else if(this.arianeService.getCurrrentSegment() === "gender") {
|
} else if (this.arianeService.getCurrrentSegment() === "gender") {
|
||||||
this.arianeService.navigateGender({});
|
this.arianeService.navigateGender({});
|
||||||
} else if(this.arianeService.getCurrrentSegment() === "playlist") {
|
} else if (this.arianeService.getCurrrentSegment() === "playlist") {
|
||||||
this.arianeService.navigatePlaylist({});
|
this.arianeService.navigatePlaylist({});
|
||||||
} else if(this.arianeService.getCurrrentSegment() === "track") {
|
} else if (this.arianeService.getCurrrentSegment() === "track") {
|
||||||
this.arianeService.navigateTrack({});
|
this.arianeService.navigateTrack({});
|
||||||
} else if(this.arianeService.getCurrrentSegment() === "album") {
|
} else if (this.arianeService.getCurrrentSegment() === "album") {
|
||||||
this.arianeService.navigateAlbum({});
|
this.arianeService.navigateAlbum({});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -134,8 +139,8 @@ export class AppComponent implements OnInit {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case MenuEventType.ARTIST:
|
case MenuEventType.ARTIST:
|
||||||
if(this.arianeService.getCurrrentSegment() === "artist") {
|
if (this.arianeService.getCurrrentSegment() === "artist") {
|
||||||
this.arianeService.navigateArtist({artistId: this.arianeService.getArtistId()});
|
this.arianeService.navigateArtist({ artistId: this.arianeService.getArtistId() });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MenuEventType.ALBUM:
|
case MenuEventType.ALBUM:
|
||||||
@@ -145,15 +150,15 @@ export class AppComponent implements OnInit {
|
|||||||
case MenuEventType.PLAYLIST:
|
case MenuEventType.PLAYLIST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
updateMainMenu(): void {
|
updateMainMenu(): void {
|
||||||
console.log("update main menu :");
|
console.log("update main menu :");
|
||||||
|
|
||||||
if (this.isConnected) {
|
if (this.isConnected) {
|
||||||
this.currentMenu = [
|
this.currentMenu = [
|
||||||
{
|
{
|
||||||
position: MenuPosition.LEFT,
|
position: MenuPosition.LEFT,
|
||||||
hover: `You are logged as: ${this.sessionService.getLogin()}`,
|
hover: "lkjljlk", //`You are logged as: ${this.sessionService.getLogin()}`,
|
||||||
icon: "menu",
|
icon: "menu",
|
||||||
title: "Menu",
|
title: "Menu",
|
||||||
subMenu: [
|
subMenu: [
|
||||||
@@ -201,13 +206,13 @@ export class AppComponent implements OnInit {
|
|||||||
}, {
|
}, {
|
||||||
position: MenuPosition.LEFT,
|
position: MenuPosition.LEFT,
|
||||||
icon: "queue_music",
|
icon: "queue_music",
|
||||||
title: this.arianeService.getPlaylistName(),
|
title: "true",//this.arianeService.getPlaylistName(),
|
||||||
otherData: MenuEventType.PLAYLIST,
|
otherData: MenuEventType.PLAYLIST,
|
||||||
callback: true,
|
callback: true,
|
||||||
enable: !isNullOrUndefined(this.arianeService.getPlaylistId()),
|
enable: !isNullOrUndefined(this.arianeService.getPlaylistId()),
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},{
|
}, {
|
||||||
position: MenuPosition.RIGHT,
|
position: MenuPosition.RIGHT,
|
||||||
image: "assets/images/avatar_generic.svg",
|
image: "assets/images/avatar_generic.svg",
|
||||||
title: "",
|
title: "",
|
||||||
@@ -257,7 +262,7 @@ export class AppComponent implements OnInit {
|
|||||||
icon: "add_circle_outline",
|
icon: "add_circle_outline",
|
||||||
title: "Sign-up",
|
title: "Sign-up",
|
||||||
callback: true,
|
callback: true,
|
||||||
model: this.signUpEnable?undefined:"disable",
|
model: this.signUpEnable ? undefined : "disable",
|
||||||
otherData: MenuEventType.SSO_SIGNUP,
|
otherData: MenuEventType.SSO_SIGNUP,
|
||||||
}, {
|
}, {
|
||||||
position: MenuPosition.RIGHT,
|
position: MenuPosition.RIGHT,
|
||||||
@@ -287,7 +292,7 @@ export class AppComponent implements OnInit {
|
|||||||
return "Tracks"
|
return "Tracks"
|
||||||
}
|
}
|
||||||
if (segment === "playlist") {
|
if (segment === "playlist") {
|
||||||
return "Playlistq"
|
return "Playlist"
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
@@ -22,8 +22,13 @@ import {
|
|||||||
} from './scene';
|
} from './scene';
|
||||||
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
|
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
|
||||||
import { UploadScene } from './scene/upload/upload';
|
import { UploadScene } from './scene/upload/upload';
|
||||||
import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent } from './component';
|
import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent, DescriptionAreaComponent } from './component';
|
||||||
import { common_module_declarations, common_module_imports, common_module_providers, common_module_exports } from 'common/module';
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
|
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -35,8 +40,8 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
ElementSeasonComponent,
|
ElementSeasonComponent,
|
||||||
ElementVideoComponent,
|
ElementVideoComponent,
|
||||||
ElementPlayerAudioComponent,
|
ElementPlayerAudioComponent,
|
||||||
|
DescriptionAreaComponent,
|
||||||
PopInCreateType,
|
PopInCreateType,
|
||||||
|
|
||||||
HomeScene,
|
HomeScene,
|
||||||
HelpScene,
|
HelpScene,
|
||||||
GenderScene,
|
GenderScene,
|
||||||
@@ -52,16 +57,21 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
AlbumEditScene,
|
AlbumEditScene,
|
||||||
ArtistEditScene,
|
ArtistEditScene,
|
||||||
UploadScene,
|
UploadScene,
|
||||||
...common_module_declarations,
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
CommonModule,
|
||||||
|
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
...common_module_imports,
|
KarCWModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||||
|
ArianeService,
|
||||||
PlayerService,
|
PlayerService,
|
||||||
GenderService,
|
GenderService,
|
||||||
DataService,
|
DataService,
|
||||||
@@ -69,8 +79,6 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
ArtistService,
|
ArtistService,
|
||||||
AlbumService,
|
AlbumService,
|
||||||
TrackService,
|
TrackService,
|
||||||
ArianeService,
|
|
||||||
...common_module_providers,
|
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
@@ -79,16 +87,10 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
ElementSeasonComponent,
|
ElementSeasonComponent,
|
||||||
ElementVideoComponent,
|
ElementVideoComponent,
|
||||||
PopInCreateType,
|
PopInCreateType,
|
||||||
...common_module_exports,
|
|
||||||
],
|
],
|
||||||
bootstrap: [
|
bootstrap: [
|
||||||
AppComponent
|
AppComponent
|
||||||
],
|
],
|
||||||
/*
|
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||||
schemas: [
|
|
||||||
CUSTOM_ELEMENTS_SCHEMA,
|
|
||||||
NO_ERRORS_SCHEMA
|
|
||||||
]
|
|
||||||
*/
|
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
||||||
|
|||||||
190
front/src/app/back-api/album-resource.ts
Normal file
190
front/src/app/back-api/album-resource.ts
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {UUID, Long, Album, isAlbum, } from "./model"
|
||||||
|
export namespace AlbumResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific album
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Album with his ID
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Update a specific album
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Album,
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Add an album (when all the data already exist)
|
||||||
|
*/
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Album,
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all the available Albums
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Album[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Add a Track on a specific album
|
||||||
|
*/
|
||||||
|
export function addTrack({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
trackId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}/track/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a Track on a specific album
|
||||||
|
*/
|
||||||
|
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,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
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,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
}
|
||||||
127
front/src/app/back-api/artist-resource.ts
Normal file
127
front/src/app/back-api/artist-resource.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
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, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Artist,
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Artist,
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Artist[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
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,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
|
}
|
||||||
104
front/src/app/back-api/data-resource.ts
Normal file
104
front/src/app/back-api/data-resource.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {UUID, } 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: {
|
||||||
|
Authorization: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
id: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 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: {
|
||||||
|
Authorization: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
id: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/thumbnail/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get back some data from the data environment (with a beautiful 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: {
|
||||||
|
Authorization: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
name: string,
|
||||||
|
id: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{id}/{name}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
8
front/src/app/back-api/front.ts
Normal file
8
front/src/app/back-api/front.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {} from "./model"
|
||||||
|
export namespace Front {
|
||||||
|
|
||||||
|
}
|
||||||
127
front/src/app/back-api/gender-resource.ts
Normal file
127
front/src/app/back-api/gender-resource.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
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, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isGender);
|
||||||
|
};
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Gender,
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isGender);
|
||||||
|
};
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Gender,
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
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: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isGender);
|
||||||
|
};
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isGender);
|
||||||
|
};
|
||||||
|
}
|
||||||
20
front/src/app/back-api/health-check.ts
Normal file
20
front/src/app/back-api/health-check.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {HealthResult, isHealthResult, } from "./model"
|
||||||
|
export namespace HealthCheck {
|
||||||
|
|
||||||
|
export function getHealth({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<HealthResult> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/health_check",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isHealthResult);
|
||||||
|
};
|
||||||
|
}
|
||||||
13
front/src/app/back-api/index.ts
Normal file
13
front/src/app/back-api/index.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Global import of the package
|
||||||
|
*/
|
||||||
|
export * from "./model";
|
||||||
|
export * from "./album-resource";
|
||||||
|
export * from "./artist-resource";
|
||||||
|
export * from "./front";
|
||||||
|
export * from "./gender-resource";
|
||||||
|
export * from "./health-check";
|
||||||
|
export * from "./playlist-resource";
|
||||||
|
export * from "./user-resource";
|
||||||
|
export * from "./track-resource";
|
||||||
|
export * from "./data-resource";
|
||||||
407
front/src/app/back-api/model.ts
Normal file
407
front/src/app/back-api/model.ts
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
export const ZodUUID = zod.string().uuid();
|
||||||
|
export type UUID = zod.infer<typeof ZodUUID>;
|
||||||
|
export function isUUID(data: any): data is UUID {
|
||||||
|
try {
|
||||||
|
ZodUUID.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLong = zod.number();
|
||||||
|
export type Long = zod.infer<typeof ZodLong>;
|
||||||
|
export function isLong(data: any): data is Long {
|
||||||
|
try {
|
||||||
|
ZodLong.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodInteger = zod.number().safe();
|
||||||
|
export type Integer = zod.infer<typeof ZodInteger>;
|
||||||
|
export function isInteger(data: any): data is Integer {
|
||||||
|
try {
|
||||||
|
ZodInteger.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodFloat = zod.number();
|
||||||
|
export type Float = zod.infer<typeof ZodFloat>;
|
||||||
|
export function isFloat(data: any): data is Float {
|
||||||
|
try {
|
||||||
|
ZodFloat.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodInstant = zod.string();
|
||||||
|
export type Instant = zod.infer<typeof ZodInstant>;
|
||||||
|
export function isInstant(data: any): data is Instant {
|
||||||
|
try {
|
||||||
|
ZodInstant.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodDate = zod.date();
|
||||||
|
export type Date = zod.infer<typeof ZodDate>;
|
||||||
|
export function isDate(data: any): data is Date {
|
||||||
|
try {
|
||||||
|
ZodDate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodTimestamp = zod.date();
|
||||||
|
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
||||||
|
export function isTimestamp(data: any): data is Timestamp {
|
||||||
|
try {
|
||||||
|
ZodTimestamp.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLocalDate = zod.date();
|
||||||
|
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
||||||
|
export function isLocalDate(data: any): data is LocalDate {
|
||||||
|
try {
|
||||||
|
ZodLocalDate.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLocalTime = zod.date();
|
||||||
|
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
||||||
|
export function isLocalTime(data: any): data is LocalTime {
|
||||||
|
try {
|
||||||
|
ZodLocalTime.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodRestErrorResponse = zod.object({
|
||||||
|
uuid: ZodUUID.optional(),
|
||||||
|
time: zod.string().max(255).optional(),
|
||||||
|
error: zod.string().max(255).optional(),
|
||||||
|
message: zod.string().max(255).optional(),
|
||||||
|
status: ZodInteger,
|
||||||
|
statusMessage: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||||
|
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||||
|
try {
|
||||||
|
ZodRestErrorResponse.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(),
|
||||||
|
// When update the object
|
||||||
|
updatedAt: ZodDate.readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||||
|
export function isGenericTiming(data: any): data is GenericTiming {
|
||||||
|
try {
|
||||||
|
ZodGenericTiming.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
|
// Unique Id of the object
|
||||||
|
id: ZodLong.readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||||
|
export function isGenericData(data: any): data is GenericData {
|
||||||
|
try {
|
||||||
|
ZodGenericData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
|
// Deleted state
|
||||||
|
deleted: zod.boolean().readonly().optional()
|
||||||
|
});
|
||||||
|
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||||
|
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||||
|
try {
|
||||||
|
ZodGenericDataSoftDelete.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().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 {
|
||||||
|
try {
|
||||||
|
ZodNodeSmall.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodAlbum = ZodNodeSmall.extend({
|
||||||
|
publication: ZodLocalDate.optional()
|
||||||
|
});
|
||||||
|
export type Album = zod.infer<typeof ZodAlbum>;
|
||||||
|
export function isAlbum(data: any): data is Album {
|
||||||
|
try {
|
||||||
|
ZodAlbum.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(),
|
||||||
|
birth: ZodLocalDate.optional(),
|
||||||
|
death: ZodLocalDate.optional()
|
||||||
|
});
|
||||||
|
export type Artist = zod.infer<typeof ZodArtist>;
|
||||||
|
export function isArtist(data: any): data is Artist {
|
||||||
|
try {
|
||||||
|
ZodArtist.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodGender = ZodNodeSmall.extend({
|
||||||
|
});
|
||||||
|
export type Gender = zod.infer<typeof ZodGender>;
|
||||||
|
export function isGender(data: any): data is Gender {
|
||||||
|
try {
|
||||||
|
ZodGender.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodHealthResult = zod.object({
|
||||||
|
});
|
||||||
|
export type HealthResult = zod.infer<typeof ZodHealthResult>;
|
||||||
|
export function isHealthResult(data: any): data is HealthResult {
|
||||||
|
try {
|
||||||
|
ZodHealthResult.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodPlaylist = ZodNodeSmall.extend({
|
||||||
|
tracks: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type Playlist = zod.infer<typeof ZodPlaylist>;
|
||||||
|
export function isPlaylist(data: any): data is Playlist {
|
||||||
|
try {
|
||||||
|
ZodPlaylist.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
|
login: zod.string().max(128).optional(),
|
||||||
|
lastConnection: ZodTimestamp.optional(),
|
||||||
|
admin: zod.boolean(),
|
||||||
|
blocked: zod.boolean(),
|
||||||
|
removed: zod.boolean(),
|
||||||
|
covers: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type User = zod.infer<typeof ZodUser>;
|
||||||
|
export function isUser(data: any): data is User {
|
||||||
|
try {
|
||||||
|
ZodUser.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserKarusic = ZodUser.extend({
|
||||||
|
});
|
||||||
|
export type UserKarusic = zod.infer<typeof ZodUserKarusic>;
|
||||||
|
export function isUserKarusic(data: any): data is UserKarusic {
|
||||||
|
try {
|
||||||
|
ZodUserKarusic.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserOut = zod.object({
|
||||||
|
id: ZodLong,
|
||||||
|
login: zod.string().max(255).optional()
|
||||||
|
});
|
||||||
|
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||||
|
export function isUserOut(data: any): data is UserOut {
|
||||||
|
try {
|
||||||
|
ZodUserOut.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodTrack = ZodNodeSmall.extend({
|
||||||
|
genderId: ZodLong.optional(),
|
||||||
|
albumId: ZodLong.optional(),
|
||||||
|
track: ZodLong.optional(),
|
||||||
|
dataId: ZodUUID.optional(),
|
||||||
|
artists: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type Track = zod.infer<typeof ZodTrack>;
|
||||||
|
export function isTrack(data: any): data is Track {
|
||||||
|
try {
|
||||||
|
ZodTrack.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUUIDGenericData = ZodGenericTiming.extend({
|
||||||
|
// Unique UUID of the object
|
||||||
|
id: ZodUUID.readonly().optional()
|
||||||
|
});
|
||||||
|
export type UUIDGenericData = zod.infer<typeof ZodUUIDGenericData>;
|
||||||
|
export function isUUIDGenericData(data: any): data is UUIDGenericData {
|
||||||
|
try {
|
||||||
|
ZodUUIDGenericData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUUIDGenericDataSoftDelete = ZodUUIDGenericData.extend({
|
||||||
|
// Deleted state
|
||||||
|
deleted: zod.boolean().readonly().optional()
|
||||||
|
});
|
||||||
|
export type UUIDGenericDataSoftDelete = zod.infer<typeof ZodUUIDGenericDataSoftDelete>;
|
||||||
|
export function isUUIDGenericDataSoftDelete(data: any): data is UUIDGenericDataSoftDelete {
|
||||||
|
try {
|
||||||
|
ZodUUIDGenericDataSoftDelete.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodData = ZodUUIDGenericDataSoftDelete.extend({
|
||||||
|
// Sha512 of the data
|
||||||
|
sha512: zod.string().max(128).optional(),
|
||||||
|
// Mime -type of the media
|
||||||
|
mimeType: zod.string().max(128).optional(),
|
||||||
|
// Size in Byte of the data
|
||||||
|
size: ZodLong.optional()
|
||||||
|
});
|
||||||
|
export type Data = zod.infer<typeof ZodData>;
|
||||||
|
export function isData(data: any): data is Data {
|
||||||
|
try {
|
||||||
|
ZodData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
163
front/src/app/back-api/playlist-resource.ts
Normal file
163
front/src/app/back-api/playlist-resource.ts
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
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, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Playlist,
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Playlist,
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Playlist[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function addTrack({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
trackId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/track/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function removeTrack({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
trackId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/track/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
}
|
||||||
246
front/src/app/back-api/rest-tools.ts
Normal file
246
front/src/app/back-api/rest-tools.ts
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2024, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL-2
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { RestErrorResponse } from "./model"
|
||||||
|
|
||||||
|
export enum HTTPRequestModel {
|
||||||
|
DELETE = 'DELETE',
|
||||||
|
GET = 'GET',
|
||||||
|
PATCH = 'PATCH',
|
||||||
|
POST = 'POST',
|
||||||
|
PUT = 'PUT',
|
||||||
|
}
|
||||||
|
export enum HTTPMimeType {
|
||||||
|
ALL = '*/*',
|
||||||
|
CSV = 'text/csv',
|
||||||
|
IMAGE = 'image/*',
|
||||||
|
IMAGE_JPEG = 'image/jpeg',
|
||||||
|
IMAGE_PNG = 'image/png',
|
||||||
|
JSON = 'application/json',
|
||||||
|
MULTIPART = 'multipart/form-data',
|
||||||
|
OCTET_STREAM = 'application/octet-stream',
|
||||||
|
TEXT_PLAIN = 'text/plain',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RESTConfig {
|
||||||
|
// base of the server: http(s)://my.server.org/plop/api/
|
||||||
|
server: string;
|
||||||
|
// Token to access of the data.
|
||||||
|
token?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RESTModel {
|
||||||
|
// base of the local API request: "sheep/{id}".
|
||||||
|
endPoint: string;
|
||||||
|
// Type of the request.
|
||||||
|
requestType?: HTTPRequestModel;
|
||||||
|
// Input type requested.
|
||||||
|
accept?: HTTPMimeType;
|
||||||
|
// Content of the local data.
|
||||||
|
contentType?: HTTPMimeType;
|
||||||
|
// Mode of the TOKEN in urk or Header
|
||||||
|
tokenInUrl?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelResponseHttp {
|
||||||
|
status: number;
|
||||||
|
data: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isArrayOf<TYPE>(
|
||||||
|
data: any,
|
||||||
|
typeChecker: (subData: any) => subData is TYPE,
|
||||||
|
length?: number
|
||||||
|
): data is TYPE[] {
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.every(typeChecker)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (length !== undefined && data.length != length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RESTRequestType = {
|
||||||
|
restModel: RESTModel,
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data?: any,
|
||||||
|
params?: object,
|
||||||
|
queries?: object,
|
||||||
|
};
|
||||||
|
|
||||||
|
function removeTrailingSlashes(input: string): string {
|
||||||
|
return input.replace(/\/+$/, '');
|
||||||
|
}
|
||||||
|
function removeLeadingSlashes(input: string): string {
|
||||||
|
return input.replace(/^\/+/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTUrl({ restModel, restConfig, data, params, queries }: RESTRequestType): string {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||||
|
if (params !== undefined) {
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
||||||
|
return generateUrl;
|
||||||
|
}
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
if (queries !== undefined) {
|
||||||
|
for (let key of Object.keys(queries)) {
|
||||||
|
const value = queries[key];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
for (let iii = 0; iii < value.length; iii++) {
|
||||||
|
searchParams.append(`${key}`, `${value[iii]}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
searchParams.append(`${key}`, `${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||||
|
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
||||||
|
}
|
||||||
|
return generateUrl + "?" + searchParams.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequest({ restModel, restConfig, data, params, queries }: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
|
let headers: any = {};
|
||||||
|
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||||
|
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
||||||
|
}
|
||||||
|
if (restModel.accept !== undefined) {
|
||||||
|
headers['Accept'] = restModel.accept;
|
||||||
|
}
|
||||||
|
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||||
|
// if Get we have not a content type, the body is empty
|
||||||
|
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||||
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
|
headers['Content-Type'] = restModel.contentType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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) => {
|
||||||
|
fetch(generateUrl, {
|
||||||
|
method: restModel.requestType,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
}).then((response: Response) => {
|
||||||
|
if (response.status >= 200 && response.status <= 299) {
|
||||||
|
const contentType = response.headers.get('Content-Type');
|
||||||
|
if (restModel.accept !== contentType) {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 901,
|
||||||
|
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
||||||
|
statusMessage: "Fetch error",
|
||||||
|
message: "rest-tools.ts Wrong type in the message return type"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
} else if (contentType === HTTPMimeType.JSON) {
|
||||||
|
response
|
||||||
|
.json()
|
||||||
|
.then((value: any) => {
|
||||||
|
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
||||||
|
resolve({ status: response.status, data: value });
|
||||||
|
})
|
||||||
|
.catch((reason: any) => {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 902,
|
||||||
|
error: `REST parse json fail: ${reason}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
message: "rest-tools.ts Wrong message model to parse"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve({ status: response.status, data: response.body });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: response.status,
|
||||||
|
error: `${response.body}`,
|
||||||
|
statusMessage: "Fetch code error",
|
||||||
|
message: "rest-tools.ts Wrong return code"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((error: any) => {
|
||||||
|
reject({
|
||||||
|
time: Date(),
|
||||||
|
status: 999,
|
||||||
|
error: error,
|
||||||
|
statusMessage: "Fetch catch error",
|
||||||
|
message: "http-wrapper.ts detect an error in the fetch request"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
if (checker(value.data)) {
|
||||||
|
resolve(value.data);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 950,
|
||||||
|
error: "REST Fail to verify the data",
|
||||||
|
statusMessage: "API cast ERROR",
|
||||||
|
message: "api.ts Check type as fail"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
if (isArrayOf(value.data, checker)) {
|
||||||
|
resolve(value.data);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 950,
|
||||||
|
error: "REST Fail to verify the data",
|
||||||
|
statusMessage: "API cast ERROR",
|
||||||
|
message: "api.ts Check type as fail"
|
||||||
|
} as RestErrorResponse);
|
||||||
|
}
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
|
resolve();
|
||||||
|
}).catch((reason: RestErrorResponse) => {
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
186
front/src/app/back-api/track-resource.ts
Normal file
186
front/src/app/back-api/track-resource.ts
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
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, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function get({ 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 patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Track,
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Track,
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
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: {
|
||||||
|
artistId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/artist/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function uploadTrack({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
gender: string,
|
||||||
|
artist: string,
|
||||||
|
album: string,
|
||||||
|
trackId: Long,
|
||||||
|
title: string,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/upload/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
}
|
||||||
51
front/src/app/back-api/user-resource.ts
Normal file
51
front/src/app/back-api/user-resource.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
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, produce, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
|
}): Promise<UserKarusic> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: produce,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserKarusic);
|
||||||
|
};
|
||||||
|
export function gets({ restConfig, produce, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
|
}): Promise<UserKarusic[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
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({
|
@Component({
|
||||||
selector: 'data-image',
|
selector: 'data-image',
|
||||||
templateUrl: './data-image.html',
|
templateUrl: './data-image.html',
|
||||||
styleUrls: [ './data-image.less' ]
|
styleUrls: ['./data-image.less']
|
||||||
})
|
})
|
||||||
export class ElementDataImageComponent implements OnInit {
|
export class ElementDataImageComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() id:number = -1;
|
@Input() id: string = "0";
|
||||||
cover: string = '';
|
cover: string = '';
|
||||||
/*
|
/*
|
||||||
imageCanvas:any;
|
imageCanvas:any;
|
||||||
@ViewChild('imageCanvas')
|
@ViewChild('imageCanvas')
|
||||||
set mainDivEl(el: ElementRef) {
|
set mainDivEl(el: ElementRef) {
|
||||||
@@ -24,16 +24,16 @@ export class ElementDataImageComponent implements OnInit {
|
|||||||
this.imageCanvas = el.nativeElement;
|
this.imageCanvas = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
constructor(private dataService: DataService) {
|
constructor(private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.cover = this.dataService.getCoverThumbnailUrl(this.id);
|
this.cover = this.dataService.getThumbnailUrl(this.id);
|
||||||
/*
|
/*
|
||||||
let canvas = this.imageCanvas.nativeElement;
|
let canvas = this.imageCanvas.nativeElement;
|
||||||
let ctx = canvas.getContext("2d");
|
let ctx = canvas.getContext("2d");
|
||||||
console.log(`Request thumnail for ---> ${this.id}`);
|
console.log(`Request thumbnail for ---> ${this.id}`);
|
||||||
this.dataService.getImageThumbnail(this.id)
|
this.dataService.getImageThumbnail(this.id)
|
||||||
.then((result:ModelResponseHttp) => {
|
.then((result:ModelResponseHttp) => {
|
||||||
console.log(`plop ---> ${result.status}`);
|
console.log(`plop ---> ${result.status}`);
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<div class="fill-title">
|
||||||
|
<div class="description-area">
|
||||||
|
@if(title) {
|
||||||
|
<div class="shadow-text title">
|
||||||
|
{{title}}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if(name) {
|
||||||
|
<div class="shadow-text sub-title-main">
|
||||||
|
{{name}}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if(description) {
|
||||||
|
<div class="description">
|
||||||
|
{{description}}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="button-area">
|
||||||
|
<button class="circular-button" (click)="playAll($event)" type="submit">
|
||||||
|
<i class="material-icons">play_arrow</i>
|
||||||
|
</button>
|
||||||
|
<button class="circular-button" (click)="playShuffle($event)" type="submit">
|
||||||
|
<i class="material-icons">shuffle</i>
|
||||||
|
</button>
|
||||||
|
<div style="flex:1;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (cover1 && cover1.length > 0) {
|
||||||
|
<div class="cover-area">
|
||||||
|
<div class="cover">
|
||||||
|
<img src="{{cover1[0]}}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (cover2 && cover2.length > 0) {
|
||||||
|
<div class="cover-area">
|
||||||
|
<div class="cover">
|
||||||
|
<img src="{{cover2[0]}}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
31
front/src/app/component/description-area/description-area.ts
Normal file
31
front/src/app/component/description-area/description-area.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license PROPRIETARY (see license file)
|
||||||
|
*/
|
||||||
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'description-area',
|
||||||
|
templateUrl: './description-area.html',
|
||||||
|
styleUrls: ['./description-area.less']
|
||||||
|
})
|
||||||
|
export class DescriptionAreaComponent {
|
||||||
|
@Input() title: string;
|
||||||
|
@Input() name?: string;
|
||||||
|
@Input() description?: string;
|
||||||
|
@Input() cover1?: number[];
|
||||||
|
@Input() cover2?: number[];
|
||||||
|
|
||||||
|
@Output() play = new EventEmitter<void>();
|
||||||
|
@Output() shuffle = new EventEmitter<void>();
|
||||||
|
|
||||||
|
playShuffle(event: any): void {
|
||||||
|
this.shuffle.emit();
|
||||||
|
}
|
||||||
|
|
||||||
|
playAll(event: any): void {
|
||||||
|
this.play.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<div class="bottom" *ngIf="mediaSource">
|
@if(mediaSource) {
|
||||||
<div class="media" >
|
<div>
|
||||||
<div class="media-elem">
|
|
||||||
<audio width="1" height="1" src="{{mediaSource}}"
|
<audio width="1" height="1" src="{{mediaSource}}"
|
||||||
#mediaPlayer
|
#mediaPlayer
|
||||||
preload
|
preload
|
||||||
@@ -11,36 +10,43 @@
|
|||||||
(loadedmetadata)="changeMetadata()"
|
(loadedmetadata)="changeMetadata()"
|
||||||
autoplay
|
autoplay
|
||||||
(ended)="onAudioEnded()"
|
(ended)="onAudioEnded()"
|
||||||
><!-- controls > --> <!--preload="none"-->
|
>
|
||||||
<!--<p>Your browser does not support HTML5 media player. download media: <a href="{{mediaSource}}>link here</a>.</p>-->
|
|
||||||
</audio>
|
</audio>
|
||||||
</div>
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="timer">
|
<div class="controls-inner">
|
||||||
<div class="timer-title">
|
<div class="title text-ellipsis">
|
||||||
<label class="unselectable label">{{nameData}}</label>
|
<label class="unselectable">{{dataTitle}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="timer-lines">
|
<div class="text-ellipsis">
|
||||||
|
<label class="unselectable">{{dataAuthor}} / {{dataAlbum}}</label>
|
||||||
|
</div>
|
||||||
|
<div class="timer-slider">
|
||||||
<input type="range" min="0" class="slider"
|
<input type="range" min="0" class="slider"
|
||||||
[value]="currentTime"
|
[value]="currentTime"
|
||||||
[max]="duration"
|
[max]="duration"
|
||||||
(input)="seek($event.target)">
|
(input)="seek($event.target)">
|
||||||
</div>
|
</div>
|
||||||
<div class="timer-text">
|
<div class="flex-row">
|
||||||
<label class="unselectable label">{{currentTimeDisplay}} / {{durationDisplay}}</label>
|
<label class="unselectable">{{currentTimeDisplay}}</label>
|
||||||
|
<label class="unselectable flex-row-last">{{durationDisplay}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="timer-control">
|
<div class="control">
|
||||||
<button (click)="onPlay()" *ngIf="!isPlaying" ><i class="material-icons">play_arrow</i></button>
|
@if(!isPlaying) {
|
||||||
<button (click)="onPause()" *ngIf="isPlaying" ><i class="material-icons">pause</i></button>
|
<button (click)="onPlay()"><i class="material-icons">play_arrow</i></button>
|
||||||
<button (click)="onStop()" ><i class="material-icons">stop</i></button>
|
}
|
||||||
|
@else {
|
||||||
|
<button (click)="onPause()"><i class="material-icons">pause</i></button>
|
||||||
|
}
|
||||||
|
<button (click)="onStop()"><i class="material-icons">stop</i></button>
|
||||||
|
<div style="margin:auto"></div>
|
||||||
<button [disabled]="havePrevious" (click)="onBefore()"><i class="material-icons">navigate_before</i></button>
|
<button [disabled]="havePrevious" (click)="onBefore()"><i class="material-icons">navigate_before</i></button>
|
||||||
<button (click)="onRewind()"><i class="material-icons">fast_rewind</i></button>
|
<button (click)="onRewind()"><i class="material-icons">fast_rewind</i></button>
|
||||||
<button (click)="onForward()"><i class="material-icons">fast_forward</i></button>
|
<button (click)="onForward()"><i class="material-icons">fast_forward</i></button>
|
||||||
<button [disabled]="haveNext" (click)="onNext()"><i class="material-icons">navigate_next</i></button>
|
<button [disabled]="haveNext" (click)="onNext()"><i class="material-icons">navigate_next</i></button>
|
||||||
|
<div style="margin:auto"></div>
|
||||||
<button (click)="onPlayMode()"><i class="material-icons">{{playMode}}</i></button>
|
<button (click)="onPlayMode()"><i class="material-icons">{{playMode}}</i></button>
|
||||||
<!--<button (click)="onMore()" ><i class="material-icons">more_vert</i></button>-->
|
|
||||||
<!--<button (click)="onTakeScreenShoot()"><i class="material-icons">add_a_photo</i></button>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
|
.controls {
|
||||||
.bottom {
|
|
||||||
.controls {
|
|
||||||
//visibility: hidden;
|
//visibility: hidden;
|
||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
width: 96%;
|
width: 96%;
|
||||||
height: 150px;
|
//height: 150px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
@@ -15,10 +13,25 @@
|
|||||||
transition: 1s all;
|
transition: 1s all;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
|
min-width: 380px;
|
||||||
|
|
||||||
|
|
||||||
|
.controls-inner {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
min-width: 350px;
|
||||||
|
font-family: monospace;
|
||||||
|
color: white;
|
||||||
|
margin: 10px 15px 1px 15px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.material-icons {
|
.material-icons {
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
@@ -31,20 +44,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.slidecontainer {
|
|
||||||
line-height: 38px;
|
|
||||||
font-size: 10px;
|
|
||||||
font-family: monospace;
|
|
||||||
text-shadow: 1px 1px 0px black;
|
|
||||||
color: white;
|
|
||||||
flex: 5;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.slider {
|
.slider {
|
||||||
position: relative;
|
position: relative;
|
||||||
-webkit-appearance: none;
|
//-webkit-appearance: none;
|
||||||
//width: calc(100% - 60px);
|
width: 100%;
|
||||||
width: 95%;
|
|
||||||
height: 10px;
|
height: 10px;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -55,6 +58,7 @@
|
|||||||
transition: opacity .2s;
|
transition: opacity .2s;
|
||||||
flex: 5;
|
flex: 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider::-webkit-slider-thumb {
|
.slider::-webkit-slider-thumb {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
@@ -73,87 +77,37 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timer-title {
|
.text-ellipsis {
|
||||||
position: absolute;
|
overflow: hidden;
|
||||||
left: 30px;
|
text-overflow: ellipsis;
|
||||||
width: 100%;
|
white-space: nowrap;
|
||||||
font-size: 20px;
|
|
||||||
font-weight:bold;
|
|
||||||
bottom: 104px;
|
|
||||||
}
|
}
|
||||||
.timer-lines {
|
|
||||||
position: absolute;
|
|
||||||
left: 30px;
|
|
||||||
//width: calc(100%-60px);
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight:bold;
|
|
||||||
bottom: 82px;
|
|
||||||
}
|
|
||||||
.timer-text {
|
|
||||||
position: absolute;
|
|
||||||
left: 30px;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight:bold;
|
|
||||||
bottom: 40px;
|
|
||||||
}
|
|
||||||
.timer-control {
|
|
||||||
position: absolute;
|
|
||||||
//top: 25px;
|
|
||||||
left: 0px;
|
|
||||||
width: 100%;
|
|
||||||
//line-height: 38px;
|
|
||||||
font-size: 30px;
|
|
||||||
font-weight:bold;
|
|
||||||
bottom: 0px;
|
|
||||||
}
|
|
||||||
.label {
|
|
||||||
//transform: translate(-12px,-12px);
|
|
||||||
vertical-align: text-top;
|
|
||||||
line-height: 18px;
|
|
||||||
min-width: 50%;
|
|
||||||
//display: block,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
:hover .controls, :focus .controls {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
button:before {
|
.title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer-slider {
|
||||||
|
width: 100%;
|
||||||
|
margin: 4px 0px 4px 0px;
|
||||||
|
font-size: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.control {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button:before {
|
||||||
font-family: HeydingsControlsRegular;
|
font-family: HeydingsControlsRegular;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
//text-shadow: 1px 1px 0px black;
|
|
||||||
}
|
|
||||||
.timer {
|
|
||||||
line-height: 38px;
|
|
||||||
font-size: 30px;
|
|
||||||
font-family: monospace;
|
|
||||||
text-shadow: 1px 1px 0px black;
|
|
||||||
color: white;
|
|
||||||
flex: 5;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timer div {
|
|
||||||
width:100%;
|
|
||||||
line-height: 38px;
|
|
||||||
font-size: 10px;
|
|
||||||
font-family: monospace;
|
|
||||||
text-shadow: 1px 1px 0px black;
|
|
||||||
color: white;
|
|
||||||
flex: 5;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timer span {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 3;
|
|
||||||
left: 19px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,13 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef, Inject } from '@angular/core';
|
||||||
import { isArray, isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { GenderService, DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service';
|
import { DataService, PlayerService, TrackService, AlbumService, ArtistService } from 'app/service';
|
||||||
import { PlaylistCurrent } from 'app/service/player';
|
import { PlaylistCurrent } from 'app/service/player';
|
||||||
import { Media } from 'app/model';
|
|
||||||
import { HttpWrapperService } from 'common/service';
|
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { environment } from 'environments/environment';
|
import { Album, Artist, Track } from 'app/back-api';
|
||||||
|
import { isArray, isNullOrUndefined, Environment } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
|
|
||||||
export enum PlayMode {
|
export enum PlayMode {
|
||||||
@@ -26,7 +23,7 @@ export enum PlayMode {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-player-audio',
|
selector: 'app-element-player-audio',
|
||||||
templateUrl: './element-player-audio.html',
|
templateUrl: './element-player-audio.html',
|
||||||
styleUrls: [ './element-player-audio.less' ]
|
styleUrls: ['./element-player-audio.less']
|
||||||
})
|
})
|
||||||
export class ElementPlayerAudioComponent implements OnInit {
|
export class ElementPlayerAudioComponent implements OnInit {
|
||||||
mediaPlayer: HTMLAudioElement;
|
mediaPlayer: HTMLAudioElement;
|
||||||
@@ -34,7 +31,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
durationDisplay: string;
|
durationDisplay: string;
|
||||||
@ViewChild('mediaPlayer')
|
@ViewChild('mediaPlayer')
|
||||||
set mainVideoEl(el: ElementRef) {
|
set mainVideoEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.mediaPlayer = el.nativeElement;
|
this.mediaPlayer = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,14 +40,16 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
public name: string = 'rr';
|
public name: string = 'rr';
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
public counttrack: number;
|
public countTrack: number;
|
||||||
|
|
||||||
public covers: string[];
|
public covers: string[];
|
||||||
|
|
||||||
public volume_value: number = 100;
|
public volume_value: number = 100;
|
||||||
public volume_displayMenu: boolean = false;
|
public volume_displayMenu: boolean = false;
|
||||||
|
|
||||||
nameData: string;
|
dataTitle: string;
|
||||||
|
dataAlbum: string;
|
||||||
|
dataAuthor: string;
|
||||||
playStream: boolean;
|
playStream: boolean;
|
||||||
isPlaying: boolean;
|
isPlaying: boolean;
|
||||||
currentTime: any;
|
currentTime: any;
|
||||||
@@ -70,16 +69,16 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject('ENVIRONMENT') private environment: Environment,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
private trackService: TrackService,
|
private trackService: TrackService,
|
||||||
|
private dataService: DataService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private httpService: HttpWrapperService,
|
|
||||||
private dataService: DataService,
|
|
||||||
private titleService: Title) {
|
private titleService: Title) {
|
||||||
// nothing to do...
|
// nothing to do...
|
||||||
}
|
}
|
||||||
private currentLMedia: Media;
|
private currentLMedia: Track;
|
||||||
private localIdStreaming: number;
|
private localIdStreaming: number;
|
||||||
private localListStreaming: number[] = [];
|
private localListStreaming: number[] = [];
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -103,202 +102,56 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.havePrevious = this.localIdStreaming <= 0;
|
this.havePrevious = this.localIdStreaming <= 0;
|
||||||
this.haveNext = this.localIdStreaming >= this.localListStreaming.length-1;
|
this.haveNext = this.localIdStreaming >= this.localListStreaming.length - 1;
|
||||||
this.trackService.get(this.localListStreaming[this.localIdStreaming])
|
this.trackService.get(this.localListStreaming[this.localIdStreaming])
|
||||||
.then((response: Media) => {
|
.then((response: Track) => {
|
||||||
//console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
|
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.currentLMedia = response;
|
self.currentLMedia = response;
|
||||||
self.nameData = response.name;
|
self.dataTitle = response.name;
|
||||||
if (!isNullOrUndefined(response.albumId)) {
|
if (!isNullOrUndefined(response.albumId)) {
|
||||||
this.albumService.get(response.albumId)
|
this.albumService.get(response.albumId)
|
||||||
.then((response2: NodeData) => {
|
.then((response2: Album) => {
|
||||||
self.nameData = response2.name + " - " + self.nameData;
|
self.dataAlbum = response2.name;
|
||||||
this.titleService.setTitle(`${environment.applName} > ${self.nameData}`)
|
self.updateTitle();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
}
|
}
|
||||||
if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) {
|
if (!isNullOrUndefined(response.artists) && isArray(response.artists) && response.artists.length > 0) {
|
||||||
this.artistService.get(response.artists[0])
|
this.artistService.get(response.artists[0])
|
||||||
.then((response2: NodeData) => {
|
.then((response2: Artist) => {
|
||||||
self.nameData = `${self.nameData} (${response2.name})`;
|
self.dataAuthor = response2.name;
|
||||||
this.titleService.setTitle(`${environment.applName} > ${self.nameData}`)
|
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
}
|
}
|
||||||
if (isNullOrUndefined(self.currentLMedia)) {
|
if (isNullOrUndefined(self.currentLMedia)) {
|
||||||
console.log("Can not retreive the media ...")
|
console.log("Can not retrieve the media ...")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isNullOrUndefined(self.currentLMedia.dataId)) {
|
if (isNullOrUndefined(self.currentLMedia.dataId)) {
|
||||||
console.log("Can not retreive the media ... null or undefined data ID")
|
console.log("Can not retrieve the media ... null or undefined data ID")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.mediaSource = self.httpService.createRESTCall2({
|
self.mediaSource = self.dataService.getUrl(self.currentLMedia.dataId, "unknownMediaName.webm");
|
||||||
api: `data/${self.currentLMedia.dataId}/unknowMediaName.webm`, //${self.generatedName}`,
|
}).catch((error) => {
|
||||||
addURLToken: true,
|
console.error(`error not unmanaged in audio player ... 111 ${error}`);
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
console.error("error not ùmanaged in audio player ... 111");
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
updateTitle() {
|
||||||
generateName() {
|
let title = this.dataTitle;
|
||||||
/*
|
if (!isNullOrUndefined(this.dataAlbum)) {
|
||||||
this.generatedName = '';
|
title = `${this.dataAlbum} - ${title}`;
|
||||||
if(this.seriesName !== undefined) {
|
|
||||||
this.generatedName = `${this.generatedName }${this.seriesName }-`;
|
|
||||||
}
|
}
|
||||||
if(this.seasonName !== undefined) {
|
if (!isNullOrUndefined(this.dataAuthor)) {
|
||||||
if(this.seasonName.length < 2) {
|
title = `${title} (${this.dataAuthor})`;
|
||||||
this.generatedName = `${this.generatedName }s0${ this.seasonName }-`;
|
|
||||||
} else {
|
|
||||||
this.generatedName = `${this.generatedName }s${ this.seasonName }-`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 + this.name;
|
|
||||||
this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
|
|
||||||
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
|
||||||
// update the path of the uri request
|
|
||||||
this.mediaSource = this.httpService.createRESTCall2({
|
|
||||||
api: `data/${ this.dataId}/${this.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myPeriodicCheckFunction() {
|
this.titleService.setTitle(`${this.environment.applName} > ${title}`)
|
||||||
console.log('check ... ');
|
|
||||||
}
|
}
|
||||||
changeMetadata() {
|
changeMetadata() {
|
||||||
console.log('list of the stream:');
|
console.log('list of the stream:');
|
||||||
|
|
||||||
/*
|
|
||||||
let captureStream = this.audioPlayer.audioTracks;
|
|
||||||
for (let iii=0; iii < captureStream.length; iii++) {
|
|
||||||
console.log(" - " + captureStream[iii].language);
|
|
||||||
if (captureStream[iii].language.substring(0,2) === "fr") {
|
|
||||||
captureStream[iii].enabled = true;
|
|
||||||
} else {
|
|
||||||
captureStream[iii].enabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
myPeriodicCheckFunction() {
|
||||||
*/
|
console.log('check ... ');
|
||||||
}
|
|
||||||
/*
|
|
||||||
ngOnInit() {
|
|
||||||
let self = this;
|
|
||||||
|
|
||||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
|
||||||
this.idVideo = this.arianeService.getVideoId();
|
|
||||||
this.arianeService.mediaChange.subscribe((mediaId) => {
|
|
||||||
console.log(`Detect mediaId change...${ mediaId}`);
|
|
||||||
self.idVideo = mediaId;
|
|
||||||
self.updateDisplay();
|
|
||||||
});
|
|
||||||
self.updateDisplay();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
updateDisplay():void {
|
|
||||||
let self = this;
|
|
||||||
/*
|
|
||||||
self.haveNext = null;
|
|
||||||
self.havePrevious = null;
|
|
||||||
this.mediaService.get(this.idVideo)
|
|
||||||
.then((response) => {
|
|
||||||
console.log(`get response of media : ${ JSON.stringify(response, null, 2)}`);
|
|
||||||
self.error = '';
|
|
||||||
self.name = response.name;
|
|
||||||
self.description = response.description;
|
|
||||||
self.episode = response.episode;
|
|
||||||
self.seriesId = response.seriesId;
|
|
||||||
self.seasonId = response.seasonId;
|
|
||||||
self.dataId = response.dataId;
|
|
||||||
self.time = response.time;
|
|
||||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
|
||||||
if(self.dataId !== -1) {
|
|
||||||
self.mediaSource = self.httpService.createRESTCall2({
|
|
||||||
api: `data/${ self.dataId}/${self.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
self.mediaSource = '';
|
|
||||||
}
|
|
||||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
|
||||||
|
|
||||||
self.generateName();
|
|
||||||
if(self.seriesId !== undefined && self.seriesId !== null) {
|
|
||||||
self.seriesService.get(self.seriesId)
|
|
||||||
.then((response2) => {
|
|
||||||
self.seriesName = response2.name;
|
|
||||||
self.generateName();
|
|
||||||
}).catch((response3) => {
|
|
||||||
// nothing to do ...
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(self.seasonId !== undefined && self.seasonId !== null) {
|
|
||||||
self.seasonService.get(self.seasonId)
|
|
||||||
.then((response4) => {
|
|
||||||
self.seasonName = response4.name;
|
|
||||||
self.generateName();
|
|
||||||
}).catch((response5) => {
|
|
||||||
// nothing to do ...
|
|
||||||
});
|
|
||||||
self.seasonService.getVideo(self.seasonId)
|
|
||||||
.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)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(response6[iii].episode < self.episode) {
|
|
||||||
if(self.havePrevious === null) {
|
|
||||||
self.havePrevious = response6[iii];
|
|
||||||
} else if(self.havePrevious.episode < response6[iii].episode) {
|
|
||||||
self.havePrevious = response6[iii];
|
|
||||||
}
|
|
||||||
} else if(response6[iii].episode > self.episode) {
|
|
||||||
if(self.haveNext === null) {
|
|
||||||
self.haveNext = response6[iii];
|
|
||||||
} else if(self.haveNext.episode > response6[iii].episode) {
|
|
||||||
self.haveNext = response6[iii];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
|
||||||
}
|
|
||||||
}).catch((response7:any) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
self.mediaIsLoading = false;
|
|
||||||
// console.log("display source " + self.mediaSource);
|
|
||||||
// console.log("set transformed : " + JSON.stringify(self, null, 2));
|
|
||||||
}).catch((response8) => {
|
|
||||||
self.error = 'Can not get the data';
|
|
||||||
self.name = '';
|
|
||||||
self.description = '';
|
|
||||||
self.episode = undefined;
|
|
||||||
self.seriesId = undefined;
|
|
||||||
self.seasonId = undefined;
|
|
||||||
self.dataId = -1;
|
|
||||||
self.time = undefined;
|
|
||||||
self.generatedName = '';
|
|
||||||
self.mediaSource = '';
|
|
||||||
self.covers = undefined;
|
|
||||||
self.seriesName = undefined;
|
|
||||||
self.seasonName = undefined;
|
|
||||||
self.mediaIsNotFound = true;
|
|
||||||
self.mediaIsLoading = false;
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
onRequirePlay() {
|
onRequirePlay() {
|
||||||
this.playStream = true;
|
this.playStream = true;
|
||||||
@@ -316,7 +169,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
this.mediaPlayer.currentTime = 0;
|
this.mediaPlayer.currentTime = 0;
|
||||||
this.onPlay();
|
this.onPlay();
|
||||||
} else {
|
} else {
|
||||||
if (this.localIdStreaming == this.localListStreaming.length-1) {
|
if (this.localIdStreaming == this.localListStreaming.length - 1) {
|
||||||
this.localIdStreaming = 0;
|
this.localIdStreaming = 0;
|
||||||
this.updateMediaStreamed();
|
this.updateMediaStreamed();
|
||||||
if (this.localListStreaming.length == 1) {
|
if (this.localListStreaming.length == 1) {
|
||||||
@@ -336,25 +189,25 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertIndisplayTime(time:number) : string {
|
convertInDisplayTime(time: number): string {
|
||||||
let tmpp = parseInt(`${ time}`, 10);
|
let temporaryValue = parseInt(`${time}`, 10);
|
||||||
let heures = parseInt(`${ tmpp / 3600}`, 10);
|
let hours = parseInt(`${temporaryValue / 3600}`, 10);
|
||||||
tmpp = tmpp - heures * 3600;
|
temporaryValue = temporaryValue - hours * 3600;
|
||||||
let minutes = parseInt(`${ tmpp / 60}`, 10);
|
let minutes = parseInt(`${temporaryValue / 60}`, 10);
|
||||||
let seconds = tmpp - minutes * 60;
|
let seconds = temporaryValue - minutes * 60;
|
||||||
let out = '';
|
let out = '';
|
||||||
if(heures !== 0) {
|
if (hours !== 0) {
|
||||||
out = `${out }${heures }:`;
|
out = `${out}${hours}:`;
|
||||||
}
|
}
|
||||||
if(minutes >= 10) {
|
if (minutes >= 10) {
|
||||||
out = `${out }${minutes }:`;
|
out = `${out}${minutes}:`;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ minutes }:`;
|
out = `${out}0${minutes}:`;
|
||||||
}
|
}
|
||||||
if(seconds >= 10) {
|
if (seconds >= 10) {
|
||||||
out = out + seconds;
|
out = out + seconds;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ seconds}`;
|
out = `${out}0${seconds}`;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -363,20 +216,20 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
// console.log("time change ");
|
// console.log("time change ");
|
||||||
// console.log(" ==> " + this.audioPlayer.currentTime);
|
// console.log(" ==> " + this.audioPlayer.currentTime);
|
||||||
this.currentTime = this.mediaPlayer.currentTime;
|
this.currentTime = this.mediaPlayer.currentTime;
|
||||||
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
|
this.currentTimeDisplay = this.convertInDisplayTime(this.currentTime);
|
||||||
// console.log(" ==> " + this.currentTimeDisplay);
|
// console.log(" ==> " + this.currentTimeDisplay);
|
||||||
}
|
}
|
||||||
changeDurationchange(duration: any) {
|
changeDurationchange(duration: any) {
|
||||||
console.log('duration change ');
|
console.log('duration change ');
|
||||||
console.log(` ==> ${ this.mediaPlayer.duration}`);
|
console.log(` ==> ${this.mediaPlayer.duration}`);
|
||||||
this.duration = this.mediaPlayer.duration;
|
this.duration = this.mediaPlayer.duration;
|
||||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
this.durationDisplay = this.convertInDisplayTime(this.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPlay() {
|
onPlay() {
|
||||||
console.log('play');
|
console.log('play');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.lockPlayerEnable();
|
this.lockPlayerEnable();
|
||||||
@@ -385,8 +238,8 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onPause() {
|
onPause() {
|
||||||
console.log('pause');
|
console.log('pause');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.unlockPlayerEnable();
|
this.unlockPlayerEnable();
|
||||||
@@ -395,7 +248,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onPauseToggle() {
|
onPauseToggle() {
|
||||||
console.log('pause toggle ...');
|
console.log('pause toggle ...');
|
||||||
if(this.isPlaying === true) {
|
if (this.isPlaying === true) {
|
||||||
this.onPause();
|
this.onPause();
|
||||||
} else {
|
} else {
|
||||||
this.onPlay();
|
this.onPlay();
|
||||||
@@ -404,8 +257,12 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onStop() {
|
onStop() {
|
||||||
console.log('stop');
|
console.log('stop');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (this.mediaPlayer.paused && this.mediaPlayer.currentTime == 0) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
this.mediaSource = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.unlockPlayerEnable();
|
this.unlockPlayerEnable();
|
||||||
@@ -426,7 +283,7 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onNext() {
|
onNext() {
|
||||||
console.log('next');
|
console.log('next');
|
||||||
if (this.localIdStreaming >= this.localListStreaming.length-1) {
|
if (this.localIdStreaming >= this.localListStreaming.length - 1) {
|
||||||
console.error("have no next !!!");
|
console.error("have no next !!!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -435,10 +292,10 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
this.playerService.next();
|
this.playerService.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
seek(newValue:any) {
|
seek(newValue: any) {
|
||||||
console.log(`seek ${ newValue.value}`);
|
console.log(`seek ${newValue.value}`);
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.mediaPlayer.currentTime = newValue.value;
|
this.mediaPlayer.currentTime = newValue.value;
|
||||||
@@ -446,8 +303,8 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onRewind() {
|
onRewind() {
|
||||||
console.log('rewind');
|
console.log('rewind');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.mediaPlayer.currentTime = this.currentTime - 10;
|
this.mediaPlayer.currentTime = this.currentTime - 10;
|
||||||
@@ -455,8 +312,8 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onForward() {
|
onForward() {
|
||||||
console.log('forward');
|
console.log('forward');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.mediaPlayer.currentTime = this.currentTime + 10;
|
this.mediaPlayer.currentTime = this.currentTime + 10;
|
||||||
@@ -464,8 +321,8 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
|
|
||||||
onMore() {
|
onMore() {
|
||||||
console.log('more');
|
console.log('more');
|
||||||
if(isNullOrUndefined(this.mediaPlayer)) {
|
if (isNullOrUndefined(this.mediaPlayer)) {
|
||||||
console.log(`error element: ${ this.mediaPlayer}`);
|
console.log(`error element: ${this.mediaPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,10 +331,11 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
// these element is to permit to not stop music when sceen is off !!
|
// these element is to permit to not stop music when sceen is off !!
|
||||||
wakeLock = null;
|
wakeLock = null;
|
||||||
unlockPlayerEnable() {
|
unlockPlayerEnable() {
|
||||||
let tmppp = this.wakeLock;
|
let temporaryValue = this.wakeLock;
|
||||||
this.wakeLock = null;
|
this.wakeLock = null;
|
||||||
if (!isNullOrUndefined(tmppp)) {
|
if (!isNullOrUndefined(temporaryValue)) {
|
||||||
tmppp.release();
|
console.log(`plopppp ${temporaryValue}`);
|
||||||
|
temporaryValue.release();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let tmp = navigator as any;
|
let tmp = navigator as any;
|
||||||
@@ -487,11 +345,11 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
console.log(`Can not lock screen element: ${err.name}, ${err.message}`);
|
console.log(`Can not lock screen element: ${err.name}, ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lockPlayerEnable() {
|
async lockPlayerEnable() {
|
||||||
if ('wakeLock' in navigator) {
|
if ('wakeLock' in navigator) {
|
||||||
try {
|
try {
|
||||||
let tmp = navigator as any;
|
let tmp = navigator as any;
|
||||||
this.wakeLock = tmp.wakeLock.request('screen');
|
this.wakeLock = await tmp.wakeLock.request('screen');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// The Wake Lock request has failed - usually system related, such as battery.
|
// The Wake Lock request has failed - usually system related, such as battery.
|
||||||
console.log(`Can not lock screen element: ${err.name}, ${err.message}`);
|
console.log(`Can not lock screen element: ${err.name}, ${err.message}`);
|
||||||
|
|||||||
@@ -1,41 +1,45 @@
|
|||||||
|
|
||||||
<div class="imgContainer-small">
|
<div class="imgContainer-small">
|
||||||
<div *ngIf="covers">
|
@if(covers && covers.length > 0) {
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
<div>
|
||||||
<img src="{{covers[0]}}"/>
|
<img src="{{covers[0]}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!covers" class="noImage">
|
}
|
||||||
|
@else {
|
||||||
</div>
|
<div class="noImage"></div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="season-small">
|
<div class="season-small">
|
||||||
{{prefixName}} {{numberAlbum}}
|
{{prefixName}} {{numberAlbum}}
|
||||||
</div>
|
</div>
|
||||||
<div class="description-small" *ngIf="countSubType && (!count || count == 0)">
|
@if(countSubType) {
|
||||||
|
<div class="description-small">
|
||||||
|
@if(!count || count == 0) {
|
||||||
No {{countSubType}}
|
No {{countSubType}}
|
||||||
</div>
|
}
|
||||||
<div class="description-small" *ngIf="countSubType && count > 1">
|
@else {
|
||||||
{{count}} {{countSubType}}s
|
{{count}} {{countSubType}}{{count>1?"s":""}}
|
||||||
</div>
|
}
|
||||||
<div class="description-small" *ngIf="countSubType && count == 1">
|
</div>
|
||||||
{{count}} {{countSubType}}
|
}
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="description-small" *ngIf="countSubType2 && (!count2 || count2 == 0)">
|
@if(countSubType2) {
|
||||||
|
<div class="description-small">
|
||||||
|
@if(!count2 || count2 == 0) {
|
||||||
No {{countSubType2}}
|
No {{countSubType2}}
|
||||||
</div>
|
}
|
||||||
<div class="description-small" *ngIf="countSubType2 && count2 > 1">
|
@else {
|
||||||
{{count2}} {{countSubType2}}s
|
{{count2}} {{countSubType2}}{{count2>1?"s":""}}
|
||||||
</div>
|
}
|
||||||
<div class="description-small" *ngIf="countSubType2 && count2 == 1">
|
</div>
|
||||||
{{count2}} {{countSubType2}}
|
}
|
||||||
</div>
|
@if(subValueData) {
|
||||||
|
<div class="description-small">
|
||||||
<div class="description-small" *ngIf="subValueData">
|
|
||||||
{{subValues}}: {{subValueData}}
|
{{subValues}}: {{subValueData}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
@if(!description) {
|
||||||
<div class="description-small" *ngIf="!description">
|
<div class="description-small">
|
||||||
{{description}}
|
{{description}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,21 +3,22 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, DataService } from 'app/service';
|
import { AlbumService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-season',
|
selector: 'app-element-season',
|
||||||
templateUrl: './element-season.html',
|
templateUrl: './element-season.html',
|
||||||
styleUrls: [ './element-season.less' ]
|
styleUrls: ['./element-season.less']
|
||||||
})
|
})
|
||||||
export class ElementSeasonComponent implements OnInit {
|
export class ElementSeasonComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() prefix:String;
|
@Input() prefix: String;
|
||||||
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
||||||
@Input() countSubType: String;
|
@Input() countSubType: String;
|
||||||
@Input() countSubType2CallBack: (arg0: number) => Promise<number>;
|
@Input() countSubType2CallBack: (arg0: number) => Promise<number>;
|
||||||
@@ -39,9 +40,10 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.prefix = this.prefixName??"";
|
this.prefix = this.prefixName ?? "";
|
||||||
this.count = undefined;
|
this.count = undefined;
|
||||||
this.count2 = undefined;
|
this.count2 = undefined;
|
||||||
|
//console.log(`element: ${JSON.stringify(this.element, null, 2)}`);
|
||||||
|
|
||||||
if (isNullOrUndefined(this.element)) {
|
if (isNullOrUndefined(this.element)) {
|
||||||
this.numberAlbum = undefined;
|
this.numberAlbum = undefined;
|
||||||
@@ -50,7 +52,7 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.numberAlbum = this.element.name;
|
this.numberAlbum = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
let self = this;
|
let self = this;
|
||||||
if (!isNullOrUndefined(this.countSubTypeCallBack)) {
|
if (!isNullOrUndefined(this.countSubTypeCallBack)) {
|
||||||
this.countSubTypeCallBack(this.element.id)
|
this.countSubTypeCallBack(this.element.id)
|
||||||
@@ -75,7 +77,7 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
this.subValuesCallBack(this.element.id)
|
this.subValuesCallBack(this.element.id)
|
||||||
.then((response: string[]) => {
|
.then((response: string[]) => {
|
||||||
this.subValueData = "";
|
this.subValueData = "";
|
||||||
for (let kkk=0; kkk<response.length; kkk++) {
|
for (let kkk = 0; kkk < response.length; kkk++) {
|
||||||
if (kkk != 0) {
|
if (kkk != 0) {
|
||||||
this.subValueData += ", ";
|
this.subValueData += ", ";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="count-base">
|
<div class="count-base">
|
||||||
<div class="count" *ngIf="counttrack">
|
@if(countTrack) {
|
||||||
{{counttrack}}
|
<div class="count">
|
||||||
|
{{countTrack}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="imgContainer-small">
|
<div class="imgContainer-small">
|
||||||
<div *ngIf="covers">
|
@if(covers && covers.length > 0) {
|
||||||
|
<div>
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
<!--<data-image id="{{cover}}"></data-image>-->
|
||||||
<img src="{{covers[0]}}"/>
|
<img src="{{covers[0]}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!covers" class="noImage">
|
}
|
||||||
|
@else {
|
||||||
</div>
|
<div class="noImage"></div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="title-small">
|
<div class="title-small">
|
||||||
{{name}}
|
{{name}}
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<div class="description-small" *ngIf="description">
|
|
||||||
{{description}}
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
@@ -4,28 +4,28 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
import { ArtistService, DataService } from 'app/service';
|
import { DataService, TrackService } from 'app/service';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-series',
|
selector: 'app-element-series',
|
||||||
templateUrl: './element-series.html',
|
templateUrl: './element-series.html',
|
||||||
styleUrls: [ './element-series.less' ]
|
styleUrls: ['./element-series.less']
|
||||||
})
|
})
|
||||||
export class ElementSeriesComponent implements OnInit {
|
export class ElementSeriesComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
|
|
||||||
name:string = 'plouf';
|
name: string = 'plouf';
|
||||||
description:string = '';
|
description: string = '';
|
||||||
counttrack:number = null;
|
countTrack: number = null;
|
||||||
|
|
||||||
covers:string[];
|
covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private trackService: TrackService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -35,16 +35,15 @@ export class ElementSeriesComponent implements OnInit {
|
|||||||
this.description = undefined;
|
this.description = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
this.name = this.element.name;
|
||||||
self.name = this.element.name;
|
this.description = this.element.description;
|
||||||
self.description = this.element.description;
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
|
||||||
|
|
||||||
this.artistService.countTrack(this.element.id)
|
this.trackService.countTracksOfAnArtist(this.element.id)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.counttrack = response;
|
this.countTrack = response;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.counttrack = 0;
|
this.countTrack = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<div class="season-small">
|
<div class="season-small">
|
||||||
{{name}}
|
{{name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="description-small" *ngIf="track">
|
@if(track) {
|
||||||
|
<div class="description-small">
|
||||||
n° {{track}}
|
n° {{track}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -3,21 +3,21 @@
|
|||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-track',
|
selector: 'app-element-track',
|
||||||
templateUrl: './element-track.html',
|
templateUrl: './element-track.html',
|
||||||
styleUrls: [ './element-track.less' ]
|
styleUrls: ['./element-track.less']
|
||||||
})
|
})
|
||||||
export class ElementTrackComponent implements OnInit {
|
export class ElementTrackComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() prefix:String;
|
@Input() prefix: String;
|
||||||
|
|
||||||
prefixName: string = "";
|
prefixName: string = "";
|
||||||
name: string;
|
name: string;
|
||||||
@@ -26,12 +26,11 @@ export class ElementTrackComponent implements OnInit {
|
|||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private albumService: AlbumService,
|
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.prefix = this.prefixName??"";
|
this.prefix = this.prefixName ?? "";
|
||||||
if (isNullOrUndefined(this.element)) {
|
if (isNullOrUndefined(this.element)) {
|
||||||
this.name = undefined;
|
this.name = undefined;
|
||||||
this.covers = undefined;
|
this.covers = undefined;
|
||||||
@@ -40,7 +39,6 @@ export class ElementTrackComponent implements OnInit {
|
|||||||
this.name = this.element.name;
|
this.name = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
this.track = this.element["track"];
|
this.track = this.element["track"];
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
let self = this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="count-base" *ngIf="counttrack">
|
@if(countTrack) {
|
||||||
<span class="count">{{counttrack}}</span>
|
<div class="count-base">
|
||||||
|
<span class="count">{{countTrack}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="imgContainer-small">
|
<div class="imgContainer-small">
|
||||||
<div *ngIf="covers">
|
@if(covers && covers.length > 0) {
|
||||||
|
<div>
|
||||||
<img src="{{covers[0]}}" class="miniature-small"/>
|
<img src="{{covers[0]}}" class="miniature-small"/>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="title-small">
|
<div class="title-small">
|
||||||
{{name}}
|
{{name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="description-small" *ngIf="description">
|
@if(description) {
|
||||||
|
<div class="description-small">
|
||||||
{{description}}
|
{{description}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -4,30 +4,30 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { GenderService, DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
|
import { NodeSmall } from 'app/back-api';
|
||||||
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-type',
|
selector: 'app-element-type',
|
||||||
templateUrl: './element-type.html',
|
templateUrl: './element-type.html',
|
||||||
styleUrls: [ './element-type.less' ]
|
styleUrls: ['./element-type.less']
|
||||||
})
|
})
|
||||||
export class ElementTypeComponent implements OnInit {
|
export class ElementTypeComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: NodeSmall;
|
||||||
@Input() functionVignette:(number) => Promise<Number>;
|
@Input() functionVignette: (number) => Promise<Number>;
|
||||||
|
|
||||||
public name: string = 'rr';
|
public name: string = 'rr';
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
public counttrack: number;
|
public countTrack: number;
|
||||||
|
|
||||||
public covers: string[];
|
public covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private typeService: GenderService,
|
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ export class ElementTypeComponent implements OnInit {
|
|||||||
if (isNullOrUndefined(this.element)) {
|
if (isNullOrUndefined(this.element)) {
|
||||||
this.name = 'Not a media';
|
this.name = 'Not a media';
|
||||||
this.description = undefined;
|
this.description = undefined;
|
||||||
this.counttrack = undefined;
|
this.countTrack = undefined;
|
||||||
this.covers = undefined;
|
this.covers = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -43,14 +43,14 @@ export class ElementTypeComponent implements OnInit {
|
|||||||
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
||||||
self.name = this.element.name;
|
self.name = this.element.name;
|
||||||
self.description = this.element.description;
|
self.description = this.element.description;
|
||||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.functionVignette)) {
|
if (!isNullOrUndefined(this.functionVignette)) {
|
||||||
this.functionVignette(this.element.id)
|
this.functionVignette(this.element.id)
|
||||||
.then((response: number) => {
|
.then((response: number) => {
|
||||||
self.counttrack = response;
|
self.countTrack = response;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
self.counttrack = 0;
|
self.countTrack = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="videoImgContainer">
|
<div class="videoImgContainer">
|
||||||
<div *ngIf="covers">
|
@if(covers && covers.length > 0) {
|
||||||
|
<div>
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
<!--<data-image id="{{cover}}"></data-image>-->
|
||||||
<img src="{{covers[0]}}"/>
|
<img src="{{covers[0]}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!covers" class="noImage">
|
}
|
||||||
|
@else {
|
||||||
|
<div class="noImage"></div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@if(element) {
|
||||||
<div class="title-small" *ngIf="data">
|
<div class="title-small">
|
||||||
{{episodeDisplay}} {{name}}
|
{{episodeDisplay}} {{name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="title-small" *ngIf="!data">
|
}
|
||||||
|
@else {
|
||||||
|
<div class="title-small">
|
||||||
Error meda: {{element?.id}}
|
Error meda: {{element?.id}}
|
||||||
</div>
|
</div>
|
||||||
<!--
|
}
|
||||||
<div class="description-small" *ngIf="description">
|
|
||||||
{{description}}
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,50 +4,34 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
||||||
import { isMedia, Media } from 'app/model';
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
import { DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-video',
|
selector: 'app-element-video',
|
||||||
templateUrl: './element-video.html',
|
templateUrl: './element-video.html',
|
||||||
styleUrls: [ './element-video.less' ]
|
styleUrls: ['./element-video.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ElementVideoComponent implements OnInit {
|
export class ElementVideoComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: Track;
|
||||||
data:Media;
|
name: string = '';
|
||||||
|
description: string = '';
|
||||||
|
episodeDisplay: string = '';
|
||||||
|
|
||||||
name:string = '';
|
cover: string = '';
|
||||||
description:string = '';
|
covers: string[];
|
||||||
episodeDisplay:string = '';
|
|
||||||
|
|
||||||
cover:string = '';
|
|
||||||
covers:string[];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (!isMedia(this.element)) {
|
|
||||||
this.data = undefined;
|
|
||||||
this.name = 'Not a media';
|
|
||||||
this.description = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.data = this.element;
|
|
||||||
this.name = this.element.name;
|
this.name = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
if(isNullOrUndefined(this.element.episode)) {
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
this.episodeDisplay = '';
|
|
||||||
} else {
|
|
||||||
this.episodeDisplay = `${this.element.episode } - `;
|
|
||||||
}
|
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { DescriptionAreaComponent } from "./description-area/description-area";
|
||||||
import { ElementPlayerAudioComponent } from "./element-player-audio/element-player-audio";
|
import { ElementPlayerAudioComponent } from "./element-player-audio/element-player-audio";
|
||||||
import { ElementSeasonComponent } from "./element-season/element-season";
|
import { ElementSeasonComponent } from "./element-season/element-season";
|
||||||
import { ElementSeriesComponent } from "./element-series/element-series";
|
import { ElementSeriesComponent } from "./element-series/element-series";
|
||||||
@@ -12,5 +13,6 @@ export {
|
|||||||
ElementSeasonComponent,
|
ElementSeasonComponent,
|
||||||
ElementPlayerAudioComponent,
|
ElementPlayerAudioComponent,
|
||||||
ElementTrackComponent,
|
ElementTrackComponent,
|
||||||
|
DescriptionAreaComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { isArrayOf, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString } from "common/utils";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface AlbumModel {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
description?: string;
|
|
||||||
covers?: number[];
|
|
||||||
tracks?: number[];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export function isAlbumModel(data: any): data is AlbumModel {
|
|
||||||
if (!isObject(data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isNumberFinite(data.id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isString(data.name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.description, isString)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalArrayOf(data.cover, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalArrayOf(data.tracks, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { Media, isMedia } from "./media";
|
|
||||||
|
|
||||||
export {
|
|
||||||
Media, isMedia,
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import { isNumberFinite, isString, isOptionalOf, isArray } from "common/utils";
|
|
||||||
import { isNodeData, NodeData } from "common/model/node";
|
|
||||||
|
|
||||||
|
|
||||||
export interface Media extends NodeData {
|
|
||||||
dataId?: number;
|
|
||||||
genderId?: number;
|
|
||||||
artists?: number[];
|
|
||||||
albumId?: number;
|
|
||||||
episode?: number;
|
|
||||||
track?: number;
|
|
||||||
date?: number;
|
|
||||||
time?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function isMedia(data: any): data is Media {
|
|
||||||
if (!isNodeData(data) as any) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.dataId, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.typeId, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.artists, isArray)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.albumId, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.track, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.episode, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.date, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isOptionalOf(data.time, isNumberFinite)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -4,13 +4,12 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { PopInService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { PopInService } from 'common/service/popin';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'create-type',
|
selector: 'create-type',
|
||||||
templateUrl: './create-type.html',
|
templateUrl: './create-type.html',
|
||||||
styleUrls: [ './create-type.less' ]
|
styleUrls: ['./create-type.less']
|
||||||
})
|
})
|
||||||
export class PopInCreateType implements OnInit {
|
export class PopInCreateType implements OnInit {
|
||||||
name: string = '';
|
name: string = '';
|
||||||
@@ -26,14 +25,14 @@ export class PopInCreateType implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
eventPopUp(event: string): void {
|
eventPopUp(event: string): void {
|
||||||
console.log(`GET event: ${ event}`);
|
console.log(`GET event: ${event}`);
|
||||||
this.popInService.close('popin-create-type');
|
this.popInService.close('popin-create-type');
|
||||||
}
|
}
|
||||||
updateNeedSend():void {
|
updateNeedSend(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
onName(value:any):void {
|
onName(value: any): void {
|
||||||
if(value.length === 0) {
|
if (value.length === 0) {
|
||||||
this.name = '';
|
this.name = '';
|
||||||
} else {
|
} else {
|
||||||
this.name = value;
|
this.name = value;
|
||||||
@@ -41,8 +40,8 @@ export class PopInCreateType implements OnInit {
|
|||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
onDescription(value:any):void {
|
onDescription(value: any): void {
|
||||||
if(value.length === 0) {
|
if (value.length === 0) {
|
||||||
this.description = '';
|
this.description = '';
|
||||||
} else {
|
} else {
|
||||||
this.description = value;
|
this.description = value;
|
||||||
|
|||||||
@@ -2,21 +2,26 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
Edit album
|
Edit album
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsRemoved">
|
@if(itemIsRemoved) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The album has been removed
|
The album has been removed
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsNotFound">
|
}
|
||||||
|
@else if (itemIsNotFound) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The album does not exist
|
The album does not exist
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsLoading">
|
}
|
||||||
|
@else if (itemIsLoading) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
Loading ...<br/>
|
Loading ...<br/>
|
||||||
@@ -24,7 +29,9 @@
|
|||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
}
|
||||||
|
@else {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
name:
|
name:
|
||||||
@@ -68,10 +75,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ------------------------- Cover section --------------------------------- -->
|
<!-- ------------------------- Cover section --------------------------------- -->
|
||||||
<div class="title" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="title">
|
||||||
Covers
|
Covers
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="fill-all">
|
||||||
<div class="hide-element">
|
<div class="hide-element">
|
||||||
<input type="file"
|
<input type="file"
|
||||||
#fileInput
|
#fileInput
|
||||||
@@ -81,7 +88,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<div class="cover" *ngFor="let element of coversDisplay">
|
@for (element of coversDisplay; track element.id;) {
|
||||||
|
<div class="cover">
|
||||||
<div class="cover-image">
|
<div class="cover-image">
|
||||||
<img src="{{element.url}}"/>
|
<img src="{{element.url}}"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,6 +99,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
<div class="cover-no-image">
|
<div class="cover-no-image">
|
||||||
</div>
|
</div>
|
||||||
@@ -105,10 +114,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ------------------------- ADMIN section --------------------------------- -->
|
<!-- ------------------------- ADMIN section --------------------------------- -->
|
||||||
<div class="title" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="title">
|
||||||
Administration
|
Administration
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<i class="material-icons">data_usage</i> ID:
|
<i class="material-icons">data_usage</i> ID:
|
||||||
@@ -131,17 +140,22 @@
|
|||||||
<div class="label">
|
<div class="label">
|
||||||
<i class="material-icons">delete_forever</i> Trash:
|
<i class="material-icons">delete_forever</i> Trash:
|
||||||
</div>
|
</div>
|
||||||
<div class="input" *ngIf="(trackCount == '0')">
|
@if(trackCount == '0') {
|
||||||
|
<div class="input">
|
||||||
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
|
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
|
||||||
<i class="material-icons">delete</i> Remove album
|
<i class="material-icons">delete</i> Remove album
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="input" *ngIf="(trackCount != '0')">
|
}
|
||||||
|
@else {
|
||||||
|
<div class="input">
|
||||||
<i class="material-icons">new_releases</i> Can not remove album, track depending on it
|
<i class="material-icons">new_releases</i> Can not remove album, track depending on it
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
||||||
[mediaUploaded]="upload.mediaSendSize"
|
[mediaUploaded]="upload.mediaSendSize"
|
||||||
|
|||||||
@@ -5,12 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { UploadProgress, PopInService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Album } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, ArianeService, DataService } from 'app/service';
|
import { AlbumService, ArianeService, DataService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
|
||||||
import { PopInService } from 'common/service';
|
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -45,7 +44,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
// --------------- confirm section ------------------
|
// --------------- confirm section ------------------
|
||||||
public confirmDeleteComment: string = null;
|
public confirmDeleteComment: string = null;
|
||||||
public confirmDeleteImageUrl: string = null;
|
public confirmDeleteImageUrl: string = null;
|
||||||
private deleteCoverId: number = null;
|
private deleteCoverId: string = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@@ -67,6 +66,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService,
|
private popInService: PopInService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
@@ -77,7 +77,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
this.idAlbum = this.arianeService.getAlbumId();
|
this.idAlbum = this.arianeService.getAlbumId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.albumService.get(this.idAlbum)
|
this.albumService.get(this.idAlbum)
|
||||||
.then((response: NodeData) => {
|
.then((response: Album) => {
|
||||||
console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of album : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.nameAlbum = response.name;
|
self.nameAlbum = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
@@ -91,7 +91,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
self.itemIsNotFound = true;
|
self.itemIsNotFound = true;
|
||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
});
|
});
|
||||||
this.albumService.getTrack(this.idAlbum)
|
this.trackService.getTracksWithAlbumId(this.idAlbum)
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
self.trackCount = response.length;
|
self.trackCount = response.length;
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
@@ -105,7 +105,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
for (let iii = 0; iii < covers.length; iii++) {
|
for (let iii = 0; iii < covers.length; iii++) {
|
||||||
this.coversDisplay.push({
|
this.coversDisplay.push({
|
||||||
id: covers[iii],
|
id: covers[iii],
|
||||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -165,7 +165,7 @@ export class AlbumEditScene implements OnInit {
|
|||||||
this.upload.clear();
|
this.upload.clear();
|
||||||
// display the upload pop-in
|
// display the upload pop-in
|
||||||
this.popInService.open('popin-upload-progress');
|
this.popInService.open('popin-upload-progress');
|
||||||
this.albumService.uploadCover(file, this.idAlbum, (count, total) => {
|
this.albumService.uploadCover(this.idAlbum, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@@ -179,14 +179,14 @@ export class AlbumEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCover(id: number) {
|
removeCover(id: string) {
|
||||||
this.cleanConfirm();
|
this.cleanConfirm();
|
||||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||||
this.deleteCoverId = id;
|
this.deleteCoverId = id;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
removeCoverAfterConfirm(id: number) {
|
removeCoverAfterConfirm(id: string) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.albumService.deleteCover(this.idAlbum, id)
|
this.albumService.deleteCover(this.idAlbum, id)
|
||||||
|
|||||||
@@ -1,40 +1,26 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
|
||||||
<div class="cover-area">
|
<description-area
|
||||||
<div class="cover" *ngIf="covers" >
|
[title]="name"
|
||||||
<img src="{{covers[0]}}"/>
|
[name]="albumName"
|
||||||
</div>
|
[description]="albumDescription"
|
||||||
</div>
|
[cover1]="artistCovers"
|
||||||
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
[cover2]="albumCovers"
|
||||||
<div class="title">
|
(play)="playAll()"
|
||||||
{{name}}
|
(shuffle)="playShuffle()"/>
|
||||||
</div>
|
@if (tracks) {
|
||||||
<div class="title">
|
<div class="fill-content colomn_single">
|
||||||
{{albumName}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="albumDescription">
|
|
||||||
{{albumDescription}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="albumDescription">
|
|
||||||
{{albumDescription}}
|
|
||||||
</div>
|
|
||||||
<button class="button color-button color-shadow-black" (click)="playAll($event)" type="submit">
|
|
||||||
<i class="material-icons">play_arrow</i> Play All
|
|
||||||
</button>
|
|
||||||
<button class="button color-button color-shadow-black" style="margin-left:10px;" (click)="playShuffe($event)" type="submit">
|
|
||||||
<i class="material-icons">shuffle</i> Shuffle
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="tracks">
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
<div class="title" *ngIf="tracks.length == 1">Track:</div>
|
@for (data of tracks; track data.id;) {
|
||||||
<app-element-track
|
<app-element-track
|
||||||
*ngFor="let data of tracks"
|
|
||||||
[element]="data"
|
[element]="data"
|
||||||
(click)="onSelectTrack($event, data.id)"
|
(click)="onSelectTrack($event, data.id)"
|
||||||
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
|
(auxclick)="onSelectTrack($event, data.id)"/>
|
||||||
|
} @empty {
|
||||||
|
Aucune piste accessible.
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear-end"></div>
|
<div class="clear-end"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -4,28 +4,29 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Media } from 'app/model';
|
import { Album, Track } from 'app/back-api';
|
||||||
|
import { arrayUnique } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-album',
|
selector: 'app-album',
|
||||||
templateUrl: './album.html'
|
templateUrl: './album.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlbumScene implements OnInit {
|
export class AlbumScene implements OnInit {
|
||||||
public idArtist = -1;
|
public artistIds: number[] = [];
|
||||||
public idAlbum = -1;
|
public idAlbum: number = -1;
|
||||||
public name: string = '';
|
public name: string = '???';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: Array<string> = undefined;
|
public artistCovers: Array<string> = undefined;
|
||||||
public albumName: string = '';
|
public albumName: string = '';
|
||||||
public albumDescription: string = undefined;
|
public albumDescription: string = undefined;
|
||||||
public albumCovers: string[] = undefined;
|
public albumCovers: string[] = undefined;
|
||||||
|
|
||||||
public tracksIds: number[] = undefined;
|
public tracksIds: number[] = undefined;
|
||||||
public tracks: Media[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
@@ -34,42 +35,53 @@
|
|||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
//this.artistIds = [this.arianeService.getArtistId()];
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
|
||||||
this.idAlbum = this.arianeService.getAlbumId();
|
this.idAlbum = this.arianeService.getAlbumId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.artistService.get(this.idArtist)
|
|
||||||
.then((response) => {
|
|
||||||
self.name = response.name;
|
|
||||||
self.description = response.description;
|
|
||||||
self.covers = this.dataService.getCoverListUrl(response.covers);
|
|
||||||
}).catch((response) => {
|
|
||||||
self.description = undefined;
|
|
||||||
self.name = '???';
|
|
||||||
self.covers = undefined;
|
|
||||||
// no check just ==> an error occured on album
|
|
||||||
});
|
|
||||||
this.albumService.get(this.idAlbum)
|
this.albumService.get(this.idAlbum)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.albumName = response.name;
|
self.albumName = response.name;
|
||||||
self.albumDescription = response.description;
|
self.albumDescription = response.description;
|
||||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((error) => {
|
||||||
self.albumDescription = undefined;
|
self.albumDescription = undefined;
|
||||||
self.albumName = '???';
|
self.albumName = '???';
|
||||||
self.albumCovers = undefined;
|
self.albumCovers = undefined;
|
||||||
// no check just ==> an error occured on album
|
// no check just ==> an error occurred on album
|
||||||
});
|
});
|
||||||
|
|
||||||
//console.log("all the tracks: " + self.tracksIds);
|
console.log(`all the tracks for a specific album: ${self.idAlbum}`);
|
||||||
this.trackService.getWithAlbum(self.idAlbum)
|
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||||
.then((response2: Media[]) => {
|
.then((response2: Track[]) => {
|
||||||
self.tracks = response2;
|
self.tracks = response2;
|
||||||
|
console.log(`get tracks : ${JSON.stringify(self.tracks, null, 2)}`);
|
||||||
|
self.artistIds = []
|
||||||
|
self.tracks.forEach(element => {
|
||||||
|
self.artistIds = [...self.artistIds, ...element.artists];
|
||||||
|
});
|
||||||
|
self.artistIds = arrayUnique(self.artistIds);
|
||||||
|
if (self.artistIds.length === 0) {
|
||||||
|
console.error("No artist found !!!");
|
||||||
|
return;
|
||||||
|
} else if (self.artistIds.length > 1) {
|
||||||
|
console.error("More than 1 artist ==> not managed");
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
// TODO: display more than 1 ...
|
||||||
|
self.artistService.get(self.artistIds[0])
|
||||||
|
.then((response) => {
|
||||||
|
self.name = response.name;
|
||||||
|
self.description = response.description;
|
||||||
|
self.artistCovers = self.dataService.getListUrl(response.covers);
|
||||||
|
}).catch((error) => {
|
||||||
|
self.description = undefined;
|
||||||
|
self.name = '???';
|
||||||
|
self.artistCovers = undefined;
|
||||||
|
});
|
||||||
|
*/
|
||||||
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
//console.log(`>>>>BBB plop`);
|
//console.log(`>>>>BBB plop`);
|
||||||
@@ -77,7 +89,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
//this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
//this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
||||||
// TODO: add on global player ...
|
// TODO: add on global player ...
|
||||||
@@ -85,7 +97,7 @@
|
|||||||
|
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
let valuePlayed: number = undefined;
|
let valuePlayed: number = undefined;
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
//console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`);
|
//console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`);
|
||||||
if (this.tracks[iii].id == idSelected) {
|
if (this.tracks[iii].id == idSelected) {
|
||||||
@@ -96,25 +108,23 @@
|
|||||||
this.playerService.playInList(valuePlayed, elements);
|
this.playerService.playInList(valuePlayed, elements);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playAll(event: any):void {
|
playAll(): void {
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
}
|
}
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
this.playerService.setNewPlaylist(elements);
|
this.playerService.setNewPlaylist(elements);
|
||||||
}
|
}
|
||||||
playShuffe(event: any):void {
|
playShuffle(): void {
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
}
|
}
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
this.playerService.setNewPlaylistShuffle(elements);
|
this.playerService.setNewPlaylistShuffle(elements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,40 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
<description-area
|
||||||
<div class="cover-area">
|
[title]="name"
|
||||||
<div class="cover" *ngIf="covers" >
|
[description]="description"
|
||||||
<img src="{{covers[0]}}"/>
|
[cover1]="covers"
|
||||||
</div>
|
(play)="playAll()"
|
||||||
</div>
|
(shuffle)="playShuffle()"/>
|
||||||
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
@if(albums) {
|
||||||
<div class="title">
|
<div class="fill-content colomn_single">
|
||||||
{{name}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="description">
|
|
||||||
{{description}}
|
|
||||||
</div>
|
|
||||||
<button class="button color-button color-shadow-black" (click)="playAll($event)" type="submit">
|
|
||||||
<i class="material-icons">play_arrow</i> Play All
|
|
||||||
</button>
|
|
||||||
<button class="button color-button color-shadow-black" style="margin-left:10px;" (click)="playShuffe($event)" type="submit">
|
|
||||||
<i class="material-icons">shuffle</i> Shuffle
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="albums">
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="albums.length > 1">Albums:</div>
|
<div class="title">Album{{albums.length > 1?"s":""}}: <app-entry placeholder="Search..." (changeValue)="onSearch($event)"></app-entry></div>
|
||||||
<div class="title" *ngIf="albums.length == 1">Album:</div>
|
@for (data of albums; track data.id;) {
|
||||||
<div *ngFor="let data of albums" class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
<div class="item-list"
|
||||||
|
(click)="onSelectAlbum($event, data.id)"
|
||||||
|
(auxclick)="onSelectAlbum($event, data.id)"
|
||||||
|
>
|
||||||
<app-element-season
|
<app-element-season
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Track"
|
countSubType="Track"
|
||||||
[countSubTypeCallBack]="countTrack"
|
[countSubTypeCallBack]="countTrack"
|
||||||
subValues="Artist"
|
subValues="Artist"
|
||||||
[subValuesCallBack]="getArtistsString"
|
[subValuesCallBack]="getArtistsString"/>
|
||||||
></app-element-season>
|
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="tracks">
|
}
|
||||||
|
@if(tracks) {
|
||||||
|
<div class="fill-content colomn_mutiple">
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
<div class="title" *ngIf="tracks.length == 1">Track:</div>
|
@for (data of tracks; track data.id;) {
|
||||||
<div *ngFor="let data of tracks" class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
<app-element-video
|
<app-element-video
|
||||||
[element]="data"
|
[element]="data"/>
|
||||||
></app-element-video>
|
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear-end"></div>
|
<div class="clear-end"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -4,21 +4,23 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { DataTools } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Album, Artist, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-albums',
|
selector: 'app-albums',
|
||||||
templateUrl: './albums.html'
|
templateUrl: './albums.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlbumsScene implements OnInit {
|
export class AlbumsScene implements OnInit {
|
||||||
public name: string = '';
|
public name: string = '';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: string[] = undefined;
|
public covers: string[] = undefined;
|
||||||
public albums: NodeData[] = undefined;
|
public albums: Album[] = undefined;
|
||||||
|
public albumsSave: Album[] = undefined;
|
||||||
public tracks: any[] = undefined;
|
public tracks: any[] = undefined;
|
||||||
public countSubElement: number = undefined;
|
public countSubElement: number = undefined;
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
@@ -34,30 +36,45 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(albumId: number) : Promise<Number> {
|
countTrackCallback(albumId: number): Promise<Number> {
|
||||||
return this.albumService.countTrack(albumId);
|
return this.trackService.countTracksWithAlbumId(albumId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArtistsStringCallback(albumId: number) : Promise<String[]> {
|
getArtistsStringCallback(albumId: number): Promise<String[]> {
|
||||||
//console.log(`request all artist for album: {albumId}`)
|
//console.log(`request all artist for album: {albumId}`)
|
||||||
return this.albumService.getArtists(albumId);
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.trackService.getTracksWithAlbumId(albumId)
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
const listArtists = DataTools.extractLimitOneList(response, "artists");
|
||||||
|
self.artistService.getAll(listArtists)
|
||||||
|
.then((listArtists: Artist[]) => {
|
||||||
|
resolve(DataTools.extractLimitOne(listArtists, "name"));
|
||||||
|
}).catch((error) => {
|
||||||
|
resolve([">> ERROR 1 <<"]);
|
||||||
|
})
|
||||||
|
}).catch((error) => {
|
||||||
|
resolve([">> ERROR 2 <<"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getArtistsString = (id:number) => {return self.getArtistsStringCallback(id);};
|
const self = this;
|
||||||
this.countTrack = (id:number) => {return self.countTrackCallback(id);};
|
this.getArtistsString = (id: number) => { return self.getArtistsStringCallback(id); };
|
||||||
let self = this;
|
this.countTrack = (id: number) => { return self.countTrackCallback(id); };
|
||||||
self.name = "All Albums";
|
self.name = "All Albums";
|
||||||
self.description = "View all albums (no specific artist)";
|
self.description = "View all albums (no specific artist)";
|
||||||
|
|
||||||
//console.log(`get parameter id: ${ this.idArtist}`);
|
//console.log(`get parameter id: ${ this.idArtist}`);
|
||||||
this.albumService.getOrder()
|
this.albumService.getOrder()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Album[]) => {
|
||||||
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
||||||
self.albums = response;
|
self.albums = response;
|
||||||
|
self.albumsSave = [...response];
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albums = undefined;
|
self.albums = undefined;
|
||||||
});
|
});
|
||||||
// TODO later: get all orfan tracks ...
|
// TODO later: get all orfans tracks ...
|
||||||
/*
|
/*
|
||||||
this.artistService.getTrack(this.idArtist)
|
this.artistService.getTrack(this.idArtist)
|
||||||
.then((response: NodeData[]) => {
|
.then((response: NodeData[]) => {
|
||||||
@@ -69,28 +86,33 @@
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSearch(value: string) {
|
||||||
|
console.log(`Search value: ${value}`);
|
||||||
|
this.albums = this.albumsSave.filter(element => {
|
||||||
|
return element.name.toLowerCase().includes(value.toLowerCase());;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectAlbum(event: any, idSelected: number): void {
|
||||||
onSelectAlbum(event: any, idSelected: number):void {
|
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 } );
|
this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateAlbum({albumId: idSelected, newWindows: event.which === 2 } );
|
this.arianeService.navigateAlbum({ albumId: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playAll(event: any):void {
|
playAll(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@@ -101,11 +123,11 @@
|
|||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o ftrack ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
playShuffe(event: any):void {
|
playShuffle(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@@ -116,6 +138,5 @@
|
|||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o ftrack ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2,21 +2,26 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
Edit artist
|
Edit artist
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsRemoved">
|
@if(itemIsRemoved) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The artist has been removed
|
The artist has been removed
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsNotFound">
|
}
|
||||||
|
@else if (itemIsNotFound) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The artist does not exist
|
The artist does not exist
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsLoading">
|
}
|
||||||
|
@else if (itemIsLoading) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
Loading ...<br/>
|
Loading ...<br/>
|
||||||
@@ -24,18 +29,9 @@
|
|||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
}
|
||||||
<div class="request_raw">
|
@else {
|
||||||
<div class="label">
|
<div class="fill-all">
|
||||||
Type:
|
|
||||||
</div>
|
|
||||||
<div class="input">
|
|
||||||
<select [ngModel]="typeId"
|
|
||||||
(ngModelChange)="onChangeType($event)">
|
|
||||||
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
Name:
|
Name:
|
||||||
@@ -66,10 +62,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ------------------------- Cover section --------------------------------- -->
|
<!-- ------------------------- Cover section --------------------------------- -->
|
||||||
<div class="title" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="title">
|
||||||
Covers
|
Covers
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="fill-all">
|
||||||
<div class="hide-element">
|
<div class="hide-element">
|
||||||
<input type="file"
|
<input type="file"
|
||||||
#fileInput
|
#fileInput
|
||||||
@@ -79,7 +75,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<div class="cover" *ngFor="let element of coversDisplay">
|
@for (element of coversDisplay; track element.id;) {
|
||||||
|
<div class="cover">
|
||||||
<div class="cover-image">
|
<div class="cover-image">
|
||||||
<img src="{{element.url}}"/>
|
<img src="{{element.url}}"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,6 +86,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
<div class="cover-no-image">
|
<div class="cover-no-image">
|
||||||
</div>
|
</div>
|
||||||
@@ -103,10 +101,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ------------------------- ADMIN section --------------------------------- -->
|
<!-- ------------------------- ADMIN section --------------------------------- -->
|
||||||
<div class="title" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="title">
|
||||||
Administration
|
Administration
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<i class="material-icons">data_usage</i> ID:
|
<i class="material-icons">data_usage</i> ID:
|
||||||
@@ -138,17 +136,22 @@
|
|||||||
<div class="label">
|
<div class="label">
|
||||||
<i class="material-icons">delete_forever</i> Trash:
|
<i class="material-icons">delete_forever</i> Trash:
|
||||||
</div>
|
</div>
|
||||||
<div class="input" *ngIf="(trackCount == '0' && albumsCount == '0')">
|
@if(trackCount == '0' && albumsCount == '0') {
|
||||||
|
<div class="input">
|
||||||
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
|
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
|
||||||
<i class="material-icons">delete</i> Remove Artist
|
<i class="material-icons">delete</i> Remove Artist
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="input" *ngIf="(trackCount != '0' || albumsCount != '0')">
|
}
|
||||||
|
@else {
|
||||||
|
<div class="input">
|
||||||
<i class="material-icons">new_releases</i> Can not remove album or track depending on it
|
<i class="material-icons">new_releases</i> Can not remove album or track depending on it
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
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';
|
|
||||||
|
|
||||||
export class ElementList {
|
export class ElementList {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -31,7 +31,6 @@ export class ArtistEditScene implements OnInit {
|
|||||||
|
|
||||||
error: string = '';
|
error: string = '';
|
||||||
|
|
||||||
typeId: number = null;
|
|
||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
coverFile: File;
|
coverFile: File;
|
||||||
@@ -45,15 +44,10 @@ export class ArtistEditScene implements OnInit {
|
|||||||
// section tha define the upload value to display in the pop-in of upload
|
// section tha define the upload value to display in the pop-in of upload
|
||||||
public upload: UploadProgress = new UploadProgress();
|
public upload: UploadProgress = new UploadProgress();
|
||||||
|
|
||||||
|
|
||||||
listType: ElementList[] = [
|
|
||||||
{ value: undefined, label: '---' },
|
|
||||||
];
|
|
||||||
|
|
||||||
// --------------- confirm section ------------------
|
// --------------- confirm section ------------------
|
||||||
public confirmDeleteComment: string = null;
|
public confirmDeleteComment: string = null;
|
||||||
public confirmDeleteImageUrl: string = null;
|
public confirmDeleteImageUrl: string = null;
|
||||||
private deleteCoverId: number = null;
|
private deleteCoverId: string = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@@ -74,8 +68,9 @@ export class ArtistEditScene implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
constructor(private dataService: DataService,
|
constructor(private dataService: DataService,
|
||||||
private typeService: GenderService,
|
private genderService: GenderService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService) {
|
private popInService: PopInService) {
|
||||||
|
|
||||||
@@ -84,22 +79,11 @@ export class ArtistEditScene implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
this.idArtist = this.arianeService.getArtistId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.listType = [{ value: null, label: '---' }];
|
|
||||||
|
|
||||||
this.typeService.getData()
|
|
||||||
.then((response2) => {
|
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
|
||||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
|
||||||
}
|
|
||||||
}).catch((response2) => {
|
|
||||||
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.artistService.get(this.idArtist)
|
this.artistService.get(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: Artist) => {
|
||||||
// console.log("get response of track : " + JSON.stringify(response, null, 2));
|
// console.log("get response of track : " + JSON.stringify(response, null, 2));
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.typeId = response.parentId;
|
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.updateCoverList(response.covers);
|
self.updateCoverList(response.covers);
|
||||||
// console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
|
// console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
|
||||||
@@ -113,14 +97,14 @@ export class ArtistEditScene implements OnInit {
|
|||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
});
|
});
|
||||||
console.log(`get parameter id: ${this.idArtist}`);
|
console.log(`get parameter id: ${this.idArtist}`);
|
||||||
this.artistService.getAlbum(this.idArtist)
|
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: number[]) => {
|
||||||
self.albumsCount = "" + response.length;
|
self.albumsCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albumsCount = '---';
|
self.albumsCount = '---';
|
||||||
});
|
});
|
||||||
this.artistService.getAllTracks(this.idArtist)
|
this.trackService.getTracksOfAnArtist(this.idArtist)
|
||||||
.then((response) => {
|
.then((response: Track[]) => {
|
||||||
self.trackCount = "" + response.length;
|
self.trackCount = "" + response.length;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.trackCount = '---';
|
self.trackCount = '---';
|
||||||
@@ -133,7 +117,7 @@ export class ArtistEditScene implements OnInit {
|
|||||||
for (let iii = 0; iii < covers.length; iii++) {
|
for (let iii = 0; iii < covers.length; iii++) {
|
||||||
this.coversDisplay.push({
|
this.coversDisplay.push({
|
||||||
id: covers[iii],
|
id: covers[iii],
|
||||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -149,18 +133,9 @@ export class ArtistEditScene implements OnInit {
|
|||||||
this.description = value;
|
this.description = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeType(value: any): void {
|
|
||||||
console.log(`Change requested of type ... ${value}`);
|
|
||||||
this.typeId = value;
|
|
||||||
if (this.typeId === undefined) {
|
|
||||||
this.typeId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendValues(): void {
|
sendValues(): void {
|
||||||
console.log('send new values....');
|
console.log('send new values....');
|
||||||
let data = {
|
let data = {
|
||||||
parentId: this.typeId,
|
|
||||||
name: this.name,
|
name: this.name,
|
||||||
description: this.description
|
description: this.description
|
||||||
};
|
};
|
||||||
@@ -203,7 +178,7 @@ export class ArtistEditScene implements OnInit {
|
|||||||
this.upload.clear();
|
this.upload.clear();
|
||||||
// display the upload pop-in
|
// display the upload pop-in
|
||||||
this.popInService.open('popin-upload-progress');
|
this.popInService.open('popin-upload-progress');
|
||||||
this.artistService.uploadCover(file, this.idArtist, (count, total) => {
|
this.artistService.uploadCover(this.idArtist, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@@ -216,14 +191,14 @@ export class ArtistEditScene implements OnInit {
|
|||||||
console.log('Can not add the cover in the track...');
|
console.log('Can not add the cover in the track...');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
removeCover(id: number) {
|
removeCover(id: string) {
|
||||||
this.cleanConfirm();
|
this.cleanConfirm();
|
||||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||||
this.deleteCoverId = id;
|
this.deleteCoverId = id;
|
||||||
this.popInService.open('popin-delete-confirm');
|
this.popInService.open('popin-delete-confirm');
|
||||||
}
|
}
|
||||||
removeCoverAfterConfirm(id: number) {
|
removeCoverAfterConfirm(id: string) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.artistService.deleteCover(this.idArtist, id)
|
this.artistService.deleteCover(this.idArtist, id)
|
||||||
|
|||||||
@@ -1,38 +1,25 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
<description-area
|
||||||
<div class="cover-area">
|
[title]="name"
|
||||||
<div class="cover" *ngIf="covers" >
|
[name]="albumName"
|
||||||
<img src="{{covers[0]}}"/>
|
[description]="albumDescription"
|
||||||
</div>
|
[cover1]="artistCovers"
|
||||||
</div>
|
[cover2]="albumCovers"
|
||||||
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
(play)="playAll()"
|
||||||
<div class="title">
|
(shuffle)="playShuffle()"/>
|
||||||
{{name}}
|
@if(tracks) {
|
||||||
</div>
|
<div class="fill-content colomn_single">
|
||||||
<div class="title">
|
|
||||||
{{albumName}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="albumDescription">
|
|
||||||
{{albumDescription}}
|
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<button class="button color-button color-shadow-black" (click)="playAll($event)" type="submit">
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
<i class="material-icons">play_arrow</i> Play All
|
@for (data of tracks; track data.id;) {
|
||||||
</button>
|
|
||||||
<button class="button color-button color-shadow-black" style="margin-left:10px;" (click)="playShuffe($event)" type="submit">
|
|
||||||
<i class="material-icons">shuffle</i> Shuffle
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="tracks">
|
|
||||||
<div class="clear"></div>
|
|
||||||
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
|
|
||||||
<div class="title" *ngIf="tracks.length == 1">Track:</div>
|
|
||||||
<app-element-track
|
<app-element-track
|
||||||
*ngFor="let data of tracks"
|
|
||||||
[element]="data"
|
[element]="data"
|
||||||
(click)="onSelectTrack($event, data.id)"
|
(click)="onSelectTrack($event, data.id)"
|
||||||
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
|
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
|
||||||
|
} @empty {
|
||||||
|
Aucune piste accessible.
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear-end"></div>
|
<div class="clear-end"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Media } from 'app/model';
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
|
|
||||||
@@ -19,13 +19,13 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
public idAlbum = -1;
|
public idAlbum = -1;
|
||||||
public name: string = '';
|
public name: string = '';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: Array<string> = undefined;
|
public artistCovers: Array<string> = undefined;
|
||||||
public albumName: string = '';
|
public albumName: string = '';
|
||||||
public albumDescription: string = undefined;
|
public albumDescription: string = undefined;
|
||||||
public albumCovers: string[] = undefined;
|
public albumCovers: string[] = undefined;
|
||||||
|
|
||||||
public tracksIds: number[] = undefined;
|
public tracksIds: number[] = undefined;
|
||||||
public tracks: Media[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
@@ -38,8 +38,6 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
this.idArtist = this.arianeService.getArtistId();
|
||||||
this.idAlbum = this.arianeService.getAlbumId();
|
this.idAlbum = this.arianeService.getAlbumId();
|
||||||
let self = this;
|
let self = this;
|
||||||
@@ -47,18 +45,18 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.covers = this.dataService.getCoverListUrl(response.covers);
|
self.artistCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.description = undefined;
|
self.description = undefined;
|
||||||
self.name = '???';
|
self.name = '???';
|
||||||
self.covers = undefined;
|
self.artistCovers = undefined;
|
||||||
// no check just ==> an error occured on album
|
// no check just ==> an error occured on album
|
||||||
});
|
});
|
||||||
this.albumService.get(this.idAlbum)
|
this.albumService.get(this.idAlbum)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.albumName = response.name;
|
self.albumName = response.name;
|
||||||
self.albumDescription = response.description;
|
self.albumDescription = response.description;
|
||||||
self.albumCovers = this.dataService.getCoverListUrl(response.covers);
|
self.albumCovers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albumDescription = undefined;
|
self.albumDescription = undefined;
|
||||||
self.albumName = '???';
|
self.albumName = '???';
|
||||||
@@ -67,8 +65,8 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//console.log("all the tracks: " + self.tracksIds);
|
//console.log("all the tracks: " + self.tracksIds);
|
||||||
this.trackService.getWithAlbum(self.idAlbum)
|
this.trackService.getTracksWithAlbumId(self.idAlbum)
|
||||||
.then((response2: Media[]) => {
|
.then((response2: Track[]) => {
|
||||||
self.tracks = response2;
|
self.tracks = response2;
|
||||||
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
//console.log(`>>>>BBB get tracks : ${JSON.stringify(response2, null, 2)}`);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@@ -77,7 +75,7 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
//this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
//this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
||||||
// TODO: add on global player ...
|
// TODO: add on global player ...
|
||||||
@@ -85,7 +83,7 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
|
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
let valuePlayed: number = undefined;
|
let valuePlayed: number = undefined;
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
//console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`);
|
//console.log(`plop: ${this.tracks[iii].id} == ${idSelected} ==> ${this.tracks[iii].name}`);
|
||||||
if (this.tracks[iii].id == idSelected) {
|
if (this.tracks[iii].id == idSelected) {
|
||||||
@@ -96,20 +94,20 @@ export class ArtistAlbumScene implements OnInit {
|
|||||||
this.playerService.playInList(valuePlayed, elements);
|
this.playerService.playInList(valuePlayed, elements);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playAll(event: any):void {
|
playAll(): void {
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
}
|
}
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
this.playerService.setNewPlaylist(elements);
|
this.playerService.setNewPlaylist(elements);
|
||||||
}
|
}
|
||||||
playShuffe(event: any):void {
|
playShuffle(): void {
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
for (let iii=0; iii< this.tracks.length; iii++) {
|
for (let iii = 0; iii < this.tracks.length; iii++) {
|
||||||
elements.push(this.tracks[iii].id);
|
elements.push(this.tracks[iii].id);
|
||||||
}
|
}
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
|
|||||||
@@ -1,46 +1,37 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
<description-area
|
||||||
<div class="cover-area">
|
[title]="name"
|
||||||
<div class="cover" *ngIf="covers" >
|
[description]="description"
|
||||||
<img src="{{covers[0]}}"/>
|
[cover1]="covers"
|
||||||
</div>
|
(play)="playAll()"
|
||||||
</div>
|
(shuffle)="playShuffle()"/>
|
||||||
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
@if(albums) {
|
||||||
<div class="title">
|
<div class="fill-content colomn_single">
|
||||||
{{name}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="description">
|
|
||||||
{{description}}
|
|
||||||
</div>
|
|
||||||
<button class="button color-button color-shadow-black" (click)="playAll($event)" type="submit">
|
|
||||||
<i class="material-icons">play_arrow</i> Play All
|
|
||||||
</button>
|
|
||||||
<button class="button color-button color-shadow-black" style="margin-left:10px;" (click)="playShuffe($event)" type="submit">
|
|
||||||
<i class="material-icons">shuffle</i> Shuffle
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="albums">
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="albums.length > 1">Albums:</div>
|
<div class="title">Album{{albums.length > 1?"s":""}}:</div>
|
||||||
<div class="title" *ngIf="albums.length == 1">Album:</div>
|
@for (data of albums; track data.id;) {
|
||||||
<div *ngFor="let data of albums" class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
<div class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
||||||
<app-element-season
|
<app-element-season
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Track"
|
countSubType="Track"
|
||||||
[countSubTypeCallBack]="countTrack"
|
[countSubTypeCallBack]="countTrack"
|
||||||
></app-element-season>
|
></app-element-season>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="tracks">
|
}
|
||||||
|
@if(tracks) {
|
||||||
|
<div class="fill-content colomn_mutiple">
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
<div class="title" *ngIf="tracks.length == 1">Track:</div>
|
@for (data of tracks; track data.id;) {
|
||||||
<div *ngFor="let data of tracks" class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
<app-element-video
|
<app-element-video
|
||||||
[element]="data"
|
[element]="data"
|
||||||
></app-element-video>
|
></app-element-video>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear-end"></div>
|
<div class="clear-end"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Album, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-artist',
|
selector: 'app-artist',
|
||||||
@@ -19,8 +19,8 @@ export class ArtistScene implements OnInit {
|
|||||||
public name: string = '';
|
public name: string = '';
|
||||||
public description: string = undefined;
|
public description: string = undefined;
|
||||||
public covers: string[] = undefined;
|
public covers: string[] = undefined;
|
||||||
public albums: NodeData[] = undefined;
|
public albums: Album[] = undefined;
|
||||||
public tracks: any[] = undefined;
|
public tracks: Track[] = undefined;
|
||||||
public countSubElement: number = undefined;
|
public countSubElement: number = undefined;
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
|
|
||||||
@@ -28,40 +28,45 @@ export class ArtistScene implements OnInit {
|
|||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(albumId: number) : Promise<Number> {
|
countTrackCallback(albumId: number): Promise<Number> {
|
||||||
return this.albumService.countTrack(albumId);
|
return this.trackService.countTracksWithAlbumId(albumId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.countTrack = (id:number) => {return self.countTrackCallback(id);};
|
this.countTrack = (id: number) => { return self.countTrackCallback(id); };
|
||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||||
this.idArtist = this.arianeService.getArtistId();
|
this.idArtist = this.arianeService.getArtistId();
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
this.artistService.get(this.idArtist)
|
this.artistService.get(this.idArtist)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.covers = this.dataService.getCoverListUrl(response.covers);
|
self.covers = this.dataService.getListUrl(response.covers);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.name = '???';
|
self.name = '???';
|
||||||
self.description = undefined;
|
self.description = undefined;
|
||||||
self.covers = undefined;
|
self.covers = undefined;
|
||||||
});
|
});
|
||||||
//console.log(`get parameter id: ${ this.idArtist}`);
|
//console.log(`get parameter id: ${ this.idArtist}`);
|
||||||
this.artistService.getAlbum(this.idArtist)
|
this.trackService.getAlbumIdsOfAnArtist(this.idArtist)
|
||||||
.then((response: NodeData[]) => {
|
.then((albumIds: number[]) => {
|
||||||
|
this.albumService.getAll(albumIds)
|
||||||
|
.then((response: Album[]) => {
|
||||||
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
|
||||||
self.albums = response;
|
self.albums = response;
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.albums = undefined;
|
self.albums = undefined;
|
||||||
});
|
});
|
||||||
|
}).catch((response) => {
|
||||||
|
self.albums = undefined;
|
||||||
|
});
|
||||||
// TODO later: get all orfan tracks ...
|
// TODO later: get all orfan tracks ...
|
||||||
/*
|
/*
|
||||||
this.artistService.getTrack(this.idArtist)
|
this.artistService.getTrack(this.idArtist)
|
||||||
@@ -76,31 +81,31 @@ export class ArtistScene implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
onSelectAlbum(event: any, idSelected: number):void {
|
onSelectAlbum(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 } );
|
this.arianeService.navigateAlbumEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateArtist({artistId: this.idArtist, albumId: idSelected, newWindows: event.which === 2 } );
|
this.arianeService.navigateArtist({ artistId: this.idArtist, albumId: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({trackId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllTracksIds(): Promise<number[]> {
|
getAllTracksIds(): Promise<number[]> {
|
||||||
let elements: number[] = [];
|
let elements: number[] = [];
|
||||||
for (let iii=0; iii< this.albums.length; iii++) {
|
for (let iii = 0; iii < this.albums.length; iii++) {
|
||||||
elements.push(this.albums[iii].id);
|
elements.push(this.albums[iii].id);
|
||||||
}
|
}
|
||||||
return this.albumService.getAllTracksForAlbums(elements);
|
return this.trackService.getTracksIdsForAlbums(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
playAll(event: any):void {
|
playAll(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.getAllTracksIds()
|
this.getAllTracksIds()
|
||||||
@@ -111,7 +116,7 @@ export class ArtistScene implements OnInit {
|
|||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o ftrack ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
playShuffe(event: any):void {
|
playShuffle(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.getAllTracksIds()
|
this.getAllTracksIds()
|
||||||
|
|||||||
@@ -1,30 +1,16 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
<description-area
|
||||||
<div class="cover-area">
|
[title]="name"
|
||||||
<div class="cover" *ngIf="covers" >
|
[description]="description"
|
||||||
<img src="{{covers[0]}}"/>
|
[cover1]="covers"
|
||||||
</div>
|
(play)="playAll()"
|
||||||
</div>
|
(shuffle)="playShuffle()"/>
|
||||||
<div [className]="covers ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
@if(artists) {
|
||||||
<div class="title">
|
<div class="fill-content colomn_single">
|
||||||
{{name}}
|
|
||||||
</div>
|
|
||||||
<div class="description" *ngIf="description">
|
|
||||||
{{description}}
|
|
||||||
</div>
|
|
||||||
<button class="button color-button color-shadow-black" (click)="playAll($event)" type="submit">
|
|
||||||
<i class="material-icons">play_arrow</i> Play All
|
|
||||||
</button>
|
|
||||||
<button class="button color-button color-shadow-black" style="margin-left:10px;" (click)="playShuffe($event)" type="submit">
|
|
||||||
<i class="material-icons">shuffle</i> Shuffle
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="fill-content colomn_mutiple" *ngIf="artists">
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title" *ngIf="artists.length > 1">Artists:</div>
|
<div class="title">Artist{{artists.length > 1?"s":""}}: <app-entry placeholder="Search..." (changeValue)="onSearch($event)"></app-entry></div>
|
||||||
<div class="title" *ngIf="artists.length == 1">Artist:</div>
|
@for (data of artists; track data.id;) {
|
||||||
<div *ngFor="let data of artists" class="item-list" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
<div class="item-list" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
||||||
<app-element-season
|
<app-element-season
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Album"
|
countSubType="Album"
|
||||||
@@ -33,6 +19,8 @@
|
|||||||
[countSubType2CallBack]="countTrack"
|
[countSubType2CallBack]="countTrack"
|
||||||
></app-element-season>
|
></app-element-season>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear-end"></div>
|
<div class="clear-end"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Artist, Track } from 'app/back-api';
|
||||||
|
|
||||||
import { ArtistService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, ArianeService, TrackService, PlayerService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-artists',
|
selector: 'app-artists',
|
||||||
@@ -19,13 +19,13 @@ export class ArtistsScene implements OnInit {
|
|||||||
covers: Array<string> = [];
|
covers: Array<string> = [];
|
||||||
name: string = "Artists";
|
name: string = "Artists";
|
||||||
description: string = "All available artists";
|
description: string = "All available artists";
|
||||||
artists: NodeData[];
|
artists: Artist[];
|
||||||
|
artistsSave: Artist[];
|
||||||
countTrack: (id: number) => Promise<Number>;
|
countTrack: (id: number) => Promise<Number>;
|
||||||
countAlbum: (id: number) => Promise<Number>;
|
countAlbum: (id: number) => Promise<Number>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
|
||||||
private trackService: TrackService,
|
private trackService: TrackService,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
private arianeService: ArianeService) {
|
private arianeService: ArianeService) {
|
||||||
@@ -34,37 +34,44 @@ export class ArtistsScene implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.countTrack = (id:number) => {return self.countTrackCallback(id);};
|
this.countTrack = (id: number) => { return self.countTrackCallback(id); };
|
||||||
this.countAlbum = (id:number) => {return self.countAlbumCallback(id);};
|
this.countAlbum = (id: number) => { return self.countAlbumCallback(id); };
|
||||||
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
|
|
||||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
|
||||||
this.artistService.getOrder()
|
this.artistService.getOrder()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Artist[]) => {
|
||||||
self.artists = response;
|
self.artists = response;
|
||||||
|
self.artistsSave = [...response];
|
||||||
//console.log("get artists: " + JSON.stringify(self.artists));
|
//console.log("get artists: " + JSON.stringify(self.artists));
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.artists = undefined;
|
self.artists = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onSelectArtist(event: any, idSelected: number):void {
|
|
||||||
|
onSearch(value: string) {
|
||||||
|
console.log(`Search value: ${value}`);
|
||||||
|
this.artists = this.artistsSave.filter(element => {
|
||||||
|
return element.name.toLowerCase().includes(value.toLowerCase());;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectArtist(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
this.arianeService.navigateArtistEdit({id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtistEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateArtist({artistId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtist({ artistId: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
countTrackCallback(artistId: number) : Promise<Number> {
|
countTrackCallback(artistId: number): Promise<Number> {
|
||||||
return this.artistService.countTrack(artistId);
|
return this.trackService.countTracksOfAnArtist(artistId);
|
||||||
}
|
}
|
||||||
countAlbumCallback(artistId: number) : Promise<Number> {
|
countAlbumCallback(artistId: number): Promise<Number> {
|
||||||
return this.artistService.countAlbum(artistId);
|
return this.trackService.countAlbumOfAnArtist(artistId);
|
||||||
}
|
}
|
||||||
playAll(event: any):void {
|
playAll(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@@ -75,11 +82,11 @@ export class ArtistsScene implements OnInit {
|
|||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o ftrack ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
playShuffe(event: any):void {
|
playShuffle(): void {
|
||||||
this.playerService.clear();
|
this.playerService.clear();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.trackService.getData()
|
this.trackService.gets()
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Track[]) => {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
response.forEach(element => {
|
response.forEach(element => {
|
||||||
ids.push(element.id);
|
ids.push(element.id);
|
||||||
@@ -87,7 +94,7 @@ export class ArtistsScene implements OnInit {
|
|||||||
self.playerService.setNewPlaylistShuffle(ids);
|
self.playerService.setNewPlaylistShuffle(ids);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log(`error to get list o ftrack ...`)
|
console.log(`error to get list o track ...`)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ArianeService } from '../../service/ariane';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-error-viewer',
|
selector: 'app-error-viewer',
|
||||||
templateUrl: './error-viewer.html',
|
templateUrl: './error-viewer.html',
|
||||||
styleUrls: [ './error-viewer.less' ]
|
styleUrls: ['./error-viewer.less']
|
||||||
})
|
})
|
||||||
export class ErrorViewerScene implements OnInit {
|
export class ErrorViewerScene implements OnInit {
|
||||||
constructor(private arianeService: ArianeService) { }
|
constructor() { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,38 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-title colomn_mutiple">
|
<div class="fill-title colomn_mutiple">
|
||||||
<div class="cover-area">
|
<div class="cover-area">
|
||||||
<div class="cover" *ngIf="cover != null" >
|
@if (cover != null) {
|
||||||
|
<div class="cover">
|
||||||
<img src="{{cover}}"/>
|
<img src="{{cover}}"/>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
<div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
{{name}}
|
{{name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="description" *ngIf="description">
|
@if(description) {
|
||||||
|
<div class="description">
|
||||||
{{description}}
|
{{description}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-content colomn_mutiple">
|
<div class="fill-content colomn_mutiple">
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div *ngFor="let data of artists" class="item" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
@for (data of artists; track data.id;) {
|
||||||
<app-element-artist [element]="data"></app-element-artist>
|
<div class="item" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
||||||
|
<!--<app-element-artist [element]="data"/>-->
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-content colomn_mutiple">
|
<div class="fill-content colomn_mutiple">
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectMedia($event, data.id)" (auxclick)="onSelectMedia($event, data.id)">
|
@for (data of tracks; track data.id;) {
|
||||||
<app-element-track [element]="data"></app-element-track>
|
<div class="item item-track" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
|
<app-element-track [element]="data"/>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,26 +6,27 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { GenderService, DataService, ArianeService } from 'app/service';
|
import { GenderService, DataService, ArianeService, TrackService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gender',
|
selector: 'app-gender',
|
||||||
templateUrl: './gender.html',
|
templateUrl: './gender.html',
|
||||||
styleUrls: [ './gender.less' ]
|
styleUrls: ['./gender.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class GenderScene implements OnInit {
|
export class GenderScene implements OnInit {
|
||||||
genderId = -1;
|
genderId = -1;
|
||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
cover:string = null;
|
cover: string = null;
|
||||||
covers:string[] = [];
|
covers: string[] = [];
|
||||||
artistsError = '';
|
artistsError = '';
|
||||||
artists = [];
|
artists = [];
|
||||||
tracksError = '';
|
tracksError = '';
|
||||||
tracks = [];
|
tracks = [];
|
||||||
constructor(
|
constructor(
|
||||||
private genderService: GenderService,
|
private genderService: GenderService,
|
||||||
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
//NOTHING TO DO ...
|
//NOTHING TO DO ...
|
||||||
@@ -34,19 +35,19 @@ export class GenderScene implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.genderId = this.arianeService.getTypeId();
|
this.genderId = this.arianeService.getTypeId();
|
||||||
let self = this;
|
let self = this;
|
||||||
console.log(`get gender global id: ${ this.genderId}`);
|
console.log(`get gender global id: ${this.genderId}`);
|
||||||
this.genderService.get(this.genderId)
|
this.genderService.get(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
console.log(` ==> get answer gender detail: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer gender detail: ${JSON.stringify(response)}`);
|
||||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
if (response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
||||||
self.cover = null;
|
self.cover = null;
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.dataService.getCoverUrl(response.covers[0]);
|
self.cover = self.dataService.getUrl(response.covers[0]);
|
||||||
for(let iii = 0; iii < response.covers.length; iii++) {
|
for (let iii = 0; iii < response.covers.length; iii++) {
|
||||||
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
|
self.covers.push(self.dataService.getUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@@ -55,7 +56,9 @@ export class GenderScene implements OnInit {
|
|||||||
self.covers = [];
|
self.covers = [];
|
||||||
self.cover = null;
|
self.cover = null;
|
||||||
});
|
});
|
||||||
this.genderService.getSubArtist(this.genderId)
|
/*
|
||||||
|
TODO ???
|
||||||
|
this.trackService.getSubArtist(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
|
||||||
self.artistsError = '';
|
self.artistsError = '';
|
||||||
@@ -65,7 +68,8 @@ export class GenderScene implements OnInit {
|
|||||||
self.artistsError = 'Wrong e-mail/login or password';
|
self.artistsError = 'Wrong e-mail/login or password';
|
||||||
self.artists = [];
|
self.artists = [];
|
||||||
});
|
});
|
||||||
this.genderService.getSubTrack(this.genderId)
|
*/
|
||||||
|
this.trackService.getTracksForGender(this.genderId)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
|
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
|
||||||
self.tracksError = '';
|
self.tracksError = '';
|
||||||
@@ -76,19 +80,19 @@ export class GenderScene implements OnInit {
|
|||||||
self.tracks = [];
|
self.tracks = [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onSelectArtist(event: any, idSelected: number):void {
|
onSelectArtist(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateArtist({ artistId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtist({ artistId: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateArtistEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateArtistEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectTrack(event: any, idSelected: number):void {
|
onSelectTrack(event: any, idSelected: number): void {
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: idSelected, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: idSelected, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
Karusic
|
Karusic
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all colomn_mutiple">
|
<div class="fill-all colomn_mutiple">
|
||||||
<div *ngFor="let data of dataList" class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
|
@for (data of dataList; track data.id) {
|
||||||
<app-element-type [element]="data"></app-element-type>
|
<div class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
|
||||||
|
<app-element-type [element]="data"/>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -11,7 +11,7 @@ import { ArianeService, GenderService } from 'app/service';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
templateUrl: './home.html',
|
templateUrl: './home.html',
|
||||||
styleUrls: [ './home.less' ]
|
styleUrls: ['./home.less']
|
||||||
})
|
})
|
||||||
export class HomeScene implements OnInit {
|
export class HomeScene implements OnInit {
|
||||||
dataList = [
|
dataList = [
|
||||||
@@ -53,17 +53,17 @@ export class HomeScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
this.arianeService.reset();
|
this.arianeService.reset();
|
||||||
}
|
}
|
||||||
onSelectType(event: any, idSelected: number):void {
|
onSelectType(event: any, idSelected: number): void {
|
||||||
if (idSelected === 1) {
|
if (idSelected === 1) {
|
||||||
this.arianeService.navigateGender({newWindows: event.which === 2});
|
this.arianeService.navigateGender({ newWindows: event.which === 2 });
|
||||||
} else if (idSelected === 2) {
|
} else if (idSelected === 2) {
|
||||||
this.arianeService.navigateArtist({newWindows: event.which === 2});
|
this.arianeService.navigateArtist({ newWindows: event.which === 2 });
|
||||||
} else if (idSelected === 3) {
|
} else if (idSelected === 3) {
|
||||||
this.arianeService.navigateAlbum({newWindows: event.which === 2});
|
this.arianeService.navigateAlbum({ newWindows: event.which === 2 });
|
||||||
} else if (idSelected === 4) {
|
} else if (idSelected === 4) {
|
||||||
this.arianeService.navigateTrack({newWindows: event.which === 2});
|
this.arianeService.navigateTrack({ newWindows: event.which === 2 });
|
||||||
} else if (idSelected === 5) {
|
} else if (idSelected === 5) {
|
||||||
this.arianeService.navigatePlaylist({newWindows: event.which === 2});
|
this.arianeService.navigatePlaylist({ newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<div class="fill-all colomn_mutiple">
|
<div class="fill-all colomn_mutiple">
|
||||||
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectTrack($event, data)" (auxclick)="onSelectTrack($event, data)">
|
@for (data of tracks; track data.id) {
|
||||||
|
<div class="item item-track" (click)="onSelectTrack($event, data)" (auxclick)="onSelectTrack($event, data)">
|
||||||
<app-element-track [element]="data"></app-element-track>
|
<app-element-track [element]="data"></app-element-track>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2,21 +2,26 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
Edit Media
|
Edit Media
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsRemoved">
|
@if(itemIsRemoved) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The media has been removed
|
The media has been removed
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsNotFound">
|
}
|
||||||
|
@else if (itemIsNotFound) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
The media does not exist
|
The media does not exist
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="itemIsLoading">
|
}
|
||||||
|
@else if (itemIsLoading) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="message-big">
|
<div class="message-big">
|
||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
Loading ...<br/>
|
Loading ...<br/>
|
||||||
@@ -24,8 +29,9 @@
|
|||||||
<br/><br/><br/>
|
<br/><br/><br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
@else {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
Title:
|
Title:
|
||||||
@@ -57,7 +63,9 @@
|
|||||||
<div class="input">
|
<div class="input">
|
||||||
<select [ngModel]="data.genderId"
|
<select [ngModel]="data.genderId"
|
||||||
(ngModelChange)="onChangeGender($event)">
|
(ngModelChange)="onChangeGender($event)">
|
||||||
<option *ngFor="let element of listGender" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listGender; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input_add">
|
<div class="input_add">
|
||||||
@@ -73,7 +81,9 @@
|
|||||||
<div class="input">
|
<div class="input">
|
||||||
<select [ngModel]="data.artistId"
|
<select [ngModel]="data.artistId"
|
||||||
(ngModelChange)="onChangeArtist($event)">
|
(ngModelChange)="onChangeArtist($event)">
|
||||||
<option *ngFor="let element of listArtist" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listArtist; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input_add">
|
<div class="input_add">
|
||||||
@@ -89,7 +99,9 @@
|
|||||||
<div class="input">
|
<div class="input">
|
||||||
<select [ngModel]="data.albumId"
|
<select [ngModel]="data.albumId"
|
||||||
(ngModelChange)="onChangeAlbum($event)">
|
(ngModelChange)="onChangeAlbum($event)">
|
||||||
<option *ngFor="let element of listAlbum" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listAlbum; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input_add">
|
<div class="input_add">
|
||||||
@@ -119,10 +131,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ------------------------- ADMIN section --------------------------------- -->
|
<!-- ------------------------- ADMIN section --------------------------------- -->
|
||||||
<div class="title" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="title">
|
||||||
Administration
|
Administration
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="!itemIsRemoved && !itemIsNotFound && !itemIsLoading">
|
<div class="fill-all">
|
||||||
<div class="request_raw">
|
<div class="request_raw">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<i class="material-icons">data_usage</i> ID:
|
<i class="material-icons">data_usage</i> ID:
|
||||||
@@ -144,6 +156,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<create-type ></create-type>
|
<create-type ></create-type>
|
||||||
|
|||||||
@@ -5,13 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { UploadProgress, PopInService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
|
|
||||||
import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
import { DataService, GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
|
||||||
import { PopInService } from 'common/service';
|
|
||||||
import { Media } from 'app/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
value?: number;
|
value?: number;
|
||||||
@@ -25,7 +23,7 @@ class DataToSend {
|
|||||||
track?: number;
|
track?: number;
|
||||||
artistId: number = null;
|
artistId: number = null;
|
||||||
albumId: number = null;
|
albumId: number = null;
|
||||||
dataId: number = -1;
|
dataId: string = "";
|
||||||
genderId: number = null;
|
genderId: number = null;
|
||||||
generatedName: string = '';
|
generatedName: string = '';
|
||||||
clone() {
|
clone() {
|
||||||
@@ -164,7 +162,7 @@ export class TrackEditScene implements OnInit {
|
|||||||
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
||||||
});
|
});
|
||||||
this.trackService.get(this.idTrack)
|
this.trackService.get(this.idTrack)
|
||||||
.then((response: Media) => {
|
.then((response: Track) => {
|
||||||
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.data.name = response.name;
|
self.data.name = response.name;
|
||||||
self.data.description = response.description;
|
self.data.description = response.description;
|
||||||
|
|||||||
@@ -1,55 +1,73 @@
|
|||||||
<div class="main-reduce">
|
<div class="main-reduce">
|
||||||
<div class="fill-all" *ngIf="mediaIsNotFound">
|
@if(mediaIsNotFound) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
Play media<br/><br/><br/><br/><br/>
|
Play media<br/><br/><br/><br/><br/>
|
||||||
The media does not exist
|
The media does not exist
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all" *ngIf="mediaIsLoading">
|
}
|
||||||
|
@if(mediaIsLoading) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
Play media<br/><br/><br/><br/><br/>
|
Play media<br/><br/><br/><br/><br/>
|
||||||
Loading ...<br/>
|
Loading ...<br/>
|
||||||
Please wait.
|
Please wait.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="fill-all" *ngIf="!mediaIsNotFound && !mediaIsLoading && !playTrack">
|
@if(!mediaIsNotFound && !mediaIsLoading && !playTrack) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
{{name}}
|
{{name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-full">
|
<div class="cover-full">
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
<div class="cover-image" *ngIf="covers">
|
@if (covers && covers.length > 0) {
|
||||||
|
<div class="cover-image">
|
||||||
<img src="{{covers[0]}}"/>
|
<img src="{{covers[0]}}"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-no-image" *ngIf="covers"></div>
|
}
|
||||||
|
@else {
|
||||||
|
<div class="cover-no-image"></div>
|
||||||
|
}
|
||||||
<div class="cover-button">
|
<div class="cover-button">
|
||||||
<button (click)="onRequirePlay()">
|
<button (click)="onRequirePlay()">
|
||||||
<i class="material-icons big-button">play_circle_outline</i>
|
<i class="material-icons big-button">play_circle_outline</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-button-next" *ngIf="haveNext !== null">
|
@if (haveNext !== null) {
|
||||||
|
<div class="cover-button-next">
|
||||||
<button (click)="onRequireNext($event)" (auxclick)="onRequireNext($event)">
|
<button (click)="onRequireNext($event)" (auxclick)="onRequireNext($event)">
|
||||||
<i class="material-icons big-button">arrow_forward_ios</i>
|
<i class="material-icons big-button">arrow_forward_ios</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-button-previous" *ngIf="havePrevious !== null">
|
}
|
||||||
|
@if (havePrevious !== null) {
|
||||||
|
<div class="cover-button-previous">
|
||||||
<button (click)="onRequirePrevious($event)" (auxclick)="onRequirePrevious($event)">
|
<button (click)="onRequirePrevious($event)" (auxclick)="onRequirePrevious($event)">
|
||||||
<i class="material-icons big-button">arrow_back_ios</i>
|
<i class="material-icons big-button">arrow_back_ios</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="episode" *ngIf="artistName!=null">
|
@if (artistName!=null) {
|
||||||
|
<div class="episode">
|
||||||
<b>Artist:</b> {{artistName}}
|
<b>Artist:</b> {{artistName}}
|
||||||
</div>
|
</div>
|
||||||
<div class="episode" *ngIf="albumName!=null">
|
}
|
||||||
|
@if (albumName!=null) {
|
||||||
|
<div class="episode">
|
||||||
<b>Album:</b> {{albumName}}
|
<b>Album:</b> {{albumName}}
|
||||||
</div>
|
</div>
|
||||||
<div class="episode" *ngIf="episode!=null">
|
}
|
||||||
<b>Episode:</b> {{episode}}
|
@if (track!=null) {
|
||||||
|
<div class="episode">
|
||||||
|
<b>Piste:</b> {{track}}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="episode">
|
<div class="episode">
|
||||||
<b>generatedName:</b> {{generatedName}}
|
<b>generatedName:</b> {{generatedName}}
|
||||||
</div>
|
</div>
|
||||||
@@ -57,11 +75,13 @@
|
|||||||
{{description}}
|
{{description}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fill-all bg-black" *ngIf="playTrack">
|
}
|
||||||
|
@if (playTrack) {
|
||||||
|
<div class="fill-all bg-black">
|
||||||
<div class="track"
|
<div class="track"
|
||||||
#globalVideoElement
|
#globalVideoElement
|
||||||
(mousemove)="startHideTimer()"
|
(mousemove)="startHideTimer()"
|
||||||
(fullscreenchange)="onFullscreenChange($event)">
|
(fullscreenchange)="onFullscreenChange()">
|
||||||
<div class="track-elem">
|
<div class="track-elem">
|
||||||
<video src="{{trackSource}}"
|
<video src="{{trackSource}}"
|
||||||
#trackPlayer
|
#trackPlayer
|
||||||
@@ -78,9 +98,14 @@
|
|||||||
<!--<p>Your browser does not support HTML5 track player. download track: <a href="{{trackSource}}>link here</a>.</p>-->
|
<!--<p>Your browser does not support HTML5 track player. download track: <a href="{{trackSource}}>link here</a>.</p>-->
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
<div class="controls" *ngIf="!displayNeedHide || !isPlaying">
|
@if (!displayNeedHide || !isPlaying) {
|
||||||
<button (click)="onPlay()" *ngIf="!isPlaying" ><i class="material-icons">play_arrow</i></button>
|
<div class="controls">
|
||||||
<button (click)="onPause()" *ngIf="isPlaying" ><i class="material-icons">pause</i></button>
|
@if (!isPlaying) {
|
||||||
|
<button (click)="onPlay()"><i class="material-icons">play_arrow</i></button>
|
||||||
|
}
|
||||||
|
@else {
|
||||||
|
<button (click)="onPause()"><i class="material-icons">pause</i></button>
|
||||||
|
}
|
||||||
<button (click)="onStop()" ><i class="material-icons">stop</i></button>
|
<button (click)="onStop()" ><i class="material-icons">stop</i></button>
|
||||||
<div class="timer">
|
<div class="timer">
|
||||||
<div>
|
<div>
|
||||||
@@ -98,36 +123,50 @@
|
|||||||
<button (click)="onForward()"><i class="material-icons">fast_forward</i></button>
|
<button (click)="onForward()"><i class="material-icons">fast_forward</i></button>
|
||||||
<!--<button (click)="onNext()"><i class="material-icons">navigate_next</i></button>-->
|
<!--<button (click)="onNext()"><i class="material-icons">navigate_next</i></button>-->
|
||||||
<!--<button (click)="onMore()" ><i class="material-icons">more_vert</i></button>-->
|
<!--<button (click)="onMore()" ><i class="material-icons">more_vert</i></button>-->
|
||||||
<button (click)="onFullscreen()" *ngIf="!isFullScreen"><i class="material-icons">fullscreen</i></button>
|
@if (!isFullScreen) {
|
||||||
<button (click)="onFullscreenExit()" *ngIf="isFullScreen"><i class="material-icons">fullscreen_exit</i></button>
|
<button (click)="onFullscreen()"><i class="material-icons">fullscreen</i></button>
|
||||||
|
}
|
||||||
|
@else {
|
||||||
|
<button (click)="onFullscreenExit()"><i class="material-icons">fullscreen_exit</i></button>
|
||||||
|
}
|
||||||
<!--<button (click)="onTakeScreenShoot()"><i class="material-icons">add_a_photo</i></button>-->
|
<!--<button (click)="onTakeScreenShoot()"><i class="material-icons">add_a_photo</i></button>-->
|
||||||
<button (click)="onVolumeMenu()" ><i class="material-icons">volume_up</i></button>
|
<button (click)="onVolumeMenu()" ><i class="material-icons">volume_up</i></button>
|
||||||
|
@if (!isPlaying) {
|
||||||
<button class="bigPause" (click)="onPauseToggle()"><i *ngIf="!isPlaying" class="material-icons">play_circle_outline</i></button>
|
<button class="bigPause" (click)="onPauseToggle()"><i class="material-icons">play_circle_outline</i></button>
|
||||||
<button class="bigRewind" (click)="onRewind()"><i *ngIf="!isPlaying" class="material-icons">fast_rewind</i></button>
|
<button class="bigRewind" (click)="onRewind()"><i class="material-icons">fast_rewind</i></button>
|
||||||
<button class="bigForward" (click)="onForward()"><i *ngIf="!isPlaying" class="material-icons">fast_forward</i></button>
|
<button class="bigForward" (click)="onForward()"><i class="material-icons">fast_forward</i></button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="title-inline" *ngIf="!isFullScreen || !isPlaying">
|
@if(!isFullScreen || !isPlaying) {
|
||||||
|
<div class="title-inline">
|
||||||
{{generatedName}}
|
{{generatedName}}
|
||||||
</div>
|
</div>
|
||||||
<div class="track-button" *ngIf="!isFullScreen || !isPlaying">
|
<div class="track-button">
|
||||||
<button (click)="onRequireStop()">
|
<button (click)="onRequireStop()">
|
||||||
<i class="material-icons big-button">highlight_off</i>
|
<i class="material-icons big-button">highlight_off</i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="volume" *ngIf="displayVolumeMenu && (!displayNeedHide || !isPlaying)">
|
}
|
||||||
|
@if (displayVolumeMenu && (!displayNeedHide || !isPlaying)) {
|
||||||
|
<div class="volume">
|
||||||
<div class="volume-menu">
|
<div class="volume-menu">
|
||||||
<div class="slidecontainer">
|
<div class="slidecontainer">
|
||||||
<input type="range" min="0" max="100" class="slider"
|
<input type="range" min="0" max="100" class="slider"
|
||||||
[value]="volumeValue"
|
[value]="volumeValue"
|
||||||
(input)="onVolume($event.target)">
|
(input)="onVolume($event.target)">
|
||||||
</div>
|
</div>
|
||||||
<button (click)="onVolumeMute()" *ngIf="!trackPlayer.muted"><i class="material-icons">volume_mute</i></button>
|
@if (!trackPlayer.muted) {
|
||||||
<button (click)="onVolumeUnMute()" *ngIf="trackPlayer.muted"><i class="material-icons">volume_off</i></button>
|
<button (click)="onVolumeMute()"><i class="material-icons">volume_mute</i></button>
|
||||||
|
}
|
||||||
|
@else {
|
||||||
|
<button (click)="onVolumeUnMute()"><i class="material-icons">volume_off</i></button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<canvas #canvascreenshoot style="overflow:auto"></canvas>
|
<canvas #canvascreenshoot style="overflow:auto"></canvas>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,77 +5,75 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||||
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Track } from 'app/back-api';
|
||||||
import { DataService, TrackService, ArtistService, AlbumService, ArianeService } from 'app/service';
|
import { DataService, TrackService, ArtistService, AlbumService, ArianeService } from 'app/service';
|
||||||
import { HttpWrapperService } from 'common/service';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-track',
|
selector: 'app-track',
|
||||||
templateUrl: './track.html',
|
templateUrl: './track.html',
|
||||||
styleUrls: [ './track.less' ]
|
styleUrls: ['./track.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class TrackScene implements OnInit {
|
export class TrackScene implements OnInit {
|
||||||
trackGlobal:any;
|
trackGlobal: any;
|
||||||
@ViewChild('globalTrackElement')
|
@ViewChild('globalTrackElement')
|
||||||
set mainDivEl(el: ElementRef) {
|
set mainDivEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.trackGlobal = el.nativeElement;
|
this.trackGlobal = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trackPlayer: HTMLVideoElement;
|
trackPlayer: HTMLVideoElement;
|
||||||
@ViewChild('videoPlayer')
|
@ViewChild('videoPlayer')
|
||||||
set mainTrackEl(el: ElementRef) {
|
set mainTrackEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.trackPlayer = el.nativeElement;
|
this.trackPlayer = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoCanva: any;
|
videoCanva: any;
|
||||||
@ViewChild('canvascreenshoot')
|
@ViewChild('canvascreenshoot')
|
||||||
set mainCanvaEl(el: ElementRef) {
|
set mainCanvaEl(el: ElementRef) {
|
||||||
if(el !== null && el !== undefined) {
|
if (el !== null && el !== undefined) {
|
||||||
this.videoCanva = el.nativeElement;
|
this.videoCanva = el.nativeElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
haveNext = null;
|
haveNext = null;
|
||||||
havePrevious = null;
|
havePrevious = null;
|
||||||
idTrack:number = -1;
|
idTrack: number = -1;
|
||||||
|
|
||||||
mediaIsNotFound:boolean = false;
|
mediaIsNotFound: boolean = false;
|
||||||
mediaIsLoading:boolean = true;
|
mediaIsLoading: boolean = true;
|
||||||
error:string = '';
|
error: string = '';
|
||||||
|
|
||||||
name:string = '';
|
name: string = '';
|
||||||
description:string = '';
|
description: string = '';
|
||||||
episode:number = undefined;
|
track?: number;
|
||||||
artists:number[] = undefined;
|
artists?: number[];
|
||||||
artistName:string = undefined;
|
artistName?: string;
|
||||||
albumId:number = undefined;
|
albumId?: number;
|
||||||
albumName:string = undefined;
|
albumName?: string;
|
||||||
dataId:number = -1;
|
dataId: string = "";
|
||||||
time:number = undefined;
|
typeId?: number;
|
||||||
typeId:number = undefined;
|
generatedName: string = '';
|
||||||
generatedName:string = '';
|
trackSource: string = '';
|
||||||
trackSource:string = '';
|
|
||||||
covers: string[];
|
covers: string[];
|
||||||
|
|
||||||
playTrack:boolean = false;
|
playTrack: boolean = false;
|
||||||
displayVolumeMenu:boolean = false;
|
displayVolumeMenu: boolean = false;
|
||||||
isPlaying:boolean = false;
|
isPlaying: boolean = false;
|
||||||
isFullScreen:boolean = false;
|
isFullScreen: boolean = false;
|
||||||
currentTime:number = 0;
|
currentTime: number = 0;
|
||||||
currentTimeDisplay:string = '00';
|
currentTimeDisplay: string = '00';
|
||||||
duration:number = 0;
|
duration: number = 0;
|
||||||
durationDisplay:string = '00';
|
durationDisplay: string = '00';
|
||||||
volumeValue:number = 100;
|
volumeValue: number = 100;
|
||||||
|
|
||||||
displayNeedHide:boolean = false;
|
displayNeedHide: boolean = false;
|
||||||
timeLeft: number = 10;
|
timeLeft: number = 10;
|
||||||
interval = null;
|
interval = null;
|
||||||
constructor(private trackService: TrackService,
|
constructor(private trackService: TrackService,
|
||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private httpService: HttpWrapperService,
|
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService) {
|
private dataService: DataService) {
|
||||||
|
|
||||||
@@ -84,13 +82,13 @@ export class TrackScene implements OnInit {
|
|||||||
startHideTimer() {
|
startHideTimer() {
|
||||||
this.displayNeedHide = false;
|
this.displayNeedHide = false;
|
||||||
this.timeLeft = 5;
|
this.timeLeft = 5;
|
||||||
if(this.interval !== null) {
|
if (this.interval !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
console.log(`periodic event: ${ self.timeLeft}`);
|
console.log(`periodic event: ${self.timeLeft}`);
|
||||||
if(self.timeLeft > 0) {
|
if (self.timeLeft > 0) {
|
||||||
self.timeLeft--;
|
self.timeLeft--;
|
||||||
} else {
|
} else {
|
||||||
clearInterval(self.interval);
|
clearInterval(self.interval);
|
||||||
@@ -105,50 +103,47 @@ export class TrackScene implements OnInit {
|
|||||||
this.interval = null;
|
this.interval = null;
|
||||||
}
|
}
|
||||||
onRequireNext(event: any) {
|
onRequireNext(event: any) {
|
||||||
console.log(`generate next : ${ this.haveNext.id}`);
|
console.log(`generate next : ${this.haveNext.id}`);
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
this.arianeService.setTrack(this.haveNext.id);
|
this.arianeService.setTrack(this.haveNext.id);
|
||||||
}
|
}
|
||||||
onRequirePrevious(event: any) {
|
onRequirePrevious(event: any) {
|
||||||
console.log(`generate previous : ${ this.havePrevious.id}`);
|
console.log(`generate previous : ${this.havePrevious.id}`);
|
||||||
if (event.ctrlKey === false) {
|
if (event.ctrlKey === false) {
|
||||||
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrack({ trackId: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
} else {
|
} else {
|
||||||
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows:event.which === 2} );
|
this.arianeService.navigateTrackEdit({ id: this.haveNext.id, newWindows: event.which === 2 });
|
||||||
}
|
}
|
||||||
this.arianeService.setTrack(this.havePrevious.id);
|
this.arianeService.setTrack(this.havePrevious.id);
|
||||||
}
|
}
|
||||||
generateName() {
|
generateName() {
|
||||||
this.generatedName = '';
|
this.generatedName = '';
|
||||||
if(this.artistName !== undefined) {
|
if (this.artistName !== undefined) {
|
||||||
this.generatedName = `${this.generatedName }${this.artistName }-`;
|
this.generatedName = `${this.generatedName}${this.artistName}-`;
|
||||||
}
|
}
|
||||||
if(this.albumName !== undefined) {
|
if (this.albumName !== undefined) {
|
||||||
if(this.albumName.length < 2) {
|
if (this.albumName.length < 2) {
|
||||||
this.generatedName = `${this.generatedName }s0${ this.albumName }-`;
|
this.generatedName = `${this.generatedName}s0${this.albumName}-`;
|
||||||
} else {
|
} else {
|
||||||
this.generatedName = `${this.generatedName }s${ this.albumName }-`;
|
this.generatedName = `${this.generatedName}s${this.albumName}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.episode !== undefined) {
|
if (this.track !== undefined) {
|
||||||
if(this.episode < 10) {
|
if (this.track < 10) {
|
||||||
this.generatedName = `${this.generatedName }e0${ this.episode }-`;
|
this.generatedName = `${this.generatedName}e0${this.track}-`;
|
||||||
} else {
|
} else {
|
||||||
this.generatedName = `${this.generatedName }e${ this.episode }-`;
|
this.generatedName = `${this.generatedName}e${this.track}-`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.generatedName = this.generatedName + this.name;
|
this.generatedName = this.generatedName + this.name;
|
||||||
this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
|
this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
|
||||||
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
||||||
// update the path of the uri request
|
// update the path of the uri request
|
||||||
this.trackSource = this.httpService.createRESTCall2({
|
this.trackSource = this.dataService.getUrl(this.dataId, this.generatedName);
|
||||||
api: `data/${ this.dataId}/${this.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myPeriodicCheckFunction() {
|
myPeriodicCheckFunction() {
|
||||||
@@ -170,7 +165,7 @@ export class TrackScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
audioTracks(event) {
|
audioTracks(event) {
|
||||||
console.log(`list of the stream:${ event}`);
|
console.log(`list of the stream:${event}`);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
let captureStream = this.trackPlayer.audioTracks;
|
let captureStream = this.trackPlayer.audioTracks;
|
||||||
@@ -190,40 +185,36 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
this.idTrack = this.arianeService.getTrackId();
|
this.idTrack = this.arianeService.getTrackId();
|
||||||
this.arianeService.trackChange.subscribe((trackId) => {
|
this.arianeService.trackChange.subscribe((trackId) => {
|
||||||
console.log(`Detect trackId change...${ trackId}`);
|
console.log(`Detect trackId change...${trackId}`);
|
||||||
self.idTrack = trackId;
|
self.idTrack = trackId;
|
||||||
self.updateDisplay();
|
self.updateDisplay();
|
||||||
});
|
});
|
||||||
self.updateDisplay();
|
self.updateDisplay();
|
||||||
}
|
}
|
||||||
updateDisplay():void {
|
updateDisplay(): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
this.trackService.get(this.idTrack)
|
this.trackService.get(this.idTrack)
|
||||||
.then((response) => {
|
.then((response: Track) => {
|
||||||
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
|
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.error = '';
|
self.error = '';
|
||||||
self.name = response.name;
|
self.name = response.name;
|
||||||
self.description = response.description;
|
self.description = response.description;
|
||||||
self.episode = response.episode;
|
//self.episode = response.episode;
|
||||||
self.artists = response.artists;
|
self.artists = response.artists;
|
||||||
self.albumId = response.albumId;
|
self.albumId = response.albumId;
|
||||||
self.dataId = response.dataId;
|
self.dataId = response.dataId;
|
||||||
self.time = response.time;
|
|
||||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
||||||
if(self.dataId !== -1) {
|
if (!isNullOrUndefined(self.dataId)) {
|
||||||
self.trackSource = self.httpService.createRESTCall2({
|
self.trackSource = this.dataService.getUrl(self.dataId);
|
||||||
api: `data/${ self.dataId}/${self.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
self.trackSource = '';
|
self.trackSource = '';
|
||||||
}
|
}
|
||||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
self.covers = self.dataService.getListUrl(response.covers);
|
||||||
|
|
||||||
self.generateName();
|
self.generateName();
|
||||||
if(!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
if (!isNullOrUndefined(self.artists) && self.artists.length !== 0) {
|
||||||
self.artistService.get(self.artists[0])
|
self.artistService.get(self.artists[0])
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
self.artistName = response2.name;
|
self.artistName = response2.name;
|
||||||
@@ -232,7 +223,7 @@ export class TrackScene implements OnInit {
|
|||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(!isNullOrUndefined(self.albumId)) {
|
if (!isNullOrUndefined(self.albumId)) {
|
||||||
self.albumService.get(self.albumId)
|
self.albumService.get(self.albumId)
|
||||||
.then((response4) => {
|
.then((response4) => {
|
||||||
self.albumName = response4.name;
|
self.albumName = response4.name;
|
||||||
@@ -240,31 +231,30 @@ export class TrackScene implements OnInit {
|
|||||||
}).catch((response5) => {
|
}).catch((response5) => {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
});
|
});
|
||||||
self.albumService.getTrack(self.albumId)
|
self.trackService.getTracksWithAlbumId(self.albumId)
|
||||||
.then((response6:any) => {
|
.then((response6: Track[]) => {
|
||||||
// console.log("saison property: " + JSON.stringify(response, null, 2));
|
|
||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
for(let iii = 0; iii < response6.length; iii++) {
|
for (let iii = 0; iii < response6.length; iii++) {
|
||||||
if(isNullOrUndefined(response6[iii].episode)) {
|
if (isNullOrUndefined(response6[iii].track)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(response6[iii].episode < self.episode) {
|
if (response6[iii].track < self.track) {
|
||||||
if(self.havePrevious === null) {
|
if (self.havePrevious === null) {
|
||||||
self.havePrevious = response6[iii];
|
self.havePrevious = response6[iii];
|
||||||
} else if(self.havePrevious.episode < response6[iii].episode) {
|
} else if (self.havePrevious.episode < response6[iii].track) {
|
||||||
self.havePrevious = response6[iii];
|
self.havePrevious = response6[iii];
|
||||||
}
|
}
|
||||||
} else if(response6[iii].episode > self.episode) {
|
} else if (response6[iii].track > self.track) {
|
||||||
if(self.haveNext === null) {
|
if (self.haveNext === null) {
|
||||||
self.haveNext = response6[iii];
|
self.haveNext = response6[iii];
|
||||||
} else if(self.haveNext.episode > response6[iii].episode) {
|
} else if (self.haveNext.episode > response6[iii].track) {
|
||||||
self.haveNext = response6[iii];
|
self.haveNext = response6[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
//self.covers.push(self.dataService.getUrl(response6[iii].covers));
|
||||||
}
|
}
|
||||||
}).catch((response7:any) => {
|
}).catch((response7: any) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -275,11 +265,10 @@ export class TrackScene implements OnInit {
|
|||||||
self.error = 'Can not get the data';
|
self.error = 'Can not get the data';
|
||||||
self.name = '';
|
self.name = '';
|
||||||
self.description = '';
|
self.description = '';
|
||||||
self.episode = undefined;
|
self.track = undefined;
|
||||||
self.artists = undefined;
|
self.artists = undefined;
|
||||||
self.albumId = undefined;
|
self.albumId = undefined;
|
||||||
self.dataId = -1;
|
self.dataId = "";
|
||||||
self.time = undefined;
|
|
||||||
self.generatedName = '';
|
self.generatedName = '';
|
||||||
self.trackSource = '';
|
self.trackSource = '';
|
||||||
self.covers = undefined;
|
self.covers = undefined;
|
||||||
@@ -313,7 +302,7 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
changeStateToPlay() {
|
changeStateToPlay() {
|
||||||
this.isPlaying = true;
|
this.isPlaying = true;
|
||||||
if(this.isFullScreen === true) {
|
if (this.isFullScreen === true) {
|
||||||
this.onFullscreen();
|
this.onFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,25 +310,25 @@ export class TrackScene implements OnInit {
|
|||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertIndisplayTime(time:number) : string {
|
convertIndisplayTime(time: number): string {
|
||||||
let tmpp = parseInt(`${ time}`, 10);
|
let tmpp = parseInt(`${time}`, 10);
|
||||||
let heures = parseInt(`${ tmpp / 3600}`, 10);
|
let heures = parseInt(`${tmpp / 3600}`, 10);
|
||||||
tmpp = tmpp - heures * 3600;
|
tmpp = tmpp - heures * 3600;
|
||||||
let minutes = parseInt(`${ tmpp / 60}`, 10);
|
let minutes = parseInt(`${tmpp / 60}`, 10);
|
||||||
let seconds = tmpp - minutes * 60;
|
let seconds = tmpp - minutes * 60;
|
||||||
let out = '';
|
let out = '';
|
||||||
if(heures !== 0) {
|
if (heures !== 0) {
|
||||||
out = `${out }${heures }:`;
|
out = `${out}${heures}:`;
|
||||||
}
|
}
|
||||||
if(minutes >= 10) {
|
if (minutes >= 10) {
|
||||||
out = `${out }${minutes }:`;
|
out = `${out}${minutes}:`;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ minutes }:`;
|
out = `${out}0${minutes}:`;
|
||||||
}
|
}
|
||||||
if(seconds >= 10) {
|
if (seconds >= 10) {
|
||||||
out = out + seconds;
|
out = out + seconds;
|
||||||
} else {
|
} else {
|
||||||
out = `${out }0${ seconds}`;
|
out = `${out}0${seconds}`;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -353,7 +342,7 @@ export class TrackScene implements OnInit {
|
|||||||
}
|
}
|
||||||
changeDurationchange(duration: any) {
|
changeDurationchange(duration: any) {
|
||||||
console.log('duration change ');
|
console.log('duration change ');
|
||||||
console.log(` ==> ${ this.trackPlayer.duration}`);
|
console.log(` ==> ${this.trackPlayer.duration}`);
|
||||||
this.duration = this.trackPlayer.duration;
|
this.duration = this.trackPlayer.duration;
|
||||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
||||||
}
|
}
|
||||||
@@ -361,9 +350,9 @@ export class TrackScene implements OnInit {
|
|||||||
onPlay() {
|
onPlay() {
|
||||||
console.log('play');
|
console.log('play');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.volume = this.volumeValue / 100;
|
this.trackPlayer.volume = this.volumeValue / 100;
|
||||||
@@ -373,9 +362,9 @@ export class TrackScene implements OnInit {
|
|||||||
onPause() {
|
onPause() {
|
||||||
console.log('pause');
|
console.log('pause');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.pause();
|
this.trackPlayer.pause();
|
||||||
@@ -383,7 +372,7 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onPauseToggle() {
|
onPauseToggle() {
|
||||||
console.log('pause toggle ...');
|
console.log('pause toggle ...');
|
||||||
if(this.isPlaying === true) {
|
if (this.isPlaying === true) {
|
||||||
this.onPause();
|
this.onPause();
|
||||||
} else {
|
} else {
|
||||||
this.onPlay();
|
this.onPlay();
|
||||||
@@ -393,9 +382,9 @@ export class TrackScene implements OnInit {
|
|||||||
onStop() {
|
onStop() {
|
||||||
console.log('stop');
|
console.log('stop');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.pause();
|
this.trackPlayer.pause();
|
||||||
@@ -412,12 +401,12 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
seek(newValue:any) {
|
seek(newValue: any) {
|
||||||
console.log(`seek ${ newValue.value}`);
|
console.log(`seek ${newValue.value}`);
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = newValue.value;
|
this.trackPlayer.currentTime = newValue.value;
|
||||||
@@ -426,9 +415,9 @@ export class TrackScene implements OnInit {
|
|||||||
onRewind() {
|
onRewind() {
|
||||||
console.log('rewind');
|
console.log('rewind');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = this.currentTime - 10;
|
this.trackPlayer.currentTime = this.currentTime - 10;
|
||||||
@@ -437,9 +426,9 @@ export class TrackScene implements OnInit {
|
|||||||
onForward() {
|
onForward() {
|
||||||
console.log('forward');
|
console.log('forward');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.currentTime = this.currentTime + 10;
|
this.trackPlayer.currentTime = this.currentTime + 10;
|
||||||
@@ -448,27 +437,27 @@ export class TrackScene implements OnInit {
|
|||||||
onMore() {
|
onMore() {
|
||||||
console.log('more');
|
console.log('more');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onFullscreen() {
|
onFullscreen() {
|
||||||
console.log('fullscreen');
|
console.log('fullscreen');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackGlobal === null ||
|
if (this.trackGlobal === null ||
|
||||||
this.trackGlobal === undefined) {
|
this.trackGlobal === undefined) {
|
||||||
console.log(`error element: ${ this.trackGlobal}`);
|
console.log(`error element: ${this.trackGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.trackGlobal.requestFullscreen) {
|
if (this.trackGlobal.requestFullscreen) {
|
||||||
this.trackGlobal.requestFullscreen();
|
this.trackGlobal.requestFullscreen();
|
||||||
} else if(this.trackGlobal.mozRequestFullScreen) {
|
} else if (this.trackGlobal.mozRequestFullScreen) {
|
||||||
this.trackGlobal.mozRequestFullScreen();
|
this.trackGlobal.mozRequestFullScreen();
|
||||||
} else if(this.trackGlobal.webkitRequestFullscreen) {
|
} else if (this.trackGlobal.webkitRequestFullscreen) {
|
||||||
this.trackGlobal.webkitRequestFullscreen();
|
this.trackGlobal.webkitRequestFullscreen();
|
||||||
} else if(this.trackGlobal.msRequestFullscreen) {
|
} else if (this.trackGlobal.msRequestFullscreen) {
|
||||||
this.trackGlobal.msRequestFullscreen();
|
this.trackGlobal.msRequestFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,21 +465,21 @@ export class TrackScene implements OnInit {
|
|||||||
onFullscreenExit() {
|
onFullscreenExit() {
|
||||||
this.onFullscreenExit22(document);
|
this.onFullscreenExit22(document);
|
||||||
}
|
}
|
||||||
onFullscreenExit22(docc:any) {
|
onFullscreenExit22(docc: any) {
|
||||||
console.log('fullscreen EXIT');
|
console.log('fullscreen EXIT');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackGlobal === null ||
|
if (this.trackGlobal === null ||
|
||||||
this.trackGlobal === undefined) {
|
this.trackGlobal === undefined) {
|
||||||
console.log(`error element: ${ this.trackGlobal}`);
|
console.log(`error element: ${this.trackGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(docc.exitFullscreen) {
|
if (docc.exitFullscreen) {
|
||||||
docc.exitFullscreen();
|
docc.exitFullscreen();
|
||||||
} else if(docc.mozCancelFullScreen) {
|
} else if (docc.mozCancelFullScreen) {
|
||||||
docc.mozCancelFullScreen();
|
docc.mozCancelFullScreen();
|
||||||
} else if(docc.webkitExitFullscreen) {
|
} else if (docc.webkitExitFullscreen) {
|
||||||
docc.webkitExitFullscreen();
|
docc.webkitExitFullscreen();
|
||||||
} else if(docc.msExitFullscreen) {
|
} else if (docc.msExitFullscreen) {
|
||||||
docc.msExitFullscreen();
|
docc.msExitFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -498,12 +487,12 @@ export class TrackScene implements OnInit {
|
|||||||
onFullscreenChange() {
|
onFullscreenChange() {
|
||||||
this.onFullscreenChange22(document);
|
this.onFullscreenChange22(document);
|
||||||
}
|
}
|
||||||
onFullscreenChange22(element:any) {
|
onFullscreenChange22(element: any) {
|
||||||
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
||||||
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
||||||
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
||||||
element.msFullscreenElement && element.msFullscreenElement !== null;
|
element.msFullscreenElement && element.msFullscreenElement !== null;
|
||||||
console.log(`onFullscreenChange(${ isInFullScreen })`);
|
console.log(`onFullscreenChange(${isInFullScreen})`);
|
||||||
this.isFullScreen = isInFullScreen;
|
this.isFullScreen = isInFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,12 +501,12 @@ export class TrackScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
onVolume(newValue:any) {
|
onVolume(newValue: any) {
|
||||||
console.log(`onVolume ${ newValue.value}`);
|
console.log(`onVolume ${newValue.value}`);
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.volumeValue = newValue.value;
|
this.volumeValue = newValue.value;
|
||||||
@@ -527,9 +516,9 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onVolumeMute() {
|
onVolumeMute() {
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.muted = true;
|
this.trackPlayer.muted = true;
|
||||||
@@ -537,9 +526,9 @@ export class TrackScene implements OnInit {
|
|||||||
|
|
||||||
onVolumeUnMute() {
|
onVolumeUnMute() {
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if(this.trackPlayer === null ||
|
if (this.trackPlayer === null ||
|
||||||
this.trackPlayer === undefined) {
|
this.trackPlayer === undefined) {
|
||||||
console.log(`error element: ${ this.trackPlayer}`);
|
console.log(`error element: ${this.trackPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackPlayer.muted = false;
|
this.trackPlayer.muted = false;
|
||||||
@@ -557,10 +546,12 @@ export class TrackScene implements OnInit {
|
|||||||
// convert it and send it to the server
|
// convert it and send it to the server
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
console.log("not implemented right now...");
|
||||||
|
/*
|
||||||
this.videoCanva.toBlob((blob) => {
|
this.videoCanva.toBlob((blob) => {
|
||||||
self.trackService.uploadCoverBlob(blob, this.idTrack);
|
self.trackService.uploadCoverBlob(blob, this.idTrack);
|
||||||
}, 'image/jpeg', 0.95);
|
}, 'image/jpeg', 0.95);
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
||||||
fetch(tmpUrl)
|
fetch(tmpUrl)
|
||||||
@@ -571,3 +562,4 @@ export class TrackScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,14 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@if(parsedElement.length !== 0) {
|
||||||
<div *ngIf="this.parsedElement.length !== 0" class="title">
|
<div class="title">
|
||||||
Meta-data:
|
Meta-data:
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="clear"><br/></div>
|
<div class="clear"><br/></div>
|
||||||
<div *ngIf="this.parsedElement.length !== 0" class="fill-all">
|
@if(parsedElement.length !== 0) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="request_raw_table">
|
<div class="request_raw_table">
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@@ -59,9 +61,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="left-colomn"></td>
|
<td class="left-colomn"></td>
|
||||||
<td class="right-colomn">
|
<td class="right-colomn">
|
||||||
<select [ngModel]="genreId"
|
<!--<select [ngModel]="genreId"-->
|
||||||
(ngModelChange)="onChangeGender($event)">
|
<select (ngModelChange)="onChangeGender($event)">
|
||||||
<option *ngFor="let element of listGender" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listGender; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="tool-colomn">
|
<td class="tool-colomn">
|
||||||
@@ -87,7 +91,9 @@
|
|||||||
<td class="right-colomn">
|
<td class="right-colomn">
|
||||||
<select [ngModel]="artistId"
|
<select [ngModel]="artistId"
|
||||||
(ngModelChange)="onChangeArtist($event)">
|
(ngModelChange)="onChangeArtist($event)">
|
||||||
<option *ngFor="let element of listArtist" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listArtist; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="tool-colomn">
|
<td class="tool-colomn">
|
||||||
@@ -111,9 +117,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="left-colomn"></td>
|
<td class="left-colomn"></td>
|
||||||
<td class="right-colomn">
|
<td class="right-colomn">
|
||||||
<select [ngModel]="albumId"
|
<select [ngModel]="albumId">
|
||||||
(ngModelChange)="onChangeAlbum($event)">
|
<!--(ngModelChange)="onChangeAlbum($event)">-->
|
||||||
<option *ngFor="let element of listAlbum" [ngValue]="element.value">{{element.label}}</option>
|
@for (element of listAlbum; track element.value;) {
|
||||||
|
<option [ngValue]="element.value">{{element.label}}</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="tool-colomn">
|
<td class="tool-colomn">
|
||||||
@@ -142,7 +150,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let data of this.parsedElement">
|
@for (data of parsedElement; track data.trackId;) {
|
||||||
|
<tr>
|
||||||
<td class="left-colomn">
|
<td class="left-colomn">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
pattern="[0-9]{0-4}"
|
pattern="[0-9]{0-4}"
|
||||||
@@ -159,19 +168,22 @@
|
|||||||
(input)="onTitle(data, $event.target.value)"
|
(input)="onTitle(data, $event.target.value)"
|
||||||
[class.error]="data.title === ''"
|
[class.error]="data.title === ''"
|
||||||
/>
|
/>
|
||||||
<span *ngIf="data.nameDetected === true" class="error">
|
@if(data.nameDetected === true) {
|
||||||
|
<span class="error">
|
||||||
^^^This title already exist !!!
|
^^^This title already exist !!!
|
||||||
</span>
|
</span>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
<td class="tool-colomn" >
|
<td class="tool-colomn" >
|
||||||
<button class="button color-button-cancel color-shadow-black"
|
<button class="button color-button-cancel color-shadow-black"
|
||||||
(click)="removeElmentFromList(data, $event.target.value)"
|
(click)="removeElementFromList(data, $event.target.value)"
|
||||||
type="submit"
|
type="submit"
|
||||||
alt="Delete">
|
alt="Delete">
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -185,7 +197,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="request_raw_table" *ngIf="this.listFileInBdd">
|
@if(listFileInBdd) {
|
||||||
|
<div class="request_raw_table">
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width:10%">
|
<col style="width:10%">
|
||||||
@@ -199,15 +212,20 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let data of this.listFileInBdd">
|
@for (data of listFileInBdd; track data.id;) {
|
||||||
|
<tr>
|
||||||
<td class="left-colomn" [class.error]="data.episodeDetected === true">{{data.episode}}</td>
|
<td class="left-colomn" [class.error]="data.episodeDetected === true">{{data.episode}}</td>
|
||||||
<td class="right-colomn" [class.error]="data.nameDetected === true">{{data.name}}</td>
|
<td class="right-colomn" [class.error]="data.nameDetected === true">{{data.name}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="this.parsedElement.length !== 0" class="fill-all">
|
}
|
||||||
|
@if(parsedElement.length !== 0) {
|
||||||
|
<div class="fill-all">
|
||||||
<div class="request_raw_table">
|
<div class="request_raw_table">
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@@ -215,24 +233,19 @@
|
|||||||
<col style="width:80%">
|
<col style="width:80%">
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tbody>
|
<tbody>
|
||||||
<!-- no need
|
@for (data of parsedFailedElement; track data.id;) {
|
||||||
<tr *ngFor="let data of this.parsedElement">
|
<tr>
|
||||||
<td class="left-colomn">Keep:</td>
|
|
||||||
<td class="right-colomn">
|
|
||||||
{{data.file.name}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
-->
|
|
||||||
<tr *ngFor="let data of this.parsedFailedElement">
|
|
||||||
<td class="left-colomn">Rejected:</td>
|
<td class="left-colomn">Rejected:</td>
|
||||||
<td class="right-colomn">
|
<td class="right-colomn">
|
||||||
{{data.file.name}}<br/> ==> {{data.reason}}
|
{{data.file.name}}<br/> ==> {{data.reason}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
<upload-progress [mediaTitle]="upload.labelMediaTitle"
|
||||||
[mediaUploaded]="upload.mediaSendSize"
|
[mediaUploaded]="upload.mediaSendSize"
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { UploadProgress,PopInService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { } from '@kangaroo-and-rabbit/kar-cw/popin/upload-progress/upload-progress';
|
||||||
|
import { Artist, Gender } from 'app/back-api';
|
||||||
|
|
||||||
|
import { GenderService, ArtistService, TrackService, AlbumService } from 'app/service';
|
||||||
|
|
||||||
import { GenderService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
|
||||||
import { PopInService } from 'common/service';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
export class ElementList {
|
export class ElementList {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -22,28 +22,29 @@ export class ElementList {
|
|||||||
export class FileParsedElement {
|
export class FileParsedElement {
|
||||||
public isSended: boolean = false;
|
public isSended: boolean = false;
|
||||||
public nameDetected: boolean = false;
|
public nameDetected: boolean = false;
|
||||||
public episodeDetected: boolean = false;s
|
public trackIdDetected: boolean = false; s
|
||||||
constructor(
|
constructor(
|
||||||
public file: File,
|
public file: File,
|
||||||
public artist: string,
|
public artist: string,
|
||||||
public album: string,
|
public album: string,
|
||||||
public trackId: number,
|
public trackId: number,
|
||||||
public title: string) {
|
public title: string) {
|
||||||
// nothiing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class FileFailParsedElement {
|
export class FileFailParsedElement {
|
||||||
constructor(
|
constructor(
|
||||||
|
public id: number,
|
||||||
public file: File,
|
public file: File,
|
||||||
public reason: string) {
|
public reason: string) {
|
||||||
// nothiing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-track-edit',
|
selector: 'app-track-edit',
|
||||||
templateUrl: './upload.html',
|
templateUrl: './upload.html',
|
||||||
styleUrls: [ './upload.less' ]
|
styleUrls: ['./upload.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class UploadScene implements OnInit {
|
export class UploadScene implements OnInit {
|
||||||
@@ -56,11 +57,11 @@ export class UploadScene implements OnInit {
|
|||||||
albumId: number = null;
|
albumId: number = null;
|
||||||
needSend: boolean = false;
|
needSend: boolean = false;
|
||||||
|
|
||||||
// list of all files already registered in the bdd to compare with the curent list of files.
|
// list of all files already registered in the bdd to compare with the current list of files.
|
||||||
listFileInBdd: any[] = undefined;
|
listFileInBdd: any[] = undefined;
|
||||||
|
|
||||||
// section tha define the upload value to display in the pop-in of upload
|
// section tha define the upload value to display in the pop-in of upload
|
||||||
public upload:UploadProgress = new UploadProgress();
|
public upload: UploadProgress = new UploadProgress();
|
||||||
|
|
||||||
listGender: ElementList[] = [
|
listGender: ElementList[] = [
|
||||||
{ value: null, label: '---' },
|
{ value: null, label: '---' },
|
||||||
@@ -81,12 +82,12 @@ export class UploadScene implements OnInit {
|
|||||||
*/
|
*/
|
||||||
config = {
|
config = {
|
||||||
displayKey: 'description', // if objects array passed which key to be displayed defaults to description
|
displayKey: 'description', // if objects array passed which key to be displayed defaults to description
|
||||||
search: true, // true/false for the search functionlity defaults to false,
|
search: true, // true/false for the search functionality defaults to false,
|
||||||
height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
|
height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
|
||||||
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
|
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
|
||||||
customComparator: () => {}, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
|
customComparator: () => { }, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
|
||||||
limitTo: 10, // number 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 whenmore than one items are selected like Option 1 + 5 more
|
moreText: 'more', // text to be displayed when more than one items are selected like Option 1 + 5 more
|
||||||
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
|
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
|
||||||
searchPlaceholder: 'Search', // label thats displayed in search input,
|
searchPlaceholder: 'Search', // label thats displayed in search input,
|
||||||
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
|
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
|
||||||
@@ -99,51 +100,45 @@ export class UploadScene implements OnInit {
|
|||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private trackService: TrackService,
|
private trackService: TrackService,
|
||||||
private arianeService: ArianeService,
|
|
||||||
private popInService: PopInService) {
|
private popInService: PopInService) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNeedSend(): boolean {
|
updateNeedSend(): boolean {
|
||||||
if(this.parsedElement.length === 0) {
|
if (this.parsedElement.length === 0) {
|
||||||
this.needSend = false;
|
this.needSend = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.needSend = true;
|
this.needSend = true;
|
||||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
for (let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||||
if(isNullOrUndefined(this.parsedElement[iii].title) || this.parsedElement[iii].title === '') {
|
if (isNullOrUndefined(this.parsedElement[iii].title) || this.parsedElement[iii].title === '') {
|
||||||
this.needSend = false;
|
this.needSend = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(isNullOrUndefined(this.genderId)) {
|
|
||||||
this.needSend = false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return this.needSend;
|
return this.needSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.listGender = [ { value: null, label: '---' } ];
|
this.listGender = [{ value: null, label: '---' }];
|
||||||
this.listArtist = [ { value: null, label: '---' } ];
|
this.listArtist = [{ value: null, label: '---' }];
|
||||||
this.listAlbum = [ { value: null, label: '---' } ];
|
this.listAlbum = [{ value: null, label: '---' }];
|
||||||
this.artistService.getOrder()
|
this.artistService.getOrder()
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for(let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
}
|
}
|
||||||
}).catch((response2) => {
|
}).catch((response2) => {
|
||||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
||||||
});
|
});
|
||||||
this.genderService.getOrder()
|
this.genderService.getOrder()
|
||||||
.then((response2: NodeData[]) => {
|
.then((response2: Gender[]) => {
|
||||||
//console.error(`Keep gender : ${ JSON.stringify(response2, null, 2)} ==> ${response2.length}`);
|
//console.error(`Keep gender : ${ JSON.stringify(response2, null, 2)} ==> ${response2.length}`);
|
||||||
for(let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listGender.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listGender.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
}
|
}
|
||||||
}).catch((response2) => {
|
}).catch((response2) => {
|
||||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
||||||
});
|
});
|
||||||
console.log(' END INIT ');
|
console.log(' END INIT ');
|
||||||
}
|
}
|
||||||
@@ -151,16 +146,16 @@ export class UploadScene implements OnInit {
|
|||||||
onGender(value: any): void {
|
onGender(value: any): void {
|
||||||
this.globalGender = value;
|
this.globalGender = value;
|
||||||
let self = this;
|
let self = this;
|
||||||
if(this.globalGender !== '') {
|
if (this.globalGender !== '') {
|
||||||
this.genderService.getLike(this.globalGender)
|
this.genderService.getLike(this.globalGender)
|
||||||
.then((response: any[]) => {
|
.then((response: any[]) => {
|
||||||
console.log(`find element: ${ response.length}`);
|
console.log(`find element: ${response.length}`);
|
||||||
for(let iii = 0; iii < response.length; iii++) {
|
for (let iii = 0; iii < response.length; iii++) {
|
||||||
console.log(` - ${ JSON.stringify(response[iii])}`);
|
console.log(` - ${JSON.stringify(response[iii])}`);
|
||||||
}
|
}
|
||||||
if(response.length === 0) {
|
if (response.length === 0) {
|
||||||
self.genderId = undefined;
|
self.genderId = undefined;
|
||||||
} else if(response.length === 1) {
|
} else if (response.length === 1) {
|
||||||
self.genderId = response[0].id;
|
self.genderId = response[0].id;
|
||||||
}
|
}
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@@ -174,9 +169,9 @@ export class UploadScene implements OnInit {
|
|||||||
|
|
||||||
onChangeGender(value: any): void {
|
onChangeGender(value: any): void {
|
||||||
this.globalGender = value;
|
this.globalGender = value;
|
||||||
if(!isNullOrUndefined(value)) {
|
if (!isNullOrUndefined(value)) {
|
||||||
for(let iii = 0; iii < this.listGender.length; iii++) {
|
for (let iii = 0; iii < this.listGender.length; iii++) {
|
||||||
if(this.listGender[iii].value === value) {
|
if (this.listGender[iii].value === value) {
|
||||||
this.globalGender = this.listGender[iii].label;
|
this.globalGender = this.listGender[iii].label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -186,31 +181,34 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateTheListOfAlbum() {
|
private updateTheListOfAlbum() {
|
||||||
this.listAlbum = [ { value: null, label: '---' } ];
|
this.listAlbum = [{ value: null, label: '---' }];
|
||||||
if (isNullOrUndefined(this.artistId)) {
|
if (isNullOrUndefined(this.artistId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.artistService.getAlbum(this.artistId)
|
this.trackService.getAlbumIdsOfAnArtist(this.artistId)
|
||||||
|
.then((listAlbumIds: number[]) => {
|
||||||
|
this.albumService.getAll(listAlbumIds)
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for(let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listAlbum.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listAlbum.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
}
|
}
|
||||||
}).catch((response2) => {
|
}).catch((response2) => {
|
||||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onArtist(value: any): void {
|
onArtist(value: any): void {
|
||||||
this.globalArtist = value;
|
this.globalArtist = value;
|
||||||
let self = this;
|
let self = this;
|
||||||
if(this.globalArtist !== '') {
|
if (this.globalArtist !== '') {
|
||||||
console.log(`update artist List Element: ${this.globalArtist}`);
|
console.log(`update artist List Element: ${this.globalArtist}`);
|
||||||
this.artistService.getLike(this.globalArtist)
|
this.artistService.getLike(this.globalArtist)
|
||||||
.then((response: any[]) => {
|
.then((response: any[]) => {
|
||||||
console.log(` ==> find artist like ${this.globalArtist} : ${ JSON.stringify(response, null, 2)}`);
|
console.log(` ==> find artist like ${this.globalArtist} : ${JSON.stringify(response, null, 2)}`);
|
||||||
if(response.length === 0) {
|
if (response.length === 0) {
|
||||||
self.artistId = undefined;
|
self.artistId = undefined;
|
||||||
} else if(response.length === 1) {
|
} else if (response.length === 1) {
|
||||||
self.artistId = response[0].id;
|
self.artistId = response[0].id;
|
||||||
self.updateTheListOfAlbum();
|
self.updateTheListOfAlbum();
|
||||||
}
|
}
|
||||||
@@ -220,7 +218,7 @@ export class UploadScene implements OnInit {
|
|||||||
self.updateListOfTrackToCheck();
|
self.updateListOfTrackToCheck();
|
||||||
}
|
}
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
console.log(` ==> CAN NOT find artist like ${this.globalArtist} : ${ response.length}`);
|
console.log(` ==> CAN NOT find artist like ${this.globalArtist} : ${response.length}`);
|
||||||
self.artistId = undefined;
|
self.artistId = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -228,9 +226,9 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
onChangeArtist(value: any): void {
|
onChangeArtist(value: any): void {
|
||||||
this.artistId = value;
|
this.artistId = value;
|
||||||
if(!isNullOrUndefined(value)) {
|
if (!isNullOrUndefined(value)) {
|
||||||
for(let iii = 0; iii < this.listArtist.length; iii++) {
|
for (let iii = 0; iii < this.listArtist.length; iii++) {
|
||||||
if(this.listArtist[iii].value === value) {
|
if (this.listArtist[iii].value === value) {
|
||||||
this.globalArtist = this.listArtist[iii].label;
|
this.globalArtist = this.listArtist[iii].label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -250,18 +248,19 @@ export class UploadScene implements OnInit {
|
|||||||
data.title = value;
|
data.title = value;
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
}
|
}
|
||||||
removeElmentFromList(data: FileParsedElement, value: any): void {
|
|
||||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
removeElementFromList(data: FileParsedElement, value: any): void {
|
||||||
if(this.parsedElement[iii] === data) {
|
for (let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||||
|
if (this.parsedElement[iii] === data) {
|
||||||
this.parsedElement.splice(iii, 1);
|
this.parsedElement.splice(iii, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.parsedFailedElement.push(new FileFailParsedElement(data.file, 'Removed by user.'));
|
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedFailedElement.length, data.file, 'Removed by user.'));
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
onEpisode(data: FileParsedElement, value: any): void {
|
onTrackId(data: FileParsedElement, value: any): void {
|
||||||
data.trackId = value;
|
data.trackId = value;
|
||||||
// console.log("change episode ID: " + value + " ==> " + this.parseEpisode.toString());
|
// console.log("change episode ID: " + value + " ==> " + this.parseEpisode.toString());
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
@@ -281,7 +280,7 @@ export class UploadScene implements OnInit {
|
|||||||
this.artistId = null;
|
this.artistId = null;
|
||||||
this.albumId = null;
|
this.albumId = null;
|
||||||
//this.listGender = [ { value: null, label: '---' } ];
|
//this.listGender = [ { value: null, label: '---' } ];
|
||||||
this.listAlbum = [ { value: null, label: '---' } ];
|
this.listAlbum = [{ value: null, label: '---' }];
|
||||||
}
|
}
|
||||||
|
|
||||||
addFileWithMetaData(file: File) {
|
addFileWithMetaData(file: File) {
|
||||||
@@ -291,38 +290,38 @@ export class UploadScene implements OnInit {
|
|||||||
let trackIdNumber: number | null = undefined;
|
let trackIdNumber: number | null = undefined;
|
||||||
let title: string = '';
|
let title: string = '';
|
||||||
|
|
||||||
console.log(`select file ${ file.name}`);
|
console.log(`select file ${file.name}`);
|
||||||
let tmpName = file.name.replace(/[ \t]*-[ \t]*/g, '-');
|
let tmpName = file.name.replace(/[ \t]*-[ \t]*/g, '-');
|
||||||
//tmpName = tmpName.replace(/_/g, '-');
|
//tmpName = tmpName.replace(/_/g, '-');
|
||||||
//tmpName = tmpName.replace(/--/g, '-');
|
//tmpName = tmpName.replace(/--/g, '-');
|
||||||
console.log(`select file ${ tmpName}`);
|
console.log(`select file ${tmpName}`);
|
||||||
const splitElement = tmpName.split('~');
|
const splitElement = tmpName.split('~');
|
||||||
if(splitElement.length > 1) {
|
if (splitElement.length > 1) {
|
||||||
artist = splitElement[0];
|
artist = splitElement[0];
|
||||||
tmpName = tmpName.substring(artist.length+1);
|
tmpName = tmpName.substring(artist.length + 1);
|
||||||
}
|
}
|
||||||
const splitElement2 = tmpName.split('\#');
|
const splitElement2 = tmpName.split('\#');
|
||||||
if(splitElement2.length > 1) {
|
if (splitElement2.length > 1) {
|
||||||
album = splitElement2[0];
|
album = splitElement2[0];
|
||||||
tmpName = tmpName.substring(album.length+1);
|
tmpName = tmpName.substring(album.length + 1);
|
||||||
}
|
}
|
||||||
//console.log("ploppppp " + tmpName);
|
//console.log("ploppppp " + tmpName);
|
||||||
const splitElement3 = tmpName.split('-');
|
const splitElement3 = tmpName.split('-');
|
||||||
if(splitElement3.length > 1) {
|
if (splitElement3.length > 1) {
|
||||||
trackIdNumber = parseInt(splitElement3[0], 10);
|
trackIdNumber = parseInt(splitElement3[0], 10);
|
||||||
tmpName = tmpName.substring(splitElement3[0].length+1);
|
tmpName = tmpName.substring(splitElement3[0].length + 1);
|
||||||
}
|
}
|
||||||
//console.log("KKKppppp " + tmpName);
|
//console.log("KKKppppp " + tmpName);
|
||||||
//console.log(" ===> " + splitElement3[0]);
|
//console.log(" ===> " + splitElement3[0]);
|
||||||
title = tmpName;
|
title = tmpName;
|
||||||
|
|
||||||
if(isNaN(trackIdNumber)) {
|
if (isNaN(trackIdNumber)) {
|
||||||
trackIdNumber = undefined;
|
trackIdNumber = undefined;
|
||||||
}
|
}
|
||||||
// remove extention
|
// remove extension
|
||||||
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
||||||
let tmp = new FileParsedElement(file, artist, album, trackIdNumber, title);
|
let tmp = new FileParsedElement(file, artist, album, trackIdNumber, title);
|
||||||
console.log(`==>${ JSON.stringify(tmp)}`);
|
console.log(`==>${JSON.stringify(tmp)}`);
|
||||||
// add it in the list.
|
// add it in the list.
|
||||||
this.parsedElement.push(tmp);
|
this.parsedElement.push(tmp);
|
||||||
}
|
}
|
||||||
@@ -333,20 +332,20 @@ export class UploadScene implements OnInit {
|
|||||||
onChangeFile(value: any): void {
|
onChangeFile(value: any): void {
|
||||||
this.clearData();
|
this.clearData();
|
||||||
|
|
||||||
for(let iii = 0; iii < value.files.length; iii++) {
|
for (let iii = 0; iii < value.files.length; iii++) {
|
||||||
this.addFileWithMetaData(value.files[iii]);
|
this.addFileWithMetaData(value.files[iii]);
|
||||||
}
|
}
|
||||||
// check if all global parameters are generic:
|
// check if all global parameters are generic:
|
||||||
if(this.parsedElement.length === 0) {
|
if (this.parsedElement.length === 0) {
|
||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// we verify fith the first value to remove all unknown ...
|
// we verify with the first value to remove all unknown ...
|
||||||
// clean different gender:
|
// clean different gender:
|
||||||
/*for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
/*for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||||
console.log(`check gender [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].gender } !== ${ this.parsedElement[iii].gender }'`);
|
console.log(`check gender [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].gender } !== ${ this.parsedElement[iii].gender }'`);
|
||||||
if(this.parsedElement[0].gender !== this.parsedElement[iii].gender) {
|
if(this.parsedElement[0].gender !== this.parsedElement[iii].gender) {
|
||||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong gender value'));
|
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedFailedElement.length, this.parsedElement[iii].file, 'Remove from list due to wrong gender value'));
|
||||||
console.log(`Remove from list (!= playlist) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
console.log(`Remove from list (!= playlist) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
||||||
this.parsedElement.splice(iii, 1);
|
this.parsedElement.splice(iii, 1);
|
||||||
iii--;
|
iii--;
|
||||||
@@ -354,21 +353,21 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// clean different artist:
|
// clean different artist:
|
||||||
for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
for (let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||||
console.log(`check artist [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].artist } !== ${ this.parsedElement[iii].artist }'`);
|
console.log(`check artist [${iii + 1}/${this.parsedElement.length}] '${this.parsedElement[0].artist} !== ${this.parsedElement[iii].artist}'`);
|
||||||
if(this.parsedElement[0].artist !== this.parsedElement[iii].artist) {
|
if (this.parsedElement[0].artist !== this.parsedElement[iii].artist) {
|
||||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong artist value'));
|
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedFailedElement.length, this.parsedElement[iii].file, 'Remove from list due to wrong artist value'));
|
||||||
console.log(`Remove from list (!= artist) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
console.log(`Remove from list (!= artist) : [${iii + 1}/${this.parsedElement.length}] '${this.parsedElement[iii].file.name}'`);
|
||||||
this.parsedElement.splice(iii, 1);
|
this.parsedElement.splice(iii, 1);
|
||||||
iii--;
|
iii--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clean different album:
|
// clean different album:
|
||||||
for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
for (let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||||
console.log(`check album [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].album } !== ${ this.parsedElement[iii].album }'`);
|
console.log(`check album [${iii + 1}/${this.parsedElement.length}] '${this.parsedElement[0].album} !== ${this.parsedElement[iii].album}'`);
|
||||||
if(this.parsedElement[0].album !== this.parsedElement[iii].album) {
|
if (this.parsedElement[0].album !== this.parsedElement[iii].album) {
|
||||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong album value'));
|
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedFailedElement.length, this.parsedElement[iii].file, 'Remove from list due to wrong album value'));
|
||||||
console.log(`Remove from list (!= album) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
console.log(`Remove from list (!= album) : [${iii + 1}/${this.parsedElement.length}] '${this.parsedElement[iii].file.name}'`);
|
||||||
this.parsedElement.splice(iii, 1);
|
this.parsedElement.splice(iii, 1);
|
||||||
iii--;
|
iii--;
|
||||||
}
|
}
|
||||||
@@ -384,7 +383,7 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendFile(): void {
|
sendFile(): void {
|
||||||
console.log(`Send file requested ... ${ this.parsedElement.length}`);
|
console.log(`Send file requested ... ${this.parsedElement.length}`);
|
||||||
this.upload = new UploadProgress();
|
this.upload = new UploadProgress();
|
||||||
// display the upload pop-in
|
// display the upload pop-in
|
||||||
this.popInService.open('popin-upload-progress');
|
this.popInService.open('popin-upload-progress');
|
||||||
@@ -395,16 +394,16 @@ export class UploadScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.uploadFile(this.parsedElement[id], id, total, () => {
|
this.uploadFile(this.parsedElement[id], id, total, () => {
|
||||||
let id2 = id + 1;
|
let id2 = id + 1;
|
||||||
if(id2 < total) {
|
if (id2 < total) {
|
||||||
self.globalUpLoad(id2, total);
|
self.globalUpLoad(id2, total);
|
||||||
} else {
|
} else {
|
||||||
self.upload.result = 'Media creation done';
|
self.upload.result = 'Media creation done';
|
||||||
}
|
}
|
||||||
}, (value:string) => {
|
}, (value: string) => {
|
||||||
self.upload.error = `Error in the upload of the data...${ value}`;
|
self.upload.error = `Error in the upload of the data...${value}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uploadFile(elemnent: FileParsedElement, id: number, total: number, sendDone: any, errorOccured: any): void {
|
uploadFile(element: FileParsedElement, id: number, total: number, sendDone: any, errorOccurred: any): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
self.upload.labelMediaTitle = '';
|
self.upload.labelMediaTitle = '';
|
||||||
@@ -415,95 +414,95 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// add artist
|
// add artist
|
||||||
if(!isNullOrUndefined(self.globalArtist)) {
|
if (!isNullOrUndefined(self.globalArtist)) {
|
||||||
if(self.upload.labelMediaTitle.length !== 0) {
|
if (self.upload.labelMediaTitle.length !== 0) {
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }:`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}:`;
|
||||||
}
|
}
|
||||||
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalArtist;
|
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalArtist;
|
||||||
}
|
}
|
||||||
// add album
|
// add album
|
||||||
if(!isNullOrUndefined(self.globalAlbum) && self.globalAlbum.toString().length !== 0) {
|
if (!isNullOrUndefined(self.globalAlbum) && self.globalAlbum.toString().length !== 0) {
|
||||||
if(self.upload.labelMediaTitle.length !== 0) {
|
if (self.upload.labelMediaTitle.length !== 0) {
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}-`;
|
||||||
}
|
}
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }s${ self.globalAlbum.toString()}`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}s${self.globalAlbum.toString()}`;
|
||||||
}
|
}
|
||||||
// add episode ID
|
// add episode ID
|
||||||
if(!isNullOrUndefined(elemnent.trackId) && elemnent.trackId.toString().length !== 0) {
|
if (!isNullOrUndefined(element.trackId) && element.trackId.toString().length !== 0) {
|
||||||
if(self.upload.labelMediaTitle.length !== 0) {
|
if (self.upload.labelMediaTitle.length !== 0) {
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}-`;
|
||||||
}
|
}
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }e${ elemnent.trackId.toString()}`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}e${element.trackId.toString()}`;
|
||||||
}
|
}
|
||||||
// add title
|
// add title
|
||||||
if(self.upload.labelMediaTitle.length !== 0) {
|
if (self.upload.labelMediaTitle.length !== 0) {
|
||||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
|
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle}-`;
|
||||||
}
|
}
|
||||||
self.upload.labelMediaTitle = `[${ id + 1 }/${ total }]${ self.upload.labelMediaTitle }${elemnent.title}`;
|
self.upload.labelMediaTitle = `[${id + 1}/${total}]${self.upload.labelMediaTitle}${element.title}`;
|
||||||
|
|
||||||
self.trackService.uploadFile(elemnent.file,
|
self.trackService.uploadFile(element.file,
|
||||||
self.globalGender,
|
self.globalGender,
|
||||||
self.globalArtist,
|
self.globalArtist,
|
||||||
self.globalAlbum,
|
self.globalAlbum,
|
||||||
elemnent.trackId,
|
element.trackId,
|
||||||
elemnent.title,
|
element.title,
|
||||||
(count, totalTmp) => {
|
(count, totalTmp) => {
|
||||||
// console.log("upload : " + count*100/totalTmp);
|
// console.log("upload : " + count*100/totalTmp);
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = totalTmp;
|
self.upload.mediaSize = totalTmp;
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
|
console.log(`get response of track : ${JSON.stringify(response, null, 2)}`);
|
||||||
sendDone();
|
sendDone();
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
// self.error = "Can not get the data";
|
// self.error = "Can not get the data";
|
||||||
console.log('Can not add the data in the system...');
|
console.log('Can not add the data in the system...');
|
||||||
errorOccured(JSON.stringify(response, null, 2));
|
errorOccurred(JSON.stringify(response, null, 2));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public checkSimilarString(valueA:string, valueB:string): boolean {
|
public checkSimilarString(valueA: string, valueB: string): boolean {
|
||||||
let valueAL = valueA.toLowerCase();
|
let valueAL = valueA.toLowerCase();
|
||||||
let valueBL = valueB.toLowerCase();
|
let valueBL = valueB.toLowerCase();
|
||||||
valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, '');
|
valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, '');
|
||||||
valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, '');
|
valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, '');
|
||||||
if(valueAL === valueBL) {
|
if (valueAL === valueBL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(valueAL.startsWith(valueBL)) {
|
if (valueAL.startsWith(valueBL)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(valueBL.startsWith(valueAL)) {
|
if (valueBL.startsWith(valueAL)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkConcordence():void {
|
checkConcordance(): void {
|
||||||
if(isNullOrUndefined(this.parsedElement)) {
|
if (isNullOrUndefined(this.parsedElement)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ckear checker
|
// ckear checker
|
||||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
for (let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||||
this.parsedElement[iii].nameDetected = false;
|
this.parsedElement[iii].nameDetected = false;
|
||||||
this.parsedElement[iii].episodeDetected = false;
|
this.parsedElement[iii].trackIdDetected = false;
|
||||||
}
|
}
|
||||||
if(isNullOrUndefined(this.listFileInBdd)) {
|
if (isNullOrUndefined(this.listFileInBdd)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(let iii = 0; iii < this.listFileInBdd.length; iii++) {
|
for (let iii = 0; iii < this.listFileInBdd.length; iii++) {
|
||||||
this.listFileInBdd[iii].nameDetected = false;
|
this.listFileInBdd[iii].nameDetected = false;
|
||||||
this.listFileInBdd[iii].episodeDetected = false;
|
this.listFileInBdd[iii].trackIdDetected = false;
|
||||||
}
|
}
|
||||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
for (let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||||
for(let jjj = 0; jjj < this.listFileInBdd.length; jjj++) {
|
for (let jjj = 0; jjj < this.listFileInBdd.length; jjj++) {
|
||||||
if(this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) {
|
if (this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) {
|
||||||
this.parsedElement[iii].nameDetected = true;
|
this.parsedElement[iii].nameDetected = true;
|
||||||
this.listFileInBdd[jjj].nameDetected = true;
|
this.listFileInBdd[jjj].nameDetected = true;
|
||||||
}
|
}
|
||||||
if(this.parsedElement[iii].trackId === this.listFileInBdd[jjj].episode) {
|
if (this.parsedElement[iii].trackId === this.listFileInBdd[jjj].episode) {
|
||||||
this.parsedElement[iii].episodeDetected = true;
|
this.parsedElement[iii].trackIdDetected = true;
|
||||||
this.listFileInBdd[jjj].episodeDetected = true;
|
this.listFileInBdd[jjj].trackIdDetected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,22 +510,22 @@ export class UploadScene implements OnInit {
|
|||||||
|
|
||||||
updateListOfTrackToCheck(): void {
|
updateListOfTrackToCheck(): void {
|
||||||
// No artist ID set ==> nothing to do.
|
// No artist ID set ==> nothing to do.
|
||||||
if(isNullOrUndefined(this.artistId)) {
|
if (isNullOrUndefined(this.artistId)) {
|
||||||
this.listFileInBdd = undefined;
|
this.listFileInBdd = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
// no album check only the artist files.
|
// no album check only the artist files.
|
||||||
if(isNullOrUndefined(this.globalAlbum)) {
|
if (isNullOrUndefined(this.globalAlbum)) {
|
||||||
console.error(`NO ALBUM ==> check artist ID...`);
|
console.error(`NO ALBUM ==> check artist ID...`);
|
||||||
self.artistService.getAllTracks(self.artistId)
|
self.trackService.getTracksOfAnArtist(self.artistId)
|
||||||
.then((response: any[]) => {
|
.then((response: any[]) => {
|
||||||
self.listFileInBdd = response;
|
self.listFileInBdd = response;
|
||||||
console.error(`find track: ${JSON.stringify(response, null, 2)}`);
|
console.error(`find track: ${JSON.stringify(response, null, 2)}`);
|
||||||
// for (let iii = 0; iii<response.length; iii++) {
|
// for (let iii = 0; iii<response.length; iii++) {
|
||||||
// console.log(" - " + JSON.stringify(response[iii]));
|
// console.log(" - " + JSON.stringify(response[iii]));
|
||||||
// }
|
// }
|
||||||
self.checkConcordence();
|
self.checkConcordance();
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.listFileInBdd = undefined;
|
self.listFileInBdd = undefined;
|
||||||
});
|
});
|
||||||
@@ -536,20 +535,21 @@ export class UploadScene implements OnInit {
|
|||||||
self.albumId = undefined;
|
self.albumId = undefined;
|
||||||
console.error(`ALBUM ==> check album values...`);
|
console.error(`ALBUM ==> check album values...`);
|
||||||
// set 1 find the ID of the album:
|
// set 1 find the ID of the album:
|
||||||
this.artistService.getAlbum(this.artistId)
|
this.trackService.getAlbumIdsOfAnArtist(this.artistId)
|
||||||
.then((response: any[]) => {
|
.then((listAlbumIds: number[]) => {
|
||||||
console.log(`find album: ${JSON.stringify(response, null, 2)}`);
|
this.artistService.getAll(listAlbumIds)
|
||||||
for(let iii = 0; iii < response.length; iii++) {
|
.then((response: Artist[]) => {
|
||||||
|
for (let iii = 0; iii < response.length; iii++) {
|
||||||
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalAlbum));
|
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalAlbum));
|
||||||
if(response[iii].name === `${self.globalAlbum}`) {
|
if (response[iii].name === `${self.globalAlbum}`) {
|
||||||
self.albumId = response[iii].id;
|
self.albumId = response[iii].id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isNullOrUndefined(self.albumId)) {
|
if (isNullOrUndefined(self.albumId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.albumService.getTrack(self.albumId)
|
self.trackService.getTracksWithAlbumId(self.albumId)
|
||||||
.then((response2: any[]) => {
|
.then((response2: any[]) => {
|
||||||
self.listFileInBdd = response2;
|
self.listFileInBdd = response2;
|
||||||
console.log(`find album: ${JSON.stringify(response, null, 2)}`);
|
console.log(`find album: ${JSON.stringify(response, null, 2)}`);
|
||||||
@@ -557,29 +557,30 @@ export class UploadScene implements OnInit {
|
|||||||
// for (let iii = 0; iii<response2.length; iii++) {
|
// for (let iii = 0; iii<response2.length; iii++) {
|
||||||
// console.log(" - " + JSON.stringify(response2[iii]));
|
// console.log(" - " + JSON.stringify(response2[iii]));
|
||||||
// }
|
// }
|
||||||
self.checkConcordence();
|
self.checkConcordance();
|
||||||
}).catch((response3) => {
|
}).catch((response3) => {
|
||||||
self.listFileInBdd = undefined;
|
self.listFileInBdd = undefined;
|
||||||
});
|
});
|
||||||
|
})
|
||||||
}).catch((response4) => {
|
}).catch((response4) => {
|
||||||
self.listFileInBdd = undefined;
|
self.listFileInBdd = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
eventPopUpAlbum(event: string): void {
|
eventPopUpAlbum(event: string): void {
|
||||||
console.log(`GET event: ${ event}`);
|
console.log(`GET event: ${event}`);
|
||||||
this.popInService.close('popin-new-album');
|
this.popInService.close('popin-new-album');
|
||||||
}
|
}
|
||||||
eventPopUpArtist(event: string): void {
|
eventPopUpArtist(event: string): void {
|
||||||
console.log(`GET event: ${ event}`);
|
console.log(`GET event: ${event}`);
|
||||||
this.popInService.close('popin-new-artist');
|
this.popInService.close('popin-new-artist');
|
||||||
}
|
}
|
||||||
eventPopUpType(event: string): void {
|
eventPopUpType(event: string): void {
|
||||||
console.log(`GET event: ${ event}`);
|
console.log(`GET event: ${event}`);
|
||||||
this.popInService.close('popin-new-type');
|
this.popInService.close('popin-new-type');
|
||||||
}
|
}
|
||||||
eventPopUpPlaylist(event: string): void {
|
eventPopUpPlaylist(event: string): void {
|
||||||
console.log(`GET event: ${ event}`);
|
console.log(`GET event: ${event}`);
|
||||||
this.popInService.close('popin-new-playlist');
|
this.popInService.close('popin-new-playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
95
front/src/app/service/GenericDataService.ts
Normal file
95
front/src/app/service/GenericDataService.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { DataStore, DataTools, TypeCheck, isNullOrUndefined } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
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 retrive BDD values`);
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(id: number): 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: number[]): 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: number, data: any): any {
|
|
||||||
let ret = this.http.patchSpecific([this.serviceName, id], data);
|
|
||||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number): any {
|
|
||||||
let ret = this.http.deleteSpecific([this.serviceName, id]);
|
|
||||||
return this.bdd.delete(this.serviceName, id, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteCover(nodeId: number, 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: number,
|
|
||||||
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 retrive data from server');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,129 +5,153 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { Album, AlbumResource, UUID } from 'app/back-api';
|
||||||
import { DataInterface, TypeCheck } from 'common/utils';
|
import { RESTConfig, isArrayOf } from 'app/back-api/rest-tools';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { DataTools, DataStore, SessionService, TypeCheck, isNumber } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlbumService extends GenericInterfaceModelDB {
|
export class AlbumService extends GenericDataService<Album> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('album', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
}
|
}
|
||||||
getAllTracksForAlbums(idAlbums: number[]): Promise<number[]> {
|
}
|
||||||
|
private lambdaGets(): Promise<Album[]> {
|
||||||
|
const self = this;
|
||||||
|
return AlbumResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start AlbumService');
|
||||||
|
this.setStore(new DataStore<Album>(() => this.lambdaGets()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
AlbumResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
coverId
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
}).then((value) => {
|
||||||
* Get all the track for a specific album
|
self.dataStore.updateValue(value);
|
||||||
* @param idAlbum - Id of the album.
|
resolve(value);
|
||||||
* @returns a promise on the list of track elements
|
}).catch((error) => {
|
||||||
*/
|
reject(error);
|
||||||
getTrack(idAlbum:number): Promise<NodeData[]> {
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Album> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
AlbumResource.uploadCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'albumId',
|
|
||||||
value: idAlbum,
|
|
||||||
},
|
},
|
||||||
],
|
data: {
|
||||||
[ 'name' ]); // tODO : set the Id in the track ...
|
file,
|
||||||
resolve(data);
|
fileName: file.name
|
||||||
}).catch((response) => {
|
}
|
||||||
reject(response);
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the artists for a specific album
|
* Get all the artists for a specific album
|
||||||
* @param idAlbum - Id of the album.
|
* @param idAlbum - Id of the album.
|
||||||
* @returns a promise on the list of Artist names for this album
|
* @returns a promise on the list of Artist ID for this album
|
||||||
*/
|
*/
|
||||||
getArtists(idAlbum:number): Promise<String[]> {
|
getArtists(idAlbum: number): Promise<number[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
self.gets()
|
||||||
.then((response: DataInterface) => {
|
.then((response: Album[]) => {
|
||||||
let data = response.getsWhere([
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'albumId',
|
key: 'albumId',
|
||||||
value: idAlbum,
|
value: idAlbum,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[ 'name' ]);
|
['name']);
|
||||||
// filter with artist- ID !!!
|
// filter with artist- ID !!!
|
||||||
const listArtistId = DataInterface.extractLimitOneList(data, "artists");
|
const listArtistId = DataTools.extractLimitOneList(data, "artists");
|
||||||
//console.log(`${idAlbum} ==> List Of ids: ${JSON.stringify(listArtistId, null, 2)} `);
|
if (isArrayOf(listArtistId, isNumber)) {
|
||||||
self.bdd.get('artist')
|
resolve(listArtistId);
|
||||||
.then((response:DataInterface) => {
|
} else {
|
||||||
let dataArtist = response.getsWhere([
|
reject(`Fail to get the ids (impossible case) ${listArtistId}`);
|
||||||
{
|
}
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: listArtistId,
|
|
||||||
},
|
|
||||||
], [ 'name']);
|
|
||||||
const listArtistNames = DataInterface.extractLimitOne(dataArtist, "name");
|
|
||||||
resolve(listArtistNames);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of track in this saison ID
|
|
||||||
* @param AlbumId - Id of the album.
|
|
||||||
* @returns The number of element present in this saison
|
|
||||||
*/
|
|
||||||
countTrack(AlbumId:number): 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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import { ArtistService } from './artist';
|
|||||||
import { AlbumService } from './album';
|
import { AlbumService } from './album';
|
||||||
import { TrackService } from './track';
|
import { TrackService } from './track';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { NodeData } from 'common/model';
|
import { NodeSmall } from 'app/back-api';
|
||||||
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
|
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
export class InputOrders {
|
export class InputOrders {
|
||||||
public genderId: number = undefined;
|
public genderId: number = undefined;
|
||||||
@@ -58,7 +58,7 @@ export class ArianeService {
|
|||||||
private artistService: ArtistService,
|
private artistService: ArtistService,
|
||||||
private albumService: AlbumService,
|
private albumService: AlbumService,
|
||||||
private trackService: TrackService) {
|
private trackService: TrackService) {
|
||||||
//console.log('Start ArianeService');
|
console.log('Start ArianeService');
|
||||||
//this.route.
|
//this.route.
|
||||||
let self = this;
|
let self = this;
|
||||||
this.router.events.subscribe((event: any) => {
|
this.router.events.subscribe((event: any) => {
|
||||||
@@ -85,17 +85,16 @@ export class ArianeService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrrentSegment(): string|undefined {
|
getCurrrentSegment(): string | undefined {
|
||||||
return this.segment;
|
return this.segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIsParam(params: any, name: string): undefined|number {
|
getIsParam(params: any, name: string): undefined | number {
|
||||||
let valueStr = params.get(name);
|
let valueStr = params.get(name);
|
||||||
if(isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return parseInt(valueStr, 10);
|
return parseInt(valueStr, 10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProperties() {
|
updateProperties() {
|
||||||
@@ -103,7 +102,6 @@ export class ArianeService {
|
|||||||
while (!isNullOrUndefined(elem.firstChild)) {
|
while (!isNullOrUndefined(elem.firstChild)) {
|
||||||
elem = elem.firstChild;
|
elem = elem.firstChild;
|
||||||
}
|
}
|
||||||
//console.log(`!!!!!!!!!!!!!!!!!!!!!!!!!! ${JSON.stringify(elem.snapshot.paramMap)}`);
|
|
||||||
let params = elem.snapshot.paramMap;
|
let params = elem.snapshot.paramMap;
|
||||||
let segment: string[] = location.pathname.split("/");
|
let segment: string[] = location.pathname.split("/");
|
||||||
while (segment.length > 1 && (segment[0] === "" || segment[0] === environment.applName)) {
|
while (segment.length > 1 && (segment[0] === "" || segment[0] === environment.applName)) {
|
||||||
@@ -141,7 +139,7 @@ export class ArianeService {
|
|||||||
trackId: this.trackId,
|
trackId: this.trackId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
reset():void {
|
reset(): void {
|
||||||
this.genderId = undefined;
|
this.genderId = undefined;
|
||||||
this.typeName = undefined;
|
this.typeName = undefined;
|
||||||
this.typeChange.emit(this.genderId);
|
this.typeChange.emit(this.genderId);
|
||||||
@@ -159,13 +157,13 @@ export class ArianeService {
|
|||||||
this.trackChange.emit(this.trackId);
|
this.trackChange.emit(this.trackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
setType(id:number):void {
|
setType(id: number): void {
|
||||||
if(this.genderId === id) {
|
if (this.genderId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.genderId = id;
|
this.genderId = id;
|
||||||
this.typeName = '??--??';
|
this.typeName = '??--??';
|
||||||
if(isUndefined(this.genderId)) {
|
if (isUndefined(this.genderId)) {
|
||||||
this.typeChange.emit(this.genderId);
|
this.typeChange.emit(this.genderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -178,78 +176,78 @@ export class ArianeService {
|
|||||||
self.typeChange.emit(self.genderId);
|
self.typeChange.emit(self.genderId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getTypeId():number|undefined {
|
getTypeId(): number | undefined {
|
||||||
return this.genderId;
|
return this.genderId;
|
||||||
}
|
}
|
||||||
getTypeName():string|undefined {
|
getTypeName(): string | undefined {
|
||||||
return this.typeName;
|
return this.typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlaylist(id:number|undefined) {
|
setPlaylist(id: number | undefined) {
|
||||||
if(this.playlistId === id) {
|
if (this.playlistId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.playlistId = id;
|
this.playlistId = id;
|
||||||
this.playlistName = '??--??';
|
this.playlistName = '??--??';
|
||||||
if(isUndefined(this.playlistId)) {
|
if (isUndefined(this.playlistId)) {
|
||||||
this.playlistChange.emit(this.playlistId);
|
this.playlistChange.emit(this.playlistId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.playlistService.get(id)
|
this.playlistService.get(id)
|
||||||
.then((response: NodeData) => {
|
.then((response: NodeSmall) => {
|
||||||
self.playlistName = response.name;
|
self.playlistName = response.name;
|
||||||
self.playlistChange.emit(self.playlistId);
|
self.playlistChange.emit(self.playlistId);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.playlistChange.emit(self.playlistId);
|
self.playlistChange.emit(self.playlistId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPlaylistId():number|undefined {
|
getPlaylistId(): number | undefined {
|
||||||
return this.playlistId;
|
return this.playlistId;
|
||||||
}
|
}
|
||||||
getPlaylistName():string|undefined {
|
getPlaylistName(): string | undefined {
|
||||||
return this.playlistName;
|
return this.playlistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setArtist(id:number|undefined):void {
|
setArtist(id: number | undefined): void {
|
||||||
if(this.artistId === id) {
|
if (this.artistId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.artistId = id;
|
this.artistId = id;
|
||||||
this.artistName = '??--??';
|
this.artistName = '??--??';
|
||||||
if(isUndefined(this.artistId)) {
|
if (isUndefined(this.artistId)) {
|
||||||
this.artistChange.emit(this.artistId);
|
this.artistChange.emit(this.artistId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.artistService.get(id)
|
this.artistService.get(id)
|
||||||
.then((response: NodeData) => {
|
.then((response: NodeSmall) => {
|
||||||
self.artistName = response.name;
|
self.artistName = response.name;
|
||||||
self.artistChange.emit(self.artistId);
|
self.artistChange.emit(self.artistId);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
self.artistChange.emit(self.artistId);
|
self.artistChange.emit(self.artistId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getArtistId():number|undefined {
|
getArtistId(): number | undefined {
|
||||||
return this.artistId;
|
return this.artistId;
|
||||||
}
|
}
|
||||||
getArtistName():string|undefined {
|
getArtistName(): string | undefined {
|
||||||
return this.artistName;
|
return this.artistName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlbum(id:number|undefined):void {
|
setAlbum(id: number | undefined): void {
|
||||||
if(this.albumId === id) {
|
if (this.albumId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.albumId = id;
|
this.albumId = id;
|
||||||
this.albumName = '??--??';
|
this.albumName = '??--??';
|
||||||
if(isUndefined(this.albumId)) {
|
if (isUndefined(this.albumId)) {
|
||||||
this.albumChange.emit(this.albumId);
|
this.albumChange.emit(this.albumId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.albumService.get(id)
|
this.albumService.get(id)
|
||||||
.then((response: NodeData) => {
|
.then((response: NodeSmall) => {
|
||||||
// self.setArtist(response.artistId);
|
// self.setArtist(response.artistId);
|
||||||
self.albumName = response.name;
|
self.albumName = response.name;
|
||||||
self.albumChange.emit(self.albumId);
|
self.albumChange.emit(self.albumId);
|
||||||
@@ -257,20 +255,20 @@ export class ArianeService {
|
|||||||
self.albumChange.emit(self.albumId);
|
self.albumChange.emit(self.albumId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getAlbumId():number|undefined {
|
getAlbumId(): number | undefined {
|
||||||
return this.albumId;
|
return this.albumId;
|
||||||
}
|
}
|
||||||
getAlbumName():string|undefined {
|
getAlbumName(): string | undefined {
|
||||||
return this.albumName;
|
return this.albumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTrack(id:number|undefined):void {
|
setTrack(id: number | undefined): void {
|
||||||
if(this.trackId === id) {
|
if (this.trackId === id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.trackId = id;
|
this.trackId = id;
|
||||||
this.trackName = '??--??';
|
this.trackName = '??--??';
|
||||||
if(isUndefined(this.trackId)) {
|
if (isUndefined(this.trackId)) {
|
||||||
this.trackChange.emit(this.trackId);
|
this.trackChange.emit(this.trackId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -285,10 +283,10 @@ export class ArianeService {
|
|||||||
self.trackChange.emit(self.trackId);
|
self.trackChange.emit(self.trackId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getTrackId():number|undefined {
|
getTrackId(): number | undefined {
|
||||||
return this.trackId;
|
return this.trackId;
|
||||||
}
|
}
|
||||||
getTrackName():string|undefined {
|
getTrackName(): string | undefined {
|
||||||
return this.trackName;
|
return this.trackName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,68 +298,68 @@ export class ArianeService {
|
|||||||
* @param replaceCurrentPage - consider the curent page is removed from history
|
* @param replaceCurrentPage - consider the curent page is removed from history
|
||||||
*/
|
*/
|
||||||
genericNavigate(
|
genericNavigate(
|
||||||
destination:string,
|
destination: string,
|
||||||
ids:number[],
|
ids: number[],
|
||||||
newWindows?:boolean,
|
newWindows?: boolean,
|
||||||
replaceCurrentPage: boolean = false): void {
|
replaceCurrentPage: boolean = false): void {
|
||||||
let addressOffset = `${destination }`;
|
let addressOffset = `${destination}`;
|
||||||
ids.forEach(element => {
|
ids.forEach(element => {
|
||||||
if (!isUndefined(element)) {
|
if (!isUndefined(element)) {
|
||||||
addressOffset += `/${element}`;
|
addressOffset += `/${element}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!isNullOrUndefined(newWindows) && newWindows === true) {
|
if (!isNullOrUndefined(newWindows) && newWindows === true) {
|
||||||
window.open(`/${ addressOffset}`);
|
window.open(`/${addressOffset}`);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate([ addressOffset ], { replaceUrl: replaceCurrentPage });
|
this.router.navigate([addressOffset], { replaceUrl: replaceCurrentPage });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
genericNavigateEdit(
|
genericNavigateEdit(
|
||||||
destination:string,
|
destination: string,
|
||||||
id:number,
|
id: number,
|
||||||
newWindows?:boolean,
|
newWindows?: boolean,
|
||||||
replaceCurrentPage: boolean = false): void {
|
replaceCurrentPage: boolean = false): void {
|
||||||
let addressOffset = `${destination }/${ id }`;
|
let addressOffset = `${destination}/${id}`;
|
||||||
if(!isNullOrUndefined(newWindows) && newWindows === true) {
|
if (!isNullOrUndefined(newWindows) && newWindows === true) {
|
||||||
window.open(`/${ addressOffset}/edit`);
|
window.open(`/${addressOffset}/edit`);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate([ `${addressOffset}/edit` ], { replaceUrl: replaceCurrentPage });
|
this.router.navigate([`${addressOffset}/edit`], { replaceUrl: replaceCurrentPage });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigatePlaylist({ id, newWindows}: { id?: number; newWindows?: boolean; }):void {
|
navigatePlaylist({ id, newWindows }: { id?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('playlist', [ id ], newWindows);
|
this.genericNavigate('playlist', [id], newWindows);
|
||||||
}
|
}
|
||||||
navigatePlaylistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void {
|
navigatePlaylistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('playlist', id, newWindows);
|
this.genericNavigateEdit('playlist', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateGender({ genderId, newWindows }: { genderId?: number; newWindows?: boolean; }):void {
|
navigateGender({ genderId, newWindows }: { genderId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('gender', [ genderId ], newWindows);
|
this.genericNavigate('gender', [genderId], newWindows);
|
||||||
}
|
}
|
||||||
navigateGenderEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void {
|
navigateGenderEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('gender', id, newWindows);
|
this.genericNavigateEdit('gender', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateAlbum({ albumId, newWindows }: { albumId?: number; newWindows?: boolean; }):void {
|
navigateAlbum({ albumId, newWindows }: { albumId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('album', [ albumId ], newWindows);
|
this.genericNavigate('album', [albumId], newWindows);
|
||||||
}
|
}
|
||||||
navigateAlbumEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void {
|
navigateAlbumEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('album', id, newWindows);
|
this.genericNavigateEdit('album', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
navigateArtist({ artistId, albumId, newWindows }: { artistId?: number; albumId?:number, newWindows?: boolean; }):void {
|
navigateArtist({ artistId, albumId, newWindows }: { artistId?: number; albumId?: number, newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('artist', [ artistId, albumId ], newWindows);
|
this.genericNavigate('artist', [artistId, albumId], newWindows);
|
||||||
}
|
}
|
||||||
navigateArtistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void {
|
navigateArtistEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('artist', id, newWindows);
|
this.genericNavigateEdit('artist', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateTrack({ trackId, newWindows }: { trackId?: number; newWindows?: boolean; }):void {
|
navigateTrack({ trackId, newWindows }: { trackId?: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigate('track', [ trackId ], newWindows);
|
this.genericNavigate('track', [trackId], newWindows);
|
||||||
}
|
}
|
||||||
navigateTrackEdit({ id, newWindows }: { id: number; newWindows?: boolean; }):void {
|
navigateTrackEdit({ id, newWindows }: { id: number; newWindows?: boolean; }): void {
|
||||||
this.genericNavigateEdit('track', id, newWindows);
|
this.genericNavigateEdit('track', id, newWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,164 +6,119 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { Artist, ArtistResource, UUID } from 'app/back-api';
|
||||||
import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { isNodeData, NodeData } from 'common/model';
|
import { environment } from 'environments/environment';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { DataStore, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ArtistService extends GenericInterfaceModelDB {
|
export class ArtistService extends GenericDataService<Artist> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('artist', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Artist[]> {
|
||||||
|
return ArtistResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start ArtistService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<Artist>(() => self.lambdaGets()));
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
delete(id: number): Promise<void> {
|
||||||
* Get all the track for a specific artist
|
const self = this;
|
||||||
* @param idArtist - Id of the artist.
|
return new Promise((resolve, reject) => {
|
||||||
* @returns a promise on the list of track elements
|
ArtistResource.remove({
|
||||||
*/
|
restConfig: this.getRestConfig(),
|
||||||
getTrackNoAlbum(idArtist:number): Promise<NodeData[]> {
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Artist> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.CONTAINS,
|
coverId
|
||||||
key: 'artists',
|
}
|
||||||
value: idArtist,
|
}).then((value) => {
|
||||||
}, {
|
self.dataStore.updateValue(value);
|
||||||
check: TypeCheck.EQUAL,
|
resolve(value);
|
||||||
key: 'albumId',
|
}).catch((error) => {
|
||||||
value: undefined,
|
reject(error);
|
||||||
},
|
|
||||||
],
|
|
||||||
[ 'track', 'name' ]);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
uploadCover(id: number,
|
||||||
* Get all the track for a specific artist
|
file: File,
|
||||||
* @param idArtist - Id of the artist.
|
progress: any = null): Promise<Artist> {
|
||||||
* @returns a promise on the list of track elements
|
|
||||||
*/
|
|
||||||
getAllTracks(idArtist:number): Promise<NodeData[]> {
|
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
ArtistResource.uploadCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
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:number): 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,
|
|
||||||
},
|
},
|
||||||
]);
|
data: {
|
||||||
resolve(data.length);
|
file,
|
||||||
}).catch((response) => {
|
fileName: file.name
|
||||||
reject(response);
|
}
|
||||||
|
}).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:number): 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:number): 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,112 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { isArrayOf, isNumberFinite } from 'common/utils';
|
import { SessionService, isArrayOf, isNullOrUndefined, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
|
import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataService {
|
export class DataService {
|
||||||
// 0: Not hide password; 1 hide password;
|
|
||||||
private serviceName:string = 'data';
|
|
||||||
|
|
||||||
constructor(private http: HttpWrapperService) {
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
console.log('Start DataService');
|
console.log('Start DataService');
|
||||||
}
|
}
|
||||||
|
|
||||||
getData():any {
|
|
||||||
return this.http.getSpecific(this.serviceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
get(_id:number):any {
|
|
||||||
return this.http.getSpecific([this.serviceName, _id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadFile(_form:FormData, _progress:any = null) {
|
|
||||||
// return this.http.uploadFileMultipart(this.serviceName, null, _file);
|
|
||||||
return this.http.uploadMultipart(`${this.serviceName }/upload/`, _form, _progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
getImage(_id:number) : Promise<ModelResponseHttp> {
|
|
||||||
return this.http.requestImage({
|
|
||||||
endPoint: this.serviceName,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.IMAGE,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getImageThumbnail(_id:number) : Promise<ModelResponseHttp> {
|
|
||||||
return this.http.requestImage({
|
|
||||||
endPoint: this.serviceName + "/thumbnail/" + _id,
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.ALL,//IMAGE,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Retreive the Cover URL of a specific data id
|
* Retrieve the Cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverUrl(coverId: number): string {
|
getUrl(dataId: string, optionalName?: string): string {
|
||||||
return this.http.createRESTCall2({
|
if (isNullOrUndefined(optionalName)) {
|
||||||
api: `data/${coverId}`,
|
const url = RESTUrl({
|
||||||
addURLToken: true,
|
restModel: {
|
||||||
|
endPoint: "data/{dataId}",
|
||||||
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
dataId
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
console.log(`get URL = ${url}`);
|
||||||
|
if (environment?.replaceDataToRealServer === true) {
|
||||||
|
return url.replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
const url = RESTUrl({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "data/{dataId}/{optionalName}",
|
||||||
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
dataId,
|
||||||
|
optionalName
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (environment?.replaceDataToRealServer === true) {
|
||||||
|
return url.replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
|
}
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the list Cover URL of a specific data id
|
* Retrieve the list Cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverListUrl(coverIds?: number[]): string[] | undefined {
|
getListUrl(dataIds?: string[]): string[] | undefined {
|
||||||
if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let covers = [] as string[];
|
let covers: string[] = [];
|
||||||
for(let iii = 0; iii < coverIds.length; iii++) {
|
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||||
covers.push(this.getCoverUrl(coverIds[iii]));
|
covers.push(this.getUrl(dataIds[iii]));
|
||||||
}
|
}
|
||||||
return covers;
|
return covers;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the thumbnail cover URL of a specific data id
|
* Retrieve the thumbnail cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverThumbnailUrl(coverId: number): string {
|
getThumbnailUrl(coverId: string): string {
|
||||||
return this.http.createRESTCall2({
|
const url = RESTUrl({
|
||||||
api: `data/thumbnail/${coverId}`,
|
restModel: {
|
||||||
addURLToken: true,
|
endPoint: "data/thumbnail/{coverId}",
|
||||||
|
tokenInUrl: true,
|
||||||
|
},
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
coverId
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
if (environment?.replaceDataToRealServer === true) {
|
||||||
|
return url.replace("http://localhost:19080", "https://atria-soft.org");
|
||||||
|
}
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retreive the list thumbnail cover URL of a specific data id
|
* Retrieve the list thumbnail cover URL of a specific data id
|
||||||
* @param coverId Id of te cover
|
* @param coverId Id of te cover
|
||||||
* @returns the url of the cover
|
* @returns the url of the cover
|
||||||
*/
|
*/
|
||||||
getCoverListThumbnailUrl(coverIds?: number[]): string[] | undefined {
|
getListThumbnailUrl(dataIds?: string[]): string[] | undefined {
|
||||||
if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let covers = [] as string[];
|
let covers: string[] = [];
|
||||||
for(let iii = 0; iii < coverIds.length; iii++) {
|
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||||
covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
|
covers.push(this.getThumbnailUrl(dataIds[iii]));
|
||||||
}
|
}
|
||||||
return covers;
|
return covers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { GenderResource, Gender, UUID } from 'app/back-api';
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { isNodeData, NodeData } from 'common/model';
|
import { environment } from 'environments/environment';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { DataStore, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
export interface MessageLogIn {
|
export interface MessageLogIn {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -18,109 +19,111 @@ export interface MessageLogIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GenderService extends GenericInterfaceModelDB {
|
export class GenderService extends GenericDataService<Gender> {
|
||||||
|
|
||||||
|
getRestConfig(): RESTConfig {
|
||||||
constructor(http: HttpWrapperService,
|
return {
|
||||||
bdd: BddService) {
|
server: environment.server.karusic,
|
||||||
super('gender', http, bdd);
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Gender[]> {
|
||||||
|
return GenderResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start GenderService');
|
||||||
countTrack(id:number): Promise<number> {
|
const self = this;
|
||||||
let self = this;
|
this.setStore(new DataStore<Gender>(() => this.lambdaGets()));
|
||||||
|
}
|
||||||
|
insert(data: Gender): Promise<Gender> {
|
||||||
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.post({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
data
|
||||||
{
|
}).then((value: Gender) => {
|
||||||
check: TypeCheck.EQUAL,
|
self.dataStore.updateValue(value);
|
||||||
key: 'typeId',
|
resolve(value);
|
||||||
value: id,
|
}).catch((error) => {
|
||||||
} ] );
|
reject(error);
|
||||||
resolve(data.length);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
patch(id: number, data: Gender): Promise<Gender> {
|
||||||
getSubTrack(id:number): Promise<NodeData[]> {
|
const self = this;
|
||||||
let self = this;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.patch({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'typeId',
|
|
||||||
value: id,
|
|
||||||
}, {
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'artistId',
|
|
||||||
value: undefined,
|
|
||||||
}, {
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'playlistId',
|
|
||||||
value: undefined,
|
|
||||||
},
|
},
|
||||||
], [ 'name' ] );
|
data
|
||||||
resolve(data);
|
}).then((value: Gender) => {
|
||||||
}).catch((response) => {
|
self.dataStore.updateValue(value);
|
||||||
reject(response);
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubArtist(id:number): Promise<NodeData[]> {
|
delete(id: number): Promise<void> {
|
||||||
let self = this;
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('artist')
|
GenderResource.remove({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id
|
||||||
check: TypeCheck.EQUAL,
|
}
|
||||||
key: 'parentId',
|
}).then(() => {
|
||||||
value: id,
|
self.dataStore.delete(id);
|
||||||
} ],
|
resolve();
|
||||||
[ 'name' ]);
|
}).catch((error) => {
|
||||||
resolve(data);
|
reject(error);
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubPlaylist(id:number): Promise<NodeData[]> {
|
deleteCover(id: number, coverId: UUID): Promise<Gender> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('track')
|
GenderResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
coverId
|
||||||
key: 'typeId',
|
}
|
||||||
value: id,
|
}).then((value) => {
|
||||||
}, {
|
self.dataStore.updateValue(value);
|
||||||
check: TypeCheck.EQUAL,
|
resolve(value);
|
||||||
key: 'artistId',
|
}).catch((error) => {
|
||||||
value: [undefined, null],
|
reject(error);
|
||||||
}, {
|
});
|
||||||
check: TypeCheck.NOT_EQUAL,
|
});
|
||||||
key: 'playlistId',
|
}
|
||||||
value: undefined,
|
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,
|
||||||
},
|
},
|
||||||
]);
|
data: {
|
||||||
//, [ 'universId' ]);
|
file,
|
||||||
resolve(data);
|
fileName: file.name
|
||||||
return;
|
}
|
||||||
}).catch((response: any) => {
|
}).then((value) => {
|
||||||
reject(response);
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,45 +5,123 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { Playlist, PlaylistResource, UUID } from 'app/back-api';
|
||||||
import { DataInterface, TypeCheck } from 'common/utils';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { SessionService, DataStore } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PlaylistService extends GenericInterfaceModelDB {
|
export class PlaylistService extends GenericDataService<Playlist> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('playlist', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Playlist[]> {
|
||||||
|
return PlaylistResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubArtist(id:number, select:Array<string> = []):any {
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start PlaylistService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<Playlist>(() => this.lambdaGets()));
|
||||||
|
}
|
||||||
|
|
||||||
|
getSubArtist(id: bigint, select: Array<string> = []): any {
|
||||||
// this.checkLocalBdd();
|
// this.checkLocalBdd();
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubTrack(id:number, select:Array<string> = []):any {
|
getSubTrack(id: bigint, select: Array<string> = []): any {
|
||||||
// this.checkLocalBdd();
|
// this.checkLocalBdd();
|
||||||
|
} insert(data: Playlist): Promise<Playlist> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.post({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
data
|
||||||
|
}).then((value: Playlist) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
patch(id: number, data: Playlist): Promise<Playlist> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Playlist) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(ids: number[]): Promise<NodeData[]> {
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
PlaylistResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Playlist> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get(self.serviceName)
|
PlaylistResource.removeCover({
|
||||||
.then((response: DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getsWhere([
|
params: {
|
||||||
{
|
id,
|
||||||
check: TypeCheck.EQUAL,
|
coverId
|
||||||
key: 'id',
|
}
|
||||||
value: ids,
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).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,
|
||||||
},
|
},
|
||||||
],
|
data: {
|
||||||
[ 'name', 'id' ]);
|
file,
|
||||||
resolve(data);
|
fileName: file.name
|
||||||
return;
|
}
|
||||||
}).catch((response) => {
|
}).then((value) => {
|
||||||
reject(response);
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,40 +5,125 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { isMedia, Media } from 'app/model';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from 'common/utils';
|
import { environment } from 'environments/environment';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { Track, TrackResource, UUID } from 'app/back-api';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { TypeCheck, isArrayOf, isNumber, DataStore, DataTools, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TrackService extends GenericInterfaceModelDB {
|
export class TrackService extends GenericDataService<Track> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('track', http, bdd);
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
}
|
}
|
||||||
get(id: number): Promise<Media> {
|
}
|
||||||
|
private lambdaGets(): Promise<Track[]> {
|
||||||
|
return TrackResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start TrackService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<Track>(() => this.lambdaGets()));
|
||||||
|
}
|
||||||
|
|
||||||
|
patch(id: number, data: Track): Promise<Track> {
|
||||||
|
const self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
super.get(id).then((data: NodeData) => {
|
TrackResource.patch({
|
||||||
if (isMedia(data)) {
|
restConfig: this.getRestConfig(),
|
||||||
resolve(data);
|
params: {
|
||||||
return;
|
id
|
||||||
}
|
},
|
||||||
reject("model is wrong !!!")
|
data
|
||||||
return
|
}).then((value: Track) => {
|
||||||
}).catch((reason: any) => {
|
self.dataStore.updateValue(value);
|
||||||
reject(reason);
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getWithAlbum(idAlbum: number): Promise<Media[]> {
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
TrackResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getTracksIdsForAlbums(idAlbums: number[]): Promise<number[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get(self.serviceName)
|
self.dataStore.getData()
|
||||||
.then((response: DataInterface) => {
|
.then((response: Track[]) => {
|
||||||
let data = response.getsWhere([
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'albumId',
|
||||||
|
value: idAlbums,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['name']); // tODO : set the Id in the track ...
|
||||||
|
// filter with artist- ID !!!
|
||||||
|
const listId = DataTools.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,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'albumId',
|
key: 'albumId',
|
||||||
@@ -46,44 +131,245 @@ export class TrackService extends GenericInterfaceModelDB {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
['track', 'name', 'id']);
|
['track', 'name', 'id']);
|
||||||
if (isArrayOf(data, isMedia)) {
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
reject("model is wrong !!!");
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
getData(): Promise<Media[]> {
|
* Get all the track for a specific artist
|
||||||
|
* @param idArtist - Id of the artist.
|
||||||
|
* @returns a promise on the list of track elements
|
||||||
|
*/
|
||||||
|
getTracksOfArtistWithNoAlbum(idArtist: number): Promise<Track[]> {
|
||||||
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
super.getData().then((data: NodeData[]) => {
|
self.gets()
|
||||||
if (isArrayOf(data, isMedia)) {
|
.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.getTracksOfAnArtist(artistId)
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
resolve(response.length);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the album of a specific artist
|
||||||
|
* @param artistId - ID of the artist
|
||||||
|
* @returns the required List.
|
||||||
|
*/
|
||||||
|
getAlbumIdsOfAnArtist(artistId: number): Promise<number[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.getTracksOfAnArtist(artistId)
|
||||||
|
.then((response: Track[]) => {
|
||||||
|
//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 = DataTools.extractLimitOne(response, "albumId");
|
||||||
|
if (isArrayOf(listAlbumId, isNumber)) {
|
||||||
|
resolve(listAlbumId);
|
||||||
|
} else {
|
||||||
|
reject(`Fail to get the ids (impossible case) ${listAlbumId}`);
|
||||||
|
}
|
||||||
|
}).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 = DataTools.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);
|
resolve(data);
|
||||||
return;
|
return;
|
||||||
}
|
}).catch((response: any) => {
|
||||||
reject("model is wrong !!!")
|
reject(response);
|
||||||
return
|
|
||||||
}).catch((reason: any) => {
|
|
||||||
reject(reason);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uploadFile(file: File,
|
uploadFile(file: File,
|
||||||
gender?: string,
|
gender?: string,
|
||||||
artist?: string,
|
artist?: string,
|
||||||
album?: string,
|
album?: string,
|
||||||
trackId?: number,
|
trackId?: number,
|
||||||
title?: string,
|
title?: string,
|
||||||
progress: any = null) {
|
progress: any = null): Promise<Track> {
|
||||||
|
const 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();
|
const formData = new FormData();
|
||||||
formData.append('fileName', file.name);
|
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('file', file ?? null);
|
||||||
formData.append('gender', gender ?? null);
|
formData.append('gender', gender ?? null);
|
||||||
formData.append('artist', artist ?? null);
|
formData.append('artist', artist ?? null);
|
||||||
@@ -96,28 +382,44 @@ export class TrackService extends GenericInterfaceModelDB {
|
|||||||
formData.append('title', title ?? null);
|
formData.append('title', title ?? null);
|
||||||
|
|
||||||
return this.http.uploadMultipart(`${this.serviceName}/upload/`, formData, progress);
|
return this.http.uploadMultipart(`${this.serviceName}/upload/`, formData, progress);
|
||||||
}
|
*/
|
||||||
|
|
||||||
uploadCoverBlob(blob: Blob,
|
deleteCover(id: number, coverId: UUID): Promise<Track> {
|
||||||
mediaId: number,
|
|
||||||
progress: any = null) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('fileName', 'take_screenshoot');
|
|
||||||
formData.append('typeId', mediaId.toString());
|
|
||||||
formData.append('file', blob);
|
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.http.uploadMultipart(`${this.serviceName}/${mediaId}/add_cover/`, formData, progress)
|
TrackResource.removeCover({
|
||||||
.then((response) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response;
|
params: {
|
||||||
if (data === null || data === undefined) {
|
id,
|
||||||
reject('error retrive data from server');
|
coverId
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
|
}).then((value) => {
|
||||||
resolve(data);
|
self.dataStore.updateValue(value);
|
||||||
}).catch((response) => {
|
resolve(value);
|
||||||
reject(response);
|
}).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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user