fix publication OrifinalFilename

This commit is contained in:
Peter Maquiran
2024-01-12 12:13:51 +01:00
parent 86b65f3e46
commit 69ee75b039
15 changed files with 187 additions and 122 deletions
@@ -51,12 +51,12 @@
<ion-img *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'image'"
name="image" ngDefaultControl [src]="seleted.FileBase64"></ion-img>
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video'" width="70" height="70"
preload="metadata" webkit-playsinline="webkit-playsinline">
<source type="video/mp4" [src]="seleted.FileBase64">
</video>
</ion-thumbnail>
<!-- Display the blurred image and count if there are more images -->
<ion-thumbnail *ngIf="seletedContent.length > displayLimit" lot="start">
@@ -102,8 +102,6 @@
</div>
</div> -->
<div class="ion-item-container-no-border hide-desktop">
<ion-label (click)="loadVideo()">
<div class="attach-icon">
@@ -130,7 +130,16 @@ export class NewPublicationPage implements OnInit {
}
console.log('edit',this.publication)
this.pub = this.publication;
this.seletedContent = this.publication.Files;
this.seletedContent = this.publication.Files.map( e => {
return new PublicationAttachmentEntity(
{
base64: e.FileBase64,
extension: e.FileExtension,
OriginalFileName: e.OriginalFileName,
FileType: this.checkFileType.checkFileType(e.FileExtension)
}
)
})
this.showLoader = false;
}, (error) => {
console.log(error)
@@ -322,52 +331,47 @@ export class NewPublicationPage implements OnInit {
if (this.publicationType == ActionType.edit) {
if (!this.publication?.OriginalFileName || !this.pub.OriginalFileName) {
if (this.pub?.OriginalFileName) {
console.log('this.pub', this.pub)
}
throw ('no this.publication.OriginalFileName')
}
const loader = this.toastService.loading()
if (this.seletedContent.length > 0) {
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 || 'foto',
Files: this.seletedContent,
}
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,
}
try {
const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.publication.Files = this.publication.Files.map( e => ({
FileBase64: e.FileBase64,
FileExtension: e.FileExtension,
OriginalFileName: 'foto'
}))
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
console.log({ response })
try {
const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
console.log({ response })
this.goBack();
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
if (error.status == 404) {
this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId)
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 {
}/*
else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { //
} finally {
loader.remove()
}
/*
else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { //
this.publication = {
DateIndex: this.publication.DateIndex,
@@ -412,6 +416,16 @@ export class NewPublicationPage implements OnInit {
}
// this.publicationFormMV.setDataToFrom(this.publication)
// this.publicationFormMV.uploadVideosFiles()
this.publication.Files = this.publication.Files.map( e => ({
FileBase64: e.FileBase64,
FileExtension: e.FileExtension,
OriginalFileName: 'foto'
}))
const loader = this.toastService.loading()
try {
@@ -1043,7 +1057,7 @@ class PublicationAttachmentEntity {
this.FileBase64 = 'data:image/jpg;base64,' + this.FileBase64
}
} else if (this.FileType == 'video' ) {
if(!this.FileBase64.startsWith('data:')) {
if(!this.FileBase64.startsWith('data:') && !this.FileBase64.startsWith('http')) {
this.FileBase64 = 'data:video/mp4;base64,' + this.FileBase64
}
@@ -73,17 +73,17 @@ export class PublicationDetailPage implements OnInit {
if(localPublication?.ProcessId) {
console.log('console.log local storage')
this.publication = localPublication
console.log('Local publication',this.publication)
} else {
console.log('API res')
this.showLoader = true;
this.publications.GetPublicationWithArrayOfFilesById(this.publicationId).subscribe(res => {
this.publication = this.publicationPipe.itemList(res)
console.log('API pub', this.publication)
@@ -96,12 +96,12 @@ export class PublicationDetailPage implements OnInit {
if(error.status == 404) {
this.publicationFolderService.deletePost(this.folderId, this.publicationId)
}
this.goBack();
this.httpErrorHandle.httpStatusHandle(error)
});
}
}
close() {
@@ -121,7 +121,7 @@ export class PublicationDetailPage implements OnInit {
if(window['app-view-publications-page-doRefresh']) {
window['app-view-publications-page-doRefresh']()
}
this.goBackToViewPublications.emit();
} catch (error) {
@@ -138,7 +138,7 @@ export class PublicationDetailPage implements OnInit {
}
async editPost(publicationType:any) {
if(window.innerWidth < 701){
const modal = await this.modalController.create({
@@ -186,10 +186,4 @@ export class PublicationDetailPage implements OnInit {
modal.present();
}
}
@@ -79,7 +79,7 @@
</div>s -->
</swiper-container>
<div class="post-content">
<div class="post-content" (click)="viewPublicationDetail(publication.DocumentId, publication.ProcessId)">
<div class="post-title-time">
<div class="post-title">
<ion-label>{{publication.Title}}</ion-label>
@@ -227,8 +227,6 @@ export class ViewPublicationsPage implements OnInit {
this.publicationFolderService.publicationList[folderId].push(publicationDetails)
} else {
// console.log("names");
let a: any = Object.assign({},this.publicationFolderService.publicationList[folderId][findIndex])
let b: any = Object.assign({}, publicationDetails)