From a5b29e330a517c671a7e0d77db74817b4c3e0219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Fri, 2 Feb 2024 12:05:42 +0100 Subject: [PATCH] Added validation to check if user add image ou video and prevent to create publication withou it --- .../new-publication/new-publication.page.ts | 248 +++++++++--------- .../new-publication/new-publication.page.ts | 106 ++++---- 2 files changed, 172 insertions(+), 182 deletions(-) diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index daecf62fc..4b100fc7f 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -278,7 +278,7 @@ export class NewPublicationPage implements OnInit { ({ multiple: true, }); - console.log(result.files) + console.log(result.files) result.files.forEach(element => { this.filesSizeSum = this.filesSizeSum + element.size @@ -293,9 +293,9 @@ export class NewPublicationPage implements OnInit { console.log(content) this.filecontent = true; let fileObject; - if(this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") { - fileObject = { - FileBase64: 'data:video/mp4;base64,'+ content.data, + if (this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") { + fileObject = { + FileBase64: 'data:video/mp4;base64,' + content.data, FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'), OriginalFileName: 'video' } @@ -306,7 +306,7 @@ export class NewPublicationPage implements OnInit { OriginalFileName: 'image' } } - + this.seletedContent.push(fileObject) }) .catch((err) => console.error(err)); @@ -405,51 +405,52 @@ export class NewPublicationPage implements OnInit { if (this.Form.invalid) return false + if (this.seletedContent.length != 0) { - if (this.publicationType == '3') { - const loader = this.toastService.loading() + if (this.publicationType == '3') { + const loader = this.toastService.loading() - // has file - if (this.PublicationFolderService.PublicationHasImage(this.publication)) { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName, - Files: this.seletedContent, - } + // has file + if (this.PublicationFolderService.PublicationHasImage(this.publication)) { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName, + Files: this.seletedContent, + } - /* } else if (this.capturedVideo != '' && this.capturedImage == '') { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName || 'video', - Files: this.seletedContent, - FileExtension: 'mp4', - } - } */ - // no names - } else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName, - Files: this.seletedContent, - } + /* } else if (this.capturedVideo != '' && this.capturedImage == '') { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName || 'video', + Files: this.seletedContent, + FileExtension: 'mp4', + } + } */ + // no names + } else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName, + Files: this.seletedContent, + } - } /* else { + } /* else { this.publication = { DateIndex: this.publication.DateIndex, DocumentId: this.publication.DocumentId, @@ -465,92 +466,95 @@ export class NewPublicationPage implements OnInit { } */ - try { + try { - const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() + const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() - this.httpErrorHandle.httpsSucessMessagge('Editar publicação') - console.log({ response }) + this.httpErrorHandle.httpsSucessMessagge('Editar publicação') + console.log({ response }) - this.close(); - } catch (error) { - if (error.status == 404) { - this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) this.close(); - } - this.httpErrorHandle.httpStatusHandle(error) - } finally { - loader.remove() - } - - } - else { - - const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss') - - /* this.seletedContent = this.seletedContent.map((e) => { - if(e.FileExtension == "mp4") { - return { - FileBase64: e.FileBase64, - FileExtension: 'data:video/mp4;base64,'+e.FileExtension, - OriginalFileName: "video", + } catch (error) { + if (error.status == 404) { + this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) + this.close(); } + this.httpErrorHandle.httpStatusHandle(error) + } finally { + loader.remove() + } + + } + else { + + const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss') + + /* this.seletedContent = this.seletedContent.map((e) => { + if(e.FileExtension == "mp4") { + return { + FileBase64: e.FileBase64, + FileExtension: 'data:video/mp4;base64,'+e.FileExtension, + OriginalFileName: "video", + } + } + + return e + }) */ + + /* if (this.capturedImage != '') { */ + this.publication = { + DateIndex: date, + DocumentId: null, + ProcessId: this.folderId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: date, + OriginalFileName: this.capturedImageTitle || 'foto', + Files: this.seletedContent, + /* FileExtension: 'jpeg', */ + } + + /* } else if (this.capturedVideo != '') { + this.publication = { + DateIndex: date, + DocumentId: null, + ProcessId: this.folderId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: date, + OriginalFileName: this.capturedImageTitle || 'video', + Files: this.seletedContent, + FileExtension: 'mp4', + } + } */ + + + const loader = this.toastService.loading() + + try { + + + await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); + this.close(); + this.httpErrorHandle.httpsSucessMessagge('Criar publicação') + window["sharedContent"] = null; + window["endSharedContent"] = null; + + this.close(); + } catch (error) { + this.httpErrorHandle.httpStatusHandle(error) + } finally { + loader.remove() } - - return e - }) */ - /* if (this.capturedImage != '') { */ - this.publication = { - DateIndex: date, - DocumentId: null, - ProcessId: this.folderId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: date, - OriginalFileName: this.capturedImageTitle || 'foto', - Files: this.seletedContent, - /* FileExtension: 'jpeg', */ } - /* } else if (this.capturedVideo != '') { - this.publication = { - DateIndex: date, - DocumentId: null, - ProcessId: this.folderId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: date, - OriginalFileName: this.capturedImageTitle || 'video', - Files: this.seletedContent, - FileExtension: 'mp4', - } - } */ - - - const loader = this.toastService.loading() - - try { - - - - await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); - this.close(); - this.httpErrorHandle.httpsSucessMessagge('Criar publicação') - window["sharedContent"] = null; - window["endSharedContent"] = null; - - this.close(); - } catch (error) { - this.httpErrorHandle.httpStatusHandle(error) - } finally { - loader.remove() - } + this.PublicationFolderService.getPublicationsIds(this.folderId) + } else { + this.httpErrorHandle.validationMessagge("noFileSelected") } - - this.PublicationFolderService.getPublicationsIds(this.folderId) } @@ -741,7 +745,7 @@ export class NewPublicationPage implements OnInit { let resultUrl = decodeURIComponent(element.url); Filesystem.readFile({ path: resultUrl }).then(async (content) => { let fileObject; - if(this.checkFileType.checkFileType(FileExtension) == 'image') { + if (this.checkFileType.checkFileType(FileExtension) == 'image') { fileObject = { FileBase64: this.removeTextBeforeSlash(content.data, ','), FileExtension: FileExtension, @@ -750,14 +754,14 @@ export class NewPublicationPage implements OnInit { } else if (this.checkFileType.checkFileType(FileExtension) == 'video') { fileObject = { - FileBase64: 'data:video/mp4;base64,'+ this.removeTextBeforeSlash(content.data, ','), + FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','), FileExtension: FileExtension, OriginalFileName: 'shared', } } console.log('shared base', content.data) - + this.seletedContent.push(fileObject) }) } else { diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index 5eaad0d59..ee0524cb9 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -368,7 +368,7 @@ export class NewPublicationPage implements OnInit { FileType: this.checkFileType.checkFileType(this.removeTextBeforeSlash(element.mimeType, '/')) }) this.seletedContent.push(fileObject) - console.log('Files array',this.seletedContent) + console.log('Files array', this.seletedContent) }) .catch((err) => console.error(err)); } catch (error) { @@ -417,72 +417,60 @@ export class NewPublicationPage implements OnInit { } - if (this.seletedContent.length == 0) { - - const newAttachment = new PublicationAttachmentEntity( - { - base64: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgMAAAIJCAIAAAC3IqlmAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAABSKSURBVHhe7d1ncuNGo4bRu/8lfh5F5qToBdyWNJbHDYgAmETqPVXnh4PAhKp+iMDu/3v9+28AkikBQDolAEinBADplAAgnRIApFMCgHRKAJBOCQDSKQFAOiUASKcEAOmUACCdEgCkUwKAdEoAkE4JANIpAUA6JQBIpwQA6ZQAIJ0SAKRTAoB0SgCQTgkA0ikBQDolAEinBADplAAgnRIApFMCgHRKAJBOCQDSKQFAOiUASKcEAOmUACCdEgCkUwKAdEoAkE4JANIpAUA6JQBIpwQA6ZQAIJ0SAKRTAoB0SgCQTgkA0ikBQDolAEinBADplAAgnRIApFMCgHRKAJBOCQDSKQFAOiUASKcEAOmUACCdEgCkUwKAdEoAkE4JANIpAUA6JQBIpwQA6ZQAIJ0SAKRTAoB0SgCQTgkA0ikBQDolAEinBADplAAgnRIApFMCgHRKAJBOCQDSKQFAOiUASKcEAOmUACCdEgCkUwKAdEoAkE4JANIpAUA6JQBIpwQA6ZQAIJ0SAKRTA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", - OriginalFileName: "foto", - FileType: 'image' - } - ) - - this.seletedContent.push(newAttachment) - } + if (this.seletedContent.length != 0) { - if (this.publicationType == ActionType.edit) { + if (this.publicationType == ActionType.edit) { - if (this.seletedContent.length >= 1) { - const loader = this.toastService.loading() + if (this.seletedContent.length >= 1) { + const loader = this.toastService.loading() - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - Files: this.seletedContent, - } - - - this.publication.Files = this.publication.Files.map(e => ({ - FileBase64: e.FileBase64, - FileExtension: e.FileExtension, - OriginalFileName: 'foto' - })) - - try { - - const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() - - this.httpErroHandle.httpsSucessMessagge('Editar publicação') - - this.goBack(); - - } catch (error) { - this.httpErroHandle.httpStatusHandle(error) - if (error.status == 404) { - this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) - this.goBack(); + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + Files: this.seletedContent, } - } finally { - loader.remove() + + + this.publication.Files = this.publication.Files.map(e => ({ + FileBase64: e.FileBase64, + FileExtension: e.FileExtension, + OriginalFileName: 'foto' + })) + + try { + + const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() + + this.httpErroHandle.httpsSucessMessagge('Editar publicação') + + this.goBack(); + + } catch (error) { + this.httpErroHandle.httpStatusHandle(error) + if (error.status == 404) { + this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) + this.goBack(); + } + } finally { + loader.remove() + } + + + } else { + this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") } - } else { - this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") } + else { + let time = new Date() - - } - else { - let time = new Date() - if (this.seletedContent.length >= 1) { this.publication = { DateIndex: time, DocumentId: null, @@ -525,11 +513,9 @@ export class NewPublicationPage implements OnInit { loader.remove() } - - } else { - this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo") } - + } else { + this.httpErrorHandle.validationMessagge("noFileSelected") } }