From c78532680369f90f105463cff3cc56484734941f Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 28 Mar 2024 16:28:17 +0100 Subject: [PATCH 1/2] fix share content --- .../new-publication/new-publication.page.ts | 57 ++++++++++++------- src/app/services/chat/room.service.ts | 3 + 2 files changed, 38 insertions(+), 22 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 bc823ac54..5ea3f061d 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -790,16 +790,21 @@ export class NewPublicationPage implements OnInit { if (this.checkFileType.checkFileType(FileExtension) == 'image') { Filesystem.readFile({ path: fullPath }).then(async (content) => { - let fileObject; try { - fileObject = { - FileBase64: this.removeTextBeforeSlash(content.data, ','), - FileExtension: FileExtension, - OriginalFileName: 'shared', - } + console.log('shared base', content.data) - this.PublicationFromMvService.form.Files.push(fileObject) + const newAttachment = new PublicationAttachmentEntity( + { + base64: this.removeTextBeforeSlash(content.data, ','), + extension: FileExtension, + FileType: this.checkFileType.checkFileType(FileExtension) as any, + OriginalFileName: 'shared' + } + ) + + + this.PublicationFromMvService.form.Files.push(newAttachment) } catch (error) { console.log('error shared filesystem', error) } @@ -811,7 +816,6 @@ export class NewPublicationPage implements OnInit { path: '', }); - let fileObject = {}; this.videoconvertService.convertVideo(fullPath, directory.uri, filename, 'mp4').then(async () => { await Filesystem.readFile({ path: `${directory.uri}${filename}.mp4` }) @@ -835,7 +839,7 @@ export class NewPublicationPage implements OnInit { newAttachment.needUpload() this.PublicationFromMvService.form.Files.push(newAttachment) - fileObject = {}; + const deleteSecretFile = async () => { await Filesystem.deleteFile({ path: `${filename}.mp4`, @@ -844,7 +848,7 @@ export class NewPublicationPage implements OnInit { }; deleteSecretFile().then((value) => { console.log('delete file', value) - fileObject = {}; + }) .catch((erro) => console.error('read converted video erro ', erro)); }); @@ -862,26 +866,35 @@ export class NewPublicationPage implements OnInit { shareContentAndroid(resultUrl, FileExtension) { Filesystem.readFile({ path: resultUrl }).then(async (content) => { - let fileObject; + let newAttachment: PublicationAttachmentEntity; try { if (this.checkFileType.checkFileType(FileExtension) == 'image') { - fileObject = { - FileBase64: 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ','), - FileExtension: FileExtension, - OriginalFileName: 'shared', - } + const newAttachment = new PublicationAttachmentEntity( + { + base64: 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ','), + extension: FileExtension, + FileType: this.checkFileType.checkFileType(FileExtension) as any, + OriginalFileName: 'shared' + } + ) + this.PublicationFromMvService.form.Files.push(newAttachment) } else if (this.checkFileType.checkFileType(FileExtension) == 'video') { - fileObject = { - FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','), - FileExtension: FileExtension, - OriginalFileName: 'shared', - } + + const newAttachment = new PublicationAttachmentEntity( + { + base64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','), + extension: 'mp4', + FileType: this.checkFileType.checkFileType('mp4') as any, + OriginalFileName: 'shared' + } + ) + newAttachment.needUpload() } console.log('shared base', content.data) - this.PublicationFromMvService.form.Files.push(fileObject) + this.PublicationFromMvService.form.Files.push(newAttachment) } catch (error) { console.log('error shared filesystem', error) } diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 3767b9518..5c002e9a3 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -219,6 +219,9 @@ export class RoomService { if (difference < 0) { this.deleteRoom(); + if(this.chatOpen) { + + } } else { setTimeout(() => { From 44a4c30e6468845389ee74db42cea428378e800f Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 1 Apr 2024 12:18:25 +0100 Subject: [PATCH 2/2] file chunk share content --- .../new-publication/new-publication.page.ts | 33 +++++++++---------- .../upload/publication-from-mv.service.ts | 23 +++++++++++-- src/environments/environment.prod.ts | 2 +- src/environments/environment.ts | 2 +- workspace.code-workspace | 3 ++ 5 files changed, 40 insertions(+), 23 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 5ea3f061d..0cb908bc5 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -374,7 +374,10 @@ export class NewPublicationPage implements OnInit { if (this.PublicationFromMvService.form.Files.length != 0) { - this.close(); + if (!window["sharedContent"]) { + this.close(); + } + this.PublicationFromMvService.setFolderId(this.folderId) await this.PublicationFromMvService.save() @@ -394,10 +397,6 @@ export class NewPublicationPage implements OnInit { this.modalController.dismiss(this.PublicationFromMvService.form).then(() => { this.showLoader = true; }); - - if (window["sharedContent"]) { - this.closeApp(); - } } clear() { @@ -631,14 +630,6 @@ export class NewPublicationPage implements OnInit { this.PublicationFromMvService.form.Files.splice(index, 1) } - closeApp() { - if (this.platform.is('android')) { - App.exitApp() - } else { - window["sharedContent"] = null - } - - } async recordevideoIos(fullPath, element) { @@ -785,6 +776,9 @@ export class NewPublicationPage implements OnInit { } async shareContentIso(fullPath, FileExtension, filename) { + + console.log({fullPath, FileExtension, filename}) + try { if (this.checkFileType.checkFileType(FileExtension) == 'image') { @@ -865,11 +859,12 @@ export class NewPublicationPage implements OnInit { shareContentAndroid(resultUrl, FileExtension) { + console.log({resultUrl, FileExtension}) + Filesystem.readFile({ path: resultUrl }).then(async (content) => { - let newAttachment: PublicationAttachmentEntity; try { if (this.checkFileType.checkFileType(FileExtension) == 'image') { - const newAttachment = new PublicationAttachmentEntity( + let newAttachment = new PublicationAttachmentEntity( { base64: 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ','), extension: FileExtension, @@ -879,22 +874,24 @@ export class NewPublicationPage implements OnInit { ) this.PublicationFromMvService.form.Files.push(newAttachment) + } else if (this.checkFileType.checkFileType(FileExtension) == 'video') { - const newAttachment = new PublicationAttachmentEntity( + let newAttachment = new PublicationAttachmentEntity( { - base64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','), + base64: content.data, extension: 'mp4', FileType: this.checkFileType.checkFileType('mp4') as any, OriginalFileName: 'shared' } ) newAttachment.needUpload() + this.PublicationFromMvService.form.Files.push(newAttachment) } console.log('shared base', content.data) - this.PublicationFromMvService.form.Files.push(newAttachment) + } catch (error) { console.log('error shared filesystem', error) } diff --git a/src/app/shared/publication/upload/publication-from-mv.service.ts b/src/app/shared/publication/upload/publication-from-mv.service.ts index 1f1c3591b..f18269bdc 100644 --- a/src/app/shared/publication/upload/publication-from-mv.service.ts +++ b/src/app/shared/publication/upload/publication-from-mv.service.ts @@ -10,6 +10,8 @@ import { v4 as uuidv4 } from 'uuid' import { Result } from 'neverthrow'; import { IPublicationFormModelEntity } from '../new-publication/interface/interface'; import { CMAPIService } from "src/app/shared/repository/CMAPI/cmapi.service" +import { App } from '@capacitor/app'; +import { ModalController, NavParams, Platform, LoadingController } from '@ionic/angular'; enum ActionType { newRapid = "1", @@ -37,7 +39,8 @@ export class PublicationFromMvService { private httpErroHandle: HttpErrorHandle, public PublicationFolderService: PublicationFolderService, private CMAPIService: CMAPIService, - public publicationFolderService: PublicationFolderService + public publicationFolderService: PublicationFolderService, + private platform: Platform, ) {} @@ -63,7 +66,7 @@ export class PublicationFromMvService { this.folderId = folderId } - save = async() => { + save = async() => { const needChunk = this.needToUploadChunk() @@ -183,7 +186,7 @@ export class PublicationFromMvService { try { await this.publications.CreatePublication(publication.ProcessId, publication).toPromise() - + this.closeApp() if (this.publicationType == '1') { } else if (this.publicationType == '2') { @@ -219,7 +222,21 @@ export class PublicationFromMvService { // this.PublicationHolderService.setPublication(this.publicationFormMV) + this.ObjectMergeNotification.close() + + } + + + closeApp() { + if (window["sharedContent"]) { + + if (this.platform.is('android')) { + App.exitApp() + } else { + window["sharedContent"] = null + } + } } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0bd217c5f..43c1647f5 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -4,4 +4,4 @@ import { environment as oaprProd } from './suport/oapr' import { DevDev } from './suport/dev' -export const environment: Environment = oaprProd; +export const environment: Environment = DevDev; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 03d2a6508..8982b9007 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,4 +4,4 @@ import { environment as oaprDev } from './suport/oapr' import { DevDev } from './suport/dev' -export const environment: Environment = oaprDev +export const environment: Environment = DevDev diff --git a/workspace.code-workspace b/workspace.code-workspace index bf4bc2067..b1838162c 100644 --- a/workspace.code-workspace +++ b/workspace.code-workspace @@ -2,6 +2,9 @@ "folders": [ { "path": "." + }, + { + "path": "../sih/ORM" } ], "settings": {