fix publication post

This commit is contained in:
Peter Maquiran
2024-03-27 13:35:56 +01:00
parent 37ae4d5325
commit 77315c3fb5
4 changed files with 34 additions and 21 deletions
@@ -30,6 +30,7 @@ export class PublicationHolderService {
} }
window['upload-header-set-add'] = (id: string, percentage: number, save: Function) => { window['upload-header-set-add'] = (id: string, percentage: number, save: Function) => {
this.remove(id)
this.PublicationFormMV.push({id, percentage, retry: false, retryFunction: save}) this.PublicationFormMV.push({id, percentage, retry: false, retryFunction: save})
this.uploadPercentage() this.uploadPercentage()
} }
@@ -139,7 +139,7 @@ class ReconnectingWebSocketSignalR {
if (!this.stop && (!error || error.message !== "Connection stopped by client.")) { if (!this.stop && (!error || error.message !== "Connection stopped by client.")) {
setTimeout(() => { setTimeout(() => {
this.connect(); this.connect();
}, 1000); // Ajuste o atraso conforme necessário }, 3000); // Ajuste o atraso conforme necessário
} }
@@ -407,30 +407,16 @@ export class ObjectMergeNotification{
constructor() { constructor() {
this.socket.onDisconnectCallback(()=> { this.socket.onDisconnectCallback(()=> {
console.log("run watch") //console.log("run watch")
this.runWatch = true this.runWatch = true
this.watch() //this.watch()
}) })
this.socket.onConnectCallback(() => { this.socket.onConnectCallback(() => {
console.log("open trigger") console.log("open trigger")
this.runWatch = false 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() { connect() {
@@ -43,8 +43,6 @@ export class PublicationFromMvService {
clear() { clear() {
this.id = uuidv4() this.id = uuidv4()
this.UploadFileUseCase = new UploadFileUseCase() this.UploadFileUseCase = new UploadFileUseCase()
this.form = new PublicationFormModel() this.form = new PublicationFormModel()
@@ -67,6 +65,8 @@ export class PublicationFromMvService {
save = async() => { save = async() => {
const needChunk = this.needToUploadChunk()
if (this.publicationType == ActionType.edit) { if (this.publicationType == ActionType.edit) {
if (this.form.Files.length >= 1) { if (this.form.Files.length >= 1) {
@@ -75,6 +75,14 @@ export class PublicationFromMvService {
this.form.send = true this.form.send = true
const upload = await this.uploadVideosFiles() 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) { if(upload) {
this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => { this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => {
if(e.FileType == 'video' && e.toUpload) { if(e.FileType == 'video' && e.toUpload) {
@@ -100,14 +108,18 @@ export class PublicationFromMvService {
this.httpErroHandle.httpsSucessMessagge('Editar publicação') this.httpErroHandle.httpsSucessMessagge('Editar publicação')
this.publicationFolderService.getPublicationsIds(this.folderId) this.publicationFolderService.getPublicationsIds(this.folderId)
window['upload-header-set-remove'](this.id);
// this.goBack(); // this.goBack();
} catch (error) { } catch (error) {
this.httpErroHandle.httpStatusHandle(error) this.httpErroHandle.httpStatusHandle(error)
if (error.status == 404) { if (error.status == 404) {
this.PublicationFolderService.deletePost(this.form.ProcessId, this.form.DocumentId) this.PublicationFolderService.deletePost(this.form.ProcessId, this.form.DocumentId)
// this.goBack(); // this.goBack();
} else {
window['upload-header-set-retry'](this.id)
} }
} finally { } finally {
// loader.remove() // loader.remove()
@@ -115,6 +127,7 @@ export class PublicationFromMvService {
} else { } else {
window['upload-header-set-retry'](this.id)
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo")
} }
@@ -129,6 +142,13 @@ export class PublicationFromMvService {
this.form.send = true this.form.send = true
const upload = await this.uploadVideosFiles() 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) { if(upload) {
this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => { this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => {
if(e.FileType == 'video' && e.toUpload) { if(e.FileType == 'video' && e.toUpload) {
@@ -176,12 +196,14 @@ export class PublicationFromMvService {
window['upload-header-set-remove'](this.id); window['upload-header-set-remove'](this.id);
this.publicationFolderService.getPublicationsIds(this.folderId) this.publicationFolderService.getPublicationsIds(this.folderId)
} catch (error) { } catch (error) {
window['upload-header-set-retry'](this.id)
this.httpErroHandle.httpStatusHandle(error) this.httpErroHandle.httpStatusHandle(error)
} finally { } finally {
// loader.remove() // loader.remove()
} }
} else { } else {
window['upload-header-set-retry'](this.id)
this.toastService._badRequest("ocorreu um erro ao enviar o ficheiro") this.toastService._badRequest("ocorreu um erro ao enviar o ficheiro")
// loader.remove() // loader.remove()
} }
@@ -189,6 +211,7 @@ export class PublicationFromMvService {
} else { } else {
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") 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) { setDataToFrom(data: IPublicationFormModelEntity) {
+1 -1
View File
@@ -4,4 +4,4 @@ import { environment as oaprDev } from './suport/oapr'
import { DevDev } from './suport/dev' import { DevDev } from './suport/dev'
export const environment: Environment = DevDev export const environment: Environment = oaprDev