[DEV] update kar-cw and new generate back-end API
This commit is contained in:
parent
95c3c0f968
commit
e0b81d2122
@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.6.3</version>
|
<version>0.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -21,12 +21,12 @@ import org.kar.archidata.migration.MigrationEngine;
|
|||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.karideo.api.Front;
|
import org.kar.karideo.api.Front;
|
||||||
import org.kar.karideo.api.HealthCheck;
|
import org.kar.karideo.api.HealthCheck;
|
||||||
|
import org.kar.karideo.api.MediaResource;
|
||||||
import org.kar.karideo.api.SeasonResource;
|
import org.kar.karideo.api.SeasonResource;
|
||||||
import org.kar.karideo.api.SeriesResource;
|
import org.kar.karideo.api.SeriesResource;
|
||||||
import org.kar.karideo.api.TypeResource;
|
import org.kar.karideo.api.TypeResource;
|
||||||
import org.kar.karideo.api.UserMediaAdvancementResource;
|
import org.kar.karideo.api.UserMediaAdvancementResource;
|
||||||
import org.kar.karideo.api.UserResource;
|
import org.kar.karideo.api.UserResource;
|
||||||
import org.kar.karideo.api.VideoResource;
|
|
||||||
import org.kar.karideo.filter.KarideoAuthenticationFilter;
|
import org.kar.karideo.filter.KarideoAuthenticationFilter;
|
||||||
import org.kar.karideo.migration.Initialization;
|
import org.kar.karideo.migration.Initialization;
|
||||||
import org.kar.karideo.migration.Migration20230810;
|
import org.kar.karideo.migration.Migration20230810;
|
||||||
@ -105,7 +105,7 @@ public class WebLauncher {
|
|||||||
rc.register(DataResource.class);
|
rc.register(DataResource.class);
|
||||||
rc.register(SeasonResource.class);
|
rc.register(SeasonResource.class);
|
||||||
rc.register(TypeResource.class);
|
rc.register(TypeResource.class);
|
||||||
rc.register(VideoResource.class);
|
rc.register(MediaResource.class);
|
||||||
rc.register(UserMediaAdvancementResource.class);
|
rc.register(UserMediaAdvancementResource.class);
|
||||||
|
|
||||||
rc.register(HealthCheck.class);
|
rc.register(HealthCheck.class);
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
|
|
||||||
package org.kar.karideo;
|
package org.kar.karideo;
|
||||||
|
|
||||||
import java.io.FileWriter;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataFactoryZod;
|
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.karideo.api.Front;
|
||||||
|
import org.kar.karideo.api.HealthCheck;
|
||||||
|
import org.kar.karideo.api.MediaResource;
|
||||||
|
import org.kar.karideo.api.SeasonResource;
|
||||||
|
import org.kar.karideo.api.SeriesResource;
|
||||||
|
import org.kar.karideo.api.TypeResource;
|
||||||
|
import org.kar.karideo.api.UserMediaAdvancementResource;
|
||||||
|
import org.kar.karideo.api.UserResource;
|
||||||
import org.kar.karideo.migration.Initialization;
|
import org.kar.karideo.migration.Initialization;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -15,11 +24,17 @@ public class WebLauncherLocal extends WebLauncher {
|
|||||||
private WebLauncherLocal() {}
|
private WebLauncherLocal() {}
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
final String model = DataFactoryZod.createTables(Initialization.CLASSES_BASE);
|
DataFactoryTsApi.generatePackage(List.of(
|
||||||
LOGGER.info("Zod Model = {}", model);
|
Front.class,
|
||||||
final FileWriter writer = new FileWriter("../front/src/app/model/server-karideo-api.ts");
|
HealthCheck.class,
|
||||||
writer.write(model);
|
SeasonResource.class,
|
||||||
writer.close();
|
SeriesResource.class,
|
||||||
|
TypeResource.class,
|
||||||
|
UserMediaAdvancementResource.class,
|
||||||
|
UserResource.class,
|
||||||
|
MediaResource.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();
|
||||||
LOGGER.info("end-configure the server & wait finish process:");
|
LOGGER.info("end-configure the server & wait finish process:");
|
||||||
|
@ -6,6 +6,7 @@ import org.kar.archidata.tools.JWTWrapper;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
@ -18,11 +19,13 @@ import jakarta.ws.rs.core.Response;
|
|||||||
public class HealthCheck {
|
public class HealthCheck {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
||||||
|
|
||||||
public record HealthResult(
|
public record HealthResult(String value) {
|
||||||
String value) {};
|
|
||||||
|
};
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@PermitAll
|
@PermitAll
|
||||||
|
@Operation(description = "Get the server state (health)", tags = "SYSTEM")
|
||||||
public HealthResult getHealth() throws FailException {
|
public HealthResult getHealth() throws FailException {
|
||||||
if (JWTWrapper.getPublicKeyJson() == null && !ConfigBaseVariable.getTestMode()) {
|
if (JWTWrapper.getPublicKeyJson() == null && !ConfigBaseVariable.getTestMode()) {
|
||||||
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Missing Jwt public token");
|
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Missing Jwt public token");
|
||||||
|
@ -8,9 +8,10 @@ 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.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
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.exception.FailException;
|
import org.kar.archidata.exception.FailException;
|
||||||
import org.kar.archidata.exception.InputException;
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
@ -22,6 +23,7 @@ import org.kar.karideo.model.Type;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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;
|
||||||
@ -35,19 +37,21 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
@Path("/video")
|
@Path("/video")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class VideoResource {
|
public class MediaResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(MediaResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Media> get() throws Exception {
|
@Operation(description = "Get all Media", tags = "GLOBAL")
|
||||||
|
public List<Media> gets() throws Exception {
|
||||||
return DataAccess.gets(Media.class);
|
return DataAccess.gets(Media.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
|
@Operation(description = "Get a specific Media with his ID", tags = "GLOBAL")
|
||||||
public Media get(@PathParam("id") final Long id) throws Exception {
|
public Media get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
@ -56,7 +60,8 @@ public class VideoResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Media put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
@Operation(description = "Modify a specific Media", tags = "GLOBAL")
|
||||||
|
public Media patch(@PathParam("id") final Long id, @AsyncType(Media.class) final String jsonRequest) throws Exception {
|
||||||
System.out.println("update video " + id + " ==> '" + jsonRequest + "'");
|
System.out.println("update video " + id + " ==> '" + jsonRequest + "'");
|
||||||
DataAccess.updateWithJson(Media.class, id, jsonRequest);
|
DataAccess.updateWithJson(Media.class, id, jsonRequest);
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
@ -76,9 +81,10 @@ public class VideoResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/upload/")
|
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
|
@Operation(description = "Create a new Media", tags = "GLOBAL")
|
||||||
|
@AsyncType(Media.class)
|
||||||
public Response uploadFile(@FormDataParam("fileName") String fileName, @FormDataParam("universe") String universe, @FormDataParam("series") String series,
|
public Response uploadFile(@FormDataParam("fileName") String fileName, @FormDataParam("universe") String universe, @FormDataParam("series") String series,
|
||||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||||
@FormDataParam("season") String season, @FormDataParam("episode") String episode, @FormDataParam("title") String title, @FormDataParam("typeId") String typeId,
|
@FormDataParam("season") String season, @FormDataParam("episode") String episode, @FormDataParam("title") String title, @FormDataParam("typeId") String typeId,
|
||||||
@ -125,7 +131,7 @@ public class VideoResource {
|
|||||||
} else if (data.deleted) {
|
} else if (data.deleted) {
|
||||||
System.out.println("Data already exist but deleted");
|
System.out.println("Data already exist but deleted");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
DataResource.undelete(data.id);
|
DataTools.undelete(data.id);
|
||||||
data.deleted = false;
|
data.deleted = false;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Data already exist ... all good");
|
System.out.println("Data already exist ... all good");
|
||||||
@ -198,27 +204,38 @@ public class VideoResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") final UUID id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
@AsyncType(Media.class)
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@Operation(description = "Upload a new season cover media", tags = "GLOBAL")
|
||||||
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
public Media uploadCover( //
|
||||||
|
@PathParam("id") final Long id, //
|
||||||
|
@FormDataParam("fileName") final String fileName, //
|
||||||
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData//
|
||||||
|
) throws Exception {
|
||||||
|
DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@DELETE
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") final UUID id, @PathParam("coverId") final UUID coverId) throws Exception {
|
@Operation(description = "Remove a specific cover of a media", tags = "GLOBAL")
|
||||||
AddOnManyToMany.removeLink(Media.class, id, "cover", coverId);
|
public Media removeCover( //
|
||||||
return Response.ok(DataAccess.get(Media.class, id)).build();
|
@PathParam("id") final Long id, //
|
||||||
|
@PathParam("coverId") final UUID coverId //
|
||||||
|
) throws Exception {
|
||||||
|
AddOnDataJson.removeLink(Media.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") final UUID id) throws Exception {
|
@Operation(description = "Remove a specific Media", tags = "GLOBAL")
|
||||||
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Media.class, id);
|
DataAccess.delete(Media.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,19 +2,22 @@ package org.kar.karideo.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.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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,23 +28,17 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/season")
|
@Path("/season")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class SeasonResource {
|
public class SeasonResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("USER")
|
|
||||||
public static Season getWithId(@PathParam("id") final Long id) throws Exception {
|
|
||||||
return DataAccess.get(Season.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Season> get() throws Exception {
|
@Operation(description = "Get a specific Season with his ID", tags = "GLOBAL")
|
||||||
|
public List<Season> gets() throws Exception {
|
||||||
return DataAccess.gets(Season.class);
|
return DataAccess.gets(Season.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +46,7 @@ public class SeasonResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Operation(description = "Get all season", tags = "GLOBAL")
|
||||||
public Season get(@PathParam("id") final Long id) throws Exception {
|
public Season get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
@ -60,15 +58,17 @@ public class SeasonResource {
|
|||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Season put(final String jsonRequest) throws Exception {
|
@Operation(description = "Create a new season", tags = "GLOBAL")
|
||||||
return DataAccess.insertWithJson(Season.class, jsonRequest);
|
public Season post(final Season jsonRequest) throws Exception {
|
||||||
|
return DataAccess.insert(jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Season put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
@Operation(description = "Modify a specific season", tags = "GLOBAL")
|
||||||
|
public Season patch(@PathParam("id") final Long id, @AsyncType(Season.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Season.class, id, jsonRequest);
|
DataAccess.updateWithJson(Season.class, id, jsonRequest);
|
||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
@ -76,26 +76,29 @@ public class SeasonResource {
|
|||||||
@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 season", tags = "GLOBAL")
|
||||||
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Season.class, id);
|
DataAccess.delete(Season.class, id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
@Operation(description = "Upload a new season cover season", tags = "GLOBAL")
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
public Season uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 specific cover of a season", tags = "GLOBAL")
|
||||||
AddOnManyToMany.removeLink(Season.class, id, "cover", coverId);
|
public Season removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
return Response.ok(DataAccess.get(Season.class, id)).build();
|
AddOnDataJson.removeLink(Season.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Season getOrCreate(final String name, final Long seriesId) {
|
public static Season getOrCreate(final String name, final Long seriesId) {
|
||||||
|
@ -2,19 +2,22 @@ package org.kar.karideo.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.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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,23 +28,16 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/series")
|
@Path("/series")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class SeriesResource {
|
public class SeriesResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Series getWithId(@PathParam("id") final Long id) throws Exception {
|
@Operation(description = "Get all Series", tags = "GLOBAL")
|
||||||
return DataAccess.get(Series.class, id);
|
public List<Series> gets() throws Exception {
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@RolesAllowed("USER")
|
|
||||||
public List<Series> get() throws Exception {
|
|
||||||
return DataAccess.gets(Series.class);
|
return DataAccess.gets(Series.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +45,7 @@ public class SeriesResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Operation(description = "Get a specific Series with his ID", tags = "GLOBAL")
|
||||||
public Series get(@PathParam("id") final Long id) throws Exception {
|
public Series get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
@ -60,15 +57,17 @@ public class SeriesResource {
|
|||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Series put(final String jsonRequest) throws Exception {
|
@Operation(description = "Create a new Series", tags = "GLOBAL")
|
||||||
return DataAccess.insertWithJson(Series.class, jsonRequest);
|
public Series post(final Series jsonRequest) throws Exception {
|
||||||
|
return DataAccess.insert(jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Series put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
@Operation(description = "Modify a specific Series", tags = "GLOBAL")
|
||||||
|
public Series patch(@PathParam("id") final Long id, @AsyncType(Series.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Series.class, id, jsonRequest);
|
DataAccess.updateWithJson(Series.class, id, jsonRequest);
|
||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
@ -76,26 +75,29 @@ public class SeriesResource {
|
|||||||
@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 Series", tags = "GLOBAL")
|
||||||
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Series.class, id);
|
DataAccess.delete(Series.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 })
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
@Operation(description = "Upload a new season cover Series", tags = "GLOBAL")
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
public Series uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 specific Series of a season", tags = "GLOBAL")
|
||||||
AddOnManyToMany.removeLink(Series.class, id, "cover", coverId);
|
public Series removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
return Response.ok(DataAccess.get(Series.class, id)).build();
|
AddOnDataJson.removeLink(Series.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Series getOrCreate(final String name, final Long typeId) {
|
public static Series getOrCreate(final String name, final Long typeId) {
|
||||||
|
@ -2,18 +2,21 @@ package org.kar.karideo.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.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Type;
|
import org.kar.karideo.model.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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;
|
||||||
@ -24,23 +27,17 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/type")
|
@Path("/type")
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class TypeResource {
|
public class TypeResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{id}")
|
|
||||||
@RolesAllowed("USER")
|
|
||||||
public static Type getWithId(@PathParam("id") final Long id) throws Exception {
|
|
||||||
return DataAccess.get(Type.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Type> get() throws Exception {
|
@Operation(description = "Get all Type", tags = "GLOBAL")
|
||||||
|
public List<Type> gets() throws Exception {
|
||||||
return DataAccess.gets(Type.class);
|
return DataAccess.gets(Type.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +45,7 @@ public class TypeResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Operation(description = "Get a specific Type with his ID", tags = "GLOBAL")
|
||||||
public Type get(@PathParam("id") final Long id) throws Exception {
|
public Type get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
@ -63,15 +61,17 @@ public class TypeResource {
|
|||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Type put(final String jsonRequest) throws Exception {
|
@Operation(description = "Create a new Type", tags = "GLOBAL")
|
||||||
return DataAccess.insertWithJson(Type.class, jsonRequest);
|
public Type post(final Type jsonRequest) throws Exception {
|
||||||
|
return DataAccess.insert(jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Type put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
@Operation(description = "Modify a specific Type", tags = "GLOBAL")
|
||||||
|
public Type patch(@PathParam("id") final Long id, @AsyncType(Type.class) final String jsonRequest) throws Exception {
|
||||||
DataAccess.updateWithJson(Type.class, id, jsonRequest);
|
DataAccess.updateWithJson(Type.class, id, jsonRequest);
|
||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
@ -79,26 +79,29 @@ public class TypeResource {
|
|||||||
@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 Type", tags = "GLOBAL")
|
||||||
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Type.class, id);
|
DataAccess.delete(Type.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 })
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
@Operation(description = "Upload a new season cover Type", tags = "GLOBAL")
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
public Type uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 specific cover of a type", tags = "GLOBAL")
|
||||||
AddOnManyToMany.removeLink(Type.class, id, "cover", coverId);
|
public Type removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
return Response.ok(DataAccess.get(Type.class, id)).build();
|
AddOnDataJson.removeLink(Type.class, id, "covers", coverId);
|
||||||
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type getOrCreate(final String name) {
|
public static Type getOrCreate(final String name) {
|
||||||
|
@ -11,6 +11,7 @@ import org.kar.karideo.model.UserMediaAdvancement;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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;
|
||||||
@ -21,24 +22,25 @@ import jakarta.ws.rs.PathParam;
|
|||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.Context;
|
import jakarta.ws.rs.core.Context;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/advancement")
|
@Path("/advancement")
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class UserMediaAdvancementResource {
|
public class UserMediaAdvancementResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public UserMediaAdvancement getWithId(@Context final SecurityContext sc, @PathParam("id") final Long id) throws Exception {
|
@Operation(description = "Get a specific user advancement with his ID", tags = "GLOBAL")
|
||||||
|
public UserMediaAdvancement get(@Context final SecurityContext sc, @PathParam("id") final Long id) throws Exception {
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
return DataAccess.getWhere(UserMediaAdvancement.class, new Condition(new QueryAnd(new QueryCondition("mediaId", "=", id), new QueryCondition("userId", "=", gc.userByToken.id))));
|
return DataAccess.getWhere(UserMediaAdvancement.class, new Condition(new QueryAnd(new QueryCondition("mediaId", "=", id), new QueryCondition("userId", "=", gc.userByToken.id))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
|
@Operation(description = "Get all user advancement", tags = "GLOBAL")
|
||||||
public List<UserMediaAdvancement> gets(@Context final SecurityContext sc) throws Exception {
|
public List<UserMediaAdvancement> gets(@Context final SecurityContext sc) throws Exception {
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
return DataAccess.getsWhere(UserMediaAdvancement.class, new Condition(new QueryCondition("userId", "=", gc.userByToken.id)));
|
return DataAccess.getsWhere(UserMediaAdvancement.class, new Condition(new QueryCondition("userId", "=", gc.userByToken.id)));
|
||||||
@ -77,8 +79,9 @@ public class UserMediaAdvancementResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public UserMediaAdvancement put(@Context final SecurityContext sc, @PathParam("id") final Long id, final MediaInformationsDelta data) throws Exception {
|
@Operation(description = "Modify a user advancement", tags = "GLOBAL")
|
||||||
final UserMediaAdvancement elem = getWithId(sc, id);
|
public UserMediaAdvancement patch(@Context final SecurityContext sc, @PathParam("id") final Long id, final MediaInformationsDelta data) throws Exception {
|
||||||
|
final UserMediaAdvancement elem = get(sc, id);
|
||||||
if (elem == null) {
|
if (elem == null) {
|
||||||
// insert element
|
// insert element
|
||||||
if (data.addCount) {
|
if (data.addCount) {
|
||||||
@ -100,10 +103,10 @@ public class UserMediaAdvancementResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public Response delete(@Context final SecurityContext sc, @PathParam("id") final Long id) throws Exception {
|
@Operation(description = "Remove a specific user advancement", tags = "GLOBAL")
|
||||||
final UserMediaAdvancement elem = getWithId(sc, id);
|
public void remove(@Context final SecurityContext sc, @PathParam("id") final Long id) throws Exception {
|
||||||
|
final UserMediaAdvancement elem = get(sc, id);
|
||||||
DataAccess.delete(UserMediaAdvancement.class, elem.id);
|
DataAccess.delete(UserMediaAdvancement.class, elem.id);
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.annotation.security.RolesAllowed;
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
@ -20,7 +21,7 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/users")
|
@Path("/users")
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||||
|
|
||||||
@ -41,7 +42,8 @@ public class UserResource {
|
|||||||
// curl http://localhost:9993/api/users
|
// curl http://localhost:9993/api/users
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public List<UserKarideo> getUsers() {
|
@Operation(description = "Get all the users", tags = "SYSTEM")
|
||||||
|
public List<UserKarideo> gets() {
|
||||||
System.out.println("getUsers");
|
System.out.println("getUsers");
|
||||||
try {
|
try {
|
||||||
return DataAccess.gets(UserKarideo.class);
|
return DataAccess.gets(UserKarideo.class);
|
||||||
@ -56,7 +58,8 @@ public class UserResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public UserKarideo getUsers(@Context final SecurityContext sc, @PathParam("id") final long userId) {
|
@Operation(description = "Get a specific user data", tags = "SYSTEM")
|
||||||
|
public UserKarideo get(@Context final SecurityContext sc, @PathParam("id") final long userId) {
|
||||||
System.out.println("getUser " + userId);
|
System.out.println("getUser " + userId);
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
System.out.println("===================================================");
|
System.out.println("===================================================");
|
||||||
@ -74,6 +77,7 @@ public class UserResource {
|
|||||||
@GET
|
@GET
|
||||||
@Path("me")
|
@Path("me")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
|
@Operation(description = "Get the user personal data", tags = "SYSTEM")
|
||||||
public UserOut getMe(@Context final SecurityContext sc) {
|
public UserOut getMe(@Context final SecurityContext sc) {
|
||||||
LOGGER.debug("getMe()");
|
LOGGER.debug("getMe()");
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
|
@ -49,9 +49,6 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
(UUID_TO_BIN('730815ef-d4ee-11ee-a8dd-02420a030203'), 'Opera', 'Recorded opera');
|
(UUID_TO_BIN('730815ef-d4ee-11ee-a8dd-02420a030203'), 'Opera', 'Recorded opera');
|
||||||
""");
|
""");
|
||||||
// set start increment element to permit to add after default elements
|
// set start increment element to permit to add after default elements
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` AUTO_INCREMENT = 1000;
|
|
||||||
""", "mysql");
|
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
||||||
""", "mysql");
|
""", "mysql");
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package org.kar.karideo.migration;
|
package org.kar.karideo.migration;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
@ -101,9 +104,11 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
for (final UUIDConversion data: datas) {
|
for (final UUIDConversion data: datas) {
|
||||||
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
final String origin = DataResource.getFileData(data.id);
|
|
||||||
final String destination = DataResource.getFileData(data.uuid);
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
"$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": "karideo",
|
|
||||||
"projects": {
|
"projects": {
|
||||||
"karideo": {
|
"karideo": {
|
||||||
"root": "",
|
"root": "",
|
||||||
@ -16,6 +15,7 @@
|
|||||||
"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": [
|
"polyfills": [
|
||||||
"zone.js"
|
"zone.js"
|
||||||
],
|
],
|
||||||
@ -52,12 +52,17 @@
|
|||||||
"develop": {
|
"develop": {
|
||||||
"optimization": false,
|
"optimization": false,
|
||||||
"outputHashing": "none",
|
"outputHashing": "none",
|
||||||
"sourceMap": true,
|
|
||||||
"namedChunks": true,
|
"namedChunks": true,
|
||||||
"aot": true,
|
"aot": false,
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
"vendorChunk": true,
|
"vendorChunk": true,
|
||||||
"buildOptimizer": false
|
"buildOptimizer": false,
|
||||||
|
"sourceMap": {
|
||||||
|
"scripts": true,
|
||||||
|
"styles": true,
|
||||||
|
"hidden": false,
|
||||||
|
"vendor": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
17122
front/package-lock.json
generated
17122
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,34 +12,38 @@
|
|||||||
"style": "prettier --write .",
|
"style": "prettier --write .",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"update_packages": "ncu --upgrade",
|
"update_packages": "ncu --upgrade",
|
||||||
"install_dependency": "npm install"
|
"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": "^17.2.0",
|
"@angular/animations": "^17.3.4",
|
||||||
"@angular/cdk": "^17.1.2",
|
"@angular/cdk": "^17.3.4",
|
||||||
"@angular/common": "^17.2.0",
|
"@angular/common": "^17.3.4",
|
||||||
"@angular/compiler": "^17.2.0",
|
"@angular/compiler": "^17.3.4",
|
||||||
"@angular/core": "^17.2.0",
|
"@angular/core": "^17.3.4",
|
||||||
"@angular/forms": "^17.2.0",
|
"@angular/forms": "^17.3.4",
|
||||||
"@angular/material": "^17.1.2",
|
"@angular/material": "^17.3.4",
|
||||||
"@angular/platform-browser": "^17.2.0",
|
"@angular/platform-browser": "^17.3.4",
|
||||||
"@angular/platform-browser-dynamic": "^17.2.0",
|
"@angular/platform-browser-dynamic": "^17.3.4",
|
||||||
"@angular/router": "^17.2.0",
|
"@angular/router": "^17.3.4",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"zone.js": "^0.14.4",
|
"zone.js": "^0.14.4",
|
||||||
"zod": "3.22.4"
|
"zod": "3.22.4",
|
||||||
|
"@kangaroo-and-rabbit/kar-cw": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.2.0",
|
"@angular-devkit/build-angular": "^17.3.4",
|
||||||
"@angular-eslint/builder": "17.2.1",
|
"@angular-eslint/builder": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||||
"@angular-eslint/schematics": "17.2.1",
|
"@angular-eslint/schematics": "17.3.0",
|
||||||
"@angular-eslint/template-parser": "17.2.1",
|
"@angular-eslint/template-parser": "17.3.0",
|
||||||
"@angular/cli": "^17.2.0",
|
"@angular/cli": "^17.3.4",
|
||||||
"@angular/compiler-cli": "^17.2.0",
|
"@angular/compiler-cli": "^17.3.4",
|
||||||
"@angular/language-service": "^17.2.0",
|
"@angular/language-service": "^17.3.4",
|
||||||
"npm-check-updates": "^16.14.15"
|
"npm-check-updates": "^16.14.18",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
9816
front/pnpm-lock.yaml
Normal file
9816
front/pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,11 +6,10 @@
|
|||||||
|
|
||||||
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, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, TypeScene, VideoEditScene, VideoScene } from './scene';
|
import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, TypeScene, VideoEditScene, VideoScene } from './scene';
|
||||||
import { UploadScene } from './scene/upload/upload';
|
import { UploadScene } from './scene/upload/upload';
|
||||||
|
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';
|
||||||
|
|
||||||
// see https://angular.io/guide/router
|
// see https://angular.io/guide/router
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
<!-- Generig global menu -->
|
<!-- Generig 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 -->
|
||||||
@if(autoConnectedDone) {
|
@if(autoConnectedDone) {
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
|
@ -5,12 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
import { ArianeService, MediaService, SeasonService, SeriesService, TypeService } from './service';
|
||||||
import { MenuItem, MenuPosition } from 'common/model';
|
import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { UserService, SessionService, SSOService } from 'common/service';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
import { ArianeService } from './service';
|
|
||||||
import { UserRoles222 } from 'common/service/session';
|
|
||||||
|
|
||||||
enum MenuEventType {
|
enum MenuEventType {
|
||||||
SSO_LOGIN = "SSO_CALL_LOGIN",
|
SSO_LOGIN = "SSO_CALL_LOGIN",
|
||||||
@ -38,6 +34,11 @@ export class AppComponent implements OnInit {
|
|||||||
location: string = "home";
|
location: string = "home";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private mediaService: MediaService,
|
||||||
|
private seasonService: SeasonService,
|
||||||
|
private seriesService: SeriesService,
|
||||||
|
private typeService: TypeService,
|
||||||
|
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private sessionService: SessionService,
|
private sessionService: SessionService,
|
||||||
private ssoService: SSOService,
|
private ssoService: SSOService,
|
||||||
@ -67,13 +68,13 @@ export class AppComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.userService.checkAutoConnect().then(() => {
|
this.userService.checkAutoConnect().then(() => {
|
||||||
console.log(` ==>>>>> Autoconnect THEN !!!`);
|
console.log(` ==>>>>> Auto-connect THEN !!!`);
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log(` ==>>>>> Autoconnect CATCH !!!`);
|
console.log(` ==>>>>> Auto-connect CATCH !!!`);
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
console.log(` ==>>>>> Autoconnect FINALLY !!!`);
|
console.log(` ==>>>>> Auto-connect FINALLY !!!`);
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
});
|
});
|
||||||
this.arianeService.segmentChange.subscribe((_segmentName: string) => {
|
this.arianeService.segmentChange.subscribe((_segmentName: string) => {
|
||||||
|
@ -22,9 +22,18 @@ import {
|
|||||||
HomeScene, HelpScene, TypeScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
|
HomeScene, HelpScene, TypeScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
|
||||||
VideoEditScene, SeasonEditScene, SeriesEditScene
|
VideoEditScene, SeasonEditScene, SeriesEditScene
|
||||||
} from './scene';
|
} from './scene';
|
||||||
import { TypeService, DataService, SeriesService, SeasonService, VideoService, ArianeService, AdvancementService } from './service';
|
import {
|
||||||
|
DataService,
|
||||||
|
AdvancementService,
|
||||||
|
MediaService,
|
||||||
|
SeasonService,
|
||||||
|
SeriesService,
|
||||||
|
TypeService,
|
||||||
|
ArianeService,
|
||||||
|
} from './service';
|
||||||
import { UploadScene } from './scene/upload/upload';
|
import { UploadScene } from './scene/upload/upload';
|
||||||
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';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -46,25 +55,24 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
VideoEditScene,
|
VideoEditScene,
|
||||||
SeasonEditScene,
|
SeasonEditScene,
|
||||||
SeriesEditScene,
|
SeriesEditScene,
|
||||||
UploadScene,
|
UploadScene
|
||||||
...common_module_declarations,
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
...common_module_imports,
|
KarCWModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
TypeService,
|
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||||
DataService,
|
DataService,
|
||||||
SeriesService,
|
|
||||||
SeasonService,
|
|
||||||
VideoService,
|
|
||||||
ArianeService,
|
|
||||||
AdvancementService,
|
AdvancementService,
|
||||||
...common_module_providers,
|
MediaService,
|
||||||
|
SeasonService,
|
||||||
|
SeriesService,
|
||||||
|
TypeService,
|
||||||
|
ArianeService,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
@ -72,8 +80,7 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
|||||||
ElementSeriesComponent,
|
ElementSeriesComponent,
|
||||||
ElementSeasonComponent,
|
ElementSeasonComponent,
|
||||||
ElementVideoComponent,
|
ElementVideoComponent,
|
||||||
PopInCreateType,
|
PopInCreateType
|
||||||
...common_module_exports,
|
|
||||||
],
|
],
|
||||||
bootstrap: [
|
bootstrap: [
|
||||||
AppComponent
|
AppComponent
|
||||||
|
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 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,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
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 {
|
||||||
|
|
||||||
|
}
|
23
front/src/app/back-api/health-check.ts
Normal file
23
front/src/app/back-api/health-check.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the server state (health)
|
||||||
|
*/
|
||||||
|
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 "./front";
|
||||||
|
export * from "./health-check";
|
||||||
|
export * from "./season-resource";
|
||||||
|
export * from "./series-resource";
|
||||||
|
export * from "./type-resource";
|
||||||
|
export * from "./user-media-advancement-resource";
|
||||||
|
export * from "./user-resource";
|
||||||
|
export * from "./media-resource";
|
||||||
|
export * from "./data-resource";
|
157
front/src/app/back-api/media-resource.ts
Normal file
157
front/src/app/back-api/media-resource.ts
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {Long, Media, UUID, isMedia, } from "./model"
|
||||||
|
export namespace MediaResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific Media
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Media with his ID
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a specific Media
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Media,
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Create a new Media
|
||||||
|
*/
|
||||||
|
export function uploadFile({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
series: string,
|
||||||
|
universe: string,
|
||||||
|
season: string,
|
||||||
|
episode: string,
|
||||||
|
typeId: string,
|
||||||
|
title: string,
|
||||||
|
},
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Upload a new season cover media
|
||||||
|
*/
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific cover of a media
|
||||||
|
*/
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all Media
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Media[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/video",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
}
|
435
front/src/app/back-api/model.ts
Normal file
435
front/src/app/back-api/model.ts
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
/**
|
||||||
|
* 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 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 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 ZodSeason = ZodGenericDataSoftDelete.extend({
|
||||||
|
// Name of the media (this represent the title)
|
||||||
|
name: zod.string().optional(),
|
||||||
|
// Description of the media
|
||||||
|
description: zod.string().optional(),
|
||||||
|
// series parent ID
|
||||||
|
parentId: ZodLong.optional(),
|
||||||
|
// List of Id of the specific covers
|
||||||
|
covers: zod.array(ZodUUID).optional()
|
||||||
|
});
|
||||||
|
export type Season = zod.infer<typeof ZodSeason>;
|
||||||
|
export function isSeason(data: any): data is Season {
|
||||||
|
try {
|
||||||
|
ZodSeason.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
||||||
|
// Name of the media (this represent the title)
|
||||||
|
name: zod.string().optional(),
|
||||||
|
// Description of the media
|
||||||
|
description: zod.string().optional(),
|
||||||
|
// series parent ID
|
||||||
|
parentId: ZodLong.optional(),
|
||||||
|
// List of Id of the specific covers
|
||||||
|
covers: zod.array(ZodUUID).optional()
|
||||||
|
});
|
||||||
|
export type Series = zod.infer<typeof ZodSeries>;
|
||||||
|
export function isSeries(data: any): data is Series {
|
||||||
|
try {
|
||||||
|
ZodSeries.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodType = ZodGenericDataSoftDelete.extend({
|
||||||
|
// Name of the media (this represent the title)
|
||||||
|
name: zod.string().optional(),
|
||||||
|
// Description of the media
|
||||||
|
description: zod.string().optional(),
|
||||||
|
// List of Id of the specific covers
|
||||||
|
covers: zod.array(ZodUUID).optional()
|
||||||
|
});
|
||||||
|
export type Type = zod.infer<typeof ZodType>;
|
||||||
|
export function isType(data: any): data is Type {
|
||||||
|
try {
|
||||||
|
ZodType.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
||||||
|
// Foreign Key Id of the user
|
||||||
|
userId: ZodLong,
|
||||||
|
// Id of the media
|
||||||
|
mediaId: ZodLong,
|
||||||
|
// Percent of advancement in the media
|
||||||
|
percent: ZodFloat,
|
||||||
|
// Number of second of advancement in the media
|
||||||
|
time: ZodInteger,
|
||||||
|
// Number of time this media has been read
|
||||||
|
count: ZodInteger
|
||||||
|
});
|
||||||
|
export type UserMediaAdvancement = zod.infer<typeof ZodUserMediaAdvancement>;
|
||||||
|
export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement {
|
||||||
|
try {
|
||||||
|
ZodUserMediaAdvancement.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodMediaInformationsDelta = zod.object({
|
||||||
|
});
|
||||||
|
export type MediaInformationsDelta = zod.infer<typeof ZodMediaInformationsDelta>;
|
||||||
|
export function isMediaInformationsDelta(data: any): data is MediaInformationsDelta {
|
||||||
|
try {
|
||||||
|
ZodMediaInformationsDelta.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 ZodUserKarideo = ZodUser.extend({
|
||||||
|
});
|
||||||
|
export type UserKarideo = zod.infer<typeof ZodUserKarideo>;
|
||||||
|
export function isUserKarideo(data: any): data is UserKarideo {
|
||||||
|
try {
|
||||||
|
ZodUserKarideo.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 ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
dataId: ZodUUID.optional(),
|
||||||
|
typeId: ZodLong.optional(),
|
||||||
|
seriesId: ZodLong.optional(),
|
||||||
|
seasonId: ZodLong.optional(),
|
||||||
|
episode: ZodInteger.optional(),
|
||||||
|
date: ZodInteger.optional(),
|
||||||
|
time: ZodInteger.optional(),
|
||||||
|
ageLimit: ZodInteger.optional(),
|
||||||
|
covers: zod.array(ZodUUID).optional()
|
||||||
|
});
|
||||||
|
export type Media = zod.infer<typeof ZodMedia>;
|
||||||
|
export function isMedia(data: any): data is Media {
|
||||||
|
try {
|
||||||
|
ZodMedia.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
149
front/src/app/back-api/season-resource.ts
Normal file
149
front/src/app/back-api/season-resource.ts
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {Long, Season, UUID, isSeason, } from "./model"
|
||||||
|
export namespace SeasonResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific season
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all season
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a specific season
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Season,
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Create a new season
|
||||||
|
*/
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Season,
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Upload a new season cover season
|
||||||
|
*/
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}/add_cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific cover of a season
|
||||||
|
*/
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Season with his ID
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Season[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isSeason);
|
||||||
|
};
|
||||||
|
}
|
149
front/src/app/back-api/series-resource.ts
Normal file
149
front/src/app/back-api/series-resource.ts
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {Series, Long, UUID, isSeries, } from "./model"
|
||||||
|
export namespace SeriesResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific Series
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Series with his ID
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a specific Series
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Series,
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Create a new Series
|
||||||
|
*/
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Series,
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Upload a new season cover Series
|
||||||
|
*/
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific Series of a season
|
||||||
|
*/
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all Series
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Series[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isSeries);
|
||||||
|
};
|
||||||
|
}
|
149
front/src/app/back-api/type-resource.ts
Normal file
149
front/src/app/back-api/type-resource.ts
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {Long, Type, UUID, isType, } from "./model"
|
||||||
|
export namespace TypeResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific Type
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Type with his ID
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a specific Type
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: Type,
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Create a new Type
|
||||||
|
*/
|
||||||
|
export function post({ restConfig, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Type,
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Upload a new season cover Type
|
||||||
|
*/
|
||||||
|
export function uploadCover({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileName: string,
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific cover of a type
|
||||||
|
*/
|
||||||
|
export function removeCover({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all Type
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Type[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isType);
|
||||||
|
};
|
||||||
|
}
|
84
front/src/app/back-api/user-media-advancement-resource.ts
Normal file
84
front/src/app/back-api/user-media-advancement-resource.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {MediaInformationsDelta, Long, UserMediaAdvancement, isUserMediaAdvancement, } from "./model"
|
||||||
|
export namespace UserMediaAdvancementResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a specific user advancement
|
||||||
|
*/
|
||||||
|
export function remove({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/advancement/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific user advancement with his ID
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<UserMediaAdvancement> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/advancement/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserMediaAdvancement);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a user advancement
|
||||||
|
*/
|
||||||
|
export function patch({ restConfig, params, data, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: MediaInformationsDelta,
|
||||||
|
}): Promise<UserMediaAdvancement> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/advancement/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isUserMediaAdvancement);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all user advancement
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserMediaAdvancement[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/advancement",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserMediaAdvancement);
|
||||||
|
};
|
||||||
|
}
|
57
front/src/app/back-api/user-resource.ts
Normal file
57
front/src/app/back-api/user-resource.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* API of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
||||||
|
import {UserOut, Long, UserKarideo, isUserOut, isUserKarideo, } from "./model"
|
||||||
|
export namespace UserResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific user data
|
||||||
|
*/
|
||||||
|
export function get({ restConfig, params, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<UserKarideo> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserKarideo);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get the user personal data
|
||||||
|
*/
|
||||||
|
export function getMe({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserOut> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/me",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserOut);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get all the users
|
||||||
|
*/
|
||||||
|
export function gets({ restConfig, }: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserKarideo[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserKarideo);
|
||||||
|
};
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
* @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 { UUID } from 'app/back-api';
|
||||||
//import { ModelResponseHttp } from '@app/service/http-wrapper';
|
//import { ModelResponseHttp } from '@app/service/http-wrapper';
|
||||||
import { DataService } from 'app/service/data';
|
import { DataService } from 'app/service/data';
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ import { DataService } from 'app/service/data';
|
|||||||
})
|
})
|
||||||
export class ElementDataImageComponent implements OnInit {
|
export class ElementDataImageComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() id:number = -1;
|
@Input() id?: UUID;
|
||||||
cover: string = '';
|
cover: string = '';
|
||||||
/*
|
/*
|
||||||
imageCanvas:any;
|
imageCanvas:any;
|
||||||
@ -29,7 +30,7 @@ export class ElementDataImageComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
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");
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
* @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 { Season } from 'app/back-api';
|
||||||
|
|
||||||
import { SeasonService, DataService } from 'app/service';
|
import { SeasonService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-season',
|
selector: 'app-element-season',
|
||||||
@ -16,7 +16,7 @@ import { isNullOrUndefined } from 'common/utils';
|
|||||||
})
|
})
|
||||||
export class ElementSeasonComponent implements OnInit {
|
export class ElementSeasonComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: Season;
|
||||||
|
|
||||||
numberSeason: string;
|
numberSeason: string;
|
||||||
count: number;
|
count: number;
|
||||||
@ -24,8 +24,9 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private dataService: DataService,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private dataService: DataService) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -36,7 +37,7 @@ export class ElementSeasonComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.numberSeason = this.element.name;
|
this.numberSeason = 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;
|
||||||
this.seasonService.countVideo(this.element.id)
|
this.seasonService.countVideo(this.element.id)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
* @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 '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { Series } from 'app/back-api';
|
||||||
|
|
||||||
import { SeriesService, DataService } from 'app/service';
|
import { SeriesService, DataService } from 'app/service';
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import { SeriesService, DataService } from 'app/service';
|
|||||||
})
|
})
|
||||||
export class ElementSeriesComponent implements OnInit {
|
export class ElementSeriesComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: Series;
|
||||||
|
|
||||||
name: string = 'plouf';
|
name: string = 'plouf';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
@ -25,8 +25,9 @@ export class ElementSeriesComponent implements OnInit {
|
|||||||
covers: string[];
|
covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private dataService: DataService,
|
||||||
private seriesService: SeriesService,
|
private seriesService: SeriesService,
|
||||||
private dataService: DataService) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -38,7 +39,7 @@ export class ElementSeriesComponent implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
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);
|
||||||
|
|
||||||
this.seriesService.countVideo(this.element.id)
|
this.seriesService.countVideo(this.element.id)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
* @license PROPRIETARY (see license file)
|
* @license PROPRIETARY (see license file)
|
||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { NodeData } from 'common/model';
|
import { Type } from 'app/back-api';
|
||||||
|
|
||||||
import { TypeService, DataService } from 'app/service';
|
import { TypeService, DataService } from 'app/service';
|
||||||
|
|
||||||
@ -16,25 +16,26 @@ import { TypeService, DataService } from 'app/service';
|
|||||||
})
|
})
|
||||||
export class ElementTypeComponent implements OnInit {
|
export class ElementTypeComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element:NodeData;
|
@Input() element: Type;
|
||||||
|
|
||||||
public name: string = 'rr';
|
public name: string = 'rr';
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
public countvideo:number;
|
public countVideo: number;
|
||||||
|
|
||||||
public covers: string[];
|
public covers: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private dataService: DataService,
|
||||||
private typeService: TypeService,
|
private typeService: TypeService,
|
||||||
private dataService: DataService) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
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.countvideo = undefined;
|
this.countVideo = undefined;
|
||||||
this.covers = undefined;
|
this.covers = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -42,13 +43,13 @@ 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);
|
||||||
|
|
||||||
this.typeService.countVideo(this.element.id)
|
this.typeService.countVideo(this.element.id)
|
||||||
.then((response: number) => {
|
.then((response: number) => {
|
||||||
self.countvideo = response;
|
self.countVideo = response;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
self.countvideo = 0;
|
self.countVideo = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
* @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 { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { UserMediaAdvancement } from 'app/model/user-media-advancement';
|
import { Media, UserMediaAdvancement } from 'app/back-api';
|
||||||
|
|
||||||
import { AdvancementService, DataService } from 'app/service';
|
import { AdvancementService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-video',
|
selector: 'app-element-video',
|
||||||
@ -20,7 +18,7 @@ import { isNullOrUndefined } from 'common/utils';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ElementVideoComponent implements OnInit {
|
export class ElementVideoComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element: NodeData;
|
@Input() element: Media;
|
||||||
data: Media;
|
data: Media;
|
||||||
|
|
||||||
name: string = '';
|
name: string = '';
|
||||||
@ -38,12 +36,6 @@ export class ElementVideoComponent implements OnInit {
|
|||||||
// 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.data = this.element;
|
||||||
this.name = this.element.name;
|
this.name = this.element.name;
|
||||||
this.description = this.element.description;
|
this.description = this.element.description;
|
||||||
@ -52,7 +44,7 @@ export class ElementVideoComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.episodeDisplay = `${this.element.episode} - `;
|
this.episodeDisplay = `${this.element.episode} - `;
|
||||||
}
|
}
|
||||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||||
|
|
||||||
this.advancementService.get(this.element.id)
|
this.advancementService.get(this.element.id)
|
||||||
.then((response: UserMediaAdvancement) => {
|
.then((response: UserMediaAdvancement) => {
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
export * from "./server-karideo-api.ts";
|
|
@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
* Interface of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import { z as zod } from "zod";
|
|
||||||
|
|
||||||
export const GenericTiming = zod.object({
|
|
||||||
// Create time of the object
|
|
||||||
createdAt: zod.date().readonly().optional(),
|
|
||||||
// When update the object
|
|
||||||
updatedAt: zod.date().readonly().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const UUIDGenericData = GenericTiming.extend({
|
|
||||||
// Unique UUID of the object
|
|
||||||
id: zod.string().uuid().readonly().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const UUIDGenericDataSoftDelete = UUIDGenericData.extend({
|
|
||||||
// Deleted state
|
|
||||||
deleted: zod.boolean().readonly().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Data = UUIDGenericDataSoftDelete.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: zod.bigint().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GenericData = GenericTiming.extend({
|
|
||||||
// Unique Id of the object
|
|
||||||
id: zod.bigint().readonly().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GenericDataSoftDelete = GenericData.extend({
|
|
||||||
// Deleted state
|
|
||||||
deleted: zod.boolean().readonly().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Media = GenericDataSoftDelete.extend({
|
|
||||||
name: zod.string().optional(),
|
|
||||||
description: zod.string().optional(),
|
|
||||||
dataId: zod.string().uuid().optional(),
|
|
||||||
typeId: zod.bigint().optional(),
|
|
||||||
seriesId: zod.bigint().optional(),
|
|
||||||
seasonId: zod.bigint().optional(),
|
|
||||||
episode: zod.number().safe().optional(),
|
|
||||||
date: zod.number().safe().optional(),
|
|
||||||
time: zod.number().safe().optional(),
|
|
||||||
ageLimit: zod.number().safe().optional(),
|
|
||||||
covers: zod.array(zod.string().uuid()).optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Type = GenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(zod.string().uuid()).optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Series = GenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// series parent ID
|
|
||||||
parentId: zod.bigint().optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(zod.string().uuid()).optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Season = GenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// series parent ID
|
|
||||||
parentId: zod.bigint().optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(zod.string().uuid()).optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const User = GenericDataSoftDelete.extend({
|
|
||||||
login: zod.string().max(128).optional(),
|
|
||||||
lastConnection: zod.date().optional(),
|
|
||||||
admin: zod.boolean(),
|
|
||||||
blocked: zod.boolean(),
|
|
||||||
removed: zod.boolean(),
|
|
||||||
covers: zod.array(zod.bigint()).optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
export const UserMediaAdvancement = GenericDataSoftDelete.extend({
|
|
||||||
// Foreign Key Id of the user
|
|
||||||
userId: zod.bigint(),
|
|
||||||
// Id of the media
|
|
||||||
mediaId: zod.bigint(),
|
|
||||||
// Percent of advancement in the media
|
|
||||||
percent: zod.number(),
|
|
||||||
// Number of second of advancement in the media
|
|
||||||
time: zod.number().safe(),
|
|
||||||
// Number of time this media has been read
|
|
||||||
count: zod.number().safe()
|
|
||||||
});
|
|
||||||
|
|
@ -4,8 +4,7 @@
|
|||||||
* @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',
|
||||||
|
@ -24,7 +24,7 @@ export class HomeScene implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.typeService.getData()
|
this.typeService.gets()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.error = '';
|
self.error = '';
|
||||||
self.dataList = response;
|
self.dataList = response;
|
||||||
|
@ -5,13 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { PopInService, UploadProgress, isNumberFinite } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Season, UUID } from 'app/back-api';
|
||||||
|
|
||||||
import { SeasonService, ArianeService, DataService } from 'app/service';
|
import { SeasonService, ArianeService, DataService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
|
||||||
import { PopInService } from 'common/service';
|
|
||||||
import { isNumberFinite } from 'common/utils';
|
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
value: number;
|
value: number;
|
||||||
@ -46,7 +43,7 @@ export class SeasonEditScene 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: UUID = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@ -67,10 +64,11 @@ export class SeasonEditScene implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private dataService: DataService,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService,
|
private popInService: PopInService,
|
||||||
private dataService: DataService) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +76,7 @@ export class SeasonEditScene implements OnInit {
|
|||||||
this.idSeason = this.arianeService.getSeasonId();
|
this.idSeason = this.arianeService.getSeasonId();
|
||||||
let self = this;
|
let self = this;
|
||||||
this.seasonService.get(this.idSeason)
|
this.seasonService.get(this.idSeason)
|
||||||
.then((response: NodeData) => {
|
.then((response: Season) => {
|
||||||
console.log(`get response of season : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of season : ${JSON.stringify(response, null, 2)}`);
|
||||||
if (isNumberFinite(response.name)) {
|
if (isNumberFinite(response.name)) {
|
||||||
self.numberVal = response.name;
|
self.numberVal = response.name;
|
||||||
@ -108,7 +106,7 @@ export class SeasonEditScene 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 {
|
||||||
@ -126,7 +124,7 @@ export class SeasonEditScene implements OnInit {
|
|||||||
sendValues(): void {
|
sendValues(): void {
|
||||||
console.log('send new values....');
|
console.log('send new values....');
|
||||||
let data = {
|
let data = {
|
||||||
name: this.numberVal,
|
name: `${this.numberVal}`,
|
||||||
description: this.description
|
description: this.description
|
||||||
};
|
};
|
||||||
if (this.description === undefined) {
|
if (this.description === undefined) {
|
||||||
@ -168,7 +166,7 @@ export class SeasonEditScene 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.seasonService.uploadCover(file, this.idSeason, (count, total) => {
|
this.seasonService.uploadCover(this.idSeason, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@ -182,14 +180,14 @@ export class SeasonEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCover(id: number) {
|
removeCover(id: UUID) {
|
||||||
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: UUID) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.seasonService.deleteCover(this.idSeason, id)
|
this.seasonService.deleteCover(this.idSeason, id)
|
||||||
|
@ -24,11 +24,12 @@ export class SeasonScene implements OnInit {
|
|||||||
videosError = '';
|
videosError = '';
|
||||||
videos = [];
|
videos = [];
|
||||||
constructor(
|
constructor(
|
||||||
|
private advancementService: AdvancementService,
|
||||||
|
private dataService: DataService,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private seriesService: SeriesService,
|
private seriesService: SeriesService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService,
|
) {
|
||||||
private advancementService: AdvancementService) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,9 +47,9 @@ export class SeasonScene implements OnInit {
|
|||||||
self.cover = null;
|
self.cover = null;
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.dataService.getCoverUrl(response.covers[0]);
|
self.cover = self.dataService.getThumbnailUrl(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.getThumbnailUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.seriesService.get(self.seriesId)
|
self.seriesService.get(self.seriesId)
|
||||||
|
@ -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 { UUID } from 'app/back-api';
|
||||||
|
|
||||||
import { SeriesService, DataService, TypeService, ArianeService } from 'app/service';
|
import { SeriesService, DataService, TypeService, ArianeService } 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(
|
||||||
@ -53,7 +53,7 @@ export class SeriesEditScene 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: UUID = null;
|
||||||
private deleteItemId: number = null;
|
private deleteItemId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@ -73,11 +73,13 @@ export class SeriesEditScene implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor(private dataService: DataService,
|
constructor(
|
||||||
private typeService: TypeService,
|
private dataService: DataService,
|
||||||
private seriesService: SeriesService,
|
private seriesService: SeriesService,
|
||||||
|
private typeService: TypeService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService) {
|
private popInService: PopInService,
|
||||||
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ export class SeriesEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
this.listType = [{ value: null, label: '---' }];
|
this.listType = [{ value: null, label: '---' }];
|
||||||
|
|
||||||
this.typeService.getData()
|
this.typeService.gets()
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
@ -133,7 +135,7 @@ export class SeriesEditScene 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 {
|
||||||
@ -203,7 +205,7 @@ export class SeriesEditScene 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.seriesService.uploadCover(file, this.idSeries, (count, total) => {
|
this.seriesService.uploadCover(this.idSeries, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
@ -216,14 +218,14 @@ export class SeriesEditScene implements OnInit {
|
|||||||
console.log('Can not add the cover in the video...');
|
console.log('Can not add the cover in the video...');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
removeCover(id: number) {
|
removeCover(id: UUID) {
|
||||||
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: UUID) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.seriesService.deleteCover(this.idSeries, id)
|
this.seriesService.deleteCover(this.idSeries, id)
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { Season } from 'app/back-api';
|
||||||
|
|
||||||
import { SeriesService, DataService, ArianeService, AdvancementService } from 'app/service';
|
import { SeriesService, DataService, ArianeService, AdvancementService } from 'app/service';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-series',
|
selector: 'app-series',
|
||||||
@ -22,14 +22,15 @@ export class SeriesScene implements OnInit {
|
|||||||
cover: string = '';
|
cover: string = '';
|
||||||
covers: Array<string> = [];
|
covers: Array<string> = [];
|
||||||
seasonsError: string = '';
|
seasonsError: string = '';
|
||||||
seasons: NodeData[] = [];
|
seasons: Season[] = [];
|
||||||
videosError: string = '';
|
videosError: string = '';
|
||||||
videos: Array<any> = [];
|
videos: Array<any> = [];
|
||||||
constructor(
|
constructor(
|
||||||
|
private advancementService: AdvancementService,
|
||||||
|
private dataService: DataService,
|
||||||
private seriesService: SeriesService,
|
private seriesService: SeriesService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dataService: DataService,
|
) {
|
||||||
private advancementService: AdvancementService) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +52,9 @@ export class SeriesScene implements OnInit {
|
|||||||
self.cover = null;
|
self.cover = null;
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.dataService.getCoverUrl(response.covers[0]);
|
self.cover = self.dataService.getThumbnailUrl(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.getThumbnailUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateEnded.seriesMetadata = true;
|
updateEnded.seriesMetadata = true;
|
||||||
@ -67,7 +68,7 @@ export class SeriesScene implements OnInit {
|
|||||||
});
|
});
|
||||||
//console.log(`get parameter id: ${ this.idSeries}`);
|
//console.log(`get parameter id: ${ this.idSeries}`);
|
||||||
this.seriesService.getSeason(this.idSeries)
|
this.seriesService.getSeason(this.idSeries)
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Season[]) => {
|
||||||
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
|
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
|
||||||
self.seasonsError = '';
|
self.seasonsError = '';
|
||||||
self.seasons = response;
|
self.seasons = response;
|
||||||
@ -80,7 +81,7 @@ export class SeriesScene implements OnInit {
|
|||||||
self.checkIfJumpIsNeeded(updateEnded);
|
self.checkIfJumpIsNeeded(updateEnded);
|
||||||
});
|
});
|
||||||
this.seriesService.getVideo(this.idSeries)
|
this.seriesService.getVideo(this.idSeries)
|
||||||
.then((response: NodeData[]) => {
|
.then((response: Season[]) => {
|
||||||
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
|
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
|
||||||
self.videosError = '';
|
self.videosError = '';
|
||||||
self.videos = response;
|
self.videos = response;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
|
|
||||||
import { TypeService, DataService, ArianeService, AdvancementService } from 'app/service';
|
import { TypeService, DataService, ArianeService, AdvancementService } from 'app/service';
|
||||||
|
|
||||||
@ -26,9 +25,9 @@ export class TypeScene implements OnInit {
|
|||||||
videosError = '';
|
videosError = '';
|
||||||
videos = [];
|
videos = [];
|
||||||
constructor(
|
constructor(
|
||||||
|
private dataService: DataService,
|
||||||
private typeService: TypeService,
|
private typeService: TypeService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private dateService: DataService,
|
|
||||||
private advancementService: AdvancementService) {
|
private advancementService: AdvancementService) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -54,9 +53,9 @@ export class TypeScene implements OnInit {
|
|||||||
self.cover = null;
|
self.cover = null;
|
||||||
self.covers = [];
|
self.covers = [];
|
||||||
} else {
|
} else {
|
||||||
self.cover = self.dateService.getCoverUrl(response.covers[0]);
|
self.cover = self.dataService.getThumbnailUrl(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.dateService.getCoverUrl(response.covers[iii]));
|
self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
|
@ -5,11 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
import { TypeService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
|
import { TypeService, SeriesService, MediaService, SeasonService } 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(
|
||||||
@ -23,7 +21,6 @@ export class FileParsedElement {
|
|||||||
public nameDetected: boolean = false;
|
public nameDetected: boolean = false;
|
||||||
public episodeDetected: boolean = false;
|
public episodeDetected: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
public id: number,
|
|
||||||
public file: File,
|
public file: File,
|
||||||
public series: string,
|
public series: string,
|
||||||
public season: number,
|
public season: number,
|
||||||
@ -79,7 +76,7 @@ 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,
|
||||||
@ -94,10 +91,11 @@ export class UploadScene implements OnInit {
|
|||||||
];
|
];
|
||||||
globalSeries: string = '';
|
globalSeries: string = '';
|
||||||
globalSeason: number = null;
|
globalSeason: number = null;
|
||||||
constructor(private typeService: TypeService,
|
constructor(
|
||||||
private seriesService: SeriesService,
|
private MediaService: MediaService,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private videoService: VideoService,
|
private seriesService: SeriesService,
|
||||||
|
private typeService: TypeService,
|
||||||
private popInService: PopInService) {
|
private popInService: PopInService) {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
}
|
}
|
||||||
@ -124,7 +122,7 @@ export class UploadScene implements OnInit {
|
|||||||
this.listType = [{ value: null, label: '---' }];
|
this.listType = [{ value: null, label: '---' }];
|
||||||
this.listSeries = [{ value: null, label: '---' }];
|
this.listSeries = [{ value: null, label: '---' }];
|
||||||
this.listSeason = [{ value: null, label: '---' }];
|
this.listSeason = [{ value: null, label: '---' }];
|
||||||
this.typeService.getData()
|
this.typeService.gets()
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
@ -305,7 +303,7 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
// remove extention
|
// remove extention
|
||||||
title = title.replace(new RegExp('\\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)'), '');
|
title = title.replace(new RegExp('\\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)'), '');
|
||||||
let tmp = new FileParsedElement(this.parsedElement.length, file, series, season, episode, title);
|
let tmp = new FileParsedElement(file, series, season, episode, 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);
|
||||||
@ -427,7 +425,7 @@ export class UploadScene implements OnInit {
|
|||||||
}
|
}
|
||||||
self.upload.labelMediaTitle = `[${id + 1}/${total}]${self.upload.labelMediaTitle}${eleemnent.title}`;
|
self.upload.labelMediaTitle = `[${id + 1}/${total}]${self.upload.labelMediaTitle}${eleemnent.title}`;
|
||||||
|
|
||||||
self.videoService.uploadFile(eleemnent.file,
|
self.MediaService.uploadFile(eleemnent.file,
|
||||||
self.globalSeries,
|
self.globalSeries,
|
||||||
self.seriesId,
|
self.seriesId,
|
||||||
self.globalSeason,
|
self.globalSeason,
|
||||||
|
@ -5,14 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
|
|
||||||
|
import { DataService, TypeService, SeriesService, MediaService, ArianeService } from 'app/service';
|
||||||
import { DataService, TypeService, SeriesService, VideoService, ArianeService } from 'app/service';
|
import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
import { Media, Season, Series, UUID } from 'app/back-api';
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
import { PopInService } from 'common/service';
|
|
||||||
import { Media } from 'app/model';
|
|
||||||
|
|
||||||
export interface ElementList {
|
export interface ElementList {
|
||||||
value?: number;
|
value?: number;
|
||||||
@ -24,27 +20,13 @@ class DataToSend {
|
|||||||
name: string = '';
|
name: string = '';
|
||||||
description: string = '';
|
description: string = '';
|
||||||
episode?: number;
|
episode?: number;
|
||||||
seriesId: number = null;
|
seriesId?: number;
|
||||||
seasonId: number = null;
|
seasonId?: number;
|
||||||
dataId: number = -1;
|
dataId?: UUID;
|
||||||
time?: number;
|
time?: number;
|
||||||
typeId: number = null;
|
typeId?: number;
|
||||||
covers: number[] = [];
|
covers: number[] = [];
|
||||||
generatedName: string = '';
|
generatedName: string = '';
|
||||||
clone() {
|
|
||||||
let tmp = new DataToSend();
|
|
||||||
tmp.name = this.name;
|
|
||||||
tmp.description = this.description;
|
|
||||||
tmp.episode = this.episode;
|
|
||||||
tmp.seriesId = this.seriesId;
|
|
||||||
tmp.seasonId = this.seasonId;
|
|
||||||
tmp.dataId = this.dataId;
|
|
||||||
tmp.time = this.time;
|
|
||||||
tmp.typeId = this.typeId;
|
|
||||||
tmp.covers = this.covers;
|
|
||||||
tmp.generatedName = this.generatedName;
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -74,7 +56,7 @@ export class VideoEditScene 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: UUID = null;
|
||||||
private deleteMediaId: number = null;
|
private deleteMediaId: number = null;
|
||||||
deleteConfirmed() {
|
deleteConfirmed() {
|
||||||
if (this.deleteCoverId !== null) {
|
if (this.deleteCoverId !== null) {
|
||||||
@ -109,12 +91,13 @@ export class VideoEditScene implements OnInit {
|
|||||||
{ value: undefined, label: '---' },
|
{ value: undefined, label: '---' },
|
||||||
];
|
];
|
||||||
constructor(
|
constructor(
|
||||||
private typeService: TypeService,
|
private dataService: DataService,
|
||||||
|
private MediaService: MediaService,
|
||||||
private seriesService: SeriesService,
|
private seriesService: SeriesService,
|
||||||
private videoService: VideoService,
|
private typeService: TypeService,
|
||||||
private arianeService: ArianeService,
|
private arianeService: ArianeService,
|
||||||
private popInService: PopInService,
|
private popInService: PopInService,
|
||||||
private dataService: DataService) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +135,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
this.data.covers.push(covers[iii]);
|
this.data.covers.push(covers[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 {
|
||||||
@ -166,7 +149,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
this.listUniverse = [{ value: null, label: '---' }];
|
this.listUniverse = [{ value: null, label: '---' }];
|
||||||
this.listSeries = [{ value: null, label: '---' }];
|
this.listSeries = [{ value: null, label: '---' }];
|
||||||
this.listSeason = [{ value: null, label: '---' }];
|
this.listSeason = [{ value: null, label: '---' }];
|
||||||
this.typeService.getData()
|
this.typeService.gets()
|
||||||
.then((response2) => {
|
.then((response2) => {
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
@ -175,7 +158,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
|
||||||
});
|
});
|
||||||
// this.seriesService.getOrder()
|
// this.seriesService.getOrder()
|
||||||
this.seriesService.getData()
|
this.seriesService.gets()
|
||||||
.then((response3) => {
|
.then((response3) => {
|
||||||
for (let iii = 0; iii < response3.length; iii++) {
|
for (let iii = 0; iii < response3.length; iii++) {
|
||||||
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
|
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
|
||||||
@ -184,7 +167,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
}).catch((response3) => {
|
}).catch((response3) => {
|
||||||
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
||||||
});
|
});
|
||||||
this.videoService.get(this.idVideo)
|
this.MediaService.get(this.idVideo)
|
||||||
.then((response: Media) => {
|
.then((response: Media) => {
|
||||||
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.data.name = response.name;
|
self.data.name = response.name;
|
||||||
@ -199,7 +182,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
if (self.data.seasonId === undefined) {
|
if (self.data.seasonId === undefined) {
|
||||||
self.data.seasonId = null;
|
self.data.seasonId = null;
|
||||||
}
|
}
|
||||||
self.dataOri = self.data.clone();
|
self.dataOri = { ...self.data };
|
||||||
self.updateCoverList(response.covers);
|
self.updateCoverList(response.covers);
|
||||||
self.updateNeedSend();
|
self.updateNeedSend();
|
||||||
console.log(`coversList : ${JSON.stringify(self.coversDisplay, null, 2)}`);
|
console.log(`coversList : ${JSON.stringify(self.coversDisplay, null, 2)}`);
|
||||||
@ -208,7 +191,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
self.error = 'Can not get the data';
|
self.error = 'Can not get the data';
|
||||||
self.data = new DataToSend();
|
self.data = new DataToSend();
|
||||||
self.coversDisplay = [];
|
self.coversDisplay = [];
|
||||||
self.dataOri = self.data.clone();
|
self.dataOri = { ...self.data };
|
||||||
self.updateNeedSend();
|
self.updateNeedSend();
|
||||||
self.itemIsNotFound = true;
|
self.itemIsNotFound = true;
|
||||||
self.itemIsLoading = false;
|
self.itemIsLoading = false;
|
||||||
@ -229,7 +212,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
this.updateNeedSend();
|
this.updateNeedSend();
|
||||||
if (this.data.typeId !== undefined) {
|
if (this.data.typeId !== undefined) {
|
||||||
self.typeService.getSubSeries(this.data.typeId)
|
self.typeService.getSubSeries(this.data.typeId)
|
||||||
.then((response2: NodeData[]) => {
|
.then((response2: Series[]) => {
|
||||||
for (let iii = 0; iii < response2.length; iii++) {
|
for (let iii = 0; iii < response2.length; iii++) {
|
||||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||||
}
|
}
|
||||||
@ -249,7 +232,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
if (this.data.seriesId !== undefined) {
|
if (this.data.seriesId !== undefined) {
|
||||||
self.seriesService.getSeason(this.data.seriesId)
|
self.seriesService.getSeason(this.data.seriesId)
|
||||||
.then((response3: NodeData[]) => {
|
.then((response3: Season[]) => {
|
||||||
for (let iii = 0; iii < response3.length; iii++) {
|
for (let iii = 0; iii < response3.length; iii++) {
|
||||||
self.listSeason.push({ value: response3[iii].id, label: `season ${response3[iii].name}` });
|
self.listSeason.push({ value: response3[iii].id, label: `season ${response3[iii].name}` });
|
||||||
}
|
}
|
||||||
@ -338,9 +321,9 @@ export class VideoEditScene implements OnInit {
|
|||||||
data.seasonId = this.data.seasonId;
|
data.seasonId = this.data.seasonId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let tmpp = this.data.clone();
|
const tmpp = { ...this.data };
|
||||||
let self = this;
|
let self = this;
|
||||||
this.videoService.patch(this.idVideo, data)
|
this.MediaService.patch(this.idVideo, data)
|
||||||
.then((response3) => {
|
.then((response3) => {
|
||||||
self.dataOri = tmpp;
|
self.dataOri = tmpp;
|
||||||
self.updateNeedSend();
|
self.updateNeedSend();
|
||||||
@ -385,14 +368,14 @@ export class VideoEditScene 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.videoService.uploadCover(file, this.idVideo, (count, total) => {
|
this.MediaService.uploadCover(this.idVideo, file, (count, total) => {
|
||||||
self.upload.mediaSendSize = count;
|
self.upload.mediaSendSize = count;
|
||||||
self.upload.mediaSize = total;
|
self.upload.mediaSize = total;
|
||||||
})
|
})
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
console.log(`get response of cover : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of cover : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.upload.result = 'Cover added done';
|
self.upload.result = 'Cover added done';
|
||||||
// we retrive the whiole media ==> update data ...
|
// we retrieve the while media ==> update data ...
|
||||||
self.updateCoverList(response.covers);
|
self.updateCoverList(response.covers);
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
// self.error = "Can not get the data";
|
// self.error = "Can not get the data";
|
||||||
@ -401,21 +384,21 @@ export class VideoEditScene implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCover(id: number) {
|
removeCover(id: UUID) {
|
||||||
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: UUID) {
|
||||||
console.log(`Request remove cover: ${id}`);
|
console.log(`Request remove cover: ${id}`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.videoService.deleteCover(this.idVideo, id)
|
this.MediaService.deleteCover(this.idVideo, id)
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
console.log(`get response of remove cover : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of remove cover : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.upload.result = 'Cover remove done';
|
self.upload.result = 'Cover remove done';
|
||||||
// we retrive the whiole media ==> update data ...
|
// we retrieve the while media ==> update data ...
|
||||||
self.updateCoverList(response.covers);
|
self.updateCoverList(response.covers);
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
// self.error = "Can not get the data";
|
// self.error = "Can not get the data";
|
||||||
@ -432,7 +415,7 @@ export class VideoEditScene implements OnInit {
|
|||||||
}
|
}
|
||||||
removeItemAfterConfirm(id: number) {
|
removeItemAfterConfirm(id: number) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.videoService.delete(id)
|
this.MediaService.delete(id)
|
||||||
.then((response3) => {
|
.then((response3) => {
|
||||||
// self.dataOri = tmpp;
|
// self.dataOri = tmpp;
|
||||||
// self.updateNeedSend();
|
// self.updateNeedSend();
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { UserMediaAdvancement } from 'app/model/user-media-advancement';
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { DataService, VideoService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
|
import { UUID, UserMediaAdvancement } from 'app/back-api';
|
||||||
import { HttpWrapperService } from 'common/service';
|
import { DataService, MediaService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-video',
|
selector: 'app-video',
|
||||||
@ -53,7 +53,7 @@ export class VideoScene implements OnInit {
|
|||||||
seriesName: string = undefined;
|
seriesName: string = undefined;
|
||||||
seasonId: number = undefined;
|
seasonId: number = undefined;
|
||||||
seasonName: string = undefined;
|
seasonName: string = undefined;
|
||||||
dataId: number = -1;
|
dataId: UUID;
|
||||||
time: number = undefined;
|
time: number = undefined;
|
||||||
typeId: number = undefined;
|
typeId: number = undefined;
|
||||||
generatedName: string = '';
|
generatedName: string = '';
|
||||||
@ -74,7 +74,7 @@ export class VideoScene implements OnInit {
|
|||||||
timeLeft: number = 10;
|
timeLeft: number = 10;
|
||||||
interval = null;
|
interval = null;
|
||||||
|
|
||||||
userMetaData: UserMediaAdvancement & { percentDisplay?: number } = undefined
|
userMetaData: UserMediaAdvancement & { percentDisplay: number } = undefined
|
||||||
|
|
||||||
previousTime: number = 0;
|
previousTime: number = 0;
|
||||||
startPlayingTime: number = undefined;
|
startPlayingTime: number = undefined;
|
||||||
@ -88,13 +88,13 @@ export class VideoScene implements OnInit {
|
|||||||
registered: false
|
registered: false
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private videoService: VideoService,
|
constructor(
|
||||||
private seriesService: SeriesService,
|
|
||||||
private seasonService: SeasonService,
|
|
||||||
private httpService: HttpWrapperService,
|
|
||||||
private arianeService: ArianeService,
|
|
||||||
private dataService: DataService,
|
private dataService: DataService,
|
||||||
private advancementService: AdvancementService) {
|
private advancementService: AdvancementService,
|
||||||
|
private MediaService: MediaService,
|
||||||
|
private seasonService: SeasonService,
|
||||||
|
private seriesService: SeriesService,
|
||||||
|
private arianeService: ArianeService,) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,10 +154,10 @@ export class VideoScene implements OnInit {
|
|||||||
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.videoSource = this.httpService.createRESTCall2({
|
this.videoSource = this.dataService.getUrl(
|
||||||
api: `data/${this.dataId}/${this.generatedName}`,
|
this.dataId,
|
||||||
addURLToken: true,
|
this.generatedName,
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
myPeriodicCheckFunction() {
|
myPeriodicCheckFunction() {
|
||||||
@ -209,7 +209,7 @@ export class VideoScene implements OnInit {
|
|||||||
let self = this;
|
let self = this;
|
||||||
self.haveNext = null;
|
self.haveNext = null;
|
||||||
self.havePrevious = null;
|
self.havePrevious = null;
|
||||||
this.videoService.get(this.idVideo)
|
this.MediaService.get(this.idVideo)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
||||||
self.error = '';
|
self.error = '';
|
||||||
@ -221,15 +221,12 @@ export class VideoScene implements OnInit {
|
|||||||
self.dataId = response.dataId;
|
self.dataId = response.dataId;
|
||||||
self.time = response.time;
|
self.time = response.time;
|
||||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
||||||
if (self.dataId !== -1) {
|
if (!isNullOrUndefined(self.dataId)) {
|
||||||
self.videoSource = self.httpService.createRESTCall2({
|
self.videoSource = self.dataService.getUrl(self.dataId, self.generatedName);
|
||||||
api: `data/${self.dataId}/${self.generatedName}`,
|
|
||||||
addURLToken: true,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
self.videoSource = '';
|
self.videoSource = '';
|
||||||
}
|
}
|
||||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
self.covers = self.dataService.getListThumbnailUrl(response.covers);
|
||||||
|
|
||||||
self.generateName();
|
self.generateName();
|
||||||
if (self.seriesId !== undefined && self.seriesId !== null) {
|
if (self.seriesId !== undefined && self.seriesId !== null) {
|
||||||
@ -271,7 +268,7 @@ export class VideoScene implements OnInit {
|
|||||||
self.haveNext = response6[iii];
|
self.haveNext = response6[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
//self.covers.push(self.dataService.getThumbnailUrl(response6[iii]));
|
||||||
}
|
}
|
||||||
}).catch((response7: any) => {
|
}).catch((response7: any) => {
|
||||||
|
|
||||||
@ -287,7 +284,7 @@ export class VideoScene implements OnInit {
|
|||||||
self.episode = undefined;
|
self.episode = undefined;
|
||||||
self.seriesId = undefined;
|
self.seriesId = undefined;
|
||||||
self.seasonId = undefined;
|
self.seasonId = undefined;
|
||||||
self.dataId = -1;
|
self.dataId = undefined;
|
||||||
self.time = undefined;
|
self.time = undefined;
|
||||||
self.generatedName = '';
|
self.generatedName = '';
|
||||||
self.videoSource = '';
|
self.videoSource = '';
|
||||||
@ -324,6 +321,12 @@ export class VideoScene implements OnInit {
|
|||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
this.playVideo = false;
|
this.playVideo = false;
|
||||||
this.displayVolumeMenu = false;
|
this.displayVolumeMenu = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(this.isFullScreen === true) {
|
||||||
|
this.isFullScreen = false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
changeStateToPlay() {
|
changeStateToPlay() {
|
||||||
@ -451,8 +454,7 @@ export class VideoScene implements OnInit {
|
|||||||
onStop() {
|
onStop() {
|
||||||
console.log('stop');
|
console.log('stop');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoPlayer === null ||
|
if (isNullOrUndefined(this.videoPlayer)) {
|
||||||
this.videoPlayer === undefined) {
|
|
||||||
console.log(`error element: ${this.videoPlayer}`);
|
console.log(`error element: ${this.videoPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -473,8 +475,7 @@ export class VideoScene implements OnInit {
|
|||||||
seek(newValue: any) {
|
seek(newValue: any) {
|
||||||
console.log(`seek ${newValue.value}`);
|
console.log(`seek ${newValue.value}`);
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoPlayer === null ||
|
if (isNullOrUndefined(this.videoPlayer)) {
|
||||||
this.videoPlayer === undefined) {
|
|
||||||
console.log(`error element: ${this.videoPlayer}`);
|
console.log(`error element: ${this.videoPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -484,8 +485,7 @@ export class VideoScene implements OnInit {
|
|||||||
onRewind() {
|
onRewind() {
|
||||||
console.log('rewind');
|
console.log('rewind');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoPlayer === null ||
|
if (isNullOrUndefined(this.videoPlayer)) {
|
||||||
this.videoPlayer === undefined) {
|
|
||||||
console.log(`error element: ${this.videoPlayer}`);
|
console.log(`error element: ${this.videoPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -495,8 +495,7 @@ export class VideoScene implements OnInit {
|
|||||||
onForward() {
|
onForward() {
|
||||||
console.log('forward');
|
console.log('forward');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoPlayer === null ||
|
if (isNullOrUndefined(this.videoPlayer)) {
|
||||||
this.videoPlayer === undefined) {
|
|
||||||
console.log(`error element: ${this.videoPlayer}`);
|
console.log(`error element: ${this.videoPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -506,8 +505,7 @@ export class VideoScene implements OnInit {
|
|||||||
onMore() {
|
onMore() {
|
||||||
console.log('more');
|
console.log('more');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoPlayer === null ||
|
if (isNullOrUndefined(this.videoPlayer)) {
|
||||||
this.videoPlayer === undefined) {
|
|
||||||
console.log(`error element: ${this.videoPlayer}`);
|
console.log(`error element: ${this.videoPlayer}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -515,8 +513,7 @@ export class VideoScene implements OnInit {
|
|||||||
onFullscreen() {
|
onFullscreen() {
|
||||||
console.log('fullscreen');
|
console.log('fullscreen');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoGlobal === null ||
|
if (isNullOrUndefined(this.videoGlobal)) {
|
||||||
this.videoGlobal === undefined) {
|
|
||||||
console.log(`error element: ${this.videoGlobal}`);
|
console.log(`error element: ${this.videoGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -537,8 +534,7 @@ export class VideoScene implements OnInit {
|
|||||||
onFullscreenExit22(docc: any) {
|
onFullscreenExit22(docc: any) {
|
||||||
console.log('fullscreen EXIT');
|
console.log('fullscreen EXIT');
|
||||||
this.startHideTimer();
|
this.startHideTimer();
|
||||||
if (this.videoGlobal === null ||
|
if (isNullOrUndefined(this.videoGlobal)) {
|
||||||
this.videoGlobal === undefined) {
|
|
||||||
console.log(`error element: ${this.videoGlobal}`);
|
console.log(`error element: ${this.videoGlobal}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -614,17 +610,18 @@ export class VideoScene implements OnInit {
|
|||||||
// canvas.crossorigin="anonymous"
|
// canvas.crossorigin="anonymous"
|
||||||
// convert it and send it to the server
|
// convert it and send it to the server
|
||||||
let self = this;
|
let self = this;
|
||||||
|
/*
|
||||||
this.videoCanva.toBlob((blob) => {
|
this.videoCanva.toBlob((blob) => {
|
||||||
self.videoService.uploadCoverBlob(blob, this.idVideo);
|
self.MediaService.uploadCoverBlob(blob, this.idVideo);
|
||||||
}, 'image/jpeg', 0.95);
|
}, 'image/jpeg', 0.95);
|
||||||
|
*/
|
||||||
|
console.log("not implement upload as row data...");
|
||||||
/*
|
/*
|
||||||
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
||||||
fetch(tmpUrl)
|
fetch(tmpUrl)
|
||||||
.then(res => res.blob()) // Gets the response and returns it as a blob
|
.then(res => res.blob()) // Gets the response and returns it as a blob
|
||||||
.then(blob => {
|
.then(blob => {
|
||||||
self.videoService.uploadCoverBlob(blob, this.idVideo);
|
self.MediaService.uploadCoverBlob(blob, this.idVideo);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
123
front/src/app/service/GenericDataService.ts
Normal file
123
front/src/app/service/GenericDataService.ts
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
import { DataStore, DataTools, TypeCheck, isNullOrUndefined } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
import { SelectModel } from "@kangaroo-and-rabbit/kar-cw/utils/data-tools";
|
||||||
|
|
||||||
|
export class GenericDataService<TYPE> {
|
||||||
|
protected dataStore: DataStore<TYPE>;
|
||||||
|
|
||||||
|
setStore(dataStore: DataStore<TYPE>) {
|
||||||
|
this.dataStore = dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gets(): Promise<TYPE[]> {
|
||||||
|
return this.dataStore.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
get(id: number): Promise<TYPE> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.get(response, id);
|
||||||
|
if (isNullOrUndefined(data)) {
|
||||||
|
reject('Data does not exist in the local BDD');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll(ids: number[]): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.getsWhere(response,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.EQUAL,
|
||||||
|
key: 'id',
|
||||||
|
value: ids,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
resolve(data);
|
||||||
|
return;
|
||||||
|
}).catch((response) => {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getFilter(filter: (subData: any) => boolean): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((data: TYPE[]) => {
|
||||||
|
if (isNullOrUndefined(data)) {
|
||||||
|
reject('Data does not exist in the local BDD');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let out: TYPE[] = [];
|
||||||
|
for (const elem of data) {
|
||||||
|
if (filter(elem)) {
|
||||||
|
out.push(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(out);
|
||||||
|
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[]> {
|
||||||
|
return this.getsWhere(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
check: TypeCheck.NOT_EQUAL,
|
||||||
|
key: 'id',
|
||||||
|
value: [undefined, null],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
["name", "id"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getsWhere(select: SelectModel[], orderByData?: string[]): Promise<TYPE[]> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
self.gets()
|
||||||
|
.then((response: TYPE[]) => {
|
||||||
|
let data = DataTools.getsWhere(response, select, orderByData);
|
||||||
|
resolve(data);
|
||||||
|
}).catch((response) => {
|
||||||
|
console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,180 +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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
import { isNodeData, NodeData } from "common/model";
|
|
||||||
import { HttpWrapperService, BddService } from "common/service";
|
|
||||||
import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
|
|
||||||
|
|
||||||
export class GenericInterfaceModelDBv2<TYPE> {
|
|
||||||
constructor(
|
|
||||||
protected serviceName: string,
|
|
||||||
protected http: HttpWrapperService,
|
|
||||||
protected bdd: BddService,
|
|
||||||
protected checker: (subData: any) => subData is TYPE) {
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
|
|
||||||
gets(): Promise<TYPE[]> {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (isArrayOf<TYPE>(data, this.checker)) {
|
|
||||||
resolve(data);
|
|
||||||
} else {
|
|
||||||
reject("The data is not an array of the correct type ...");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(id: number): Promise<TYPE> {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (this.checker(data)) {
|
|
||||||
resolve(data);
|
|
||||||
} else {
|
|
||||||
reject("The data is not an array of the correct type ...");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getFilter(filter: (subData: any) => boolean): Promise<TYPE[]> {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
let out = [];
|
|
||||||
for (const elem of data) {
|
|
||||||
if (filter(elem)) {
|
|
||||||
out.push(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resolve(out as TYPE[]);
|
|
||||||
return;
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
insert(data: object): TYPE {
|
|
||||||
let ret = this.http.postSpecific([this.serviceName], data);
|
|
||||||
return this.bdd.addAfterPost(this.serviceName, ret) as TYPE;
|
|
||||||
|
|
||||||
}
|
|
||||||
patch(id: number, data: object): TYPE {
|
|
||||||
let ret = this.http.patchSpecific([this.serviceName, id], data);
|
|
||||||
return this.bdd.setAfterPut(this.serviceName, id, ret) as TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: number): TYPE {
|
|
||||||
let ret = this.http.deleteSpecific([this.serviceName, id]);
|
|
||||||
return this.bdd.delete(this.serviceName, id, ret) as TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -6,16 +6,30 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { GenericDataService } from './GenericDataService';
|
||||||
import { isUserMediaAdvancement, UserMediaAdvancement } from 'app/model/user-media-advancement';
|
import { environment } from 'environments/environment';
|
||||||
import { GenericInterfaceModelDBv2 } from './GenericInterfaceModelDBv2';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { UserMediaAdvancement, UserMediaAdvancementResource } from 'app/back-api';
|
||||||
|
import { DataStore, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdvancementService extends GenericInterfaceModelDBv2<UserMediaAdvancement> {
|
export class AdvancementService extends GenericDataService<UserMediaAdvancement> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
getRestConfig(): RESTConfig {
|
||||||
bdd: BddService) {
|
return {
|
||||||
super('advancement', http, bdd, isUserMediaAdvancement);
|
server: environment.server.karideo,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<UserMediaAdvancement[]> {
|
||||||
|
return UserMediaAdvancementResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start ArtistService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<UserMediaAdvancement>(() => self.lambdaGets()));
|
||||||
}
|
}
|
||||||
get(id: number): Promise<UserMediaAdvancement> {
|
get(id: number): Promise<UserMediaAdvancement> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -28,10 +42,25 @@ export class AdvancementService extends GenericInterfaceModelDBv2<UserMediaAdvan
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateTime(id: number, time: number, total: number, addCount: boolean) {
|
updateTime(id: number, time: number, total: number, addCount: boolean) {
|
||||||
this.patch(id, {
|
const data = {
|
||||||
time: time,
|
time,
|
||||||
percent: time / total,
|
percent: time / total,
|
||||||
addCount: addCount
|
addCount
|
||||||
|
};
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
UserMediaAdvancementResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: UserMediaAdvancement) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ import { NavigationEnd, NavigationError, NavigationStart, Router } from '@angula
|
|||||||
import { TypeService } from './type';
|
import { TypeService } from './type';
|
||||||
import { SeriesService } from './series';
|
import { SeriesService } from './series';
|
||||||
import { SeasonService } from './season';
|
import { SeasonService } from './season';
|
||||||
import { VideoService } from './video';
|
import { MediaService } from './media';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { NodeData } from 'common/model';
|
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
|
import { Season } from 'app/back-api';
|
||||||
|
|
||||||
export class InputOrders {
|
export class InputOrders {
|
||||||
public typeId: number = undefined;
|
public typeId: number = undefined;
|
||||||
@ -44,11 +44,13 @@ export class ArianeService {
|
|||||||
public segment: string = "";
|
public segment: string = "";
|
||||||
@Output() segmentChange: EventEmitter<string> = new EventEmitter();
|
@Output() segmentChange: EventEmitter<string> = new EventEmitter();
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(
|
||||||
private typeService: TypeService,
|
private router: Router,
|
||||||
private seriesService: SeriesService,
|
private MediaService: MediaService,
|
||||||
private seasonService: SeasonService,
|
private seasonService: SeasonService,
|
||||||
private videoService: VideoService) {
|
private seriesService: SeriesService,
|
||||||
|
private typeService: TypeService,
|
||||||
|
) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.router.events.subscribe((event: any) => {
|
this.router.events.subscribe((event: any) => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
@ -213,7 +215,7 @@ export class ArianeService {
|
|||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.seriesService.get(id)
|
this.seriesService.get(id)
|
||||||
.then((response: NodeData) => {
|
.then((response: Season) => {
|
||||||
self.seriesName = response.name;
|
self.seriesName = response.name;
|
||||||
self.seriesChange.emit(self.seriesId);
|
self.seriesChange.emit(self.seriesId);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@ -239,7 +241,7 @@ export class ArianeService {
|
|||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.seasonService.get(id)
|
this.seasonService.get(id)
|
||||||
.then((response: NodeData) => {
|
.then((response: Season) => {
|
||||||
// self.setSeries(response.seriesId);
|
// self.setSeries(response.seriesId);
|
||||||
self.seasonName = response.name;
|
self.seasonName = response.name;
|
||||||
self.seasonChange.emit(self.seasonId);
|
self.seasonChange.emit(self.seasonId);
|
||||||
@ -265,7 +267,7 @@ export class ArianeService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.videoService.get(id)
|
this.MediaService.get(id)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// self.setSeason(response.seasonId);
|
// self.setSeason(response.seasonId);
|
||||||
// self.setSeries(response.seriesId);
|
// self.setSeries(response.seriesId);
|
||||||
|
@ -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 { UUID } from 'app/back-api';
|
||||||
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.karideo,
|
||||||
|
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: UUID, 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:18080", "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:18080", "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?: UUID[]): 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: UUID): 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:18080", "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?: UUID[]): 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;
|
||||||
}
|
}
|
||||||
|
@ -4,18 +4,18 @@ import { DataService } from "./data";
|
|||||||
import { SeasonService } from "./season";
|
import { SeasonService } from "./season";
|
||||||
import { SeriesService } from "./series";
|
import { SeriesService } from "./series";
|
||||||
import { TypeService } from "./type";
|
import { TypeService } from "./type";
|
||||||
import { VideoService } from "./video";
|
import { MediaService } from "./media";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ArianeService,
|
|
||||||
DataService,
|
DataService,
|
||||||
|
AdvancementService,
|
||||||
|
MediaService,
|
||||||
SeasonService,
|
SeasonService,
|
||||||
SeriesService,
|
SeriesService,
|
||||||
TypeService,
|
TypeService,
|
||||||
VideoService,
|
ArianeService,
|
||||||
AdvancementService
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
135
front/src/app/service/media.ts
Normal file
135
front/src/app/service/media.ts
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @license PROPRIETARY (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { SessionService, DataStore } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Media, MediaResource, UUID } from 'app/back-api';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MediaService extends GenericDataService<Media> {
|
||||||
|
getRestConfig(): RESTConfig {
|
||||||
|
return {
|
||||||
|
server: environment.server.karideo,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Media[]> {
|
||||||
|
return MediaResource.gets({ restConfig: this.getRestConfig() });
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService) {
|
||||||
|
super();
|
||||||
|
console.log('Start MediaService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<Media>(() => self.lambdaGets()));
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadFile(file: File,
|
||||||
|
series?: string,
|
||||||
|
seriesId?: number,
|
||||||
|
season?: number,
|
||||||
|
episode?: number,
|
||||||
|
title?: string,
|
||||||
|
typeId?: number,
|
||||||
|
progress: any = null) {
|
||||||
|
const formData = {
|
||||||
|
fileName: file.name,
|
||||||
|
file,
|
||||||
|
seriesId: seriesId !== null ? seriesId.toString() : null,
|
||||||
|
series: series ?? null,
|
||||||
|
season: season !== null ? season.toString() : null,
|
||||||
|
episode: episode !== null ? episode.toString() : null,
|
||||||
|
title: title ?? null,
|
||||||
|
typeId: typeId !== null ? typeId.toString() : null,
|
||||||
|
universe: null,
|
||||||
|
};
|
||||||
|
return MediaResource.uploadFile({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
data: formData,
|
||||||
|
//progress
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
patch(id: number, data: Media): Promise<Media> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
MediaResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Media) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
MediaResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Media> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
MediaResource.removeCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
coverId
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Media> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
MediaResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
},
|
||||||
|
//progress
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,67 +5,161 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NodeData } from 'common/model';
|
import { DataStore, SessionService, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
import { Media, Season, SeasonResource, UUID } from 'app/back-api';
|
||||||
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { MediaService } from './media';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
|
||||||
import { DataInterface, TypeCheck } from 'common/utils';
|
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SeasonService extends GenericInterfaceModelDB {
|
export class SeasonService extends GenericDataService<Season> {
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
|
||||||
bdd: BddService) {
|
getRestConfig(): RESTConfig {
|
||||||
super('season', http, bdd);
|
return {
|
||||||
|
server: environment.server.karusic,
|
||||||
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Season[]> {
|
||||||
|
return SeasonResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private session: SessionService,
|
||||||
|
private MediaService: MediaService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
console.log('Start SeasonService');
|
||||||
|
const self = this;
|
||||||
|
this.setStore(new DataStore<Season>(() => self.lambdaGets()));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get all the video for a specific season
|
* Get all the video for a specific season
|
||||||
* @param id - Id of the season.
|
* @param id - Id of the season.
|
||||||
* @returns a promise on the list of video elements
|
* @returns a promise on the list of video elements
|
||||||
*/
|
*/
|
||||||
getVideo(id:number): Promise<NodeData[]> {
|
getVideo(id: number): Promise<Media[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere(
|
||||||
.then((response: DataInterface) => {
|
[
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'seasonId',
|
key: 'seasonId',
|
||||||
value: id,
|
value: id,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[ 'episode', 'name' ]);
|
['episode', 'name'])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of video in this saison ID
|
* Get the number of video in this season ID
|
||||||
* @param id - Id of the season.
|
* @param id - Id of the season.
|
||||||
* @returns The number of element present in this saison
|
* @returns The number of element present in this season
|
||||||
*/
|
*/
|
||||||
countVideo(id: number): Promise<number> {
|
countVideo(id: number): Promise<number> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere([
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'seasonId',
|
key: 'seasonId',
|
||||||
value: id,
|
value: id,
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
patch(id: number, data: Season): Promise<Season> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeasonResource.patch({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
}).then((value: Media) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeasonResource.remove({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Season> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeasonResource.removeCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
coverId
|
||||||
|
}
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Season> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeasonResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
},
|
||||||
|
//progress
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,43 +6,36 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
|
import { Media, Season, Series, SeriesResource, UUID } from 'app/back-api';
|
||||||
import { isNodeData, NodeData } from 'common/model';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { SeasonService, MediaService } from '.';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SeriesService extends GenericInterfaceModelDB {
|
export class SeriesService extends GenericDataService<Series> {
|
||||||
|
getRestConfig(): RESTConfig {
|
||||||
constructor(http: HttpWrapperService,
|
return {
|
||||||
bdd: BddService) {
|
server: environment.server.karideo,
|
||||||
super('series', http, bdd);
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Series[]> {
|
||||||
|
return SeriesResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrder(): Promise<NodeData[]> {
|
constructor(
|
||||||
let self = this;
|
private session: SessionService,
|
||||||
return new Promise((resolve, reject) => {
|
private MediaService: MediaService,
|
||||||
self.bdd.get(self.serviceName)
|
private seasonService: SeasonService,
|
||||||
.then((response: DataInterface) => {
|
) {
|
||||||
let data = response.getsWhere([
|
super();
|
||||||
{
|
console.log('Start SeriesService');
|
||||||
check: TypeCheck.NOT_EQUAL,
|
const self = this;
|
||||||
key: 'id',
|
this.setStore(new DataStore<Series>(() => self.lambdaGets()));
|
||||||
value: [undefined, null],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[ 'name', 'id' ]);
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,12 +43,11 @@ export class SeriesService extends GenericInterfaceModelDB {
|
|||||||
* @param id - Id of the series.
|
* @param id - Id of the series.
|
||||||
* @returns a promise on the list of video elements
|
* @returns a promise on the list of video elements
|
||||||
*/
|
*/
|
||||||
getVideo(id:number): Promise<NodeData[]> {
|
getVideo(id: number): Promise<Media[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere(
|
||||||
.then((response: DataInterface) => {
|
[
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'seriesId',
|
key: 'seriesId',
|
||||||
@ -66,7 +58,8 @@ export class SeriesService extends GenericInterfaceModelDB {
|
|||||||
value: undefined,
|
value: undefined,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[ 'episode', 'name' ]);
|
['episode', 'name'])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -82,17 +75,18 @@ export class SeriesService extends GenericInterfaceModelDB {
|
|||||||
countVideo(id: number): Promise<number> {
|
countVideo(id: number): Promise<number> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere(
|
||||||
.then((response:DataInterface) => {
|
[
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'seriesId',
|
key: 'seriesId',
|
||||||
value: id,
|
value: id,
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -103,42 +97,109 @@ export class SeriesService extends GenericInterfaceModelDB {
|
|||||||
* @param id - ID of the series
|
* @param id - ID of the series
|
||||||
* @returns the required List.
|
* @returns the required List.
|
||||||
*/
|
*/
|
||||||
getSeason(id:number): Promise<NodeData[]> {
|
getSeason(id: number): Promise<Season[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('season')
|
self.seasonService.getsWhere(
|
||||||
.then((response:DataInterface) => {
|
[
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'parentId',
|
key: 'parentId',
|
||||||
value: id,
|
value: id,
|
||||||
},
|
},
|
||||||
], [ 'id' ]);
|
], ['id'])
|
||||||
|
.then((data: Season[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return;
|
})
|
||||||
}).catch((response) => {
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getLike(nameSeries:string):any {
|
|
||||||
|
patch(id: number, data: Series): Promise<Series> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeriesResource.patch(
|
||||||
|
{
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data
|
||||||
|
})
|
||||||
|
.then((value: Media) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: number): Promise<void> {
|
||||||
|
const self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeriesResource.remove(
|
||||||
|
{
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
self.dataStore.delete(id);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCover(id: number, coverId: UUID): Promise<Series> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('series')
|
SeriesResource.removeCover({
|
||||||
.then((response:DataInterface) => {
|
restConfig: this.getRestConfig(),
|
||||||
let data = response.getNameLike(nameSeries);
|
params: {
|
||||||
if(data === null || data === undefined || data.length === 0) {
|
id,
|
||||||
reject('Data does not exist in the local BDD');
|
coverId
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
resolve(data);
|
}).then((value) => {
|
||||||
return;
|
self.dataStore.updateValue(value);
|
||||||
}).catch((response) => {
|
resolve(value);
|
||||||
reject(response);
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
uploadCover(id: number,
|
||||||
|
file: File,
|
||||||
|
progress: any = null): Promise<Media> {
|
||||||
|
let self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
SeriesResource.uploadCover({
|
||||||
|
restConfig: this.getRestConfig(),
|
||||||
|
params: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file,
|
||||||
|
fileName: file.name
|
||||||
|
},
|
||||||
|
//progress
|
||||||
|
}).then((value) => {
|
||||||
|
self.dataStore.updateValue(value);
|
||||||
|
resolve(value);
|
||||||
|
}).catch((error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,13 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
import { Media, Series, Type, TypeResource } from 'app/back-api';
|
||||||
import { DataInterface, isNullOrUndefined, TypeCheck } from 'common/utils';
|
import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { NodeData } from 'common/model';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
import { environment } from 'environments/environment';
|
||||||
|
import { GenericDataService } from './GenericDataService';
|
||||||
|
import { MediaService } from './media';
|
||||||
|
import { SeriesService } from './series';
|
||||||
|
|
||||||
export interface MessageLogIn {
|
export interface MessageLogIn {
|
||||||
id: number;
|
id: number;
|
||||||
@ -18,74 +21,50 @@ export interface MessageLogIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TypeService extends GenericInterfaceModelDB {
|
export class TypeService extends GenericDataService<Type> {
|
||||||
|
getRestConfig(): RESTConfig {
|
||||||
constructor(http: HttpWrapperService,
|
return {
|
||||||
bdd: BddService) {
|
server: environment.server.karideo,
|
||||||
super('type', http, bdd);
|
token: this.session.getToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lambdaGets(): Promise<Type[]> {
|
||||||
|
return TypeResource.gets({ restConfig: this.getRestConfig() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(private session: SessionService,
|
||||||
get(id:number): Promise<NodeData> {
|
private MediaService: MediaService,
|
||||||
let self = this;
|
private seriesService: SeriesService,
|
||||||
return new Promise((resolve, reject) => {
|
) {
|
||||||
self.bdd.get(self.serviceName)
|
super();
|
||||||
.then((response: DataInterface) => {
|
console.log('Start TypeService');
|
||||||
let data = response.get(id);
|
const self = this;
|
||||||
if(isNullOrUndefined(data)) {
|
this.setStore(new DataStore<Type>(() => self.lambdaGets()));
|
||||||
reject('Data does not exist in the local BDD');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
resolve(data);
|
|
||||||
}).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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
countVideo(id: number): Promise<number> {
|
countVideo(id: number): Promise<number> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere([
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'typeId',
|
key: 'typeId',
|
||||||
value: id,
|
value: id,
|
||||||
} ] );
|
}])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data.length);
|
resolve(data.length);
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubVideo(id:number): Promise<NodeData[]> {
|
getSubVideo(id: number): Promise<Media[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere([
|
||||||
.then((response: DataInterface) => {
|
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'typeId',
|
key: 'typeId',
|
||||||
@ -99,7 +78,8 @@ export class TypeService extends GenericInterfaceModelDB {
|
|||||||
key: 'universeId',
|
key: 'universeId',
|
||||||
value: undefined,
|
value: undefined,
|
||||||
},
|
},
|
||||||
], [ 'name' ] );
|
], ['name'])
|
||||||
|
.then((data: Media[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
@ -107,31 +87,33 @@ export class TypeService extends GenericInterfaceModelDB {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubSeries(id:number): Promise<NodeData[]> {
|
getSubSeries(id: number): Promise<Series[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('series')
|
resolve([]);
|
||||||
.then((response: DataInterface) => {
|
/*
|
||||||
let data = response.getsWhere([
|
self.seriesService.getsWhere([
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'parentId',
|
key: 'parentId',
|
||||||
value: id,
|
value: id,
|
||||||
}],
|
}],
|
||||||
[ 'name' ]);
|
['name'])
|
||||||
|
.then((data: Series[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch((response) => {
|
})
|
||||||
|
.catch((response) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubUniverse(id:number): Promise<NodeData[]> {
|
getSubUniverse(id: number): Promise<any[]> {
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
self.bdd.get('video')
|
self.MediaService.getsWhere(
|
||||||
.then((response: DataInterface) => {
|
[
|
||||||
let data = response.getsWhere([
|
|
||||||
{
|
{
|
||||||
check: TypeCheck.EQUAL,
|
check: TypeCheck.EQUAL,
|
||||||
key: 'typeId',
|
key: 'typeId',
|
||||||
@ -145,10 +127,9 @@ export class TypeService extends GenericInterfaceModelDB {
|
|||||||
key: 'universeId',
|
key: 'universeId',
|
||||||
value: undefined,
|
value: undefined,
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
//, [ 'universId' ]);
|
.then((data: Media[]) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return;
|
|
||||||
}).catch((response: any) => {
|
}).catch((response: any) => {
|
||||||
reject(response);
|
reject(response);
|
||||||
});
|
});
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @license PROPRIETARY (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { isMedia, Media } from 'app/model';
|
|
||||||
import { NodeData } from 'common/model';
|
|
||||||
|
|
||||||
import { HttpWrapperService, BddService } from 'common/service';
|
|
||||||
import { isArrayOf } from 'common/utils';
|
|
||||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class VideoService extends GenericInterfaceModelDB {
|
|
||||||
|
|
||||||
constructor(http: HttpWrapperService,
|
|
||||||
bdd: BddService) {
|
|
||||||
super('video', http, bdd);
|
|
||||||
}
|
|
||||||
get(id:number): Promise<Media> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
super.get(id).then((data: NodeData) => {
|
|
||||||
if (isMedia(data)) {
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reject("model is wrong !!!")
|
|
||||||
return
|
|
||||||
}).catch((reason:any) => {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getData(): Promise<Media[]> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
super.getData().then((data: NodeData[]) => {
|
|
||||||
if (isArrayOf(data, isMedia)) {
|
|
||||||
resolve(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reject("model is wrong !!!")
|
|
||||||
return
|
|
||||||
}).catch((reason:any) => {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadFile(file:File,
|
|
||||||
series?:string,
|
|
||||||
seriesId?:number,
|
|
||||||
season?:number,
|
|
||||||
episode?:number,
|
|
||||||
title?:string,
|
|
||||||
typeId?:number,
|
|
||||||
progress:any = null) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('fileName', file.name);
|
|
||||||
// set the file at hte begining it will permit to abort the transmission
|
|
||||||
formData.append('file', file?? null);
|
|
||||||
if(seriesId !== null) {
|
|
||||||
formData.append('seriesId', seriesId.toString());
|
|
||||||
} else {
|
|
||||||
formData.append('seriesId', null);
|
|
||||||
}
|
|
||||||
formData.append('series', series?? null);
|
|
||||||
if(season !== null) {
|
|
||||||
formData.append('season', season.toString());
|
|
||||||
} else {
|
|
||||||
formData.append('season', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(episode !== null) {
|
|
||||||
formData.append('episode', episode.toString());
|
|
||||||
} else {
|
|
||||||
formData.append('episode', null);
|
|
||||||
}
|
|
||||||
formData.append('title', title?? null);
|
|
||||||
|
|
||||||
if(typeId !== null) {
|
|
||||||
formData.append('typeId', typeId.toString());
|
|
||||||
} else {
|
|
||||||
formData.append('typeId', null);
|
|
||||||
}
|
|
||||||
return this.http.uploadMultipart(`${this.serviceName }/upload/`, formData, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadCoverBlob(blob:Blob,
|
|
||||||
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;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
self.http.uploadMultipart(`${this.serviceName }/${ mediaId }/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, mediaId, data);
|
|
||||||
resolve(data);
|
|
||||||
}).catch((response) => {
|
|
||||||
reject(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 147a955b195eb7c90e445d404f043d9a363087ca
|
|
@ -3,7 +3,9 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
|
export const environment: Environment = {
|
||||||
production: true,
|
production: true,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
const serverSSOAddress = 'http://atria-soft.org'
|
const serverSSOAddress = 'http://atria-soft.org'
|
||||||
|
|
||||||
const environment_back_prod = {
|
const environment_back_prod: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
@ -21,7 +23,7 @@ const environment_back_prod = {
|
|||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const environment_local = {
|
const environment_local: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
@ -37,7 +39,7 @@ const environment_local = {
|
|||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const environment_hybrid = {
|
const environment_hybrid: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required to support Web Animations `@angular/platform-browser/animations`.
|
|
||||||
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
|
|
||||||
**/
|
|
||||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
|
||||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
|
||||||
*/
|
|
||||||
|
|
||||||
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
|
||||||
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
|
||||||
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
|
||||||
|
|
||||||
/*
|
|
||||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
|
||||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
|
||||||
*/
|
|
||||||
// (window as any).__Zone_enable_cross_context_check = true;
|
|
||||||
|
|
||||||
/** *************************************************************************************************
|
|
||||||
* Zone JS is required by default for Angular itself.
|
|
||||||
*/
|
|
||||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
|
||||||
|
|
||||||
|
|
||||||
/** *************************************************************************************************
|
|
||||||
* APPLICATION IMPORTS
|
|
||||||
*/
|
|
@ -9,19 +9,23 @@
|
|||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es2018",
|
"target": "es2022",
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
],
|
],
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2018",
|
"ES2022",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
"module": "es2020",
|
"module": "es2022",
|
||||||
"baseUrl": "./src",
|
"baseUrl": "./src",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@app/*": ["./src/app/*"],
|
"@app/*": [
|
||||||
"@common/*": ["./src/common/*"]
|
"./src/app/*"
|
||||||
|
],
|
||||||
|
"@common/*": [
|
||||||
|
"./src/common/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user