diff --git a/src/app/services/publication/publication-holder.service.ts b/src/app/services/publication/publication-holder.service.ts index efcf34b3b..beda76b73 100644 --- a/src/app/services/publication/publication-holder.service.ts +++ b/src/app/services/publication/publication-holder.service.ts @@ -30,6 +30,7 @@ export class PublicationHolderService { } window['upload-header-set-add'] = (id: string, percentage: number, save: Function) => { + this.remove(id) this.PublicationFormMV.push({id, percentage, retry: false, retryFunction: save}) this.uploadPercentage() } diff --git a/src/app/services/socket-connection-mcr.service.ts b/src/app/services/socket-connection-mcr.service.ts index b39836fbf..3ea38070c 100644 --- a/src/app/services/socket-connection-mcr.service.ts +++ b/src/app/services/socket-connection-mcr.service.ts @@ -139,7 +139,7 @@ class ReconnectingWebSocketSignalR { if (!this.stop && (!error || error.message !== "Connection stopped by client.")) { setTimeout(() => { this.connect(); - }, 1000); // Ajuste o atraso conforme necessário + }, 3000); // Ajuste o atraso conforme necessário } @@ -407,30 +407,16 @@ export class ObjectMergeNotification{ constructor() { this.socket.onDisconnectCallback(()=> { - console.log("run watch") + //console.log("run watch") this.runWatch = true - this.watch() + //this.watch() }) - this.socket.onConnectCallback(()=> { - + this.socket.onConnectCallback(() => { console.log("open trigger") this.runWatch = false }) - // this.socket.subscribe((data: socketResponse) => { - // if(data.IsCompleted == true) { - // console.log("==================!!!====================") - // try { - // this.callbacks[data.Guid](data) - // delete this.callbacks[data.Guid] - // } catch (error) {} - // } else { - // console.log("else", data) - // } - // }) - - // this.watch() } connect() { diff --git a/src/app/shared/publication/upload/publication-from-mv.service.ts b/src/app/shared/publication/upload/publication-from-mv.service.ts index 832039070..1f1c3591b 100644 --- a/src/app/shared/publication/upload/publication-from-mv.service.ts +++ b/src/app/shared/publication/upload/publication-from-mv.service.ts @@ -43,8 +43,6 @@ export class PublicationFromMvService { clear() { - - this.id = uuidv4() this.UploadFileUseCase = new UploadFileUseCase() this.form = new PublicationFormModel() @@ -67,6 +65,8 @@ export class PublicationFromMvService { save = async() => { + const needChunk = this.needToUploadChunk() + if (this.publicationType == ActionType.edit) { if (this.form.Files.length >= 1) { @@ -75,6 +75,14 @@ export class PublicationFromMvService { this.form.send = true const upload = await this.uploadVideosFiles() + + const needChunk = this.needToUploadChunk() + if(needChunk.length == 0 ) { + window['upload-header-set-percentage'](this.id, 50) + } else { + window['upload-header-set-percentage'](this.id, 100) + } + if(upload) { this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => { if(e.FileType == 'video' && e.toUpload) { @@ -100,14 +108,18 @@ export class PublicationFromMvService { this.httpErroHandle.httpsSucessMessagge('Editar publicação') this.publicationFolderService.getPublicationsIds(this.folderId) + window['upload-header-set-remove'](this.id); // this.goBack(); } catch (error) { + this.httpErroHandle.httpStatusHandle(error) if (error.status == 404) { this.PublicationFolderService.deletePost(this.form.ProcessId, this.form.DocumentId) // this.goBack(); + } else { + window['upload-header-set-retry'](this.id) } } finally { // loader.remove() @@ -115,6 +127,7 @@ export class PublicationFromMvService { } else { + window['upload-header-set-retry'](this.id) this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") } @@ -129,6 +142,13 @@ export class PublicationFromMvService { this.form.send = true const upload = await this.uploadVideosFiles() + const needChunk = this.needToUploadChunk() + if(needChunk.length ==0 ) { + window['upload-header-set-percentage'](this.id, 50) + } else { + window['upload-header-set-percentage'](this.id, 100) + } + if(upload) { this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => { if(e.FileType == 'video' && e.toUpload) { @@ -176,12 +196,14 @@ export class PublicationFromMvService { window['upload-header-set-remove'](this.id); this.publicationFolderService.getPublicationsIds(this.folderId) } catch (error) { + window['upload-header-set-retry'](this.id) this.httpErroHandle.httpStatusHandle(error) } finally { // loader.remove() } } else { + window['upload-header-set-retry'](this.id) this.toastService._badRequest("ocorreu um erro ao enviar o ficheiro") // loader.remove() } @@ -189,6 +211,7 @@ export class PublicationFromMvService { } else { + this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") } @@ -200,6 +223,9 @@ export class PublicationFromMvService { } + needToUploadChunk() { + return this.form.Files.filter( e => e.FileType == "video" && e.toUpload) + } setDataToFrom(data: IPublicationFormModelEntity) { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 8982b9007..03d2a6508 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,4 +4,4 @@ import { environment as oaprDev } from './suport/oapr' import { DevDev } from './suport/dev' -export const environment: Environment = DevDev +export const environment: Environment = oaprDev