mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
fix
This commit is contained in:
@@ -20,10 +20,11 @@ import { environment } from 'src/environments/environment';
|
||||
import { CaptureImageOptions, MediaCapture } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
import { Directory, Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { PublicationAttachmentEntity, PublicationFormMV } from '../upload/upload-streaming.service';
|
||||
import { PublicationFormMVService } from "src/app/shared/publication/upload/publication-form-mv.service"
|
||||
import { PublicationAttachmentEntity } from '../upload/upload-streaming.service';
|
||||
import { VideoconvertService } from 'src/app/services/videoconvert.service';
|
||||
|
||||
import { PublicationHolderService } from 'src/app/services/publication/publication-holder.service'
|
||||
import { PublicationFromMvService } from "src/app/shared/publication/upload/publication-from-mv.service"
|
||||
import { UploadStreamingService } from "src/app/shared/publication/upload/upload-streaming.service"
|
||||
enum ActionType {
|
||||
newRapid = "1",
|
||||
new = "2",
|
||||
@@ -68,11 +69,8 @@ export class NewPublicationPage implements OnInit {
|
||||
photoOrVideo: boolean = false;
|
||||
video: any;
|
||||
|
||||
publicationFormMV = new PublicationFormMV()
|
||||
|
||||
|
||||
constructor(
|
||||
PublicationFormMVService: PublicationFormMVService,
|
||||
public PublicationFromMvService: PublicationFromMvService,
|
||||
public photoService: PhotoService,
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
@@ -87,9 +85,12 @@ export class NewPublicationPage implements OnInit {
|
||||
private MiddlewareServiceService: MiddlewareServiceService,
|
||||
private LakefsRepositoryService: LakefsRepositoryService,
|
||||
private SocketConnectionMCRService: SocketConnectionMCRService,
|
||||
private videoconvertService: VideoconvertService
|
||||
private videoconvertService: VideoconvertService,
|
||||
public UploadStreamingService: UploadStreamingService
|
||||
) {
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
this.PublicationFromMvService.clear()
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -124,8 +125,8 @@ export class NewPublicationPage implements OnInit {
|
||||
processData(res) {
|
||||
|
||||
console.log("res process", res)
|
||||
this.publicationFormMV.form.Files = []
|
||||
this.publicationFormMV.form.setData({
|
||||
this.PublicationFromMvService.form.Files = []
|
||||
this.PublicationFromMvService.form.setData({
|
||||
DateIndex: res.DateIndex,
|
||||
DocumentId: res.DocumentId,
|
||||
ProcessId: res.ProcessId,
|
||||
@@ -146,7 +147,7 @@ export class NewPublicationPage implements OnInit {
|
||||
})
|
||||
|
||||
for(const files of newFiles) {
|
||||
this.publicationFormMV.form.Files.push(files)
|
||||
this.PublicationFromMvService.form.Files.push(files)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -181,7 +182,7 @@ export class NewPublicationPage implements OnInit {
|
||||
FileType: 'image'
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(newAttachment)
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -215,7 +216,8 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
)
|
||||
//newAttachment.needUpload();
|
||||
this.publicationFormMV.form.Files.push(newAttachment)
|
||||
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
});
|
||||
|
||||
}
|
||||
@@ -252,12 +254,14 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
)
|
||||
|
||||
// newAttachment.needUpload()
|
||||
this.publicationFormMV.form.Files.push(newAttachment)
|
||||
|
||||
|
||||
newAttachment.needUpload()
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
this.filecontent = true;
|
||||
|
||||
} else {
|
||||
if (this.publicationFormMV.form.Files.length === 0)
|
||||
if (this.PublicationFromMvService.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErroHandle.validationMessagge('filessize');
|
||||
@@ -300,7 +304,7 @@ export class NewPublicationPage implements OnInit {
|
||||
})
|
||||
|
||||
/* fileObject.needUpload() */
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
this.PublicationFromMvService.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
@@ -309,7 +313,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
}
|
||||
} else {
|
||||
if (this.publicationFormMV.form.Files.length === 0)
|
||||
if (this.PublicationFromMvService.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErrorHandle.validationMessagge('filessize')
|
||||
@@ -325,11 +329,11 @@ export class NewPublicationPage implements OnInit {
|
||||
injectValidation() {
|
||||
|
||||
this.Form = new FormGroup({
|
||||
Subject: new FormControl(this.publicationFormMV.form.Title, [
|
||||
Subject: new FormControl(this.PublicationFromMvService.form.Title, [
|
||||
Validators.required,
|
||||
// Validators.minLength(4)
|
||||
]),
|
||||
Message: new FormControl(this.publicationFormMV.form.Message, [
|
||||
Message: new FormControl(this.PublicationFromMvService.form.Message, [
|
||||
Validators.required,
|
||||
Validators.maxLength(1000)
|
||||
])
|
||||
@@ -346,149 +350,32 @@ export class NewPublicationPage implements OnInit {
|
||||
return false
|
||||
}
|
||||
|
||||
this.PublicationFromMvService.setFolderId(this.folderId)
|
||||
this.goBack();
|
||||
await this.PublicationFromMvService.save()
|
||||
|
||||
if (this.publicationType == ActionType.edit) {
|
||||
|
||||
if (this.publicationFormMV.form.Files.length >= 1) {
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
const upload = await this.publicationFormMV.uploadVideosFiles()
|
||||
|
||||
if(upload) {
|
||||
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity) => {
|
||||
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
||||
e.OriginalFileName = e?.chucksManager?.path?.replace(".mp4", "") || e.OriginalFileName
|
||||
e.FileExtension = "mp4"
|
||||
}
|
||||
return e
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const publication: any = Object.assign({}, this.publicationFormMV.form)
|
||||
|
||||
publication.Files = publication.Files.map( (e:PublicationAttachmentEntity) => ({
|
||||
FileBase64: e.url,
|
||||
FileExtension: e.FileExtension,
|
||||
OriginalFileName: e.OriginalFileName || 'foto'
|
||||
}))
|
||||
|
||||
try {
|
||||
|
||||
const response = await this.publications.UpdatePublication(publication.ProcessId, publication).toPromise()
|
||||
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
|
||||
this.goBack();
|
||||
|
||||
} catch (error) {
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
if (error.status == 404) {
|
||||
this.PublicationFolderService.deletePost(this.publicationFormMV.form.ProcessId, this.publicationFormMV.form.DocumentId)
|
||||
this.goBack();
|
||||
}
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
let time = new Date()
|
||||
if (this.publicationFormMV.form.Files.length >= 1) {
|
||||
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
const upload = await this.publicationFormMV.uploadVideosFiles()
|
||||
|
||||
console.log({upload})
|
||||
|
||||
if(upload) {
|
||||
this.publicationFormMV.form.Files = this.publicationFormMV.form.Files.map((e:PublicationAttachmentEntity) => {
|
||||
if(e.FileType == 'video' && e.blobFile && e.toUpload) {
|
||||
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
||||
e.FileExtension = "mp4"
|
||||
e.Base64 = ''
|
||||
}
|
||||
|
||||
if(e.FileType == 'video' && !e.toUpload) {
|
||||
e.Base64 = e.url
|
||||
}
|
||||
|
||||
|
||||
return e
|
||||
})
|
||||
|
||||
|
||||
|
||||
const publication: any = Object.assign({}, this.publicationFormMV.form)
|
||||
|
||||
publication.Files = publication.Files.map( (e:PublicationAttachmentEntity) => ({
|
||||
FileBase64: e.Base64,
|
||||
FileExtension: e.FileExtension,
|
||||
OriginalFileName: e.OriginalFileName || 'foto'
|
||||
}))
|
||||
|
||||
publication.DocumentId = null;
|
||||
publication.ProcessId = this.folderId
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
await this.publications.CreatePublication(publication.ProcessId, publication).toPromise()
|
||||
if (this.publicationTitle == '1') {
|
||||
|
||||
} else if (this.publicationTitle == '2') {
|
||||
this.httpErroHandle.httpsSucessMessagge('Criar publicação')
|
||||
} else if (this.publicationTitle == '3') {
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
}
|
||||
|
||||
this.goBackToViewPublications.emit();
|
||||
} catch (error) {
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
} else {
|
||||
this.toastService._badRequest("Tive um erro ao enviar o ficheiro")
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.publicationFormMV.ObjectMergeNotification.close()
|
||||
// this.PublicationHolderService.setPublication(this.PublicationFromMvService)
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.publicationFormMV.ObjectMergeNotification.close()
|
||||
// if(!this.PublicationFromMvService.form.send) {
|
||||
// this.PublicationFromMvService.cancel()
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
close() {
|
||||
this.goBack();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.publicationFormMV.form.Files = [];
|
||||
this.PublicationFromMvService.form.Files = [];
|
||||
}
|
||||
|
||||
deletePublicationImage() {
|
||||
|
||||
this.publicationFormMV.form.Files = []
|
||||
this.PublicationFromMvService.form.Files = []
|
||||
}
|
||||
|
||||
setAction() {
|
||||
@@ -728,7 +615,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
deleteFromSeletedContent(index) {
|
||||
this.publicationFormMV.form.Files.splice(index, 1)
|
||||
this.PublicationFromMvService.form.Files.splice(index, 1)
|
||||
}
|
||||
|
||||
chossePhotoOrVideo() {
|
||||
@@ -750,7 +637,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.recordVideoPc(element.fullPath)
|
||||
}
|
||||
} else {
|
||||
if (this.publicationFormMV.form.Files.length === 0)
|
||||
if (this.PublicationFromMvService.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErrorHandle.validationMessagge('filessize')
|
||||
@@ -798,7 +685,7 @@ console.log(stringGerada);
|
||||
}
|
||||
)
|
||||
/* fileObject.needUpload() */
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
this.PublicationFromMvService.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
} catch (error) {
|
||||
@@ -840,7 +727,7 @@ console.log(stringGerada);
|
||||
}
|
||||
|
||||
/* fileObject.needUpload() */
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
this.PublicationFromMvService.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user