mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
Merge branches 'feature/viewer-attachment' and 'feature/viewer-attachment' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/viewer-attachment
This commit is contained in:
@@ -489,7 +489,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 96;
|
||||
CURRENT_PROJECT_VERSION = 97;
|
||||
DEVELOPMENT_TEAM = 94BRNM2LSS;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
@@ -516,7 +516,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 96;
|
||||
CURRENT_PROJECT_VERSION = 97;
|
||||
DEVELOPMENT_TEAM = 94BRNM2LSS;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
<button (click)="cancel()">Cancelar</button>
|
||||
</div> -->
|
||||
|
||||
<ion-footer class="ion-no-border">
|
||||
</ion-content>
|
||||
<ion-footer class="ion-no-border">
|
||||
<ion-toolbar class="footer-toolbar">
|
||||
<ion-buttons slot="start">
|
||||
<button class="btn-ok" fill="clear" color="#fff" (click)="save()">
|
||||
@@ -39,5 +40,3 @@
|
||||
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
|
||||
</ion-content>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
</button>
|
||||
</ion-buttons>
|
||||
<ion-buttons slot="end">
|
||||
<button class="btn-cancel" fill="clear" color="#061b52" (click)="close()">
|
||||
<button class="btn-cancel" fill="clear" color="#061b52" (click)="cancel()">
|
||||
<ion-label>Cancelar</ion-label>
|
||||
</button>
|
||||
</ion-buttons>
|
||||
|
||||
@@ -143,6 +143,7 @@ export class NewPublicationPage implements OnInit {
|
||||
private videoconvertService: VideoconvertService,
|
||||
public PublicationFromMvService: PublicationFromMvService,
|
||||
) {
|
||||
this.PublicationFromMvService.clear()
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
this.folderId = this.navParams.get('folderId');
|
||||
@@ -166,12 +167,25 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
if(this.publicationType == '3') {
|
||||
this.PublicationFromMvService.form.setData({
|
||||
DateIndex: publication.DateIndex,
|
||||
DocumentId: publication.DocumentId,
|
||||
ProcessId: publication.ProcessId,
|
||||
Title: publication.Title,
|
||||
Message: publication.Message,
|
||||
DatePublication: publication.DatePublication
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
this.intent = this.navParams.get('intent');
|
||||
|
||||
this.convertBlobToBase64Worker = new Worker(new URL('./convertBlobToBase64.worker.js', import.meta.url));
|
||||
this.PublicationFromMvService.clear()
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -375,6 +389,8 @@ export class NewPublicationPage implements OnInit {
|
||||
if (this.PublicationFromMvService.form.Files.length != 0) {
|
||||
|
||||
this.close();
|
||||
|
||||
this.PublicationFromMvService.publicationType = this.publicationType as any
|
||||
this.PublicationFromMvService.setFolderId(this.folderId)
|
||||
await this.PublicationFromMvService.save()
|
||||
|
||||
@@ -394,10 +410,28 @@ export class NewPublicationPage implements OnInit {
|
||||
this.modalController.dismiss(this.PublicationFromMvService.form).then(() => {
|
||||
this.showLoader = true;
|
||||
});
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
||||
this.PublicationFromMvService.form.cancel = true
|
||||
if(this.PublicationFromMvService.form.send == false) {
|
||||
this.PublicationFromMvService.cancel()
|
||||
this.PublicationFromMvService.ObjectMergeNotification.close()
|
||||
}
|
||||
|
||||
if (window["sharedContent"]) {
|
||||
this.closeApp();
|
||||
|
||||
if (this.platform.is('android')) {
|
||||
App.exitApp()
|
||||
} else {
|
||||
window["sharedContent"] = null;
|
||||
this.close()
|
||||
}
|
||||
} else {
|
||||
this.close()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clear() {
|
||||
@@ -631,14 +665,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,21 +811,19 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
async shareContentIso(fullPath, FileExtension, filename) {
|
||||
|
||||
console.log({fullPath, FileExtension, filename})
|
||||
|
||||
try {
|
||||
|
||||
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)
|
||||
console.log('shared base', content.data)
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ',');
|
||||
this.showCroppModal()
|
||||
} catch (error) {
|
||||
console.log('error shared filesystem', error)
|
||||
}
|
||||
@@ -811,7 +835,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` })
|
||||
|
||||
@@ -826,7 +849,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
const 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'
|
||||
@@ -835,7 +858,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 +867,7 @@ export class NewPublicationPage implements OnInit {
|
||||
};
|
||||
deleteSecretFile().then((value) => {
|
||||
console.log('delete file', value)
|
||||
fileObject = {};
|
||||
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
});
|
||||
@@ -861,27 +884,31 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
shareContentAndroid(resultUrl, FileExtension) {
|
||||
|
||||
console.log({resultUrl, FileExtension})
|
||||
|
||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||
let fileObject;
|
||||
try {
|
||||
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
||||
fileObject = {
|
||||
FileBase64: 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ','),
|
||||
FileExtension: FileExtension,
|
||||
OriginalFileName: 'shared',
|
||||
}
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(content.data, ',');
|
||||
this.showCroppModal()
|
||||
|
||||
} else if (this.checkFileType.checkFileType(FileExtension) == 'video') {
|
||||
fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','),
|
||||
FileExtension: FileExtension,
|
||||
OriginalFileName: 'shared',
|
||||
}
|
||||
|
||||
let newAttachment = new PublicationAttachmentEntity(
|
||||
{
|
||||
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(fileObject)
|
||||
|
||||
} catch (error) {
|
||||
console.log('error shared filesystem', error)
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ export class PublicationsPage implements OnInit {
|
||||
this.getActions();
|
||||
this.checkQueryParameter()
|
||||
}
|
||||
this.intent = window['sharedContent']
|
||||
});
|
||||
|
||||
this.hideRefreshButton();
|
||||
|
||||
@@ -6,7 +6,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { capitalizeTxt } from 'src/plugin/text';
|
||||
import { Update as room } from 'src/app/models/chatMethod';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { ModalController, NavController, Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
@@ -68,6 +68,8 @@ export class ChatSystemService {
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService,
|
||||
private modalController: ModalController,
|
||||
private navController: NavController
|
||||
) {
|
||||
|
||||
|
||||
@@ -482,7 +484,7 @@ export class ChatSystemService {
|
||||
if (setData.name != 'Rocket Cat' && setData.name != 'general' && chat == false) {
|
||||
// create room
|
||||
if (!this.roomExist(roomId)) {
|
||||
let room: RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.notificationService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService, this.notificationService)
|
||||
let room: RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.notificationService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService, this.notificationService,this.modalController,this.navController)
|
||||
room.setData(setData)
|
||||
room.receiveMessage()
|
||||
room.getAllUsers = this.getUsers
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MessageService, MessageServiceDateLabel } from 'src/app/services/chat/m
|
||||
import { showDateDuration } from 'src/plugin/showDateDuration';
|
||||
import { chatHistory } from 'src/app/models/chatMethod';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { ModalController, NavController, Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
@@ -101,7 +101,9 @@ export class RoomService {
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ChatSystemService: ChatSystemService,
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
private notificationService: NotificationsService,
|
||||
private modalController: ModalController,
|
||||
private navController: NavController
|
||||
) {
|
||||
/* this.NativeNotificationService.askForPermission() */
|
||||
|
||||
@@ -219,6 +221,9 @@ export class RoomService {
|
||||
if (difference < 0) {
|
||||
|
||||
this.deleteRoom();
|
||||
if(this.chatOpen && window.location.pathname.includes('chat')) {
|
||||
this.closeModal()
|
||||
}
|
||||
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
@@ -1287,4 +1292,8 @@ export class RoomService {
|
||||
this.members = members
|
||||
this.membersExcludeMe = users
|
||||
}
|
||||
|
||||
async closeModal() {
|
||||
await this.modalController.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { PublicationFormMV } from 'src/app/shared/publication/upload/upload-streaming.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@@ -151,6 +151,7 @@ class ReconnectingWebSocketSignalR {
|
||||
console.log('committing')
|
||||
return new Promise((resolve, reject) => {
|
||||
if(this.isOpen) {
|
||||
console.log('open')
|
||||
try {
|
||||
console.log('this.connection.invoke', this.connection)
|
||||
this.connection.invoke("CommitUpload", path).then((e) => {
|
||||
@@ -168,6 +169,7 @@ class ReconnectingWebSocketSignalR {
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('wait')
|
||||
this.onConnect.push(()=> {
|
||||
resolve(this.commit(path))
|
||||
})
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<ion-img *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'image'"
|
||||
name="image" ngDefaultControl [src]="'data:image/jpg;base64,' + seleted.Base64" style="height: 69px; width: 69px;"></ion-img>
|
||||
|
||||
<video class="sdf" *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkDesktop() == true" width="70" height="70"
|
||||
<video class="sdf" *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' " width="70" height="70"
|
||||
preload="metadata" webkit-playsinline="webkit-playsinline">
|
||||
<source type="video/mp4" [src]="seleted.url">
|
||||
</video>
|
||||
|
||||
@@ -19,7 +19,7 @@ import { CMAPIService } from '../../repository/CMAPI/cmapi.service';
|
||||
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 { ModalController, Platform } from '@ionic/angular';
|
||||
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'
|
||||
@@ -86,14 +86,15 @@ export class NewPublicationPage implements OnInit {
|
||||
private LakefsRepositoryService: LakefsRepositoryService,
|
||||
private SocketConnectionMCRService: SocketConnectionMCRService,
|
||||
private videoconvertService: VideoconvertService,
|
||||
public UploadStreamingService: UploadStreamingService
|
||||
public UploadStreamingService: UploadStreamingService,
|
||||
private modalController: ModalController
|
||||
) {
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
this.PublicationFromMvService.clear()
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.PublicationFromMvService.clear()
|
||||
this.setAction();
|
||||
this.setData()
|
||||
}
|
||||
@@ -163,8 +164,9 @@ export class NewPublicationPage implements OnInit {
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
|
||||
this.capturedImageTitle = 'foto';
|
||||
|
||||
this.showCroppModal()
|
||||
/* if(validation.isOk) { */
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
/* const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
@@ -183,7 +185,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
)
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
async laodPicture() {
|
||||
@@ -233,12 +235,22 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
result.files.forEach(async blobFile => {
|
||||
console.log(blobFile)
|
||||
if (this.checkFileType.checkFileType(blobFile.mimeType) == 'image' || this.checkFileType.checkFileType(blobFile.mimeType) == 'video') {
|
||||
if (this.checkFileType.checkFileType(blobFile.mimeType) == 'image') {
|
||||
|
||||
this.convertBlobToBase64(blobFile.blob).then((value: string) => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + blobFile.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + this.removeTextBeforeSlash(value, ','),
|
||||
this.showCroppModal();
|
||||
this.filecontent = true;
|
||||
|
||||
}).catch((erro) => {
|
||||
console.log(erro)
|
||||
})
|
||||
} else if (this.checkFileType.checkFileType(blobFile.mimeType) == 'video'){
|
||||
this.convertBlobToBase64(blobFile.blob).then((value: string) => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + blobFile.size
|
||||
|
||||
const FileExtension = this.removeTextBeforeSlash(blobFile.mimeType, '/')
|
||||
|
||||
@@ -254,21 +266,13 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
newAttachment.needUpload()
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
this.filecontent = true;
|
||||
|
||||
} else {
|
||||
if (this.PublicationFromMvService.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErroHandle.validationMessagge('filessize');
|
||||
}
|
||||
}).catch((erro) => {
|
||||
console.log(erro)
|
||||
})
|
||||
|
||||
} else {
|
||||
this.httpErroHandle.validationMessagge('filetype');
|
||||
}
|
||||
@@ -286,8 +290,22 @@ export class NewPublicationPage implements OnInit {
|
||||
result.files.forEach(element => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
if (this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') {
|
||||
if (this.checkFileType.checkFileType(element.mimeType) == 'image') {
|
||||
let resultUrl = decodeURIComponent(element.path);
|
||||
try {
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(result)
|
||||
this.capturedImage = 'data:image/jpeg;base64,'+content.data
|
||||
this.showCroppModal()
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
|
||||
} else if (this.checkFileType.checkFileType(element.mimeType) == 'video'){
|
||||
let resultUrl = decodeURIComponent(element.path);
|
||||
try {
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
@@ -297,7 +315,7 @@ export class NewPublicationPage implements OnInit {
|
||||
console.log('load video tablet base64', content)
|
||||
this.filecontent = true;
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: 'data:video/mp4;base64,'+content.data,
|
||||
base64: content.data,
|
||||
extension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'video',
|
||||
FileType: this.checkFileType.checkFileType( this.removeTextBeforeSlash(element.mimeType, '/')) as any
|
||||
@@ -311,13 +329,9 @@ export class NewPublicationPage implements OnInit {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
|
||||
} else {
|
||||
this.httpErroHandle.validationMessagge('filetype');
|
||||
}
|
||||
} else {
|
||||
if (this.PublicationFromMvService.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErrorHandle.validationMessagge('filessize')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -366,6 +380,10 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
close() {
|
||||
if(this.PublicationFromMvService.form.send == false) {
|
||||
this.PublicationFromMvService.cancel()
|
||||
this.PublicationFromMvService.ObjectMergeNotification.close()
|
||||
}
|
||||
this.goBack();
|
||||
}
|
||||
|
||||
@@ -746,12 +764,46 @@ console.log(stringGerada);
|
||||
|
||||
return stringAleatoria;
|
||||
}
|
||||
|
||||
async showCroppModal() {
|
||||
const modal = await this.modalController.create({
|
||||
component: CropImagePage,
|
||||
componentProps: {
|
||||
base64ToCroppe: this.capturedImage
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then((res) => {
|
||||
if (res) {
|
||||
this.capturedImage = res.data
|
||||
this.filecontent = true;
|
||||
this.photoOrVideo = false;
|
||||
|
||||
const newAttachment = new PublicationAttachmentEntity(
|
||||
{
|
||||
base64: res.data.base64ToCroppe,
|
||||
extension: 'jpeg',
|
||||
OriginalFileName: "image",
|
||||
FileType: 'image'
|
||||
}
|
||||
)
|
||||
|
||||
this.PublicationFromMvService.form.Files.push(newAttachment)
|
||||
}
|
||||
}, (error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
import { Observable, of, Subject } from 'rxjs';
|
||||
import { tap, switchMap, delay, map } from 'rxjs/operators';
|
||||
import { CropImagePage } from 'src/app/modals/crop-image/crop-image.page';
|
||||
|
||||
function shareResponse<T>(): MethodDecorator {
|
||||
return function (
|
||||
|
||||
@@ -10,6 +10,9 @@ 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';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
enum ActionType {
|
||||
newRapid = "1",
|
||||
@@ -31,13 +34,17 @@ export class PublicationFromMvService {
|
||||
folderId: string
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
private httpErroHandle: HttpErrorHandle,
|
||||
public PublicationFolderService: PublicationFolderService,
|
||||
private CMAPIService: CMAPIService,
|
||||
public publicationFolderService: PublicationFolderService
|
||||
public publicationFolderService: PublicationFolderService,
|
||||
private platform: Platform,
|
||||
private modalController: ModalController,
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
|
||||
@@ -63,7 +70,7 @@ export class PublicationFromMvService {
|
||||
this.folderId = folderId
|
||||
}
|
||||
|
||||
save = async() => {
|
||||
save = async() => {
|
||||
|
||||
const needChunk = this.needToUploadChunk()
|
||||
|
||||
@@ -75,6 +82,8 @@ export class PublicationFromMvService {
|
||||
this.form.send = true
|
||||
const upload = await this.uploadVideosFiles()
|
||||
|
||||
console.log('release chunks')
|
||||
|
||||
|
||||
const needChunk = this.needToUploadChunk()
|
||||
if(needChunk.length == 0 ) {
|
||||
@@ -102,11 +111,21 @@ export class PublicationFromMvService {
|
||||
OriginalFileName: e.OriginalFileName || 'foto'
|
||||
}))
|
||||
|
||||
publication.ProcessId = this.folderId
|
||||
|
||||
if(this.form.cancel) {
|
||||
window['upload-header-set-remove'](this.id);
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const response = await this.publications.UpdatePublication(publication.ProcessId, publication).toPromise()
|
||||
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
if (this.form.cancel == false) {
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
}
|
||||
|
||||
this.publicationFolderService.getPublicationsIds(this.folderId)
|
||||
window['upload-header-set-remove'](this.id);
|
||||
|
||||
@@ -117,7 +136,6 @@ export class PublicationFromMvService {
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
if (error.status == 404) {
|
||||
this.PublicationFolderService.deletePost(this.form.ProcessId, this.form.DocumentId)
|
||||
// this.goBack();
|
||||
} else {
|
||||
window['upload-header-set-retry'](this.id)
|
||||
}
|
||||
@@ -127,7 +145,6 @@ export class PublicationFromMvService {
|
||||
|
||||
|
||||
} else {
|
||||
window['upload-header-set-retry'](this.id)
|
||||
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo")
|
||||
}
|
||||
|
||||
@@ -149,6 +166,8 @@ export class PublicationFromMvService {
|
||||
window['upload-header-set-percentage'](this.id, 100)
|
||||
}
|
||||
|
||||
console.log('release chunk')
|
||||
|
||||
if(upload) {
|
||||
this.form.Files = this.form.Files.map((e:PublicationAttachmentEntity) => {
|
||||
if(e.FileType == 'video' && e.toUpload) {
|
||||
@@ -164,6 +183,12 @@ export class PublicationFromMvService {
|
||||
|
||||
return e
|
||||
})
|
||||
} else {
|
||||
window['upload-header-set-retry'](this.id)
|
||||
this.toastService._badRequest("ocorreu um erro ao enviar o ficheiro")
|
||||
return true
|
||||
// loader.remove()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -178,22 +203,24 @@ export class PublicationFromMvService {
|
||||
publication.DocumentId = null;
|
||||
publication.ProcessId = this.folderId
|
||||
|
||||
|
||||
if(this.form.cancel == false) {
|
||||
window['upload-header-set-remove'](this.id);
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
await this.publications.CreatePublication(publication.ProcessId, publication).toPromise()
|
||||
|
||||
if (this.publicationType == '1') {
|
||||
|
||||
this.httpErroHandle.httpsSucessMessagge('Criar publicação')
|
||||
} else if (this.publicationType == '2') {
|
||||
this.httpErroHandle.httpsSucessMessagge('Criar publicação')
|
||||
} else if (this.publicationType == '3') {
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
}
|
||||
|
||||
// this.goBackToViewPublications.emit();
|
||||
window['upload-header-set-remove'](this.id);
|
||||
this.doneUpload()
|
||||
this.publicationFolderService.getPublicationsIds(this.folderId)
|
||||
} catch (error) {
|
||||
window['upload-header-set-retry'](this.id)
|
||||
@@ -202,14 +229,6 @@ export class PublicationFromMvService {
|
||||
// loader.remove()
|
||||
}
|
||||
|
||||
} else {
|
||||
window['upload-header-set-retry'](this.id)
|
||||
this.toastService._badRequest("ocorreu um erro ao enviar o ficheiro")
|
||||
// loader.remove()
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
this.toastService._badRequest("É necessário adicionar uma imagem ou vídeo")
|
||||
@@ -219,7 +238,29 @@ export class PublicationFromMvService {
|
||||
|
||||
|
||||
// this.PublicationHolderService.setPublication(this.publicationFormMV)
|
||||
|
||||
this.ObjectMergeNotification.close()
|
||||
|
||||
}
|
||||
|
||||
doneUpload() {
|
||||
if (window["sharedContent"]) {
|
||||
|
||||
if (this.platform.is('android')) {
|
||||
window["sharedContent"] = null
|
||||
this.modalController.dismiss(this.form).then(() => {
|
||||
this.router.navigate(['/home/publications', this.folderId])
|
||||
});
|
||||
} else {
|
||||
window["sharedContent"] = null
|
||||
this.modalController.dismiss(this.form).then(() => {
|
||||
this.router.navigate(['/home/publications', this.folderId])
|
||||
});
|
||||
|
||||
}
|
||||
} else {
|
||||
this.modalController.dismiss(this.form).then(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +299,7 @@ export class PublicationFromMvService {
|
||||
if(PublicationAttachmentEntity.hasBlob) {
|
||||
|
||||
const fileBlob = PublicationAttachmentEntity.blobFile;
|
||||
const fileChunks = new Chunks({chunkSize: 1000 })
|
||||
const fileChunks = new Chunks({chunkSize: 50 })
|
||||
fileChunks.setFile(fileBlob)
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
} else {
|
||||
@@ -305,6 +346,7 @@ export class PublicationFromMvService {
|
||||
|
||||
} else {
|
||||
console.log('already uploading')
|
||||
resolve(true)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -330,6 +372,8 @@ export class PublicationFromMvService {
|
||||
Promises.push(promise)
|
||||
}
|
||||
|
||||
console.log('Promises', Promises)
|
||||
|
||||
// Use Promise.all to wait for all promises to resolve
|
||||
Promise.all(Promises)
|
||||
.then((results) => {
|
||||
|
||||
@@ -215,6 +215,7 @@ export class PublicationFormModel implements IPublicationFormModelEntity {
|
||||
|
||||
hasSet = false
|
||||
send = false
|
||||
cancel = false
|
||||
|
||||
setData(data: IPublicationFormModelEntity) {
|
||||
if(data.Files) {
|
||||
@@ -227,171 +228,6 @@ export class PublicationFormModel implements IPublicationFormModelEntity {
|
||||
}
|
||||
}
|
||||
|
||||
export class PublicationFormMV {
|
||||
|
||||
readonly id = uuidv4()
|
||||
private UploadFileUseCase = new UploadFileUseCase()
|
||||
form = new PublicationFormModel()
|
||||
ObjectMergeNotification = new ObjectMergeNotification()
|
||||
totalPercentage = 0
|
||||
|
||||
constructor() {
|
||||
this.ObjectMergeNotification.connect();
|
||||
window['upload-header-set-add'](this.id, this.totalPercentage)
|
||||
}
|
||||
|
||||
setDataToFrom(data: IPublicationFormModelEntity) {
|
||||
this.form.setData(data)
|
||||
}
|
||||
|
||||
private getVideoFiles() {
|
||||
return this.form.Files.filter( x => x.FileType == 'video')
|
||||
}
|
||||
|
||||
async commit(PublicationAttachmentEntity: PublicationAttachmentEntity) {
|
||||
PublicationAttachmentEntity.chucksManager.doneChunkUpload()
|
||||
const mergeRequest = await this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path)
|
||||
|
||||
if(mergeRequest.isOk()) {
|
||||
console.log("commit")
|
||||
PublicationAttachmentEntity.chucksManager.contentSetReady()
|
||||
return true
|
||||
} else {
|
||||
console.log('no commit')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private upload(PublicationAttachmentEntity: PublicationAttachmentEntity) {
|
||||
|
||||
return new Promise(async (resolve, reject)=> {
|
||||
|
||||
if(!PublicationAttachmentEntity.hasChunkManger) {
|
||||
|
||||
if(PublicationAttachmentEntity.hasBlob) {
|
||||
|
||||
const fileBlob = PublicationAttachmentEntity.blobFile;
|
||||
const fileChunks = new Chunks({chunkSize: 50 })
|
||||
fileChunks.setFile(fileBlob)
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
} else {
|
||||
const Base64 = PublicationAttachmentEntity.Base64;
|
||||
const fileChunks = new ChunksBase64({chunkSize: 50 })
|
||||
fileChunks.setFile(Base64)
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
}
|
||||
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.updateTotalPercentageTrigger = () => {
|
||||
this.uploadPercentage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let attemp = 0;
|
||||
let result: Result<true, IOUploadError>
|
||||
|
||||
if( PublicationAttachmentEntity.chucksManager.isUploading == false && PublicationAttachmentEntity.chucksManager.doneUpload == false) {
|
||||
|
||||
do {
|
||||
attemp++
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.clearManualRetry()
|
||||
PublicationAttachmentEntity.chucksManager.setUploading()
|
||||
result = await this.UploadFileUseCase.execute(PublicationAttachmentEntity)
|
||||
PublicationAttachmentEntity.chucksManager.clearUploading()
|
||||
|
||||
} while (attemp<3 && result.isErr() && result.error == 'slow')
|
||||
|
||||
|
||||
if(result.isErr()) {
|
||||
PublicationAttachmentEntity.chucksManager.setManualRetry()
|
||||
resolve(false)
|
||||
} else {
|
||||
|
||||
return await resolve(this.commit(PublicationAttachmentEntity))
|
||||
|
||||
}
|
||||
|
||||
} else if ( PublicationAttachmentEntity.chucksManager.contentReady == false) {
|
||||
console.log("try to send again")
|
||||
return await resolve(this.commit(PublicationAttachmentEntity))
|
||||
|
||||
} else {
|
||||
console.log('already uploading')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
uploadVideosFiles(): Promise<Boolean> {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// this.ObjectMergeNotification.socket.registerWhenConnected(() => {
|
||||
const videosFiles = this.getVideoFiles()
|
||||
|
||||
window['upload-header-set-percentage'](this.id, 1)
|
||||
|
||||
const videosFilesToUploads = videosFiles.filter( e => e.FileType == "video" && e.toUpload && e.blobFile)
|
||||
|
||||
const Promises: Promise<any>[] = []
|
||||
|
||||
for(const file of videosFilesToUploads) {
|
||||
const promise = this.upload(file)
|
||||
Promises.push(promise)
|
||||
}
|
||||
|
||||
// Use Promise.all to wait for all promises to resolve
|
||||
Promise.all(Promises)
|
||||
.then((results) => {
|
||||
// Check if every promise resolved successfully
|
||||
const allPromisesResolvedSuccessfully = results.every((result) => result == true);
|
||||
|
||||
if (allPromisesResolvedSuccessfully) {
|
||||
console.log('All promises resolved successfully.');
|
||||
window['upload-header-set-remove'](this.id);
|
||||
resolve(true)
|
||||
} else {
|
||||
window['upload-header-set-remove'](this.id);
|
||||
resolve(false)
|
||||
console.log('Some promises failed to resolve successfully.');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
resolve(false)
|
||||
console.error('An error occurred while resolving promises:', error);
|
||||
});
|
||||
//})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
uploadPercentage() {
|
||||
|
||||
const videosFiles = this.getVideoFiles()
|
||||
const percentageArray = videosFiles.map((e) => e.chucksManager.calculatePercentage())
|
||||
|
||||
// Check if the array is not empty
|
||||
if (percentageArray.length === 0) {
|
||||
window['upload-header-set-percentage'](this.id, this.totalPercentage)
|
||||
return 0;
|
||||
} else {
|
||||
let sum = percentageArray.reduce((acc, percentage) => acc + percentage, 0);
|
||||
|
||||
// Calculate the average percentage
|
||||
let averagePercentage = sum / percentageArray.length;
|
||||
|
||||
this.totalPercentage = averagePercentage
|
||||
window['upload-header-set-percentage'](this.id, this.totalPercentage)
|
||||
return averagePercentage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class Chunks {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../sih/ORM"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
|
||||
Reference in New Issue
Block a user