mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Added validation to check if user add image ou video and prevent to create publication withou it
This commit is contained in:
@@ -278,7 +278,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
({
|
({
|
||||||
multiple: true,
|
multiple: true,
|
||||||
});
|
});
|
||||||
console.log(result.files)
|
console.log(result.files)
|
||||||
result.files.forEach(element => {
|
result.files.forEach(element => {
|
||||||
|
|
||||||
this.filesSizeSum = this.filesSizeSum + element.size
|
this.filesSizeSum = this.filesSizeSum + element.size
|
||||||
@@ -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,51 +405,52 @@ 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()
|
||||||
|
|
||||||
// has file
|
// has file
|
||||||
if (this.PublicationFolderService.PublicationHasImage(this.publication)) {
|
if (this.PublicationFolderService.PublicationHasImage(this.publication)) {
|
||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: this.publication.DateIndex,
|
DateIndex: this.publication.DateIndex,
|
||||||
DocumentId: this.publication.DocumentId,
|
DocumentId: this.publication.DocumentId,
|
||||||
ProcessId: this.publication.ProcessId,
|
ProcessId: this.publication.ProcessId,
|
||||||
Title: this.pub.Title,
|
Title: this.pub.Title,
|
||||||
Message: this.pub.Message,
|
Message: this.pub.Message,
|
||||||
DatePublication: this.publication.DatePublication,
|
DatePublication: this.publication.DatePublication,
|
||||||
OriginalFileName: this.publication.OriginalFileName,
|
OriginalFileName: this.publication.OriginalFileName,
|
||||||
Files: this.seletedContent,
|
Files: this.seletedContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* } else if (this.capturedVideo != '' && this.capturedImage == '') {
|
/* } else if (this.capturedVideo != '' && this.capturedImage == '') {
|
||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: this.publication.DateIndex,
|
DateIndex: this.publication.DateIndex,
|
||||||
DocumentId: this.publication.DocumentId,
|
DocumentId: this.publication.DocumentId,
|
||||||
ProcessId: this.publication.ProcessId,
|
ProcessId: this.publication.ProcessId,
|
||||||
Title: this.pub.Title,
|
Title: this.pub.Title,
|
||||||
Message: this.pub.Message,
|
Message: this.pub.Message,
|
||||||
DatePublication: this.publication.DatePublication,
|
DatePublication: this.publication.DatePublication,
|
||||||
OriginalFileName: this.publication.OriginalFileName || 'video',
|
OriginalFileName: this.publication.OriginalFileName || 'video',
|
||||||
Files: this.seletedContent,
|
Files: this.seletedContent,
|
||||||
FileExtension: 'mp4',
|
FileExtension: 'mp4',
|
||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
// no names
|
// no names
|
||||||
} else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) {
|
} else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) {
|
||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: this.publication.DateIndex,
|
DateIndex: this.publication.DateIndex,
|
||||||
DocumentId: this.publication.DocumentId,
|
DocumentId: this.publication.DocumentId,
|
||||||
ProcessId: this.publication.ProcessId,
|
ProcessId: this.publication.ProcessId,
|
||||||
Title: this.pub.Title,
|
Title: this.pub.Title,
|
||||||
Message: this.pub.Message,
|
Message: this.pub.Message,
|
||||||
DatePublication: this.publication.DatePublication,
|
DatePublication: this.publication.DatePublication,
|
||||||
OriginalFileName: this.publication.OriginalFileName,
|
OriginalFileName: this.publication.OriginalFileName,
|
||||||
Files: this.seletedContent,
|
Files: this.seletedContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} /* else {
|
} /* else {
|
||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: this.publication.DateIndex,
|
DateIndex: this.publication.DateIndex,
|
||||||
DocumentId: this.publication.DocumentId,
|
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')
|
this.httpErrorHandle.httpsSucessMessagge('Editar publicação')
|
||||||
console.log({ response })
|
console.log({ response })
|
||||||
|
|
||||||
|
|
||||||
this.close();
|
|
||||||
} catch (error) {
|
|
||||||
if (error.status == 404) {
|
|
||||||
this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId)
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
} catch (error) {
|
||||||
this.httpErrorHandle.httpStatusHandle(error)
|
if (error.status == 404) {
|
||||||
} finally {
|
this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId)
|
||||||
loader.remove()
|
this.close();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
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",
|
|
||||||
}
|
}
|
||||||
|
this.httpErrorHandle.httpStatusHandle(error)
|
||||||
|
} finally {
|
||||||
|
loader.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
return e
|
}
|
||||||
}) */
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
/* 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.PublicationFolderService.getPublicationsIds(this.folderId)
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.httpErrorHandle.validationMessagge("noFileSelected")
|
||||||
}
|
}
|
||||||
|
|
||||||
this.PublicationFolderService.getPublicationsIds(this.folderId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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
Reference in New Issue
Block a user