[DEV] update kar-cw and new generate back-end API
This commit is contained in:
parent
95c3c0f968
commit
e0b81d2122
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.6.3</version>
|
||||
<version>0.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -21,12 +21,12 @@ import org.kar.archidata.migration.MigrationEngine;
|
||||
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.api.VideoResource;
|
||||
import org.kar.karideo.filter.KarideoAuthenticationFilter;
|
||||
import org.kar.karideo.migration.Initialization;
|
||||
import org.kar.karideo.migration.Migration20230810;
|
||||
@ -105,7 +105,7 @@ public class WebLauncher {
|
||||
rc.register(DataResource.class);
|
||||
rc.register(SeasonResource.class);
|
||||
rc.register(TypeResource.class);
|
||||
rc.register(VideoResource.class);
|
||||
rc.register(MediaResource.class);
|
||||
rc.register(UserMediaAdvancementResource.class);
|
||||
|
||||
rc.register(HealthCheck.class);
|
||||
|
@ -1,10 +1,19 @@
|
||||
|
||||
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.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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -15,11 +24,17 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
private WebLauncherLocal() {}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
final String model = DataFactoryZod.createTables(Initialization.CLASSES_BASE);
|
||||
LOGGER.info("Zod Model = {}", model);
|
||||
final FileWriter writer = new FileWriter("../front/src/app/model/server-karideo-api.ts");
|
||||
writer.write(model);
|
||||
writer.close();
|
||||
DataFactoryTsApi.generatePackage(List.of(
|
||||
Front.class,
|
||||
HealthCheck.class,
|
||||
SeasonResource.class,
|
||||
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();
|
||||
launcher.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.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
@ -17,12 +18,14 @@ import jakarta.ws.rs.core.Response;
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class HealthCheck {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(HealthCheck.class);
|
||||
|
||||
public record HealthResult(
|
||||
String value) {};
|
||||
|
||||
|
||||
public record HealthResult(String value) {
|
||||
|
||||
};
|
||||
|
||||
@GET
|
||||
@PermitAll
|
||||
@Operation(description = "Get the server state (health)", tags = "SYSTEM")
|
||||
public HealthResult getHealth() throws FailException {
|
||||
if (JWTWrapper.getPublicKeyJson() == null && !ConfigBaseVariable.getTestMode()) {
|
||||
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.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
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.InputException;
|
||||
import org.kar.archidata.model.Data;
|
||||
@ -22,6 +23,7 @@ import org.kar.karideo.model.Type;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
@ -35,19 +37,21 @@ import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/video")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public class VideoResource {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class MediaResource {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(MediaResource.class);
|
||||
|
||||
@GET
|
||||
@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);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
@Operation(description = "Get a specific Media with his ID", tags = "GLOBAL")
|
||||
public Media get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Media.class, id);
|
||||
}
|
||||
@ -56,7 +60,8 @@ public class VideoResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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 + "'");
|
||||
DataAccess.updateWithJson(Media.class, id, jsonRequest);
|
||||
return DataAccess.get(Media.class, id);
|
||||
@ -76,9 +81,10 @@ public class VideoResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/upload/")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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,
|
||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||
@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) {
|
||||
System.out.println("Data already exist but deleted");
|
||||
System.out.flush();
|
||||
DataResource.undelete(data.id);
|
||||
DataTools.undelete(data.id);
|
||||
data.deleted = false;
|
||||
} else {
|
||||
System.out.println("Data already exist ... all good");
|
||||
@ -198,27 +204,38 @@ public class VideoResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/add_cover")
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
public Response uploadCover(@PathParam("id") final UUID id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@AsyncType(Media.class)
|
||||
@Operation(description = "Upload a new season cover media", tags = "GLOBAL")
|
||||
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
|
||||
@Path("{id}/rm_cover/{coverId}")
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final UUID id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Media.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Media.class, id)).build();
|
||||
@Operation(description = "Remove a specific cover of a media", tags = "GLOBAL")
|
||||
public Media removeCover( //
|
||||
@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
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
}
|
@ -2,19 +2,22 @@ package org.kar.karideo.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
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.tools.DataTools;
|
||||
import org.kar.karideo.model.Season;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
@ -25,23 +28,17 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/season")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class SeasonResource {
|
||||
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
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -49,6 +46,7 @@ public class SeasonResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Operation(description = "Get all season", tags = "GLOBAL")
|
||||
public Season get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
@ -60,15 +58,17 @@ public class SeasonResource {
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Season put(final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Season.class, jsonRequest);
|
||||
@Operation(description = "Create a new season", tags = "GLOBAL")
|
||||
public Season post(final Season jsonRequest) throws Exception {
|
||||
return DataAccess.insert(jsonRequest);
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
@ -76,26 +76,29 @@ public class SeasonResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/add_cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@Operation(description = "Upload a new season cover season", tags = "GLOBAL")
|
||||
public Season 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(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{id}/rm_cover/{coverId}")
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Season.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Season.class, id)).build();
|
||||
@Operation(description = "Remove a specific cover of a season", tags = "GLOBAL")
|
||||
public Season removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
AddOnDataJson.removeLink(Season.class, id, "covers", coverId);
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
|
||||
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.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
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.tools.DataTools;
|
||||
import org.kar.karideo.model.Series;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
@ -25,23 +28,16 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/series")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class SeriesResource {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
public static Series getWithId(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Series> get() throws Exception {
|
||||
@Operation(description = "Get all Series", tags = "GLOBAL")
|
||||
public List<Series> gets() throws Exception {
|
||||
return DataAccess.gets(Series.class);
|
||||
}
|
||||
|
||||
@ -49,6 +45,7 @@ public class SeriesResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
@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 {
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
@ -60,15 +57,17 @@ public class SeriesResource {
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Series put(final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Series.class, jsonRequest);
|
||||
@Operation(description = "Create a new Series", tags = "GLOBAL")
|
||||
public Series post(final Series jsonRequest) throws Exception {
|
||||
return DataAccess.insert(jsonRequest);
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
@ -76,26 +75,29 @@ public class SeriesResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/add_cover")
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@Operation(description = "Upload a new season cover Series", tags = "GLOBAL")
|
||||
public Series 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(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{id}/rm_cover/{coverId}")
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Series.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Series.class, id)).build();
|
||||
@Operation(description = "Remove a specific Series of a season", tags = "GLOBAL")
|
||||
public Series removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
AddOnDataJson.removeLink(Series.class, id, "covers", coverId);
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
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.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||
import org.kar.archidata.dataAccess.options.Condition;
|
||||
import org.kar.archidata.tools.DataTools;
|
||||
import org.kar.karideo.model.Type;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
@ -24,23 +27,17 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/type")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class TypeResource {
|
||||
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
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -48,6 +45,7 @@ public class TypeResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
@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 {
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
@ -63,15 +61,17 @@ public class TypeResource {
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Type put(final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Type.class, jsonRequest);
|
||||
@Operation(description = "Create a new Type", tags = "GLOBAL")
|
||||
public Type post(final Type jsonRequest) throws Exception {
|
||||
return DataAccess.insert(jsonRequest);
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
@ -79,26 +79,29 @@ public class TypeResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/add_cover")
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||
@Operation(description = "Upload a new season cover Type", tags = "GLOBAL")
|
||||
public Type 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(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{id}/rm_cover/{coverId}")
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response removeCover(@PathParam("id") final Long id, @PathParam("coverId") final Long coverId) throws Exception {
|
||||
AddOnManyToMany.removeLink(Type.class, id, "cover", coverId);
|
||||
return Response.ok(DataAccess.get(Type.class, id)).build();
|
||||
@Operation(description = "Remove a specific cover of a type", tags = "GLOBAL")
|
||||
public Type removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||
AddOnDataJson.removeLink(Type.class, id, "covers", coverId);
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
|
||||
public static Type getOrCreate(final String name) {
|
||||
|
@ -11,6 +11,7 @@ import org.kar.karideo.model.UserMediaAdvancement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
@ -21,24 +22,25 @@ import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
@Path("/advancement")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class UserMediaAdvancementResource {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class);
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@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();
|
||||
return DataAccess.getWhere(UserMediaAdvancement.class, new Condition(new QueryAnd(new QueryCondition("mediaId", "=", id), new QueryCondition("userId", "=", gc.userByToken.id))));
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
@Operation(description = "Get all user advancement", tags = "GLOBAL")
|
||||
public List<UserMediaAdvancement> gets(@Context final SecurityContext sc) throws Exception {
|
||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
return DataAccess.getsWhere(UserMediaAdvancement.class, new Condition(new QueryCondition("userId", "=", gc.userByToken.id)));
|
||||
@ -77,8 +79,9 @@ public class UserMediaAdvancementResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public UserMediaAdvancement put(@Context final SecurityContext sc, @PathParam("id") final Long id, final MediaInformationsDelta data) throws Exception {
|
||||
final UserMediaAdvancement elem = getWithId(sc, id);
|
||||
@Operation(description = "Modify a user advancement", tags = "GLOBAL")
|
||||
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) {
|
||||
// insert element
|
||||
if (data.addCount) {
|
||||
@ -100,10 +103,10 @@ public class UserMediaAdvancementResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
public Response delete(@Context final SecurityContext sc, @PathParam("id") final Long id) throws Exception {
|
||||
final UserMediaAdvancement elem = getWithId(sc, id);
|
||||
@Operation(description = "Remove a specific user advancement", tags = "GLOBAL")
|
||||
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);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
@ -20,7 +21,7 @@ import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
@Path("/users")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class UserResource {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||
|
||||
@ -41,7 +42,8 @@ public class UserResource {
|
||||
// curl http://localhost:9993/api/users
|
||||
@GET
|
||||
@RolesAllowed("ADMIN")
|
||||
public List<UserKarideo> getUsers() {
|
||||
@Operation(description = "Get all the users", tags = "SYSTEM")
|
||||
public List<UserKarideo> gets() {
|
||||
System.out.println("getUsers");
|
||||
try {
|
||||
return DataAccess.gets(UserKarideo.class);
|
||||
@ -56,7 +58,8 @@ public class UserResource {
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@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);
|
||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
System.out.println("===================================================");
|
||||
@ -74,6 +77,7 @@ public class UserResource {
|
||||
@GET
|
||||
@Path("me")
|
||||
@RolesAllowed("USER")
|
||||
@Operation(description = "Get the user personal data", tags = "SYSTEM")
|
||||
public UserOut getMe(@Context final SecurityContext sc) {
|
||||
LOGGER.debug("getMe()");
|
||||
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');
|
||||
""");
|
||||
// set start increment element to permit to add after default elements
|
||||
addAction("""
|
||||
ALTER TABLE `data` AUTO_INCREMENT = 1000;
|
||||
""", "mysql");
|
||||
addAction("""
|
||||
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
||||
""", "mysql");
|
||||
|
@ -1,5 +1,8 @@
|
||||
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 org.kar.archidata.api.DataResource;
|
||||
@ -101,9 +104,11 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
for (final UUIDConversion data: datas) {
|
||||
|
||||
final String origin = DataResource.getFileData(data.id);
|
||||
final String origin = DataResource.getFileDataOld(data.id);
|
||||
final String destination = DataResource.getFileData(data.uuid);
|
||||
LOGGER.info("move file = {}", origin);
|
||||
LOGGER.info(" ==> {}", destination);
|
||||
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"defaultProject": "karideo",
|
||||
"projects": {
|
||||
"karideo": {
|
||||
"root": "",
|
||||
@ -16,6 +15,7 @@
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"tsConfig": "src/tsconfig.app.json",
|
||||
"preserveSymlinks": true,
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
@ -52,12 +52,17 @@
|
||||
"develop": {
|
||||
"optimization": false,
|
||||
"outputHashing": "none",
|
||||
"sourceMap": true,
|
||||
"namedChunks": true,
|
||||
"aot": true,
|
||||
"aot": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": true,
|
||||
"buildOptimizer": false
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": {
|
||||
"scripts": true,
|
||||
"styles": true,
|
||||
"hidden": false,
|
||||
"vendor": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -164,4 +169,4 @@
|
||||
"prefix": "app"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17122
front/package-lock.json
generated
17122
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,45 +1,49 @@
|
||||
{
|
||||
"name": "karideo",
|
||||
"version": "0.0.0",
|
||||
"license": "MPL-2",
|
||||
"scripts": {
|
||||
"all": "npm run build && npm run test",
|
||||
"ng": "ng",
|
||||
"dev": "ng serve --configuration=develop --watch --port 4202",
|
||||
"build": "ng build --prod",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"style": "prettier --write .",
|
||||
"e2e": "ng e2e",
|
||||
"update_packages": "ncu --upgrade",
|
||||
"install_dependency": "npm install"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.2.0",
|
||||
"@angular/cdk": "^17.1.2",
|
||||
"@angular/common": "^17.2.0",
|
||||
"@angular/compiler": "^17.2.0",
|
||||
"@angular/core": "^17.2.0",
|
||||
"@angular/forms": "^17.2.0",
|
||||
"@angular/material": "^17.1.2",
|
||||
"@angular/platform-browser": "^17.2.0",
|
||||
"@angular/platform-browser-dynamic": "^17.2.0",
|
||||
"@angular/router": "^17.2.0",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.4",
|
||||
"zod": "3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.2.0",
|
||||
"@angular-eslint/builder": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
||||
"@angular-eslint/schematics": "17.2.1",
|
||||
"@angular-eslint/template-parser": "17.2.1",
|
||||
"@angular/cli": "^17.2.0",
|
||||
"@angular/compiler-cli": "^17.2.0",
|
||||
"@angular/language-service": "^17.2.0",
|
||||
"npm-check-updates": "^16.14.15"
|
||||
}
|
||||
}
|
||||
"name": "karideo",
|
||||
"version": "0.0.0",
|
||||
"license": "MPL-2",
|
||||
"scripts": {
|
||||
"all": "npm run build && npm run test",
|
||||
"ng": "ng",
|
||||
"dev": "ng serve --configuration=develop --watch --port 4202",
|
||||
"build": "ng build --prod",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"style": "prettier --write .",
|
||||
"e2e": "ng e2e",
|
||||
"update_packages": "ncu --upgrade",
|
||||
"install_dependency": "pnpm install --force",
|
||||
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.3.4",
|
||||
"@angular/cdk": "^17.3.4",
|
||||
"@angular/common": "^17.3.4",
|
||||
"@angular/compiler": "^17.3.4",
|
||||
"@angular/core": "^17.3.4",
|
||||
"@angular/forms": "^17.3.4",
|
||||
"@angular/material": "^17.3.4",
|
||||
"@angular/platform-browser": "^17.3.4",
|
||||
"@angular/platform-browser-dynamic": "^17.3.4",
|
||||
"@angular/router": "^17.3.4",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.4",
|
||||
"zod": "3.22.4",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.3.4",
|
||||
"@angular-eslint/builder": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||
"@angular-eslint/schematics": "17.3.0",
|
||||
"@angular-eslint/template-parser": "17.3.0",
|
||||
"@angular/cli": "^17.3.4",
|
||||
"@angular/compiler-cli": "^17.3.4",
|
||||
"@angular/language-service": "^17.3.4",
|
||||
"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 { 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 { 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';
|
||||
|
||||
// see https://angular.io/guide/router
|
||||
@ -20,13 +19,13 @@ const routes: Routes = [
|
||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||
|
||||
{ path: 'forbidden', component: ForbiddenScene },
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// -- home global interface
|
||||
// ------------------------------------
|
||||
{
|
||||
path: 'home',
|
||||
component: HomeScene,
|
||||
component: HomeScene,
|
||||
canActivate: [OnlyUsersGuardHome], // this route to unregistered path when not logged ==> permit to simplify display
|
||||
},
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
<!-- 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 -->
|
||||
@if(autoConnectedDone) {
|
||||
<div class="main-content">
|
||||
|
@ -5,12 +5,8 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
||||
import { MenuItem, MenuPosition } from 'common/model';
|
||||
import { UserService, SessionService, SSOService } from 'common/service';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
import { ArianeService } from './service';
|
||||
import { UserRoles222 } from 'common/service/session';
|
||||
import { ArianeService, MediaService, SeasonService, SeriesService, TypeService } from './service';
|
||||
import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
enum MenuEventType {
|
||||
SSO_LOGIN = "SSO_CALL_LOGIN",
|
||||
@ -38,6 +34,11 @@ export class AppComponent implements OnInit {
|
||||
location: string = "home";
|
||||
|
||||
constructor(
|
||||
private mediaService: MediaService,
|
||||
private seasonService: SeasonService,
|
||||
private seriesService: SeriesService,
|
||||
private typeService: TypeService,
|
||||
|
||||
private userService: UserService,
|
||||
private sessionService: SessionService,
|
||||
private ssoService: SSOService,
|
||||
@ -67,13 +68,13 @@ export class AppComponent implements OnInit {
|
||||
});
|
||||
|
||||
this.userService.checkAutoConnect().then(() => {
|
||||
console.log(` ==>>>>> Autoconnect THEN !!!`);
|
||||
console.log(` ==>>>>> Auto-connect THEN !!!`);
|
||||
self.autoConnectedDone = true;
|
||||
}).catch(() => {
|
||||
console.log(` ==>>>>> Autoconnect CATCH !!!`);
|
||||
console.log(` ==>>>>> Auto-connect CATCH !!!`);
|
||||
self.autoConnectedDone = true;
|
||||
}).finally(() => {
|
||||
console.log(` ==>>>>> Autoconnect FINALLY !!!`);
|
||||
console.log(` ==>>>>> Auto-connect FINALLY !!!`);
|
||||
self.autoConnectedDone = true;
|
||||
});
|
||||
this.arianeService.segmentChange.subscribe((_segmentName: string) => {
|
||||
|
@ -22,9 +22,18 @@ import {
|
||||
HomeScene, HelpScene, TypeScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
|
||||
VideoEditScene, SeasonEditScene, SeriesEditScene
|
||||
} 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 { 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({
|
||||
declarations: [
|
||||
@ -46,25 +55,24 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
||||
VideoEditScene,
|
||||
SeasonEditScene,
|
||||
SeriesEditScene,
|
||||
UploadScene,
|
||||
...common_module_declarations,
|
||||
UploadScene
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule,
|
||||
AppRoutingModule,
|
||||
HttpClientModule,
|
||||
...common_module_imports,
|
||||
KarCWModule,
|
||||
],
|
||||
providers: [
|
||||
TypeService,
|
||||
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||
DataService,
|
||||
SeriesService,
|
||||
SeasonService,
|
||||
VideoService,
|
||||
ArianeService,
|
||||
AdvancementService,
|
||||
...common_module_providers,
|
||||
MediaService,
|
||||
SeasonService,
|
||||
SeriesService,
|
||||
TypeService,
|
||||
ArianeService,
|
||||
],
|
||||
exports: [
|
||||
AppComponent,
|
||||
@ -72,8 +80,7 @@ import { common_module_declarations, common_module_imports, common_module_provid
|
||||
ElementSeriesComponent,
|
||||
ElementSeasonComponent,
|
||||
ElementVideoComponent,
|
||||
PopInCreateType,
|
||||
...common_module_exports,
|
||||
PopInCreateType
|
||||
],
|
||||
bootstrap: [
|
||||
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,32 +4,33 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { UUID } from 'app/back-api';
|
||||
//import { ModelResponseHttp } from '@app/service/http-wrapper';
|
||||
import { DataService } from 'app/service/data';
|
||||
|
||||
@Component({
|
||||
selector: 'data-image',
|
||||
templateUrl: './data-image.html',
|
||||
styleUrls: [ './data-image.less' ]
|
||||
styleUrls: ['./data-image.less']
|
||||
})
|
||||
export class ElementDataImageComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id:number = -1;
|
||||
@Input() id?: UUID;
|
||||
cover: string = '';
|
||||
/*
|
||||
imageCanvas:any;
|
||||
@ViewChild('imageCanvas')
|
||||
set mainDivEl(el: ElementRef) {
|
||||
if(el !== null && el !== undefined) {
|
||||
this.imageCanvas = el.nativeElement;
|
||||
/*
|
||||
imageCanvas:any;
|
||||
@ViewChild('imageCanvas')
|
||||
set mainDivEl(el: ElementRef) {
|
||||
if(el !== null && el !== undefined) {
|
||||
this.imageCanvas = el.nativeElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
constructor(private dataService: DataService) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.cover = this.dataService.getCoverThumbnailUrl(this.id);
|
||||
this.cover = this.dataService.getThumbnailUrl(this.id);
|
||||
/*
|
||||
let canvas = this.imageCanvas.nativeElement;
|
||||
let ctx = canvas.getContext("2d");
|
||||
|
@ -3,29 +3,30 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import {Component, OnInit, Input } from '@angular/core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Season } from 'app/back-api';
|
||||
|
||||
import { SeasonService, DataService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-season',
|
||||
templateUrl: './element-season.html',
|
||||
styleUrls: [ './element-season.less' ]
|
||||
styleUrls: ['./element-season.less']
|
||||
})
|
||||
export class ElementSeasonComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
|
||||
@Input() element: Season;
|
||||
|
||||
numberSeason: string;
|
||||
count: number;
|
||||
covers: string[];
|
||||
description: string;
|
||||
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private seasonService: SeasonService,
|
||||
private dataService: DataService) {
|
||||
) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
@ -36,7 +37,7 @@ export class ElementSeasonComponent implements OnInit {
|
||||
}
|
||||
this.numberSeason = this.element.name;
|
||||
this.description = this.element.description;
|
||||
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
||||
let self = this;
|
||||
this.seasonService.countVideo(this.element.id)
|
||||
.then((response) => {
|
||||
|
@ -4,29 +4,30 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Series } from 'app/back-api';
|
||||
|
||||
import { SeriesService, DataService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-series',
|
||||
templateUrl: './element-series.html',
|
||||
styleUrls: [ './element-series.less' ]
|
||||
styleUrls: ['./element-series.less']
|
||||
})
|
||||
export class ElementSeriesComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
|
||||
name:string = 'plouf';
|
||||
description:string = '';
|
||||
countvideo:number = null;
|
||||
@Input() element: Series;
|
||||
|
||||
covers:string[];
|
||||
name: string = 'plouf';
|
||||
description: string = '';
|
||||
countvideo: number = null;
|
||||
|
||||
covers: string[];
|
||||
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private seriesService: SeriesService,
|
||||
private dataService: DataService) {
|
||||
) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
@ -38,7 +39,7 @@ export class ElementSeriesComponent implements OnInit {
|
||||
let self = this;
|
||||
self.name = this.element.name;
|
||||
self.description = this.element.description;
|
||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
|
||||
|
||||
this.seriesService.countVideo(this.element.id)
|
||||
.then((response) => {
|
||||
|
@ -4,37 +4,38 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Type } from 'app/back-api';
|
||||
|
||||
import { TypeService, DataService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-type',
|
||||
templateUrl: './element-type.html',
|
||||
styleUrls: [ './element-type.less' ]
|
||||
styleUrls: ['./element-type.less']
|
||||
})
|
||||
export class ElementTypeComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element:NodeData;
|
||||
@Input() element: Type;
|
||||
|
||||
public name: string = 'rr';
|
||||
public description: string;
|
||||
|
||||
public countvideo:number;
|
||||
public countVideo: number;
|
||||
|
||||
public covers: string[];
|
||||
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private typeService: TypeService,
|
||||
private dataService: DataService) {
|
||||
) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
if (isNullOrUndefined(this.element)) {
|
||||
this.name = 'Not a media';
|
||||
this.description = undefined;
|
||||
this.countvideo = undefined;
|
||||
this.countVideo = undefined;
|
||||
this.covers = undefined;
|
||||
return;
|
||||
}
|
||||
@ -42,13 +43,13 @@ export class ElementTypeComponent implements OnInit {
|
||||
console.log(" ??? Get element ! " + JSON.stringify(this.element));
|
||||
self.name = this.element.name;
|
||||
self.description = this.element.description;
|
||||
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
|
||||
|
||||
self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
|
||||
|
||||
this.typeService.countVideo(this.element.id)
|
||||
.then((response: number) => {
|
||||
self.countvideo = response;
|
||||
self.countVideo = response;
|
||||
}).catch(() => {
|
||||
self.countvideo = 0;
|
||||
self.countVideo = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,10 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
||||
import { isMedia, Media } from 'app/model';
|
||||
import { UserMediaAdvancement } from 'app/model/user-media-advancement';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Media, UserMediaAdvancement } from 'app/back-api';
|
||||
|
||||
import { AdvancementService, DataService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-video',
|
||||
@ -20,7 +18,7 @@ import { isNullOrUndefined } from 'common/utils';
|
||||
@Injectable()
|
||||
export class ElementVideoComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element: NodeData;
|
||||
@Input() element: Media;
|
||||
data: Media;
|
||||
|
||||
name: string = '';
|
||||
@ -38,12 +36,6 @@ export class ElementVideoComponent implements OnInit {
|
||||
// nothing to do.
|
||||
}
|
||||
ngOnInit() {
|
||||
if (!isMedia(this.element)) {
|
||||
this.data = undefined;
|
||||
this.name = 'Not a media';
|
||||
this.description = undefined;
|
||||
return;
|
||||
}
|
||||
this.data = this.element;
|
||||
this.name = this.element.name;
|
||||
this.description = this.element.description;
|
||||
@ -52,7 +44,7 @@ export class ElementVideoComponent implements OnInit {
|
||||
} else {
|
||||
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)
|
||||
.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,13 +4,12 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { PopInService } from 'common/service/popin';
|
||||
import { PopInService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
@Component({
|
||||
selector: 'create-type',
|
||||
templateUrl: './create-type.html',
|
||||
styleUrls: [ './create-type.less' ]
|
||||
styleUrls: ['./create-type.less']
|
||||
})
|
||||
export class PopInCreateType implements OnInit {
|
||||
name: string = '';
|
||||
@ -26,14 +25,14 @@ export class PopInCreateType implements OnInit {
|
||||
|
||||
}
|
||||
eventPopUp(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
console.log(`GET event: ${event}`);
|
||||
this.popInService.close('popin-create-type');
|
||||
}
|
||||
updateNeedSend():void {
|
||||
updateNeedSend(): void {
|
||||
|
||||
}
|
||||
onName(value:any):void {
|
||||
if(value.length === 0) {
|
||||
onName(value: any): void {
|
||||
if (value.length === 0) {
|
||||
this.name = '';
|
||||
} else {
|
||||
this.name = value;
|
||||
@ -41,8 +40,8 @@ export class PopInCreateType implements OnInit {
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onDescription(value:any):void {
|
||||
if(value.length === 0) {
|
||||
onDescription(value: any): void {
|
||||
if (value.length === 0) {
|
||||
this.description = '';
|
||||
} else {
|
||||
this.description = value;
|
||||
|
@ -12,31 +12,31 @@ import { ArianeService } from 'app/service/ariane';
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.html',
|
||||
styleUrls: [ './home.less' ]
|
||||
styleUrls: ['./home.less']
|
||||
})
|
||||
export class HomeScene implements OnInit {
|
||||
dataList = [];
|
||||
error = '';
|
||||
constructor(private typeService: TypeService,
|
||||
private arianeService: ArianeService) {
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let self = this;
|
||||
this.typeService.getData()
|
||||
this.typeService.gets()
|
||||
.then((response) => {
|
||||
self.error = '';
|
||||
self.dataList = response;
|
||||
console.log(`Get response: ${ JSON.stringify(response, null, 2)}`);
|
||||
console.log(`Get response: ${JSON.stringify(response, null, 2)}`);
|
||||
}).catch((response) => {
|
||||
self.error = 'Wrong e-mail/login or password';
|
||||
console.log(`[E] ${ self.constructor.name }: Does not get a correct response from the server ...`);
|
||||
console.log(`[E] ${self.constructor.name}: Does not get a correct response from the server ...`);
|
||||
self.dataList = [];
|
||||
});
|
||||
this.arianeService.reset();
|
||||
}
|
||||
onSelectType(_event: any, _idSelected: number):void {
|
||||
onSelectType(_event: any, _idSelected: number): void {
|
||||
this.arianeService.navigateType(_idSelected, _event.which === 2);
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,10 @@
|
||||
*/
|
||||
|
||||
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 { 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 {
|
||||
value: number;
|
||||
@ -46,7 +43,7 @@ export class SeasonEditScene implements OnInit {
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteCoverId: UUID = null;
|
||||
private deleteItemId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
@ -67,10 +64,11 @@ export class SeasonEditScene implements OnInit {
|
||||
|
||||
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private seasonService: SeasonService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService,
|
||||
private dataService: DataService) {
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@ -78,7 +76,7 @@ export class SeasonEditScene implements OnInit {
|
||||
this.idSeason = this.arianeService.getSeasonId();
|
||||
let self = this;
|
||||
this.seasonService.get(this.idSeason)
|
||||
.then((response: NodeData) => {
|
||||
.then((response: Season) => {
|
||||
console.log(`get response of season : ${JSON.stringify(response, null, 2)}`);
|
||||
if (isNumberFinite(response.name)) {
|
||||
self.numberVal = response.name;
|
||||
@ -108,7 +106,7 @@ export class SeasonEditScene implements OnInit {
|
||||
for (let iii = 0; iii < covers.length; iii++) {
|
||||
this.coversDisplay.push({
|
||||
id: covers[iii],
|
||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
||||
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -126,7 +124,7 @@ export class SeasonEditScene implements OnInit {
|
||||
sendValues(): void {
|
||||
console.log('send new values....');
|
||||
let data = {
|
||||
name: this.numberVal,
|
||||
name: `${this.numberVal}`,
|
||||
description: this.description
|
||||
};
|
||||
if (this.description === undefined) {
|
||||
@ -168,7 +166,7 @@ export class SeasonEditScene implements OnInit {
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
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.mediaSize = total;
|
||||
})
|
||||
@ -182,14 +180,14 @@ export class SeasonEditScene implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
removeCover(id: number) {
|
||||
removeCover(id: UUID) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
||||
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(id: number) {
|
||||
removeCoverAfterConfirm(id: UUID) {
|
||||
console.log(`Request remove cover: ${id}`);
|
||||
let self = this;
|
||||
this.seasonService.deleteCover(this.idSeason, id)
|
||||
|
@ -24,11 +24,12 @@ export class SeasonScene implements OnInit {
|
||||
videosError = '';
|
||||
videos = [];
|
||||
constructor(
|
||||
private advancementService: AdvancementService,
|
||||
private dataService: DataService,
|
||||
private seasonService: SeasonService,
|
||||
private seriesService: SeriesService,
|
||||
private arianeService: ArianeService,
|
||||
private dataService: DataService,
|
||||
private advancementService: AdvancementService) {
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@ -46,9 +47,9 @@ export class SeasonScene implements OnInit {
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
} 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++) {
|
||||
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
|
||||
self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
|
||||
}
|
||||
}
|
||||
self.seriesService.get(self.seriesId)
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
|
||||
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 { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { PopInService } from 'common/service';
|
||||
|
||||
export class ElementList {
|
||||
constructor(
|
||||
@ -53,7 +53,7 @@ export class SeriesEditScene implements OnInit {
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteCoverId: UUID = null;
|
||||
private deleteItemId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
@ -73,11 +73,13 @@ export class SeriesEditScene implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
constructor(private dataService: DataService,
|
||||
private typeService: TypeService,
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private seriesService: SeriesService,
|
||||
private typeService: TypeService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService) {
|
||||
private popInService: PopInService,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +88,7 @@ export class SeriesEditScene implements OnInit {
|
||||
let self = this;
|
||||
this.listType = [{ value: null, label: '---' }];
|
||||
|
||||
this.typeService.getData()
|
||||
this.typeService.gets()
|
||||
.then((response2) => {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
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++) {
|
||||
this.coversDisplay.push({
|
||||
id: covers[iii],
|
||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
||||
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -203,7 +205,7 @@ export class SeriesEditScene implements OnInit {
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
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.mediaSize = total;
|
||||
})
|
||||
@ -216,14 +218,14 @@ export class SeriesEditScene implements OnInit {
|
||||
console.log('Can not add the cover in the video...');
|
||||
});
|
||||
}
|
||||
removeCover(id: number) {
|
||||
removeCover(id: UUID) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
||||
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(id: number) {
|
||||
removeCoverAfterConfirm(id: UUID) {
|
||||
console.log(`Request remove cover: ${id}`);
|
||||
let self = this;
|
||||
this.seriesService.deleteCover(this.idSeries, id)
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Season } from 'app/back-api';
|
||||
|
||||
import { SeriesService, DataService, ArianeService, AdvancementService } from 'app/service';
|
||||
import { NodeData } from 'common/model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-series',
|
||||
@ -22,14 +22,15 @@ export class SeriesScene implements OnInit {
|
||||
cover: string = '';
|
||||
covers: Array<string> = [];
|
||||
seasonsError: string = '';
|
||||
seasons: NodeData[] = [];
|
||||
seasons: Season[] = [];
|
||||
videosError: string = '';
|
||||
videos: Array<any> = [];
|
||||
constructor(
|
||||
private advancementService: AdvancementService,
|
||||
private dataService: DataService,
|
||||
private seriesService: SeriesService,
|
||||
private arianeService: ArianeService,
|
||||
private dataService: DataService,
|
||||
private advancementService: AdvancementService) {
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@ -51,9 +52,9 @@ export class SeriesScene implements OnInit {
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
} 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++) {
|
||||
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
|
||||
self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
|
||||
}
|
||||
}
|
||||
updateEnded.seriesMetadata = true;
|
||||
@ -67,7 +68,7 @@ export class SeriesScene implements OnInit {
|
||||
});
|
||||
//console.log(`get parameter id: ${ this.idSeries}`);
|
||||
this.seriesService.getSeason(this.idSeries)
|
||||
.then((response: NodeData[]) => {
|
||||
.then((response: Season[]) => {
|
||||
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
|
||||
self.seasonsError = '';
|
||||
self.seasons = response;
|
||||
@ -80,7 +81,7 @@ export class SeriesScene implements OnInit {
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
});
|
||||
this.seriesService.getVideo(this.idSeries)
|
||||
.then((response: NodeData[]) => {
|
||||
.then((response: Season[]) => {
|
||||
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
|
||||
self.videosError = '';
|
||||
self.videos = response;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { TypeService, DataService, ArianeService, AdvancementService } from 'app/service';
|
||||
|
||||
@ -26,9 +25,9 @@ export class TypeScene implements OnInit {
|
||||
videosError = '';
|
||||
videos = [];
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private typeService: TypeService,
|
||||
private arianeService: ArianeService,
|
||||
private dateService: DataService,
|
||||
private advancementService: AdvancementService) {
|
||||
|
||||
/*
|
||||
@ -54,9 +53,9 @@ export class TypeScene implements OnInit {
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
} 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++) {
|
||||
self.covers.push(self.dateService.getCoverUrl(response.covers[iii]));
|
||||
self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
|
||||
}
|
||||
}
|
||||
}).catch((response) => {
|
||||
|
@ -5,11 +5,9 @@
|
||||
*/
|
||||
|
||||
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 { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { PopInService } from 'common/service';
|
||||
import { TypeService, SeriesService, MediaService, SeasonService } from 'app/service';
|
||||
|
||||
export class ElementList {
|
||||
constructor(
|
||||
@ -23,7 +21,6 @@ export class FileParsedElement {
|
||||
public nameDetected: boolean = false;
|
||||
public episodeDetected: boolean = false;
|
||||
constructor(
|
||||
public id: number,
|
||||
public file: File,
|
||||
public series: string,
|
||||
public season: number,
|
||||
@ -79,7 +76,7 @@ export class UploadScene implements OnInit {
|
||||
*/
|
||||
config = {
|
||||
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
|
||||
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,
|
||||
@ -94,10 +91,11 @@ export class UploadScene implements OnInit {
|
||||
];
|
||||
globalSeries: string = '';
|
||||
globalSeason: number = null;
|
||||
constructor(private typeService: TypeService,
|
||||
private seriesService: SeriesService,
|
||||
constructor(
|
||||
private MediaService: MediaService,
|
||||
private seasonService: SeasonService,
|
||||
private videoService: VideoService,
|
||||
private seriesService: SeriesService,
|
||||
private typeService: TypeService,
|
||||
private popInService: PopInService) {
|
||||
// nothing to do.
|
||||
}
|
||||
@ -124,7 +122,7 @@ export class UploadScene implements OnInit {
|
||||
this.listType = [{ value: null, label: '---' }];
|
||||
this.listSeries = [{ value: null, label: '---' }];
|
||||
this.listSeason = [{ value: null, label: '---' }];
|
||||
this.typeService.getData()
|
||||
this.typeService.gets()
|
||||
.then((response2) => {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
@ -305,7 +303,7 @@ export class UploadScene implements OnInit {
|
||||
}
|
||||
// remove extention
|
||||
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)}`);
|
||||
// add it in the list.
|
||||
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.videoService.uploadFile(eleemnent.file,
|
||||
self.MediaService.uploadFile(eleemnent.file,
|
||||
self.globalSeries,
|
||||
self.seriesId,
|
||||
self.globalSeason,
|
||||
|
@ -5,14 +5,10 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
|
||||
import { DataService, TypeService, SeriesService, VideoService, ArianeService } from 'app/service';
|
||||
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
|
||||
import { NodeData } from 'common/model';
|
||||
import { PopInService } from 'common/service';
|
||||
import { Media } from 'app/model';
|
||||
import { DataService, TypeService, SeriesService, MediaService, ArianeService } from 'app/service';
|
||||
import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Media, Season, Series, UUID } from 'app/back-api';
|
||||
|
||||
export interface ElementList {
|
||||
value?: number;
|
||||
@ -24,27 +20,13 @@ class DataToSend {
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
episode?: number;
|
||||
seriesId: number = null;
|
||||
seasonId: number = null;
|
||||
dataId: number = -1;
|
||||
seriesId?: number;
|
||||
seasonId?: number;
|
||||
dataId?: UUID;
|
||||
time?: number;
|
||||
typeId: number = null;
|
||||
typeId?: number;
|
||||
covers: number[] = [];
|
||||
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({
|
||||
@ -74,7 +56,7 @@ export class VideoEditScene implements OnInit {
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteCoverId: UUID = null;
|
||||
private deleteMediaId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
@ -109,12 +91,13 @@ export class VideoEditScene implements OnInit {
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
constructor(
|
||||
private typeService: TypeService,
|
||||
private dataService: DataService,
|
||||
private MediaService: MediaService,
|
||||
private seriesService: SeriesService,
|
||||
private videoService: VideoService,
|
||||
private typeService: TypeService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService,
|
||||
private dataService: DataService) {
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@ -152,7 +135,7 @@ export class VideoEditScene implements OnInit {
|
||||
this.data.covers.push(covers[iii]);
|
||||
this.coversDisplay.push({
|
||||
id: covers[iii],
|
||||
url: this.dataService.getCoverThumbnailUrl(covers[iii])
|
||||
url: this.dataService.getThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -166,7 +149,7 @@ export class VideoEditScene implements OnInit {
|
||||
this.listUniverse = [{ value: null, label: '---' }];
|
||||
this.listSeries = [{ value: null, label: '---' }];
|
||||
this.listSeason = [{ value: null, label: '---' }];
|
||||
this.typeService.getData()
|
||||
this.typeService.gets()
|
||||
.then((response2) => {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
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)}`);
|
||||
});
|
||||
// this.seriesService.getOrder()
|
||||
this.seriesService.getData()
|
||||
this.seriesService.gets()
|
||||
.then((response3) => {
|
||||
for (let iii = 0; iii < response3.length; iii++) {
|
||||
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
|
||||
@ -184,7 +167,7 @@ export class VideoEditScene implements OnInit {
|
||||
}).catch((response3) => {
|
||||
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
|
||||
});
|
||||
this.videoService.get(this.idVideo)
|
||||
this.MediaService.get(this.idVideo)
|
||||
.then((response: Media) => {
|
||||
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
||||
self.data.name = response.name;
|
||||
@ -199,7 +182,7 @@ export class VideoEditScene implements OnInit {
|
||||
if (self.data.seasonId === undefined) {
|
||||
self.data.seasonId = null;
|
||||
}
|
||||
self.dataOri = self.data.clone();
|
||||
self.dataOri = { ...self.data };
|
||||
self.updateCoverList(response.covers);
|
||||
self.updateNeedSend();
|
||||
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.data = new DataToSend();
|
||||
self.coversDisplay = [];
|
||||
self.dataOri = self.data.clone();
|
||||
self.dataOri = { ...self.data };
|
||||
self.updateNeedSend();
|
||||
self.itemIsNotFound = true;
|
||||
self.itemIsLoading = false;
|
||||
@ -229,7 +212,7 @@ export class VideoEditScene implements OnInit {
|
||||
this.updateNeedSend();
|
||||
if (this.data.typeId !== undefined) {
|
||||
self.typeService.getSubSeries(this.data.typeId)
|
||||
.then((response2: NodeData[]) => {
|
||||
.then((response2: Series[]) => {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
@ -249,7 +232,7 @@ export class VideoEditScene implements OnInit {
|
||||
let self = this;
|
||||
if (this.data.seriesId !== undefined) {
|
||||
self.seriesService.getSeason(this.data.seriesId)
|
||||
.then((response3: NodeData[]) => {
|
||||
.then((response3: Season[]) => {
|
||||
for (let iii = 0; iii < response3.length; iii++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
let tmpp = this.data.clone();
|
||||
const tmpp = { ...this.data };
|
||||
let self = this;
|
||||
this.videoService.patch(this.idVideo, data)
|
||||
this.MediaService.patch(this.idVideo, data)
|
||||
.then((response3) => {
|
||||
self.dataOri = tmpp;
|
||||
self.updateNeedSend();
|
||||
@ -385,14 +368,14 @@ export class VideoEditScene implements OnInit {
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
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.mediaSize = total;
|
||||
})
|
||||
.then((response: any) => {
|
||||
console.log(`get response of cover : ${JSON.stringify(response, null, 2)}`);
|
||||
self.upload.result = 'Cover added done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
// we retrieve the while media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch((response: any) => {
|
||||
// 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.confirmDeleteComment = `Delete the cover ID: ${id}`;
|
||||
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
|
||||
this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(id: number) {
|
||||
removeCoverAfterConfirm(id: UUID) {
|
||||
console.log(`Request remove cover: ${id}`);
|
||||
let self = this;
|
||||
this.videoService.deleteCover(this.idVideo, id)
|
||||
this.MediaService.deleteCover(this.idVideo, id)
|
||||
.then((response: any) => {
|
||||
console.log(`get response of remove cover : ${JSON.stringify(response, null, 2)}`);
|
||||
self.upload.result = 'Cover remove done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
// we retrieve the while media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch((response: any) => {
|
||||
// self.error = "Can not get the data";
|
||||
@ -432,7 +415,7 @@ export class VideoEditScene implements OnInit {
|
||||
}
|
||||
removeItemAfterConfirm(id: number) {
|
||||
let self = this;
|
||||
this.videoService.delete(id)
|
||||
this.MediaService.delete(id)
|
||||
.then((response3) => {
|
||||
// self.dataOri = tmpp;
|
||||
// self.updateNeedSend();
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { UserMediaAdvancement } from 'app/model/user-media-advancement';
|
||||
import { DataService, VideoService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
|
||||
import { HttpWrapperService } from 'common/service';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { UUID, UserMediaAdvancement } from 'app/back-api';
|
||||
import { DataService, MediaService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-video',
|
||||
@ -53,7 +53,7 @@ export class VideoScene implements OnInit {
|
||||
seriesName: string = undefined;
|
||||
seasonId: number = undefined;
|
||||
seasonName: string = undefined;
|
||||
dataId: number = -1;
|
||||
dataId: UUID;
|
||||
time: number = undefined;
|
||||
typeId: number = undefined;
|
||||
generatedName: string = '';
|
||||
@ -74,7 +74,7 @@ export class VideoScene implements OnInit {
|
||||
timeLeft: number = 10;
|
||||
interval = null;
|
||||
|
||||
userMetaData: UserMediaAdvancement & { percentDisplay?: number } = undefined
|
||||
userMetaData: UserMediaAdvancement & { percentDisplay: number } = undefined
|
||||
|
||||
previousTime: number = 0;
|
||||
startPlayingTime: number = undefined;
|
||||
@ -88,13 +88,13 @@ export class VideoScene implements OnInit {
|
||||
registered: false
|
||||
};
|
||||
|
||||
constructor(private videoService: VideoService,
|
||||
private seriesService: SeriesService,
|
||||
private seasonService: SeasonService,
|
||||
private httpService: HttpWrapperService,
|
||||
private arianeService: ArianeService,
|
||||
constructor(
|
||||
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'), '_');
|
||||
// update the path of the uri request
|
||||
this.videoSource = this.httpService.createRESTCall2({
|
||||
api: `data/${this.dataId}/${this.generatedName}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
this.videoSource = this.dataService.getUrl(
|
||||
this.dataId,
|
||||
this.generatedName,
|
||||
);
|
||||
}
|
||||
|
||||
myPeriodicCheckFunction() {
|
||||
@ -209,7 +209,7 @@ export class VideoScene implements OnInit {
|
||||
let self = this;
|
||||
self.haveNext = null;
|
||||
self.havePrevious = null;
|
||||
this.videoService.get(this.idVideo)
|
||||
this.MediaService.get(this.idVideo)
|
||||
.then((response) => {
|
||||
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
|
||||
self.error = '';
|
||||
@ -221,15 +221,12 @@ export class VideoScene implements OnInit {
|
||||
self.dataId = response.dataId;
|
||||
self.time = response.time;
|
||||
self.generatedName = "????????? TODO: ???????" //response.generatedName;
|
||||
if (self.dataId !== -1) {
|
||||
self.videoSource = self.httpService.createRESTCall2({
|
||||
api: `data/${self.dataId}/${self.generatedName}`,
|
||||
addURLToken: true,
|
||||
});
|
||||
if (!isNullOrUndefined(self.dataId)) {
|
||||
self.videoSource = self.dataService.getUrl(self.dataId, self.generatedName);
|
||||
} else {
|
||||
self.videoSource = '';
|
||||
}
|
||||
self.covers = self.dataService.getCoverListUrl(response.covers);
|
||||
self.covers = self.dataService.getListThumbnailUrl(response.covers);
|
||||
|
||||
self.generateName();
|
||||
if (self.seriesId !== undefined && self.seriesId !== null) {
|
||||
@ -271,7 +268,7 @@ export class VideoScene implements OnInit {
|
||||
self.haveNext = response6[iii];
|
||||
}
|
||||
}
|
||||
//self.covers.push(self.dataService.getCoverUrl(response6[iii]));
|
||||
//self.covers.push(self.dataService.getThumbnailUrl(response6[iii]));
|
||||
}
|
||||
}).catch((response7: any) => {
|
||||
|
||||
@ -287,7 +284,7 @@ export class VideoScene implements OnInit {
|
||||
self.episode = undefined;
|
||||
self.seriesId = undefined;
|
||||
self.seasonId = undefined;
|
||||
self.dataId = -1;
|
||||
self.dataId = undefined;
|
||||
self.time = undefined;
|
||||
self.generatedName = '';
|
||||
self.videoSource = '';
|
||||
@ -324,6 +321,12 @@ export class VideoScene implements OnInit {
|
||||
this.startHideTimer();
|
||||
this.playVideo = false;
|
||||
this.displayVolumeMenu = false;
|
||||
|
||||
/*
|
||||
if(this.isFullScreen === true) {
|
||||
this.isFullScreen = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
changeStateToPlay() {
|
||||
@ -451,8 +454,7 @@ export class VideoScene implements OnInit {
|
||||
onStop() {
|
||||
console.log('stop');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
if (isNullOrUndefined(this.videoPlayer)) {
|
||||
console.log(`error element: ${this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
@ -473,8 +475,7 @@ export class VideoScene implements OnInit {
|
||||
seek(newValue: any) {
|
||||
console.log(`seek ${newValue.value}`);
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
if (isNullOrUndefined(this.videoPlayer)) {
|
||||
console.log(`error element: ${this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
@ -484,8 +485,7 @@ export class VideoScene implements OnInit {
|
||||
onRewind() {
|
||||
console.log('rewind');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
if (isNullOrUndefined(this.videoPlayer)) {
|
||||
console.log(`error element: ${this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
@ -495,8 +495,7 @@ export class VideoScene implements OnInit {
|
||||
onForward() {
|
||||
console.log('forward');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
if (isNullOrUndefined(this.videoPlayer)) {
|
||||
console.log(`error element: ${this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
@ -506,8 +505,7 @@ export class VideoScene implements OnInit {
|
||||
onMore() {
|
||||
console.log('more');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
if (isNullOrUndefined(this.videoPlayer)) {
|
||||
console.log(`error element: ${this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
@ -515,8 +513,7 @@ export class VideoScene implements OnInit {
|
||||
onFullscreen() {
|
||||
console.log('fullscreen');
|
||||
this.startHideTimer();
|
||||
if (this.videoGlobal === null ||
|
||||
this.videoGlobal === undefined) {
|
||||
if (isNullOrUndefined(this.videoGlobal)) {
|
||||
console.log(`error element: ${this.videoGlobal}`);
|
||||
return;
|
||||
}
|
||||
@ -537,8 +534,7 @@ export class VideoScene implements OnInit {
|
||||
onFullscreenExit22(docc: any) {
|
||||
console.log('fullscreen EXIT');
|
||||
this.startHideTimer();
|
||||
if (this.videoGlobal === null ||
|
||||
this.videoGlobal === undefined) {
|
||||
if (isNullOrUndefined(this.videoGlobal)) {
|
||||
console.log(`error element: ${this.videoGlobal}`);
|
||||
return;
|
||||
}
|
||||
@ -614,17 +610,18 @@ export class VideoScene implements OnInit {
|
||||
// canvas.crossorigin="anonymous"
|
||||
// convert it and send it to the server
|
||||
let self = this;
|
||||
|
||||
/*
|
||||
this.videoCanva.toBlob((blob) => {
|
||||
self.videoService.uploadCoverBlob(blob, this.idVideo);
|
||||
self.MediaService.uploadCoverBlob(blob, this.idVideo);
|
||||
}, 'image/jpeg', 0.95);
|
||||
|
||||
*/
|
||||
console.log("not implement upload as row data...");
|
||||
/*
|
||||
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
||||
fetch(tmpUrl)
|
||||
.then(res => res.blob()) // Gets the response and returns it as a 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 { HttpWrapperService, BddService } from 'common/service';
|
||||
import { isUserMediaAdvancement, UserMediaAdvancement } from 'app/model/user-media-advancement';
|
||||
import { GenericInterfaceModelDBv2 } from './GenericInterfaceModelDBv2';
|
||||
import { GenericDataService } from './GenericDataService';
|
||||
import { environment } from 'environments/environment';
|
||||
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()
|
||||
export class AdvancementService extends GenericInterfaceModelDBv2<UserMediaAdvancement> {
|
||||
export class AdvancementService extends GenericDataService<UserMediaAdvancement> {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('advancement', http, bdd, isUserMediaAdvancement);
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
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> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -28,10 +42,25 @@ export class AdvancementService extends GenericInterfaceModelDBv2<UserMediaAdvan
|
||||
});
|
||||
}
|
||||
updateTime(id: number, time: number, total: number, addCount: boolean) {
|
||||
this.patch(id, {
|
||||
time: time,
|
||||
const data = {
|
||||
time,
|
||||
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 { SeriesService } from './series';
|
||||
import { SeasonService } from './season';
|
||||
import { VideoService } from './video';
|
||||
import { MediaService } from './media';
|
||||
import { environment } from 'environments/environment';
|
||||
import { NodeData } from 'common/model';
|
||||
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
|
||||
import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Season } from 'app/back-api';
|
||||
|
||||
export class InputOrders {
|
||||
public typeId: number = undefined;
|
||||
@ -27,74 +27,76 @@ export class InputOrders {
|
||||
export class ArianeService {
|
||||
public typeId: number = undefined;
|
||||
public typeName: string = undefined;
|
||||
@Output() typeChange: EventEmitter<number> = new EventEmitter();
|
||||
@Output() typeChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public seriesId: number = undefined;
|
||||
public seriesName: string = undefined;
|
||||
@Output() seriesChange: EventEmitter<number> = new EventEmitter();
|
||||
public seriesId: number = undefined;
|
||||
public seriesName: string = undefined;
|
||||
@Output() seriesChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public seasonId: number = undefined;
|
||||
public seasonName: string = undefined;
|
||||
@Output() seasonChange: EventEmitter<number> = new EventEmitter();
|
||||
public seasonId: number = undefined;
|
||||
public seasonName: string = undefined;
|
||||
@Output() seasonChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public videoId: number = undefined;
|
||||
public videoName: string = undefined;
|
||||
@Output() videoChange: EventEmitter<number> = new EventEmitter();
|
||||
public videoId: number = undefined;
|
||||
public videoName: string = undefined;
|
||||
@Output() videoChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public segment: string = "";
|
||||
@Output() segmentChange: EventEmitter<string> = new EventEmitter();
|
||||
@Output() segmentChange: EventEmitter<string> = new EventEmitter();
|
||||
|
||||
constructor(private router: Router,
|
||||
private typeService: TypeService,
|
||||
private seriesService: SeriesService,
|
||||
private seasonService: SeasonService,
|
||||
private videoService: VideoService) {
|
||||
let self = this;
|
||||
this.router.events.subscribe((event: any) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
// Show progress spinner or progress bar
|
||||
//console.log('>>>>>>>>>>>>>> Route change detected');
|
||||
}
|
||||
constructor(
|
||||
private router: Router,
|
||||
private MediaService: MediaService,
|
||||
private seasonService: SeasonService,
|
||||
private seriesService: SeriesService,
|
||||
private typeService: TypeService,
|
||||
) {
|
||||
let self = this;
|
||||
this.router.events.subscribe((event: any) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
// Show progress spinner or progress bar
|
||||
//console.log('>>>>>>>>>>>>>> Route change detected');
|
||||
}
|
||||
|
||||
if (event instanceof NavigationEnd) {
|
||||
// Hide progress spinner or progress bar
|
||||
//this.currentRoute = event.url;
|
||||
//console.log(`>>>>>>>>>>>> ${event}`);
|
||||
self.updateProperties();
|
||||
}
|
||||
if (event instanceof NavigationEnd) {
|
||||
// Hide progress spinner or progress bar
|
||||
//this.currentRoute = event.url;
|
||||
//console.log(`>>>>>>>>>>>> ${event}`);
|
||||
self.updateProperties();
|
||||
}
|
||||
|
||||
if (event instanceof NavigationError) {
|
||||
// Hide progress spinner or progress bar
|
||||
if (event instanceof NavigationError) {
|
||||
// Hide progress spinner or progress bar
|
||||
|
||||
// Present error to user
|
||||
//console.log(`<<<<<<<<<<<<< ${event.error}`);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
updateParams(params) {
|
||||
console.log(`sparams ${ params}`);
|
||||
console.log(`sparams['typeId'] ${ params.typeId}`);
|
||||
if(params.typeId) {
|
||||
this.setType(params.typeId);
|
||||
} else {
|
||||
this.setType(undefined);
|
||||
}
|
||||
}
|
||||
getCurrrentSegment(): string|undefined {
|
||||
// Present error to user
|
||||
//console.log(`<<<<<<<<<<<<< ${event.error}`);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
updateParams(params) {
|
||||
console.log(`sparams ${params}`);
|
||||
console.log(`sparams['typeId'] ${params.typeId}`);
|
||||
if (params.typeId) {
|
||||
this.setType(params.typeId);
|
||||
} else {
|
||||
this.setType(undefined);
|
||||
}
|
||||
}
|
||||
getCurrrentSegment(): string | undefined {
|
||||
return this.segment;
|
||||
}
|
||||
|
||||
getIsParam(params: any, name: string): undefined|number {
|
||||
let valueStr = params.get(name);
|
||||
if(isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
||||
return undefined;
|
||||
}
|
||||
return parseInt(valueStr, 10);
|
||||
getIsParam(params: any, name: string): undefined | number {
|
||||
let valueStr = params.get(name);
|
||||
if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
|
||||
return undefined;
|
||||
}
|
||||
return parseInt(valueStr, 10);
|
||||
|
||||
}
|
||||
|
||||
updateProperties() {
|
||||
updateProperties() {
|
||||
let elem = this.router.routerState.root;
|
||||
while (!isNullOrUndefined(elem.firstChild)) {
|
||||
elem = elem.firstChild;
|
||||
@ -121,231 +123,231 @@ export class ArianeService {
|
||||
|
||||
|
||||
|
||||
let typeId = this.getIsParam(params, 'typeId');
|
||||
let seriesId = this.getIsParam(params, 'seriesId');
|
||||
let seasonId = this.getIsParam(params, 'seasonId');
|
||||
let videoId = this.getIsParam(params, 'videoId');
|
||||
let typeId = this.getIsParam(params, 'typeId');
|
||||
let seriesId = this.getIsParam(params, 'seriesId');
|
||||
let seasonId = this.getIsParam(params, 'seasonId');
|
||||
let videoId = this.getIsParam(params, 'videoId');
|
||||
|
||||
this.setType(typeId);
|
||||
this.setSeries(seriesId);
|
||||
this.setSeason(seasonId);
|
||||
this.setVideo(videoId);
|
||||
}
|
||||
reset():void {
|
||||
this.typeId = undefined;
|
||||
this.typeName = undefined;
|
||||
this.typeChange.emit(this.typeId);
|
||||
this.seriesId = undefined;
|
||||
this.seriesName = undefined;
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
this.seasonId = undefined;
|
||||
this.seasonName = undefined;
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
this.videoId = undefined;
|
||||
this.videoName = undefined;
|
||||
this.videoChange.emit(this.videoId);
|
||||
}
|
||||
this.setType(typeId);
|
||||
this.setSeries(seriesId);
|
||||
this.setSeason(seasonId);
|
||||
this.setVideo(videoId);
|
||||
}
|
||||
reset(): void {
|
||||
this.typeId = undefined;
|
||||
this.typeName = undefined;
|
||||
this.typeChange.emit(this.typeId);
|
||||
this.seriesId = undefined;
|
||||
this.seriesName = undefined;
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
this.seasonId = undefined;
|
||||
this.seasonName = undefined;
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
this.videoId = undefined;
|
||||
this.videoName = undefined;
|
||||
this.videoChange.emit(this.videoId);
|
||||
}
|
||||
|
||||
/*
|
||||
getCurrentRoute():InputOrders {
|
||||
let out = new InputOrders()
|
||||
out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||
if (out.typeId === 0){
|
||||
out.typeId = undefined;
|
||||
}
|
||||
out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
|
||||
if (out.seriesId === 0){
|
||||
out.seriesId = undefined;
|
||||
}
|
||||
out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
|
||||
if (out.seasonId === 0){
|
||||
out.seasonId = undefined;
|
||||
}
|
||||
out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
|
||||
if (out.videoId === 0){
|
||||
out.videoId = undefined;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/*
|
||||
getCurrentRoute():InputOrders {
|
||||
let out = new InputOrders()
|
||||
out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||
if (out.typeId === 0){
|
||||
out.typeId = undefined;
|
||||
}
|
||||
out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
|
||||
if (out.seriesId === 0){
|
||||
out.seriesId = undefined;
|
||||
}
|
||||
out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
|
||||
if (out.seasonId === 0){
|
||||
out.seasonId = undefined;
|
||||
}
|
||||
out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
|
||||
if (out.videoId === 0){
|
||||
out.videoId = undefined;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
routeTo(data:InputOrders, destination:string = null) {
|
||||
routeTo = ""
|
||||
//if (
|
||||
this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
|
||||
}
|
||||
*/
|
||||
routeTo(data:InputOrders, destination:string = null) {
|
||||
routeTo = ""
|
||||
//if (
|
||||
this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
|
||||
}
|
||||
*/
|
||||
|
||||
setType(id:number):void {
|
||||
if(this.typeId === id) {
|
||||
return;
|
||||
}
|
||||
this.typeId = id;
|
||||
this.typeName = '??--??';
|
||||
if(isUndefined(this.typeId)) {
|
||||
this.typeChange.emit(this.typeId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.typeService.get(id)
|
||||
.then((response) => {
|
||||
self.typeName = response.name;
|
||||
self.typeChange.emit(self.typeId);
|
||||
}).catch((response) => {
|
||||
self.typeChange.emit(self.typeId);
|
||||
});
|
||||
}
|
||||
getTypeId():number|undefined {
|
||||
return this.typeId;
|
||||
}
|
||||
getTypeName():string|undefined {
|
||||
return this.typeName;
|
||||
}
|
||||
setType(id: number): void {
|
||||
if (this.typeId === id) {
|
||||
return;
|
||||
}
|
||||
this.typeId = id;
|
||||
this.typeName = '??--??';
|
||||
if (isUndefined(this.typeId)) {
|
||||
this.typeChange.emit(this.typeId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.typeService.get(id)
|
||||
.then((response) => {
|
||||
self.typeName = response.name;
|
||||
self.typeChange.emit(self.typeId);
|
||||
}).catch((response) => {
|
||||
self.typeChange.emit(self.typeId);
|
||||
});
|
||||
}
|
||||
getTypeId(): number | undefined {
|
||||
return this.typeId;
|
||||
}
|
||||
getTypeName(): string | undefined {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
setSeries(id:number|undefined):void {
|
||||
if(this.seriesId === id) {
|
||||
return;
|
||||
}
|
||||
this.seriesId = id;
|
||||
this.seriesName = '??--??';
|
||||
if(isUndefined(this.seriesId)) {
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seriesService.get(id)
|
||||
.then((response: NodeData) => {
|
||||
self.seriesName = response.name;
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
}).catch((response) => {
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
});
|
||||
}
|
||||
getSeriesId():number {
|
||||
return this.seriesId;
|
||||
}
|
||||
getSeriesName():string {
|
||||
return this.seriesName;
|
||||
}
|
||||
setSeries(id: number | undefined): void {
|
||||
if (this.seriesId === id) {
|
||||
return;
|
||||
}
|
||||
this.seriesId = id;
|
||||
this.seriesName = '??--??';
|
||||
if (isUndefined(this.seriesId)) {
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seriesService.get(id)
|
||||
.then((response: Season) => {
|
||||
self.seriesName = response.name;
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
}).catch((response) => {
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
});
|
||||
}
|
||||
getSeriesId(): number {
|
||||
return this.seriesId;
|
||||
}
|
||||
getSeriesName(): string {
|
||||
return this.seriesName;
|
||||
}
|
||||
|
||||
setSeason(id:number|undefined):void {
|
||||
if(this.seasonId === id) {
|
||||
return;
|
||||
}
|
||||
this.seasonId = id;
|
||||
this.seasonName = '??--??';
|
||||
if(isUndefined(this.seasonId)) {
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seasonService.get(id)
|
||||
.then((response: NodeData) => {
|
||||
// self.setSeries(response.seriesId);
|
||||
self.seasonName = response.name;
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
}).catch((response) => {
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
});
|
||||
}
|
||||
getSeasonId():number {
|
||||
return this.seasonId;
|
||||
}
|
||||
getSeasonName():string {
|
||||
return this.seasonName;
|
||||
}
|
||||
setSeason(id: number | undefined): void {
|
||||
if (this.seasonId === id) {
|
||||
return;
|
||||
}
|
||||
this.seasonId = id;
|
||||
this.seasonName = '??--??';
|
||||
if (isUndefined(this.seasonId)) {
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seasonService.get(id)
|
||||
.then((response: Season) => {
|
||||
// self.setSeries(response.seriesId);
|
||||
self.seasonName = response.name;
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
}).catch((response) => {
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
});
|
||||
}
|
||||
getSeasonId(): number {
|
||||
return this.seasonId;
|
||||
}
|
||||
getSeasonName(): string {
|
||||
return this.seasonName;
|
||||
}
|
||||
|
||||
setVideo(id:number|undefined):void {
|
||||
if(this.videoId === id) {
|
||||
return;
|
||||
}
|
||||
this.videoId = id;
|
||||
this.videoName = '??--??';
|
||||
if(isUndefined(this.videoId)) {
|
||||
this.videoChange.emit(this.videoId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.videoService.get(id)
|
||||
.then((response) => {
|
||||
// self.setSeason(response.seasonId);
|
||||
// self.setSeries(response.seriesId);
|
||||
self.videoName = response.name;
|
||||
self.videoChange.emit(self.videoId);
|
||||
}).catch((response) => {
|
||||
self.videoChange.emit(self.videoId);
|
||||
});
|
||||
}
|
||||
getVideoId():number {
|
||||
return this.videoId;
|
||||
}
|
||||
getVideoName():string {
|
||||
return this.videoName;
|
||||
}
|
||||
setVideo(id: number | undefined): void {
|
||||
if (this.videoId === id) {
|
||||
return;
|
||||
}
|
||||
this.videoId = id;
|
||||
this.videoName = '??--??';
|
||||
if (isUndefined(this.videoId)) {
|
||||
this.videoChange.emit(this.videoId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.MediaService.get(id)
|
||||
.then((response) => {
|
||||
// self.setSeason(response.seasonId);
|
||||
// self.setSeries(response.seriesId);
|
||||
self.videoName = response.name;
|
||||
self.videoChange.emit(self.videoId);
|
||||
}).catch((response) => {
|
||||
self.videoChange.emit(self.videoId);
|
||||
});
|
||||
}
|
||||
getVideoId(): number {
|
||||
return this.videoId;
|
||||
}
|
||||
getVideoName(): string {
|
||||
return this.videoName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic navigation on the browser.
|
||||
* @param destination - new destination url
|
||||
* @param typeId - type IF
|
||||
* @param seriesId - series real ID
|
||||
* @param seasonId - season ID
|
||||
* @param videoId - Video ID
|
||||
* @param newWindows - open in a new windows
|
||||
* @param replaceCurrentPage - consider the curent page is removed from history
|
||||
*/
|
||||
genericNavigate(
|
||||
destination:string,
|
||||
typeId:number,
|
||||
seriesId:number,
|
||||
seasonId:number,
|
||||
videoId:number,
|
||||
newWindows:boolean = false,
|
||||
replaceCurrentPage: boolean = false): void {
|
||||
let addressOffset = `${ destination }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId }`;
|
||||
if(newWindows === true) {
|
||||
window.open(`/${ addressOffset}`);
|
||||
} else {
|
||||
this.router.navigate([ addressOffset ], { replaceUrl: replaceCurrentPage });
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generic navigation on the browser.
|
||||
* @param destination - new destination url
|
||||
* @param typeId - type IF
|
||||
* @param seriesId - series real ID
|
||||
* @param seasonId - season ID
|
||||
* @param videoId - Video ID
|
||||
* @param newWindows - open in a new windows
|
||||
* @param replaceCurrentPage - consider the curent page is removed from history
|
||||
*/
|
||||
genericNavigate(
|
||||
destination: string,
|
||||
typeId: number,
|
||||
seriesId: number,
|
||||
seasonId: number,
|
||||
videoId: number,
|
||||
newWindows: boolean = false,
|
||||
replaceCurrentPage: boolean = false): void {
|
||||
let addressOffset = `${destination}/${typeId}/${seriesId}/${seasonId}/${videoId}`;
|
||||
if (newWindows === true) {
|
||||
window.open(`/${addressOffset}`);
|
||||
} else {
|
||||
this.router.navigate([addressOffset], { replaceUrl: replaceCurrentPage });
|
||||
}
|
||||
}
|
||||
|
||||
navigateType(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateTypeEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('type', id, null, null, null, newWindows);
|
||||
}
|
||||
navigateTypeEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('type-edit', id, null, null, null, newWindows);
|
||||
}
|
||||
navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateSeriesEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('series', this.typeId, id, null, null, newWindows);
|
||||
}
|
||||
navigateSeriesEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('series-edit', this.typeId, id, null, null, newWindows);
|
||||
}
|
||||
navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateSeasonEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('season', this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
|
||||
}
|
||||
navigateSeasonEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('season-edit', this.typeId, this.seriesId, id, null, newWindows);
|
||||
}
|
||||
navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateVideoEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('video', this.typeId, this.seriesId, this.seasonId, id, newWindows);
|
||||
}
|
||||
navigateVideoEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('video-edit', this.typeId, this.seriesId, this.seasonId, id, newWindows);
|
||||
}
|
||||
navigateType(id: number, newWindows: boolean, ctrl: boolean = false): void {
|
||||
if (ctrl === true) {
|
||||
this.navigateTypeEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('type', id, null, null, null, newWindows);
|
||||
}
|
||||
navigateTypeEdit(id: number, newWindows: boolean): void {
|
||||
this.genericNavigate('type-edit', id, null, null, null, newWindows);
|
||||
}
|
||||
navigateSeries(id: number, newWindows: boolean, ctrl: boolean = false): void {
|
||||
if (ctrl === true) {
|
||||
this.navigateSeriesEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('series', this.typeId, id, null, null, newWindows);
|
||||
}
|
||||
navigateSeriesEdit(id: number, newWindows: boolean): void {
|
||||
this.genericNavigate('series-edit', this.typeId, id, null, null, newWindows);
|
||||
}
|
||||
navigateSeason(id: number, newWindows: boolean, ctrl: boolean = false, replaceCurrentPage: boolean = false): void {
|
||||
if (ctrl === true) {
|
||||
this.navigateSeasonEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('season', this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
|
||||
}
|
||||
navigateSeasonEdit(id: number, newWindows: boolean): void {
|
||||
this.genericNavigate('season-edit', this.typeId, this.seriesId, id, null, newWindows);
|
||||
}
|
||||
navigateVideo(id: number, newWindows: boolean, ctrl: boolean = false): void {
|
||||
if (ctrl === true) {
|
||||
this.navigateVideoEdit(id, newWindows);
|
||||
return;
|
||||
}
|
||||
this.genericNavigate('video', this.typeId, this.seriesId, this.seasonId, id, newWindows);
|
||||
}
|
||||
navigateVideoEdit(id: number, newWindows: boolean): void {
|
||||
this.genericNavigate('video-edit', this.typeId, this.seriesId, this.seasonId, id, newWindows);
|
||||
}
|
||||
}
|
||||
|
@ -5,97 +5,112 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { isArrayOf, isNumberFinite } from 'common/utils';
|
||||
|
||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
|
||||
import { SessionService, isArrayOf, isNullOrUndefined, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { UUID } from 'app/back-api';
|
||||
import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class DataService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private serviceName:string = 'data';
|
||||
|
||||
constructor(private http: HttpWrapperService) {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karideo,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private session: SessionService) {
|
||||
console.log('Start DataService');
|
||||
}
|
||||
|
||||
getData():any {
|
||||
return this.http.getSpecific(this.serviceName);
|
||||
}
|
||||
|
||||
get(_id:number):any {
|
||||
return this.http.getSpecific([this.serviceName, _id]);
|
||||
}
|
||||
|
||||
uploadFile(_form:FormData, _progress:any = null) {
|
||||
// return this.http.uploadFileMultipart(this.serviceName, null, _file);
|
||||
return this.http.uploadMultipart(`${this.serviceName }/upload/`, _form, _progress);
|
||||
}
|
||||
|
||||
getImage(_id:number) : Promise<ModelResponseHttp> {
|
||||
return this.http.requestImage({
|
||||
endPoint: this.serviceName,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.IMAGE,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
});
|
||||
}
|
||||
getImageThumbnail(_id:number) : Promise<ModelResponseHttp> {
|
||||
return this.http.requestImage({
|
||||
endPoint: this.serviceName + "/thumbnail/" + _id,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.ALL,//IMAGE,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Retreive the Cover URL of a specific data id
|
||||
* Retrieve the Cover URL of a specific data id
|
||||
* @param coverId Id of te cover
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverUrl(coverId: number): string {
|
||||
return this.http.createRESTCall2({
|
||||
api: `data/${coverId}`,
|
||||
addURLToken: true,
|
||||
getUrl(dataId: UUID, optionalName?: string): string {
|
||||
if (isNullOrUndefined(optionalName)) {
|
||||
const url = RESTUrl({
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverListUrl(coverIds?: number[]): string[] | undefined {
|
||||
if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
||||
getListUrl(dataIds?: UUID[]): string[] | undefined {
|
||||
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
let covers = [] as string[];
|
||||
for(let iii = 0; iii < coverIds.length; iii++) {
|
||||
covers.push(this.getCoverUrl(coverIds[iii]));
|
||||
let covers: string[] = [];
|
||||
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||
covers.push(this.getUrl(dataIds[iii]));
|
||||
}
|
||||
return covers;
|
||||
}
|
||||
/**
|
||||
* Retreive the thumbnail cover URL of a specific data id
|
||||
* Retrieve the thumbnail cover URL of a specific data id
|
||||
* @param coverId Id of te cover
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverThumbnailUrl(coverId: number): string {
|
||||
return this.http.createRESTCall2({
|
||||
api: `data/thumbnail/${coverId}`,
|
||||
addURLToken: true,
|
||||
getThumbnailUrl(coverId: UUID): string {
|
||||
const url = RESTUrl({
|
||||
restModel: {
|
||||
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
|
||||
* @returns the url of the cover
|
||||
*/
|
||||
getCoverListThumbnailUrl(coverIds?: number[]): string[] | undefined {
|
||||
if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
|
||||
getListThumbnailUrl(dataIds?: UUID[]): string[] | undefined {
|
||||
if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
let covers = [] as string[];
|
||||
for(let iii = 0; iii < coverIds.length; iii++) {
|
||||
covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
|
||||
let covers: string[] = [];
|
||||
for (let iii = 0; iii < dataIds.length; iii++) {
|
||||
covers.push(this.getThumbnailUrl(dataIds[iii]));
|
||||
}
|
||||
return covers;
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ import { DataService } from "./data";
|
||||
import { SeasonService } from "./season";
|
||||
import { SeriesService } from "./series";
|
||||
import { TypeService } from "./type";
|
||||
import { VideoService } from "./video";
|
||||
import { MediaService } from "./media";
|
||||
|
||||
|
||||
|
||||
export {
|
||||
ArianeService,
|
||||
DataService,
|
||||
AdvancementService,
|
||||
MediaService,
|
||||
SeasonService,
|
||||
SeriesService,
|
||||
TypeService,
|
||||
VideoService,
|
||||
AdvancementService
|
||||
ArianeService,
|
||||
};
|
||||
|
||||
|
||||
|
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 { 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()
|
||||
export class SeasonService extends GenericInterfaceModelDB {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('season', http, bdd);
|
||||
export class SeasonService extends GenericDataService<Season> {
|
||||
|
||||
|
||||
getRestConfig(): RESTConfig {
|
||||
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
|
||||
* @param id - Id of the season.
|
||||
* @returns a promise on the list of video elements
|
||||
*/
|
||||
getVideo(id:number): Promise<NodeData[]> {
|
||||
getVideo(id: number): Promise<Media[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: id,
|
||||
},
|
||||
],
|
||||
[ 'episode', 'name' ]);
|
||||
self.MediaService.getsWhere(
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: id,
|
||||
},
|
||||
],
|
||||
['episode', 'name'])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((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.
|
||||
* @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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: id,
|
||||
},
|
||||
]);
|
||||
self.MediaService.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: id,
|
||||
},
|
||||
])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((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 { HttpWrapperService, BddService } from 'common/service';
|
||||
import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
|
||||
import { isNodeData, NodeData } from 'common/model';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Media, Season, Series, SeriesResource, UUID } from 'app/back-api';
|
||||
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
import { GenericDataService } from './GenericDataService';
|
||||
import { SeasonService, MediaService } from '.';
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class SeriesService extends GenericInterfaceModelDB {
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('series', http, bdd);
|
||||
export class SeriesService extends GenericDataService<Series> {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karideo,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
private lambdaGets(): Promise<Series[]> {
|
||||
return SeriesResource.gets({ restConfig: this.getRestConfig() });
|
||||
}
|
||||
|
||||
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' ]);
|
||||
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);
|
||||
});
|
||||
});
|
||||
constructor(
|
||||
private session: SessionService,
|
||||
private MediaService: MediaService,
|
||||
private seasonService: SeasonService,
|
||||
) {
|
||||
super();
|
||||
console.log('Start SeriesService');
|
||||
const self = this;
|
||||
this.setStore(new DataStore<Series>(() => self.lambdaGets()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,23 +43,23 @@ export class SeriesService extends GenericInterfaceModelDB {
|
||||
* @param id - Id of the series.
|
||||
* @returns a promise on the list of video elements
|
||||
*/
|
||||
getVideo(id:number): Promise<NodeData[]> {
|
||||
getVideo(id: number): Promise<Media[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
[ 'episode', 'name' ]);
|
||||
self.MediaService.getsWhere(
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seasonId',
|
||||
value: undefined,
|
||||
},
|
||||
],
|
||||
['episode', 'name'])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
@ -79,20 +72,21 @@ export class SeriesService extends GenericInterfaceModelDB {
|
||||
* @param id - Id of the series.
|
||||
* @returns The number of video present in this series
|
||||
*/
|
||||
countVideo(id:number): Promise<number> {
|
||||
countVideo(id: number): Promise<number> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: id,
|
||||
},
|
||||
]);
|
||||
self.MediaService.getsWhere(
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: id,
|
||||
},
|
||||
])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
@ -103,42 +97,109 @@ export class SeriesService extends GenericInterfaceModelDB {
|
||||
* @param id - ID of the series
|
||||
* @returns the required List.
|
||||
*/
|
||||
getSeason(id:number): Promise<NodeData[]> {
|
||||
getSeason(id: number): Promise<Season[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('season')
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'parentId',
|
||||
value: id,
|
||||
},
|
||||
], [ 'id' ]);
|
||||
self.seasonService.getsWhere(
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'parentId',
|
||||
value: id,
|
||||
},
|
||||
], ['id'])
|
||||
.then((data: Season[]) => {
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getLike(nameSeries:string):any {
|
||||
let self = this;
|
||||
|
||||
patch(id: number, data: Series): Promise<Series> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('series')
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getNameLike(nameSeries);
|
||||
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);
|
||||
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;
|
||||
return new Promise((resolve, reject) => {
|
||||
SeriesResource.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) => {
|
||||
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 { HttpWrapperService, BddService } from 'common/service';
|
||||
import { DataInterface, isNullOrUndefined, TypeCheck } from 'common/utils';
|
||||
import { NodeData } from 'common/model';
|
||||
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
|
||||
import { Media, Series, Type, TypeResource } from 'app/back-api';
|
||||
import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
import { GenericDataService } from './GenericDataService';
|
||||
import { MediaService } from './media';
|
||||
import { SeriesService } from './series';
|
||||
|
||||
export interface MessageLogIn {
|
||||
id: number;
|
||||
@ -18,88 +21,65 @@ export interface MessageLogIn {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TypeService extends GenericInterfaceModelDB {
|
||||
export class TypeService extends GenericDataService<Type> {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karideo,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
private lambdaGets(): Promise<Type[]> {
|
||||
return TypeResource.gets({ restConfig: this.getRestConfig() });
|
||||
}
|
||||
|
||||
constructor(http: HttpWrapperService,
|
||||
bdd: BddService) {
|
||||
super('type', http, bdd);
|
||||
constructor(private session: SessionService,
|
||||
private MediaService: MediaService,
|
||||
private seriesService: SeriesService,
|
||||
) {
|
||||
super();
|
||||
console.log('Start TypeService');
|
||||
const self = this;
|
||||
this.setStore(new DataStore<Type>(() => self.lambdaGets()));
|
||||
}
|
||||
|
||||
|
||||
get(id:number): Promise<NodeData> {
|
||||
countVideo(id: number): Promise<number> {
|
||||
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);
|
||||
}).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> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
} ] );
|
||||
self.MediaService.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getSubVideo(id:number): Promise<NodeData[]> {
|
||||
getSubVideo(id: number): Promise<Media[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: undefined,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'universeId',
|
||||
value: undefined,
|
||||
},
|
||||
], [ 'name' ] );
|
||||
self.MediaService.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: undefined,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'universeId',
|
||||
value: undefined,
|
||||
},
|
||||
], ['name'])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
@ -107,48 +87,49 @@ export class TypeService extends GenericInterfaceModelDB {
|
||||
});
|
||||
}
|
||||
|
||||
getSubSeries(id:number): Promise<NodeData[]> {
|
||||
getSubSeries(id: number): Promise<Series[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('series')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'parentId',
|
||||
value: id,
|
||||
} ],
|
||||
[ 'name' ]);
|
||||
resolve([]);
|
||||
/*
|
||||
self.seriesService.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'parentId',
|
||||
value: id,
|
||||
}],
|
||||
['name'])
|
||||
.then((data: Series[]) => {
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
})
|
||||
.catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
getSubUniverse(id:number): Promise<NodeData[]> {
|
||||
getSubUniverse(id: number): Promise<any[]> {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get('video')
|
||||
.then((response: DataInterface) => {
|
||||
let data = response.getsWhere([
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: [undefined, null],
|
||||
}, {
|
||||
check: TypeCheck.NOT_EQUAL,
|
||||
key: 'universeId',
|
||||
value: undefined,
|
||||
},
|
||||
]);
|
||||
//, [ 'universId' ]);
|
||||
self.MediaService.getsWhere(
|
||||
[
|
||||
{
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'typeId',
|
||||
value: id,
|
||||
}, {
|
||||
check: TypeCheck.EQUAL,
|
||||
key: 'seriesId',
|
||||
value: [undefined, null],
|
||||
}, {
|
||||
check: TypeCheck.NOT_EQUAL,
|
||||
key: 'universeId',
|
||||
value: undefined,
|
||||
},
|
||||
])
|
||||
.then((data: Media[]) => {
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch((response: any) => {
|
||||
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.
|
||||
// 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,
|
||||
// URL of development API
|
||||
applName: "karideo",
|
||||
|
@ -3,9 +3,11 @@
|
||||
// `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`.
|
||||
|
||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||
|
||||
const serverSSOAddress = 'http://atria-soft.org'
|
||||
|
||||
const environment_back_prod = {
|
||||
const environment_back_prod: Environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
applName: "karideo",
|
||||
@ -21,7 +23,7 @@ const environment_back_prod = {
|
||||
tokenStoredInPermanentStorage: false,
|
||||
};
|
||||
|
||||
const environment_local = {
|
||||
const environment_local: Environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
applName: "karideo",
|
||||
@ -37,7 +39,7 @@ const environment_local = {
|
||||
tokenStoredInPermanentStorage: false,
|
||||
};
|
||||
|
||||
const environment_hybrid = {
|
||||
const environment_hybrid: Environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
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",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es2018",
|
||||
"target": "es2022",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"es2018",
|
||||
"ES2022",
|
||||
"dom"
|
||||
],
|
||||
"module": "es2020",
|
||||
"module": "es2022",
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@app/*": ["./src/app/*"],
|
||||
"@common/*": ["./src/common/*"]
|
||||
"@app/*": [
|
||||
"./src/app/*"
|
||||
],
|
||||
"@common/*": [
|
||||
"./src/common/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user