mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
merge
This commit is contained in:
@@ -146,7 +146,6 @@
|
||||
[eventSource]="listToPresent"
|
||||
[calendarMode]="calendar.mode"
|
||||
[currentDate]="calendar.currentDate"
|
||||
(onEventSelected)="onEventSelected($event)"
|
||||
(onTitleChanged)="onViewTitleChanged($event)"
|
||||
(onRangeChanged)="onRangeChanged($event)"
|
||||
(onCurrentDateChanged)="onCurrentChanged($event)"
|
||||
|
||||
@@ -290,6 +290,7 @@ export class AgendaPage implements OnInit {
|
||||
this.onDropDownScrollWeal()
|
||||
} catch (e) { }
|
||||
|
||||
this.reloadCalendar();
|
||||
this.updateEventListBox()
|
||||
|
||||
realoadCounter++;
|
||||
|
||||
@@ -35,6 +35,7 @@ import { RouteService } from 'src/app/services/route.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
import { FilePicker } from '@capawesome/capacitor-file-picker';
|
||||
import { ViewDocumentSecondOptionsPage } from 'src/app/modals/view-document-second-options/view-document-second-options.page';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
@@ -1160,7 +1161,16 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
async openFile(pdfString, filename, type) {
|
||||
const blob = this.b64toBlob(pdfString, type)
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewDocumentSecondOptionsPage,
|
||||
componentProps: {
|
||||
fileUrl: pdfString,
|
||||
filename: filename
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
await modal.present();
|
||||
/* const blob = this.b64toBlob(pdfString, type)
|
||||
let pathFile = ''
|
||||
const fileName = filename
|
||||
const contentFile = blob
|
||||
@@ -1180,7 +1190,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
.open(dir.uri, type)
|
||||
.then(() => console.log())
|
||||
.catch(e => console.error(e))
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
downloadFileMsg(msg: MessageService) {
|
||||
@@ -1242,7 +1252,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
this.openFile(str, msg.attachments[0].title, msg.file.type);
|
||||
this.openFile(msg.attachments[0].image_url, msg.attachments[0].title, msg.file.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="msg.file && msg.delate == false">
|
||||
<div (press)="handlePress(msg._id)"
|
||||
class='message-container incoming-{{msg.u.username!=sessionStore.user.UserName}}'
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } fr
|
||||
import { Router } from '@angular/router'
|
||||
import { GestureController, ModalController, NavParams, PopoverController, Platform, AlertController } from '@ionic/angular';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
import { ViewDocumentSecondOptionsPage} from 'src/app/modals/view-document-second-options/view-document-second-options.page';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
|
||||
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
||||
@@ -143,7 +144,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.ChatSystemService.getDmRoom(this.roomId).loadHistory({})
|
||||
this.ChatSystemService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.ChatSystemService.openRoom(this.roomId)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(()=> {
|
||||
this.ChatSystemService.getDmRoom(this.roomId).setChangeDetector(() => {
|
||||
|
||||
this.changeDetector()
|
||||
})
|
||||
@@ -163,7 +164,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
try {
|
||||
// console.log(this.router.url);
|
||||
// console.log(this.router.url);
|
||||
this.createDirectoryImage()
|
||||
// this.chatService.refreshtoken();
|
||||
this.ChatSystemService.getUserOfRoom(this.roomId).then((value) => {
|
||||
@@ -852,7 +853,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log('add file ')
|
||||
const roomId = this.roomId
|
||||
|
||||
if(this.platform.is('ios')) {
|
||||
if (this.platform.is('ios')) {
|
||||
console.log('ios add file ')
|
||||
|
||||
const resultt = await FilePicker.pickFiles({
|
||||
@@ -861,7 +862,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
readData: true,
|
||||
});
|
||||
|
||||
console.log('RESULT', resultt.files[0])
|
||||
console.log('RESULT', resultt.files[0].data)
|
||||
|
||||
const blobb = this.fileService.base64toBlob(resultt.files[0].data, resultt.files[0].mimeType)
|
||||
|
||||
@@ -886,7 +887,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
})
|
||||
return
|
||||
|
||||
|
||||
}
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
@@ -904,41 +905,41 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
formData.append('blobFile', blob);
|
||||
console.log('add file', fileBase64) */
|
||||
|
||||
const fileName = file.name
|
||||
const fileName = file.name
|
||||
|
||||
const validation = this.FileValidatorService.fileNameValidation(fileName)
|
||||
const validation = this.FileValidatorService.fileNameValidation(fileName)
|
||||
|
||||
if(validation.isOk) {
|
||||
if (validation.isOk) {
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
console.log(encodedData)
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
console.log(encodedData)
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
/* console.log('add file', fileBase64) */
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
/* console.log('add file', fileBase64) */
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": sanitize(fileName),
|
||||
"name": sanitize(fileName),
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.toastService._badRequest("Ficheiro inválido")
|
||||
}
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": sanitize(fileName),
|
||||
"name": sanitize(fileName),
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.toastService._badRequest("Ficheiro inválido")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1105,7 +1106,38 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
return blob;
|
||||
}
|
||||
|
||||
blobToBase64(blob) {
|
||||
return new Promise((resolve, _) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => resolve(reader.result);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
async openFile(pdfString, filename, type) {
|
||||
|
||||
console.log('url while open ',pdfString)
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewDocumentSecondOptionsPage,
|
||||
componentProps: {
|
||||
fileUrl: pdfString,
|
||||
filename: filename
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
await modal.present();
|
||||
/*
|
||||
var blob = new Blob([pdfString], { type: 'application/pdf' });
|
||||
|
||||
console.log('blob blob', blob)
|
||||
|
||||
this.blobToBase64(blob).then((value) => {
|
||||
console.log(value)
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
let pathFile = ''
|
||||
const fileName = filename
|
||||
if (this.platform.is('ios')) {
|
||||
@@ -1114,13 +1146,17 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
pathFile = this.file.externalRootDirectory
|
||||
}
|
||||
|
||||
console.log('file data', pdfString)
|
||||
console.log(pathFile)
|
||||
|
||||
let removePre = this.removeTextBeforeSlash(pdfString,',')
|
||||
console.log('file data remove ', removePre)
|
||||
|
||||
await Filesystem.writeFile({
|
||||
path: fileName,
|
||||
data: pdfString,
|
||||
data: removePre,
|
||||
directory: Directory.Cache,
|
||||
encoding: Encoding.UTF8,
|
||||
encoding: Encoding.UTF8
|
||||
}).then((dir) => {
|
||||
console.log('DIR ', dir)
|
||||
this.fileOpener
|
||||
@@ -1129,7 +1165,16 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
.catch(e => console.error(e))
|
||||
}).catch((error) => {
|
||||
console.log('error writing the file', error)
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
removeTextBeforeSlash(inputString, controlString) {
|
||||
if (inputString.includes(controlString)) {
|
||||
const parts = inputString.split(controlString);
|
||||
return parts.length > 1 ? parts[1] : inputString;
|
||||
} else {
|
||||
return inputString;
|
||||
}
|
||||
}
|
||||
|
||||
downloadFileFromBrowser(fileName: string, data: any): void {
|
||||
@@ -1195,7 +1240,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
modal.present();
|
||||
} else {
|
||||
this.openFile(str, msg.attachments[0].title, msg.file.type);
|
||||
this.openFile(msg.attachments[0].image_url, msg.attachments[0].title, msg.file.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1293,9 +1338,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
for (let i = 0; i < byteString.length; i++) {
|
||||
int8Array[i] = byteString.charCodeAt(i);
|
||||
}
|
||||
const blob = new Blob([int8Array], { type: 'application/pdf' });
|
||||
const blob = new Blob([int8Array], { type: 'application/pdf' });
|
||||
return blob;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -277,43 +277,37 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async loadVideo() {
|
||||
|
||||
const result = await FilePicker.pickMedia
|
||||
({
|
||||
multiple: true,
|
||||
});
|
||||
console.log(result.files)
|
||||
result.files.forEach(async element => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
console.log('pass size verificartion')
|
||||
if (this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') {
|
||||
async loadVideo() {
|
||||
const result = await FilePicker.pickMedia ({ multiple: true, });
|
||||
console.log(result.files)
|
||||
result.files.forEach(async element => {
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
console.log('pass size verificartion')
|
||||
if (this.checkFileType.checkFileType(element.mimeType) == 'video' && this.platform.is('ios')) {
|
||||
let resultUrl = decodeURIComponent(element.path); console.log('pass type verification ', resultUrl)
|
||||
try {
|
||||
this.recordevideoIos(resultUrl)
|
||||
} catch (error) {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
} else if (this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') {
|
||||
let resultUrl = decodeURIComponent(element.path);
|
||||
console.log('pass type verification ', resultUrl)
|
||||
console.log('pass type verification ', resultUrl)
|
||||
try {
|
||||
this.loadVideoAndroid(resultUrl,element)
|
||||
} catch (error) {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.seletedContent.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
try {
|
||||
|
||||
if(this.platform.is('ios')) {
|
||||
this.recordevideoIos(resultUrl)
|
||||
} else {
|
||||
this.loadVideoAndroid(resultUrl,element)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (this.seletedContent.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
this.httpErrorHandle.validationMessagge('filessize')
|
||||
}
|
||||
});
|
||||
};
|
||||
this.httpErrorHandle.validationMessagge('filessize')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
chossePhotoOrVideo() {
|
||||
@@ -841,7 +835,7 @@ console.log(stringGerada);
|
||||
fileObject ={};
|
||||
const deleteSecretFile = async () => {
|
||||
await Filesystem.deleteFile({
|
||||
path: 'output.mp4',
|
||||
path: `${stringGerada}.mp4`,
|
||||
directory: Directory.Cache,
|
||||
});
|
||||
};
|
||||
@@ -958,27 +952,27 @@ console.log(stringGerada);
|
||||
});
|
||||
|
||||
let fileObject ={};
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,filename,'mp4').then(() => {
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,filename,'mp4').then(async () => {
|
||||
await Filesystem.readFile({ path: `${directory.uri}${filename}.mp4`})
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content.data)
|
||||
this.filecontent = true;
|
||||
fileObject = {
|
||||
/* fileObject = {
|
||||
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||
FileExtension: FileExtension,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'shared',
|
||||
}
|
||||
} */
|
||||
fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','),
|
||||
FileExtension: FileExtension,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'shared',
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
fileObject ={};
|
||||
const deleteSecretFile = async () => {
|
||||
await Filesystem.deleteFile({
|
||||
path: 'output.mp4',
|
||||
path: `${filename}.mp4`,
|
||||
directory: Directory.Cache,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user