From d5f335e1e7c04693930857bd315d0936d29792b1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 15 Apr 2024 00:56:45 +0200 Subject: [PATCH] [DEV] add progress callback --- .../org/kar/karusic/api/AlbumResource.java | 2 ++ .../org/kar/karusic/api/ArtistResource.java | 2 ++ .../org/kar/karusic/api/GenderResource.java | 2 ++ .../org/kar/karusic/api/TrackResource.java | 20 ++++++++------ front/package.json | 3 +-- front/src/app/scene/track/track.ts | 4 ++- front/src/app/service/data.ts | 4 +-- front/src/app/service/track.ts | 27 ------------------- 8 files changed, 24 insertions(+), 40 deletions(-) diff --git a/back/src/org/kar/karusic/api/AlbumResource.java b/back/src/org/kar/karusic/api/AlbumResource.java index 3689153..56eb152 100644 --- a/back/src/org/kar/karusic/api/AlbumResource.java +++ b/back/src/org/kar/karusic/api/AlbumResource.java @@ -7,6 +7,7 @@ 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.annotation.TypeScriptProgress; import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.dataAccess.addOn.AddOnManyToMany; @@ -99,6 +100,7 @@ public class AlbumResource { @Consumes({ MediaType.MULTIPART_FORM_DATA }) @Operation(description = "Add a cover on a specific album") @AsyncType(Album.class) + @TypeScriptProgress public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData); diff --git a/back/src/org/kar/karusic/api/ArtistResource.java b/back/src/org/kar/karusic/api/ArtistResource.java index 05ae3dd..6c4ef67 100644 --- a/back/src/org/kar/karusic/api/ArtistResource.java +++ b/back/src/org/kar/karusic/api/ArtistResource.java @@ -7,6 +7,7 @@ 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.annotation.TypeScriptProgress; import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.tools.DataTools; @@ -72,6 +73,7 @@ public class ArtistResource { @RolesAllowed("ADMIN") @Consumes({ MediaType.MULTIPART_FORM_DATA }) @AsyncType(Artist.class) + @TypeScriptProgress public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData); diff --git a/back/src/org/kar/karusic/api/GenderResource.java b/back/src/org/kar/karusic/api/GenderResource.java index 34334bb..a94e044 100644 --- a/back/src/org/kar/karusic/api/GenderResource.java +++ b/back/src/org/kar/karusic/api/GenderResource.java @@ -7,6 +7,7 @@ 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.annotation.TypeScriptProgress; import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.addOn.AddOnDataJson; import org.kar.archidata.tools.DataTools; @@ -72,6 +73,7 @@ public class GenderResource { @RolesAllowed("ADMIN") @Consumes({ MediaType.MULTIPART_FORM_DATA }) @AsyncType(Gender.class) + @TypeScriptProgress public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData); diff --git a/back/src/org/kar/karusic/api/TrackResource.java b/back/src/org/kar/karusic/api/TrackResource.java index 9a33992..f87f00c 100644 --- a/back/src/org/kar/karusic/api/TrackResource.java +++ b/back/src/org/kar/karusic/api/TrackResource.java @@ -10,6 +10,7 @@ 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.annotation.TypeScriptProgress; import org.kar.archidata.dataAccess.DataAccess; import org.kar.archidata.dataAccess.QueryCondition; import org.kar.archidata.dataAccess.addOn.AddOnDataJson; @@ -99,6 +100,7 @@ public class TrackResource { @RolesAllowed("ADMIN") @Consumes({ MediaType.MULTIPART_FORM_DATA }) @AsyncType(Track.class) + @TypeScriptProgress public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData) { return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData); @@ -118,16 +120,18 @@ public class TrackResource { @Consumes({ MediaType.MULTIPART_FORM_DATA }) // Formatter:off @AsyncType(Track.class) + @TypeScriptProgress public Response uploadTrack( - @FormDataParam("fileName") String fileName, - @FormDataParam("gender") String gender, - @FormDataParam("artist") String artist, + @FormDataParam("fileName") String fileName, // + @FormDataParam("gender") String gender, // + @FormDataParam("artist") String artist, // //@FormDataParam("seriesId") String seriesId, Not used ... - @FormDataParam("album") String album, - @AsyncType(Long.class) @FormDataParam("trackId") String trackId, - @FormDataParam("title") String title, - @FormDataParam("file") final InputStream fileInputStream, - @FormDataParam("file") final FormDataContentDisposition fileMetaData) { + @FormDataParam("album") String album, // + @AsyncType(Long.class) @FormDataParam("trackId") String trackId, // + @FormDataParam("title") String title, // + @FormDataParam("file") final InputStream fileInputStream, // + @FormDataParam("file") final FormDataContentDisposition fileMetaData // + ) { // Formatter:on try { // correct input string stream : diff --git a/front/package.json b/front/package.json index 9aec6f3..9609b15 100644 --- a/front/package.json +++ b/front/package.json @@ -14,8 +14,7 @@ "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/", - "publish": "pnpm publish --no-git-checks" + "unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/" }, "private": true, "dependencies": { diff --git a/front/src/app/scene/track/track.ts b/front/src/app/scene/track/track.ts index 616a3a5..ad0475f 100644 --- a/front/src/app/scene/track/track.ts +++ b/front/src/app/scene/track/track.ts @@ -546,10 +546,12 @@ export class TrackScene implements OnInit { // convert it and send it to the server let self = this; + console.log("not implemented right now..."); + /* this.videoCanva.toBlob((blob) => { self.trackService.uploadCoverBlob(blob, this.idTrack); }, 'image/jpeg', 0.95); - + */ /* let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95); fetch(tmpUrl) diff --git a/front/src/app/service/data.ts b/front/src/app/service/data.ts index 9d6fef1..582c007 100644 --- a/front/src/app/service/data.ts +++ b/front/src/app/service/data.ts @@ -5,9 +5,9 @@ */ import { Injectable } from '@angular/core'; -import { SessionService, isNullOrUndefined, isString } from '@kangaroo-and-rabbit/kar-cw'; +import { SessionService, isArrayOf, isNullOrUndefined, isString } from '@kangaroo-and-rabbit/kar-cw'; -import { RESTConfig, RESTUrl, isArrayOf } from 'app/back-api/rest-tools'; +import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools'; import { environment } from 'environments/environment'; @Injectable() diff --git a/front/src/app/service/track.ts b/front/src/app/service/track.ts index 1bc6853..db358f8 100644 --- a/front/src/app/service/track.ts +++ b/front/src/app/service/track.ts @@ -423,32 +423,5 @@ export class TrackService extends GenericDataService { }); }); } - - - uploadCoverBlob(blob: Blob, - TrackId: number, - progress: any = null) { - /* - const formData = new FormData(); - formData.append('fileName', 'take_screenshoot'); - formData.append('typeId', TrackId.toString()); - formData.append('file', blob); - let self = this; - return new Promise((resolve, reject) => { - self.http.uploadMultipart(`${this.serviceName}/${TrackId}/add_cover/`, formData, progress) - .then((response) => { - let data = response; - if (data === null || data === undefined) { - reject('error retrieve data from server'); - return; - } - self.bdd.asyncSetInDB(self.serviceName, TrackId, data); - resolve(data); - }).catch((response) => { - reject(response); - }); - }); - */ - } }