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
@@ -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) {