From 6210dfc16e74d07b03a5225c92dd35cf390647c5 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 19 Jan 2024 01:01:44 +0100 Subject: [PATCH] [DEV] update to the new system --- back/pom.xml | 4 +- .../src/org/kar/karideo/WebLauncherLocal.java | 8 +- .../org/kar/karideo/api/SeasonResource.java | 26 +- .../org/kar/karideo/api/SeriesResource.java | 26 +- .../src/org/kar/karideo/api/TypeResource.java | 28 +- .../api/UserMediaAdvancementResource.java | 30 +-- .../org/kar/karideo/api/VideoResource.java | 30 +-- .../karideo/migration/Migration20231015.java | 12 +- back/src/org/kar/karideo/model/Season.java | 10 +- back/src/org/kar/karideo/model/Series.java | 10 +- back/src/org/kar/karideo/model/Type.java | 8 +- .../karideo/model/UserMediaAdvancement.java | 12 +- .../src/app/scene/season-edit/season-edit.ts | 82 +++--- .../src/app/scene/series-edit/series-edit.ts | 114 ++++---- front/src/app/scene/video-edit/video-edit.ts | 244 +++++++++--------- .../app/service/GenericInterfaceModelDB.ts | 68 ++--- .../app/service/GenericInterfaceModelDBv2.ts | 4 +- front/src/app/service/advancement.ts | 2 +- front/src/common | 2 +- 19 files changed, 359 insertions(+), 361 deletions(-) diff --git a/back/pom.xml b/back/pom.xml index 406076d..3254296 100644 --- a/back/pom.xml +++ b/back/pom.xml @@ -6,8 +6,8 @@ 0.2.0 3.1 - 17 - 17 + 21 + 21 3.1.1 diff --git a/back/src/org/kar/karideo/WebLauncherLocal.java b/back/src/org/kar/karideo/WebLauncherLocal.java index e0a8f61..f73c769 100755 --- a/back/src/org/kar/karideo/WebLauncherLocal.java +++ b/back/src/org/kar/karideo/WebLauncherLocal.java @@ -7,9 +7,9 @@ import org.slf4j.LoggerFactory; public class WebLauncherLocal extends WebLauncher { private final static Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class); - + private WebLauncherLocal() {} - + public static void main(final String[] args) throws InterruptedException { final WebLauncherLocal launcher = new WebLauncherLocal(); launcher.process(); @@ -17,13 +17,13 @@ public class WebLauncherLocal extends WebLauncher { Thread.currentThread().join(); LOGGER.info("STOP the REST server:"); } - + @Override public void process() throws InterruptedException { if (true) { // for local test: ConfigBaseVariable.apiAdress = "http://0.0.0.0:18080/karideo/api/"; - ConfigBaseVariable.dbPort = "3307"; + ConfigBaseVariable.dbPort = "3906"; } try { super.migrateDB(); diff --git a/back/src/org/kar/karideo/api/SeasonResource.java b/back/src/org/kar/karideo/api/SeasonResource.java index 2bea035..62ec4b6 100644 --- a/back/src/org/kar/karideo/api/SeasonResource.java +++ b/back/src/org/kar/karideo/api/SeasonResource.java @@ -19,8 +19,8 @@ import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; +import jakarta.ws.rs.PATCH; import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @@ -31,20 +31,20 @@ import jakarta.ws.rs.core.Response; @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 get() throws Exception { return DataAccess.gets(Season.class); } - + @GET @Path("{id}") @RolesAllowed("USER") @@ -52,19 +52,19 @@ public class SeasonResource { public Season get(@PathParam("id") final Long id) throws Exception { return DataAccess.get(Season.class, id); } - + /* ============================================================================= * ADMIN SECTION: * ============================================================================= */ - + @POST @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) public Season put(final String jsonRequest) throws Exception { return DataAccess.insertWithJson(Season.class, jsonRequest); } - - @PUT + + @PATCH @Path("{id}") @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) @@ -72,7 +72,7 @@ public class SeasonResource { DataAccess.updateWithJson(Season.class, id, jsonRequest); return DataAccess.get(Season.class, id); } - + @DELETE @Path("{id}") @RolesAllowed("ADMIN") @@ -80,7 +80,7 @@ public class SeasonResource { DataAccess.delete(Season.class, id); return Response.ok().build(); } - + @POST @Path("{id}/add_cover") @RolesAllowed("ADMIN") @@ -89,7 +89,7 @@ public class SeasonResource { @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData); } - + @GET @Path("{id}/rm_cover/{coverId}") @RolesAllowed("ADMIN") @@ -97,7 +97,7 @@ public class SeasonResource { AddOnManyToMany.removeLink(Season.class, id, "cover", coverId); return Response.ok(DataAccess.get(Season.class, id)).build(); } - + public static Season getOrCreate(final String name, final Long seriesId) { try { Season out = DataAccess.getWhere(Season.class, new Condition(new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", seriesId)))); @@ -114,5 +114,5 @@ public class SeasonResource { } return null; } - + } diff --git a/back/src/org/kar/karideo/api/SeriesResource.java b/back/src/org/kar/karideo/api/SeriesResource.java index 3497759..c8a6d6d 100644 --- a/back/src/org/kar/karideo/api/SeriesResource.java +++ b/back/src/org/kar/karideo/api/SeriesResource.java @@ -19,8 +19,8 @@ import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; +import jakarta.ws.rs.PATCH; import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @@ -31,20 +31,20 @@ import jakarta.ws.rs.core.Response; @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 get() throws Exception { return DataAccess.gets(Series.class); } - + @GET @Path("{id}") @RolesAllowed("USER") @@ -52,19 +52,19 @@ public class SeriesResource { public Series get(@PathParam("id") final Long id) throws Exception { return DataAccess.get(Series.class, id); } - + /* ============================================================================= * ADMIN SECTION: * ============================================================================= */ - + @POST @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) public Series put(final String jsonRequest) throws Exception { return DataAccess.insertWithJson(Series.class, jsonRequest); } - - @PUT + + @PATCH @Path("{id}") @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) @@ -72,7 +72,7 @@ public class SeriesResource { DataAccess.updateWithJson(Series.class, id, jsonRequest); return DataAccess.get(Series.class, id); } - + @DELETE @Path("{id}") @RolesAllowed("ADMIN") @@ -80,7 +80,7 @@ public class SeriesResource { DataAccess.delete(Series.class, id); return Response.ok().build(); } - + @POST @Path("{id}/add_cover") @RolesAllowed("ADMIN") @@ -89,7 +89,7 @@ public class SeriesResource { @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData); } - + @GET @Path("{id}/rm_cover/{coverId}") @RolesAllowed("ADMIN") @@ -97,7 +97,7 @@ public class SeriesResource { AddOnManyToMany.removeLink(Series.class, id, "cover", coverId); return Response.ok(DataAccess.get(Series.class, id)).build(); } - + public static Series getOrCreate(final String name, final Long typeId) { try { Series out = DataAccess.getWhere(Series.class, new Condition(new QueryAnd(new QueryCondition("name", "=", name), new QueryCondition("parentId", "=", typeId)))); @@ -114,5 +114,5 @@ public class SeriesResource { } return null; } - + } diff --git a/back/src/org/kar/karideo/api/TypeResource.java b/back/src/org/kar/karideo/api/TypeResource.java index aeeaa22..bddc965 100644 --- a/back/src/org/kar/karideo/api/TypeResource.java +++ b/back/src/org/kar/karideo/api/TypeResource.java @@ -18,8 +18,8 @@ import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; +import jakarta.ws.rs.PATCH; import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @@ -30,20 +30,20 @@ import jakarta.ws.rs.core.Response; @Produces({ MediaType.APPLICATION_XML, 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 get() throws Exception { return DataAccess.gets(Type.class); } - + @GET @Path("{id}") @RolesAllowed("USER") @@ -51,23 +51,23 @@ public class TypeResource { public Type get(@PathParam("id") final Long id) throws Exception { return DataAccess.get(Type.class, id); } - + public static Type getId(final Long id) throws Exception { return DataAccess.get(Type.class, id); } - + /* ============================================================================= * ADMIN SECTION: * ============================================================================= */ - + @POST @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) public Type put(final String jsonRequest) throws Exception { return DataAccess.insertWithJson(Type.class, jsonRequest); } - - @PUT + + @PATCH @Path("{id}") @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) @@ -75,7 +75,7 @@ public class TypeResource { DataAccess.updateWithJson(Type.class, id, jsonRequest); return DataAccess.get(Type.class, id); } - + @DELETE @Path("{id}") @RolesAllowed("ADMIN") @@ -83,7 +83,7 @@ public class TypeResource { DataAccess.delete(Type.class, id); return Response.ok().build(); } - + @POST @Path("{id}/add_cover") @RolesAllowed("ADMIN") @@ -92,7 +92,7 @@ public class TypeResource { @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData); } - + @GET @Path("{id}/rm_cover/{coverId}") @RolesAllowed("ADMIN") @@ -100,7 +100,7 @@ public class TypeResource { AddOnManyToMany.removeLink(Type.class, id, "cover", coverId); return Response.ok(DataAccess.get(Type.class, id)).build(); } - + public static Type getOrCreate(final String name) { try { Type out = DataAccess.getWhere(Type.class, new Condition(new QueryCondition("name", "=", name))); @@ -116,5 +116,5 @@ public class TypeResource { } return null; } - + } diff --git a/back/src/org/kar/karideo/api/UserMediaAdvancementResource.java b/back/src/org/kar/karideo/api/UserMediaAdvancementResource.java index 976599c..e23bfc2 100644 --- a/back/src/org/kar/karideo/api/UserMediaAdvancementResource.java +++ b/back/src/org/kar/karideo/api/UserMediaAdvancementResource.java @@ -15,7 +15,7 @@ import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; -import jakarta.ws.rs.PUT; +import jakarta.ws.rs.PATCH; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @@ -28,7 +28,7 @@ import jakarta.ws.rs.core.SecurityContext; @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public class UserMediaAdvancementResource { static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class); - + @GET @Path("{id}") @RolesAllowed("USER") @@ -36,23 +36,23 @@ public class UserMediaAdvancementResource { 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") public List 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))); } - + /* ============================================================================= * Modification SECTION: * ============================================================================= */ - + public record MediaInformations( int time, float percent, - int count) {}; - + int count) {} + //@POST //@Path("{id}") //@RolesAllowed("USER") @@ -67,13 +67,13 @@ public class UserMediaAdvancementResource { elem.count = data.count; return DataAccess.insert(elem); } - + public record MediaInformationsDelta( int time, float percent, - boolean addCount) {}; - - @PUT + boolean addCount) {} + + @PATCH @Path("{id}") @RolesAllowed("USER") @Consumes(MediaType.APPLICATION_JSON) @@ -94,11 +94,9 @@ public class UserMediaAdvancementResource { } LOGGER.info("{},{},{}", elem.time, elem.percent, elem.count); final int nbAfected = DataAccess.update(elem, elem.id, List.of("time", "percent", "count")); - // TODO: manage the fact that no element has been updated ... - final UserMediaAdvancement ret = DataAccess.get(UserMediaAdvancement.class, elem.id); - return ret; + return DataAccess.get(UserMediaAdvancement.class, elem.id); } - + @DELETE @Path("{id}") @RolesAllowed("USER") @@ -107,5 +105,5 @@ public class UserMediaAdvancementResource { DataAccess.delete(UserMediaAdvancement.class, elem.id); return Response.ok().build(); } - + } diff --git a/back/src/org/kar/karideo/api/VideoResource.java b/back/src/org/kar/karideo/api/VideoResource.java index 3ae9154..5508f04 100644 --- a/back/src/org/kar/karideo/api/VideoResource.java +++ b/back/src/org/kar/karideo/api/VideoResource.java @@ -25,8 +25,8 @@ import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; +import jakarta.ws.rs.PATCH; import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @@ -37,21 +37,21 @@ import jakarta.ws.rs.core.Response; @Produces({ MediaType.APPLICATION_JSON }) public class VideoResource { static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class); - + @GET @RolesAllowed("USER") public List get() throws Exception { return DataAccess.gets(Media.class); } - + @GET @Path("{id}") @RolesAllowed("USER") public Media get(@PathParam("id") final Long id) throws Exception { return DataAccess.get(Media.class, id); } - - @PUT + + @PATCH @Path("{id}") @RolesAllowed("ADMIN") @Consumes(MediaType.APPLICATION_JSON) @@ -60,7 +60,7 @@ public class VideoResource { DataAccess.updateWithJson(Media.class, id, jsonRequest); return DataAccess.get(Media.class, id); } - + private String multipartCorrection(final String data) { if (data == null) { return null; @@ -73,7 +73,7 @@ public class VideoResource { } return data; } - + @POST @Path("/upload/") @RolesAllowed("ADMIN") @@ -91,7 +91,7 @@ public class VideoResource { episode = multipartCorrection(episode); title = multipartCorrection(title); typeId = multipartCorrection(typeId); - + //public NodeSmall uploadFile(final FormDataMultiPart form) { System.out.println("Upload media file: " + fileMetaData); System.out.println(" - fileName: " + fileName); @@ -107,7 +107,7 @@ public class VideoResource { if (typeId == null) { throw new InputException("typeId", "TypiId is not specified"); } - + final long tmpUID = DataResource.getTmpDataId(); final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID); Data data = DataResource.getWithSha512(sha512); @@ -145,7 +145,7 @@ public class VideoResource { if (series != null) { seriesNode = SeriesResource.getOrCreate(series, typeNode.id); } - + System.out.println(" ==> " + seriesNode); System.out.println("Find seasonNode"); // get uid of season: @@ -157,10 +157,10 @@ public class VideoResource { if (season != null) { seasonNode = SeasonResource.getOrCreate(season, seriesNode.id); } - + System.out.println(" ==> " + seasonNode); System.out.println("add media"); - + final long uniqueSQLID = -1; try { final Media media = new Media(); @@ -195,7 +195,7 @@ public class VideoResource { throw new FailException("Catch Exception ==> check server logs"); } } - + @POST @Path("{id}/add_cover") @RolesAllowed("ADMIN") @@ -204,7 +204,7 @@ public class VideoResource { @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData); } - + @GET @Path("{id}/rm_cover/{coverId}") @RolesAllowed("ADMIN") @@ -212,7 +212,7 @@ public class VideoResource { AddOnManyToMany.removeLink(Media.class, id, "cover", coverId); return Response.ok(DataAccess.get(Media.class, id)).build(); } - + @DELETE @Path("{id}") @RolesAllowed("ADMIN") diff --git a/back/src/org/kar/karideo/migration/Migration20231015.java b/back/src/org/kar/karideo/migration/Migration20231015.java index e43b617..c7a7868 100644 --- a/back/src/org/kar/karideo/migration/Migration20231015.java +++ b/back/src/org/kar/karideo/migration/Migration20231015.java @@ -5,18 +5,18 @@ import java.util.List; import org.kar.archidata.migration.MigrationSqlStep; public class Migration20231015 extends MigrationSqlStep { - + public static final int KARSO_INITIALISATION_ID = 1; - + @Override public String getName() { - return "refactor creation and update time"; + return "migration-2023-10-15: refactor creation and update time"; } - + public Migration20231015() { - + } - + @Override public void generateStep() throws Exception { for (String elem : List.of("data", "media", "media_link_cover", "season", "season_link_cover", "series", "series_link_cover", "type", "type_link_cover", "user", "userMediaAdvancement")) { diff --git a/back/src/org/kar/karideo/model/Season.java b/back/src/org/kar/karideo/model/Season.java index 5b62cdb..ef19342 100644 --- a/back/src/org/kar/karideo/model/Season.java +++ b/back/src/org/kar/karideo/model/Season.java @@ -2,13 +2,13 @@ package org.kar.karideo.model; import java.util.List; -import org.kar.archidata.annotation.DataComment; import org.kar.archidata.annotation.DataIfNotExists; import org.kar.archidata.model.Data; import org.kar.archidata.model.GenericDataSoftDelete; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.Column; import jakarta.persistence.FetchType; import jakarta.persistence.ManyToMany; @@ -20,16 +20,16 @@ import jakarta.persistence.Table; @JsonInclude(JsonInclude.Include.NON_NULL) public class Season extends GenericDataSoftDelete { @Column(nullable = false, length = 0) - @DataComment("Name of the media (this represent the title)") + @Schema(description = "Name of the media (this represent the title)") public String name; @Column(length = 0) - @DataComment("Description of the media") + @Schema(description = "Description of the media") public String description; @Column(nullable = false) - @DataComment("series parent ID") + @Schema(description = "series parent ID") @ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class) public Long parentId; - @DataComment("List of Id of the sopecific covers") + @Schema(description = "List of Id of the sopecific covers") @ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class) public List covers = null; } \ No newline at end of file diff --git a/back/src/org/kar/karideo/model/Series.java b/back/src/org/kar/karideo/model/Series.java index f8f3a02..cf89d02 100644 --- a/back/src/org/kar/karideo/model/Series.java +++ b/back/src/org/kar/karideo/model/Series.java @@ -2,13 +2,13 @@ package org.kar.karideo.model; import java.util.List; -import org.kar.archidata.annotation.DataComment; import org.kar.archidata.annotation.DataIfNotExists; import org.kar.archidata.model.Data; import org.kar.archidata.model.GenericDataSoftDelete; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.Column; import jakarta.persistence.FetchType; import jakarta.persistence.ManyToMany; @@ -20,16 +20,16 @@ import jakarta.persistence.Table; @JsonInclude(JsonInclude.Include.NON_NULL) public class Series extends GenericDataSoftDelete { @Column(nullable = false, length = 0) - @DataComment("Name of the media (this represent the title)") + @Schema(description = "Name of the media (this represent the title)") public String name; @Column(length = 0) - @DataComment("Description of the media") + @Schema(description = "Description of the media") public String description; @Column(nullable = false) - @DataComment("series parent ID") + @Schema(description = "series parent ID") @ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class) public Long parentId; - @DataComment("List of Id of the sopecific covers") + @Schema(description = "List of Id of the sopecific covers") @ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class) public List covers = null; } diff --git a/back/src/org/kar/karideo/model/Type.java b/back/src/org/kar/karideo/model/Type.java index fdb67d0..5a387f6 100644 --- a/back/src/org/kar/karideo/model/Type.java +++ b/back/src/org/kar/karideo/model/Type.java @@ -2,13 +2,13 @@ package org.kar.karideo.model; import java.util.List; -import org.kar.archidata.annotation.DataComment; import org.kar.archidata.annotation.DataIfNotExists; import org.kar.archidata.model.Data; import org.kar.archidata.model.GenericDataSoftDelete; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.Column; import jakarta.persistence.FetchType; import jakarta.persistence.ManyToMany; @@ -19,12 +19,12 @@ import jakarta.persistence.Table; @JsonInclude(JsonInclude.Include.NON_NULL) public class Type extends GenericDataSoftDelete { @Column(nullable = false, length = 0) - @DataComment("Name of the media (this represent the title)") + @Schema(description = "Name of the media (this represent the title)") public String name; @Column(length = 0) - @DataComment("Description of the media") + @Schema(description = "Description of the media") public String description; - @DataComment("List of Id of the sopecific covers") + @Schema(description = "List of Id of the sopecific covers") @ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class) public List covers = null; } diff --git a/back/src/org/kar/karideo/model/UserMediaAdvancement.java b/back/src/org/kar/karideo/model/UserMediaAdvancement.java index d6ba050..58a576c 100644 --- a/back/src/org/kar/karideo/model/UserMediaAdvancement.java +++ b/back/src/org/kar/karideo/model/UserMediaAdvancement.java @@ -1,11 +1,11 @@ package org.kar.karideo.model; -import org.kar.archidata.annotation.DataComment; import org.kar.archidata.annotation.DataIfNotExists; import org.kar.archidata.model.GenericDataSoftDelete; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.Column; import jakarta.persistence.FetchType; import jakarta.persistence.ManyToOne; @@ -16,20 +16,20 @@ import jakarta.persistence.Table; @JsonInclude(JsonInclude.Include.NON_NULL) public class UserMediaAdvancement extends GenericDataSoftDelete { @Column(nullable = false) - @DataComment("Foreign Key Id of the user") + @Schema(description = "Foreign Key Id of the user") @ManyToOne(fetch = FetchType.LAZY, targetEntity = UserKarideo.class) public long userId; @Column(nullable = false) - @DataComment("Id of the media") + @Schema(description = "Id of the media") @ManyToOne(fetch = FetchType.LAZY, targetEntity = Media.class) public long mediaId; @Column(nullable = false) - @DataComment("Percent of admencement in the media") + @Schema(description = "Percent of admencement in the media") public float percent; @Column(nullable = false) - @DataComment("Number of second of admencement in the media") + @Schema(description = "Number of second of admencement in the media") public int time; @Column(nullable = false) - @DataComment("Number of time this media has been read") + @Schema(description = "Number of time this media has been read") public int count; } diff --git a/front/src/app/scene/season-edit/season-edit.ts b/front/src/app/scene/season-edit/season-edit.ts index 0915bcf..7d04092 100644 --- a/front/src/app/scene/season-edit/season-edit.ts +++ b/front/src/app/scene/season-edit/season-edit.ts @@ -6,7 +6,7 @@ import { Component, OnInit } from '@angular/core'; -import { SeasonService , ArianeService, DataService} from 'app/service'; +import { SeasonService, ArianeService, DataService } from 'app/service'; import { NodeData } from 'common/model'; import { UploadProgress } from 'common/popin/upload-progress/upload-progress'; @@ -21,16 +21,16 @@ export interface ElementList { @Component({ selector: 'app-season-edit', templateUrl: './season-edit.html', - styleUrls: [ './season-edit.less' ] + styleUrls: ['./season-edit.less'] }) export class SeasonEditScene implements OnInit { - idSeason:number = -1; - itemIsRemoved:boolean = false; - itemIsNotFound:boolean = false; - itemIsLoading:boolean = true; + idSeason: number = -1; + itemIsRemoved: boolean = false; + itemIsNotFound: boolean = false; + itemIsLoading: boolean = true; - error:string = ''; + error: string = ''; numberVal: number = null; description: string = ''; @@ -49,11 +49,11 @@ export class SeasonEditScene implements OnInit { private deleteCoverId: number = null; private deleteItemId: number = null; deleteConfirmed() { - if(this.deleteCoverId !== null) { + if (this.deleteCoverId !== null) { this.removeCoverAfterConfirm(this.deleteCoverId); this.cleanConfirm(); } - if(this.deleteItemId !== null) { + if (this.deleteItemId !== null) { this.removeItemAfterConfirm(this.deleteItemId); this.cleanConfirm(); } @@ -67,9 +67,9 @@ export class SeasonEditScene implements OnInit { constructor( - private seasonService: SeasonService, - private arianeService: ArianeService, - private popInService: PopInService, + private seasonService: SeasonService, + private arianeService: ArianeService, + private popInService: PopInService, private dataService: DataService) { } @@ -79,7 +79,7 @@ export class SeasonEditScene implements OnInit { let self = this; this.seasonService.get(this.idSeason) .then((response: NodeData) => { - console.log(`get response of season : ${ JSON.stringify(response, null, 2)}`); + console.log(`get response of season : ${JSON.stringify(response, null, 2)}`); if (isNumberFinite(response.name)) { self.numberVal = response.name; } @@ -95,44 +95,44 @@ export class SeasonEditScene implements OnInit { self.itemIsLoading = false; }); this.seasonService.getVideo(this.idSeason) - .then((response:any) => { + .then((response: any) => { self.videoCount = response.length; - }).catch((response:any) => { + }).catch((response: any) => { self.videoCount = '---'; }); } updateCoverList(covers: any) { this.coversDisplay = []; - if(covers !== undefined && covers !== null) { - for(let iii = 0; iii < covers.length; iii++) { + if (covers !== undefined && covers !== null) { + for (let iii = 0; iii < covers.length; iii++) { this.coversDisplay.push({ - id:covers[iii], - url:this.dataService.getCoverThumbnailUrl(covers[iii]) + id: covers[iii], + url: this.dataService.getCoverThumbnailUrl(covers[iii]) }); } } else { this.coversDisplay = []; } } - onNumber(value:any):void { + onNumber(value: any): void { this.numberVal = value; } - onDescription(value:any):void { + onDescription(value: any): void { this.description = value; } - sendValues():void { + sendValues(): void { console.log('send new values....'); let data = { name: this.numberVal, description: this.description }; - if(this.description === undefined) { + if (this.description === undefined) { data.description = null; } - this.seasonService.put(this.idSeason, data); + this.seasonService.patch(this.idSeason, data); } // At the drag drop area @@ -151,15 +151,15 @@ export class SeasonEditScene implements OnInit { // At the file input element // (change)="selectFile($event)" - onChangeCover(value:any):void { + onChangeCover(value: any): void { this.selectedFiles = value.files; this.coverFile = this.selectedFiles[0]; - console.log(`select file ${ this.coverFile.name}`); + console.log(`select file ${this.coverFile.name}`); this.uploadCover(this.coverFile); } - uploadCover(file:File) { - if(file === undefined) { + uploadCover(file: File) { + if (file === undefined) { console.log('No file selected!'); return; } @@ -169,35 +169,35 @@ export class SeasonEditScene implements OnInit { // display the upload pop-in this.popInService.open('popin-upload-progress'); this.seasonService.uploadCover(file, this.idSeason, (count, total) => { - self.upload.mediaSendSize = count; - self.upload.mediaSize = total; - }) - .then((response:any) => { + self.upload.mediaSendSize = count; + self.upload.mediaSize = total; + }) + .then((response: any) => { self.upload.result = 'Cover added done'; // we retrive the whiole media ==> update data ... self.updateCoverList(response.covers); - }).catch((response:any) => { + }).catch((response: any) => { // self.error = "Can not get the data"; console.log('Can not add the cover in the video...'); }); } - removeCover(id:number) { + removeCover(id: number) { this.cleanConfirm(); - this.confirmDeleteComment = `Delete the cover ID: ${ id}`; + this.confirmDeleteComment = `Delete the cover ID: ${id}`; this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); this.deleteCoverId = id; this.popInService.open('popin-delete-confirm'); } - removeCoverAfterConfirm(id:number) { - console.log(`Request remove cover: ${ id}`); + removeCoverAfterConfirm(id: number) { + console.log(`Request remove cover: ${id}`); let self = this; this.seasonService.deleteCover(this.idSeason, id) - .then((response:any) => { + .then((response: any) => { self.upload.result = 'Cover remove done'; // we retrive the whiole media ==> update data ... self.updateCoverList(response.covers); - }).catch((response:any) => { + }).catch((response: any) => { // self.error = "Can not get the data"; console.log('Can not remove the cover of the video...'); }); @@ -206,11 +206,11 @@ export class SeasonEditScene implements OnInit { removeItem() { console.log('Request remove Media...'); this.cleanConfirm(); - this.confirmDeleteComment = `Delete the Season: ${ this.idSeason}`; + this.confirmDeleteComment = `Delete the Season: ${this.idSeason}`; this.deleteItemId = this.idSeason; this.popInService.open('popin-delete-confirm'); } - removeItemAfterConfirm(id:number) { + removeItemAfterConfirm(id: number) { let self = this; this.seasonService.delete(id) .then((response3) => { diff --git a/front/src/app/scene/series-edit/series-edit.ts b/front/src/app/scene/series-edit/series-edit.ts index 9562e47..ed3850b 100644 --- a/front/src/app/scene/series-edit/series-edit.ts +++ b/front/src/app/scene/series-edit/series-edit.ts @@ -20,30 +20,30 @@ export class ElementList { @Component({ selector: 'app-series-edit', templateUrl: './series-edit.html', - styleUrls: [ './series-edit.less' ] + styleUrls: ['./series-edit.less'] }) export class SeriesEditScene implements OnInit { - idSeries:number = -1; - itemIsRemoved:boolean = false; - itemIsNotFound:boolean = false; - itemIsLoading:boolean = true; + idSeries: number = -1; + itemIsRemoved: boolean = false; + itemIsNotFound: boolean = false; + itemIsLoading: boolean = true; - error:string = ''; + error: string = ''; - typeId:number = null; - name:string = ''; - description:string = ''; - coverFile:File; - uploadFileValue:string = ''; - selectedFiles:FileList; + typeId: number = null; + name: string = ''; + description: string = ''; + coverFile: File; + uploadFileValue: string = ''; + selectedFiles: FileList; seasonsCount: string = null; videoCount: string = null; - coversDisplay:Array = []; + coversDisplay: Array = []; // section tha define the upload value to display in the pop-in of upload - public upload:UploadProgress = new UploadProgress(); + public upload: UploadProgress = new UploadProgress(); listType: ElementList[] = [ @@ -51,16 +51,16 @@ export class SeriesEditScene implements OnInit { ]; // --------------- confirm section ------------------ - public confirmDeleteComment:string = null; - public confirmDeleteImageUrl:string = null; - private deleteCoverId:number = null; - private deleteItemId:number = null; + public confirmDeleteComment: string = null; + public confirmDeleteImageUrl: string = null; + private deleteCoverId: number = null; + private deleteItemId: number = null; deleteConfirmed() { - if(this.deleteCoverId !== null) { + if (this.deleteCoverId !== null) { this.removeCoverAfterConfirm(this.deleteCoverId); this.cleanConfirm(); } - if(this.deleteItemId !== null) { + if (this.deleteItemId !== null) { this.removeItemAfterConfirm(this.deleteItemId); this.cleanConfirm(); } @@ -74,25 +74,25 @@ export class SeriesEditScene implements OnInit { constructor(private dataService: DataService, - private typeService: TypeService, - private seriesService: SeriesService, - private arianeService: ArianeService, - private popInService: PopInService) { + private typeService: TypeService, + private seriesService: SeriesService, + private arianeService: ArianeService, + private popInService: PopInService) { } ngOnInit() { this.idSeries = this.arianeService.getSeriesId(); let self = this; - this.listType = [ { value: null, label: '---' } ]; + this.listType = [{ value: null, label: '---' }]; this.typeService.getData() .then((response2) => { - for(let iii = 0; iii < response2.length; iii++) { + for (let iii = 0; iii < response2.length; iii++) { self.listType.push({ value: response2[iii].id, label: response2[iii].name }); } }).catch((response2) => { - console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); + console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`); }); this.seriesService.get(this.idSeries) @@ -112,7 +112,7 @@ export class SeriesEditScene implements OnInit { self.itemIsNotFound = true; self.itemIsLoading = false; }); - console.log(`get parameter id: ${ this.idSeries}`); + console.log(`get parameter id: ${this.idSeries}`); this.seriesService.getSeason(this.idSeries) .then((response) => { self.seasonsCount = "" + response.length; @@ -129,11 +129,11 @@ export class SeriesEditScene implements OnInit { updateCoverList(covers: any) { this.coversDisplay = []; - if(covers !== undefined && covers !== null) { - for(let iii = 0; iii < covers.length; iii++) { + if (covers !== undefined && covers !== null) { + for (let iii = 0; iii < covers.length; iii++) { this.coversDisplay.push({ - id:covers[iii], - url:this.dataService.getCoverThumbnailUrl(covers[iii]) + id: covers[iii], + url: this.dataService.getCoverThumbnailUrl(covers[iii]) }); } } else { @@ -141,33 +141,33 @@ export class SeriesEditScene implements OnInit { } } - onName(value:any):void { + onName(value: any): void { this.name = value; } - onDescription(value:any):void { + onDescription(value: any): void { this.description = value; } - onChangeType(value:any):void { - console.log(`Change requested of type ... ${ value}`); + onChangeType(value: any): void { + console.log(`Change requested of type ... ${value}`); this.typeId = value; - if(this.typeId === undefined) { + if (this.typeId === undefined) { this.typeId = null; } } - sendValues():void { + sendValues(): void { console.log('send new values....'); let data = { parentId: this.typeId, name: this.name, description: this.description }; - if(this.description === undefined) { + if (this.description === undefined) { data.description = null; } - this.seriesService.put(this.idSeries, data); + this.seriesService.patch(this.idSeries, data); } // At the drag drop area @@ -186,15 +186,15 @@ export class SeriesEditScene implements OnInit { // At the file input element // (change)="selectFile($event)" - onChangeCover(value:any):void { + onChangeCover(value: any): void { this.selectedFiles = value.files; this.coverFile = this.selectedFiles[0]; - console.log(`select file ${ this.coverFile.name}`); + console.log(`select file ${this.coverFile.name}`); this.uploadCover(this.coverFile); } - uploadCover(file:File) { - if(file === undefined) { + uploadCover(file: File) { + if (file === undefined) { console.log('No file selected!'); return; } @@ -204,34 +204,34 @@ export class SeriesEditScene implements OnInit { // display the upload pop-in this.popInService.open('popin-upload-progress'); this.seriesService.uploadCover(file, this.idSeries, (count, total) => { - self.upload.mediaSendSize = count; - self.upload.mediaSize = total; - }) - .then((response:any) => { + self.upload.mediaSendSize = count; + self.upload.mediaSize = total; + }) + .then((response: any) => { self.upload.result = 'Cover added done'; // we retrive the whiole media ==> update data ... self.updateCoverList(response.covers); - }).catch((response:any) => { + }).catch((response: any) => { // self.error = "Can not get the data"; console.log('Can not add the cover in the video...'); }); } - removeCover(id:number) { + removeCover(id: number) { this.cleanConfirm(); - this.confirmDeleteComment = `Delete the cover ID: ${ id}`; + this.confirmDeleteComment = `Delete the cover ID: ${id}`; this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); this.deleteCoverId = id; this.popInService.open('popin-delete-confirm'); } - removeCoverAfterConfirm(id:number) { - console.log(`Request remove cover: ${ id}`); + removeCoverAfterConfirm(id: number) { + console.log(`Request remove cover: ${id}`); let self = this; this.seriesService.deleteCover(this.idSeries, id) - .then((response:any) => { + .then((response: any) => { self.upload.result = 'Cover remove done'; // we retrive the whiole media ==> update data ... self.updateCoverList(response.covers); - }).catch((response:any) => { + }).catch((response: any) => { // self.error = "Can not get the data"; console.log('Can not remove the cover of the video...'); }); @@ -239,11 +239,11 @@ export class SeriesEditScene implements OnInit { removeItem() { console.log('Request remove Media...'); this.cleanConfirm(); - this.confirmDeleteComment = `Delete the Series: ${ this.idSeries}`; + this.confirmDeleteComment = `Delete the Series: ${this.idSeries}`; this.deleteItemId = this.idSeries; this.popInService.open('popin-delete-confirm'); } - removeItemAfterConfirm(_id:number) { + removeItemAfterConfirm(_id: number) { let self = this; this.seriesService.delete(_id) .then((response3) => { diff --git a/front/src/app/scene/video-edit/video-edit.ts b/front/src/app/scene/video-edit/video-edit.ts index aec88f8..00505f8 100644 --- a/front/src/app/scene/video-edit/video-edit.ts +++ b/front/src/app/scene/video-edit/video-edit.ts @@ -21,16 +21,16 @@ export interface ElementList { class DataToSend { - name:string = ''; - description:string = ''; - episode?:number; - seriesId:number = null; - seasonId:number = null; - dataId:number = -1; - time?:number; - typeId:number = null; - covers:number[] = []; - generatedName:string = ''; + name: string = ''; + description: string = ''; + episode?: number; + seriesId: number = null; + seasonId: number = null; + dataId: number = -1; + time?: number; + typeId: number = null; + covers: number[] = []; + generatedName: string = ''; clone() { let tmp = new DataToSend(); tmp.name = this.name; @@ -50,38 +50,38 @@ class DataToSend { @Component({ selector: 'app-video-edit', templateUrl: './video-edit.html', - styleUrls: [ './video-edit.less' ] + styleUrls: ['./video-edit.less'] }) export class VideoEditScene implements OnInit { - idVideo:number = -1; - itemIsRemoved:boolean = false; - itemIsNotFound:boolean = false; - itemIsLoading:boolean = true; + idVideo: number = -1; + itemIsRemoved: boolean = false; + itemIsNotFound: boolean = false; + itemIsLoading: boolean = true; - error:string = ''; + error: string = ''; - data:DataToSend = new DataToSend(); - dataOri:DataToSend = new DataToSend(); - coverFile:File; - uploadFileValue:string = ''; - selectedFiles:FileList; - needSend:boolean = false; + data: DataToSend = new DataToSend(); + dataOri: DataToSend = new DataToSend(); + coverFile: File; + uploadFileValue: string = ''; + selectedFiles: FileList; + needSend: boolean = false; // section tha define the upload value to display in the pop-in of upload - upload:UploadProgress = new UploadProgress(); + upload: UploadProgress = new UploadProgress(); // --------------- confirm section ------------------ - public confirmDeleteComment:string = null; - public confirmDeleteImageUrl:string = null; - private deleteCoverId:number = null; - private deleteMediaId:number = null; + public confirmDeleteComment: string = null; + public confirmDeleteImageUrl: string = null; + private deleteCoverId: number = null; + private deleteMediaId: number = null; deleteConfirmed() { - if(this.deleteCoverId !== null) { + if (this.deleteCoverId !== null) { this.removeCoverAfterConfirm(this.deleteCoverId); this.cleanConfirm(); } - if(this.deleteMediaId !== null) { + if (this.deleteMediaId !== null) { this.removeItemAfterConfirm(this.deleteMediaId); this.cleanConfirm(); } @@ -93,7 +93,7 @@ export class VideoEditScene implements OnInit { this.deleteMediaId = null; } - coversDisplay:Array = []; + coversDisplay: Array = []; listType: ElementList[] = [ { value: undefined, label: '---' }, @@ -109,36 +109,36 @@ export class VideoEditScene implements OnInit { { value: undefined, label: '---' }, ]; constructor( - private typeService: TypeService, - private seriesService: SeriesService, - private videoService: VideoService, - private arianeService: ArianeService, - private popInService: PopInService, - private dataService: DataService) { + private typeService: TypeService, + private seriesService: SeriesService, + private videoService: VideoService, + private arianeService: ArianeService, + private popInService: PopInService, + private dataService: DataService) { } updateNeedSend(): boolean { this.needSend = false; - if(this.data.name !== this.dataOri.name) { + if (this.data.name !== this.dataOri.name) { this.needSend = true; } - if(this.data.description !== this.dataOri.description) { + if (this.data.description !== this.dataOri.description) { this.needSend = true; } - if(this.data.episode !== this.dataOri.episode) { + if (this.data.episode !== this.dataOri.episode) { this.needSend = true; } - if(this.data.time !== this.dataOri.time) { + if (this.data.time !== this.dataOri.time) { this.needSend = true; } - if(this.data.typeId !== this.dataOri.typeId) { + if (this.data.typeId !== this.dataOri.typeId) { this.needSend = true; } - if(this.data.seriesId !== this.dataOri.seriesId) { + if (this.data.seriesId !== this.dataOri.seriesId) { this.needSend = true; } - if(this.data.seasonId !== this.dataOri.seasonId) { + if (this.data.seasonId !== this.dataOri.seasonId) { this.needSend = true; } return this.needSend; @@ -147,12 +147,12 @@ export class VideoEditScene implements OnInit { updateCoverList(covers: any) { this.coversDisplay = []; this.data.covers = []; - if(covers !== undefined && covers !== null) { - for(let iii = 0; iii < covers.length; iii++) { + if (covers !== undefined && covers !== null) { + for (let iii = 0; iii < covers.length; iii++) { this.data.covers.push(covers[iii]); this.coversDisplay.push({ - id:covers[iii], - url:this.dataService.getCoverThumbnailUrl(covers[iii]) + id: covers[iii], + url: this.dataService.getCoverThumbnailUrl(covers[iii]) }); } } else { @@ -162,31 +162,31 @@ export class VideoEditScene implements OnInit { ngOnInit() { this.idVideo = this.arianeService.getVideoId(); let self = this; - this.listType = [ { value: null, label: '---' } ]; - this.listUniverse = [ { value: null, label: '---' } ]; - this.listSeries = [ { value: null, label: '---' } ]; - this.listSeason = [ { value: null, label: '---' } ]; + this.listType = [{ value: null, label: '---' }]; + this.listUniverse = [{ value: null, label: '---' }]; + this.listSeries = [{ value: null, label: '---' }]; + this.listSeason = [{ value: null, label: '---' }]; this.typeService.getData() .then((response2) => { - for(let iii = 0; iii < response2.length; iii++) { + for (let iii = 0; iii < response2.length; iii++) { self.listType.push({ value: response2[iii].id, label: response2[iii].name }); } }).catch((response2) => { - console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); + console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`); }); // this.seriesService.getOrder() this.seriesService.getData() .then((response3) => { - for(let iii = 0; iii < response3.length; iii++) { + for (let iii = 0; iii < response3.length; iii++) { self.listSeries.push({ value: response3[iii].id, label: response3[iii].name }); - console.log(`[${ self.data.dataId }] Get series: ${ response3[iii].id }, label:${ response3[iii].name}`); + console.log(`[${self.data.dataId}] Get series: ${response3[iii].id}, label:${response3[iii].name}`); } }).catch((response3) => { - console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`); + console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`); }); this.videoService.get(this.idVideo) .then((response: Media) => { - console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`); + console.log(`get response of video : ${JSON.stringify(response, null, 2)}`); self.data.name = response.name; self.data.description = response.description; self.data.episode = response.episode; @@ -196,13 +196,13 @@ export class VideoEditScene implements OnInit { self.onChangeType(response.typeId); self.onChangeSeries(response.seriesId); self.data.seasonId = response.seasonId; - if(self.data.seasonId === undefined) { + if (self.data.seasonId === undefined) { self.data.seasonId = null; } self.dataOri = self.data.clone(); self.updateCoverList(response.covers); self.updateNeedSend(); - console.log(`coversList : ${ JSON.stringify(self.coversDisplay, null, 2)}`); + console.log(`coversList : ${JSON.stringify(self.coversDisplay, null, 2)}`); self.itemIsLoading = false; }).catch((response) => { self.error = 'Can not get the data'; @@ -215,82 +215,82 @@ export class VideoEditScene implements OnInit { }); } - onChangeType(value:any):void { + onChangeType(value: any): void { console.log(`Change requested of type ... ${value}`); this.data.typeId = value; - if(this.data.typeId === undefined) { + if (this.data.typeId === undefined) { this.data.typeId = null; } this.data.seriesId = null; this.data.seasonId = null; - this.listSeries = [ { value: undefined, label: '---' } ]; - this.listSeason = [ { value: undefined, label: '---' } ]; + this.listSeries = [{ value: undefined, label: '---' }]; + this.listSeason = [{ value: undefined, label: '---' }]; let self = this; this.updateNeedSend(); - if(this.data.typeId !== undefined) { + if (this.data.typeId !== undefined) { self.typeService.getSubSeries(this.data.typeId) .then((response2: NodeData[]) => { - for(let iii = 0; iii < response2.length; iii++) { + for (let iii = 0; iii < response2.length; iii++) { self.listSeries.push({ value: response2[iii].id, label: response2[iii].name }); } }).catch((response2) => { - console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`); + console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`); }); } } - onChangeSeries(value:any):void { + onChangeSeries(value: any): void { this.data.seriesId = value; - if(this.data.seriesId === undefined) { + if (this.data.seriesId === undefined) { this.data.seriesId = null; } this.data.seasonId = null; - this.listSeason = [ { value: undefined, label: '---' } ]; + this.listSeason = [{ value: undefined, label: '---' }]; let self = this; - if(this.data.seriesId !== undefined) { + if (this.data.seriesId !== undefined) { self.seriesService.getSeason(this.data.seriesId) .then((response3: NodeData[]) => { - for(let iii = 0; iii < response3.length; iii++) { - self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` }); + for (let iii = 0; iii < response3.length; iii++) { + self.listSeason.push({ value: response3[iii].id, label: `season ${response3[iii].name}` }); } }).catch((response3) => { - console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`); + console.log(`get response22 : ${JSON.stringify(response3, null, 2)}`); }); } this.updateNeedSend(); } - onChangeSeason(value:any):void { + onChangeSeason(value: any): void { this.data.seasonId = value; this.updateNeedSend(); } - onName(value:any):void { + onName(value: any): void { this.data.name = value; this.updateNeedSend(); } - onDescription(value:any):void { - if(value.length === 0) { + onDescription(value: any): void { + if (value.length === 0) { this.data.description = null; } else { this.data.description = value; } this.updateNeedSend(); } - onDate(value:any):void { - if(value.value.length > 4) { + onDate(value: any): void { + if (value.value.length > 4) { value.value = this.data.time; } else { this.data.time = value.value; } - if(this.data.time < 10) { + if (this.data.time < 10) { this.data.time = null; } this.updateNeedSend(); } - onEpisode(value:any):void { - if(value.value.length > 4) { + onEpisode(value: any): void { + if (value.value.length > 4) { value.value = this.data.episode; } else { this.data.episode = parseInt(value.value, 10); @@ -298,41 +298,41 @@ export class VideoEditScene implements OnInit { this.updateNeedSend(); } - sendValues():void { + sendValues(): void { console.log('send new values....'); - let data:any = {}; - if(this.data.name !== this.dataOri.name) { + let data: any = {}; + if (this.data.name !== this.dataOri.name) { data.name = this.data.name; } - if(this.data.description !== this.dataOri.description) { - if(this.data.description === undefined) { + if (this.data.description !== this.dataOri.description) { + if (this.data.description === undefined) { data.description = null; } else { data.description = this.data.description; } } - if(this.data.episode !== this.dataOri.episode) { + if (this.data.episode !== this.dataOri.episode) { data.episode = this.data.episode; } - if(this.data.time !== this.dataOri.time) { + if (this.data.time !== this.dataOri.time) { data.time = this.data.time; } - if(this.data.typeId !== this.dataOri.typeId) { - if(this.data.typeId === undefined) { + if (this.data.typeId !== this.dataOri.typeId) { + if (this.data.typeId === undefined) { data.typeId = null; } else { data.typeId = this.data.typeId; } } - if(this.data.seriesId !== this.dataOri.seriesId) { - if(this.data.seriesId === undefined) { + if (this.data.seriesId !== this.dataOri.seriesId) { + if (this.data.seriesId === undefined) { data.seriesId = null; } else { data.seriesId = this.data.seriesId; } } - if(this.data.seasonId !== this.dataOri.seasonId) { - if(this.data.seasonId === undefined) { + if (this.data.seasonId !== this.dataOri.seasonId) { + if (this.data.seasonId === undefined) { data.seasonId = null; } else { data.seasonId = this.data.seasonId; @@ -340,12 +340,12 @@ export class VideoEditScene implements OnInit { } let tmpp = this.data.clone(); let self = this; - this.videoService.put(this.idVideo, data) + this.videoService.patch(this.idVideo, data) .then((response3) => { self.dataOri = tmpp; self.updateNeedSend(); }).catch((response3) => { - console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`); + console.log(`get response22 : ${JSON.stringify(response3, null, 2)}`); self.updateNeedSend(); }); } @@ -367,16 +367,16 @@ export class VideoEditScene implements OnInit { // At the file input element // (change)="selectFile($event)" - onChangeCover(value:any):void { + onChangeCover(value: any): void { this.selectedFiles = value.files; this.coverFile = this.selectedFiles[0]; - console.log(`select file ${ this.coverFile.name}`); + console.log(`select file ${this.coverFile.name}`); this.uploadCover(this.coverFile); this.updateNeedSend(); } - uploadCover(file?:File) { - if(file === undefined) { + uploadCover(file?: File) { + if (file === undefined) { console.log('No file selected!'); return; } @@ -386,51 +386,51 @@ export class VideoEditScene implements OnInit { // display the upload pop-in this.popInService.open('popin-upload-progress'); this.videoService.uploadCover(file, this.idVideo, (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.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 ... self.updateCoverList(response.covers); - }).catch((response:any) => { - // self.error = "Can not get the data"; + }).catch((response: any) => { + // self.error = "Can not get the data"; console.log('Can not add the cover in the video...'); - self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`; + self.upload.error = `Error in the upload of the cover...${JSON.stringify(response, null, 2)}`; }); } - removeCover(id:number) { + removeCover(id: number) { this.cleanConfirm(); - this.confirmDeleteComment = `Delete the cover ID: ${ id}`; + this.confirmDeleteComment = `Delete the cover ID: ${id}`; this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id); this.deleteCoverId = id; this.popInService.open('popin-delete-confirm'); } - removeCoverAfterConfirm(id:number) { - console.log(`Request remove cover: ${ id}`); + removeCoverAfterConfirm(id: number) { + console.log(`Request remove cover: ${id}`); let self = this; this.videoService.deleteCover(this.idVideo, id) - .then((response:any) => { - console.log(`get response of remove cover : ${ JSON.stringify(response, null, 2)}`); + .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 ... self.updateCoverList(response.covers); - }).catch((response:any) => { + }).catch((response: any) => { // self.error = "Can not get the data"; console.log('Can not remove the cover of the video...'); - self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`; + self.upload.error = `Error in the upload of the cover...${JSON.stringify(response, null, 2)}`; }); } removeItem() { console.log('Request remove Media...'); this.cleanConfirm(); - this.confirmDeleteComment = `Delete the Media: ${ this.idVideo}`; + this.confirmDeleteComment = `Delete the Media: ${this.idVideo}`; this.deleteMediaId = this.idVideo; this.popInService.open('popin-delete-confirm'); } - removeItemAfterConfirm(id:number) { + removeItemAfterConfirm(id: number) { let self = this; this.videoService.delete(id) .then((response3) => { @@ -443,15 +443,15 @@ export class VideoEditScene implements OnInit { } eventPopUpSeason(event: string): void { - console.log(`GET event: ${ event}`); + console.log(`GET event: ${event}`); this.popInService.close('popin-new-season'); } eventPopUpSeries(event: string): void { - console.log(`GET event: ${ event}`); + console.log(`GET event: ${event}`); this.popInService.close('popin-new-series'); } eventPopUpType(event: string): void { - console.log(`GET event: ${ event}`); + console.log(`GET event: ${event}`); this.popInService.close('popin-new-type'); } diff --git a/front/src/app/service/GenericInterfaceModelDB.ts b/front/src/app/service/GenericInterfaceModelDB.ts index 9e93dd3..a79af24 100644 --- a/front/src/app/service/GenericInterfaceModelDB.ts +++ b/front/src/app/service/GenericInterfaceModelDB.ts @@ -4,7 +4,7 @@ import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/u export class GenericInterfaceModelDB { constructor( - protected serviceName:string, + protected serviceName: string, protected http: HttpWrapperService, protected bdd: BddService) { // nothing to do ... @@ -16,7 +16,7 @@ export class GenericInterfaceModelDB { self.bdd.get(self.serviceName) .then((response: DataInterface) => { let data = response.gets(); - if(isNullOrUndefined(data)) { + if (isNullOrUndefined(data)) { reject('Data does not exist in the local BDD'); return; } @@ -28,13 +28,13 @@ export class GenericInterfaceModelDB { }); } - getLike(nameArtist:string):any { + getLike(nameArtist: string): any { let self = this; return new Promise((resolve, reject) => { self.bdd.get(self.serviceName) - .then((response:DataInterface) => { + .then((response: DataInterface) => { let data = response.getNameLike(nameArtist); - if(data === null || data === undefined || data.length === 0) { + if (data === null || data === undefined || data.length === 0) { reject('Data does not exist in the local BDD'); return; } @@ -56,26 +56,26 @@ export class GenericInterfaceModelDB { key: 'id', value: [undefined, null], }, - ], - [ 'name', 'id' ]); + ], + ['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`); + console.log(`[E] ${self.constructor.name}: can not retrive BDD values`); reject(response); }); }); } - get(id:number): Promise { + get(id: number): Promise { let self = this; return new Promise((resolve, reject) => { self.bdd.get(self.serviceName) .then((response: DataInterface) => { let data = response.get(id); - if(isNullOrUndefined(data)) { + if (isNullOrUndefined(data)) { reject('Data does not exist in the local BDD'); return; } @@ -92,13 +92,13 @@ export class GenericInterfaceModelDB { self.bdd.get(self.serviceName) .then((response: DataInterface) => { let data = response.getsWhere([ - { - check: TypeCheck.EQUAL, - key: 'id', - value: ids, - }, - ], - [ 'name', 'id' ]); + { + check: TypeCheck.EQUAL, + key: 'id', + value: ids, + }, + ], + ['name', 'id']); resolve(data); return; }).catch((response) => { @@ -111,11 +111,11 @@ export class GenericInterfaceModelDB { let self = this; return new Promise((resolve, reject) => { self.bdd.get(self.serviceName) - .then((response:DataInterface) => { + .then((response: DataInterface) => { let data = response.gets(); resolve(data); }).catch((response) => { - console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`); + console.log(`[E] ${self.constructor.name}: can not retrive BDD values`); reject(response); }); }); @@ -124,25 +124,25 @@ export class GenericInterfaceModelDB { insert(data: any): any { let ret = this.http.postSpecific([this.serviceName], data); return this.bdd.addAfterPost(this.serviceName, ret); - + } - put(id:number, data:any):any { - let ret = this.http.putSpecific([this.serviceName, id], data); + 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 { + 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) { + 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) { + if (data === null || data === undefined) { reject('error retrive data from server'); return; } @@ -153,19 +153,19 @@ export class GenericInterfaceModelDB { }); }); } - uploadCover(file:File, - nodeId:number, - progress:any = null) { - const formData = new FormData(); - formData.append('fileName', file.name); + 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; + formData.append('file', file); + let self = this; return new Promise((resolve, reject) => { - self.http.uploadMultipart(`${this.serviceName }/${nodeId}/add_cover/`, formData, progress) + self.http.uploadMultipart(`${this.serviceName}/${nodeId}/add_cover/`, formData, progress) .then((response) => { let data = response; - if(data === null || data === undefined) { + if (data === null || data === undefined) { reject('error retrive data from server'); return; } diff --git a/front/src/app/service/GenericInterfaceModelDBv2.ts b/front/src/app/service/GenericInterfaceModelDBv2.ts index 597b0ec..77e3dd8 100644 --- a/front/src/app/service/GenericInterfaceModelDBv2.ts +++ b/front/src/app/service/GenericInterfaceModelDBv2.ts @@ -83,8 +83,8 @@ export class GenericInterfaceModelDBv2 { return this.bdd.addAfterPost(this.serviceName, ret) as TYPE; } - put(id: number, data: object): TYPE { - let ret = this.http.putSpecific([this.serviceName, id], data); + 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; } diff --git a/front/src/app/service/advancement.ts b/front/src/app/service/advancement.ts index 7e4bb09..bd701a7 100644 --- a/front/src/app/service/advancement.ts +++ b/front/src/app/service/advancement.ts @@ -28,7 +28,7 @@ export class AdvancementService extends GenericInterfaceModelDBv2