Added validation to check if user add image ou video and prevent to create publication withou it

This commit is contained in:
Eudes Inácio
2024-02-02 12:05:42 +01:00
parent 01f15f97ac
commit a5b29e330a
2 changed files with 172 additions and 182 deletions
@@ -293,9 +293,9 @@ export class NewPublicationPage implements OnInit {
console.log(content) console.log(content)
this.filecontent = true; this.filecontent = true;
let fileObject; let fileObject;
if(this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") { if (this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") {
fileObject = { fileObject = {
FileBase64: 'data:video/mp4;base64,'+ content.data, FileBase64: 'data:video/mp4;base64,' + content.data,
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'), FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
OriginalFileName: 'video' OriginalFileName: 'video'
} }
@@ -405,6 +405,7 @@ export class NewPublicationPage implements OnInit {
if (this.Form.invalid) return false if (this.Form.invalid) return false
if (this.seletedContent.length != 0) {
if (this.publicationType == '3') { if (this.publicationType == '3') {
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -534,7 +535,6 @@ export class NewPublicationPage implements OnInit {
try { try {
await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
this.close(); this.close();
this.httpErrorHandle.httpsSucessMessagge('Criar publicação') this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
@@ -551,6 +551,10 @@ export class NewPublicationPage implements OnInit {
} }
this.PublicationFolderService.getPublicationsIds(this.folderId) this.PublicationFolderService.getPublicationsIds(this.folderId)
} else {
this.httpErrorHandle.validationMessagge("noFileSelected")
}
} }
@@ -741,7 +745,7 @@ export class NewPublicationPage implements OnInit {
let resultUrl = decodeURIComponent(element.url); let resultUrl = decodeURIComponent(element.url);
Filesystem.readFile({ path: resultUrl }).then(async (content) => { Filesystem.readFile({ path: resultUrl }).then(async (content) => {
let fileObject; let fileObject;
if(this.checkFileType.checkFileType(FileExtension) == 'image') { if (this.checkFileType.checkFileType(FileExtension) == 'image') {
fileObject = { fileObject = {
FileBase64: this.removeTextBeforeSlash(content.data, ','), FileBase64: this.removeTextBeforeSlash(content.data, ','),
FileExtension: FileExtension, FileExtension: FileExtension,
@@ -750,7 +754,7 @@ export class NewPublicationPage implements OnInit {
} else if (this.checkFileType.checkFileType(FileExtension) == 'video') { } else if (this.checkFileType.checkFileType(FileExtension) == 'video') {
fileObject = { fileObject = {
FileBase64: 'data:video/mp4;base64,'+ this.removeTextBeforeSlash(content.data, ','), FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','),
FileExtension: FileExtension, FileExtension: FileExtension,
OriginalFileName: 'shared', OriginalFileName: 'shared',
} }
File diff suppressed because one or more lines are too long