mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Download file and display
This commit is contained in:
@@ -495,6 +495,7 @@ export class ChatPage implements OnInit {
|
||||
roomsArray.push(roomList)
|
||||
});
|
||||
|
||||
this.storageservice.remove('rooms');
|
||||
this.storageservice.store('rooms', roomsArray);
|
||||
|
||||
} else {
|
||||
@@ -513,7 +514,7 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
transformDataUserList(users) {
|
||||
async transformDataUserList(users) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
let usersArray = [];
|
||||
users.forEach(element => {
|
||||
@@ -526,7 +527,8 @@ export class ChatPage implements OnInit {
|
||||
console.log('TRANSFORM USER CHAT 2', chatusers)
|
||||
usersArray.push(chatusers);
|
||||
});
|
||||
this.storageservice.store('chatusers',usersArray);
|
||||
await this.storageservice.remove('chatusers');
|
||||
await this.storageservice.store('chatusers',usersArray);
|
||||
} else {
|
||||
users.forEach(element => {
|
||||
console.log('TRANSFORM USER CHAT 1', element)
|
||||
@@ -669,7 +671,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
transformGroups(data) {
|
||||
async transformGroups(data) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
let groupsArray = [];
|
||||
data.forEach(element => {
|
||||
@@ -687,7 +689,8 @@ export class ChatPage implements OnInit {
|
||||
groupsArray.push(roomList)
|
||||
});
|
||||
|
||||
this.storageservice.store('grouprooms', groupsArray);
|
||||
await this.storageservice.remove('grouprooms');
|
||||
await this.storageservice.store('grouprooms', groupsArray);
|
||||
|
||||
} else {
|
||||
data.forEach(element => {
|
||||
|
||||
@@ -59,6 +59,8 @@ export class FileService {
|
||||
|
||||
uploadFile(formData:any){
|
||||
|
||||
console.log('UPLOAD file', formData)
|
||||
|
||||
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
|
||||
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
|
||||
|
||||
@@ -253,7 +255,7 @@ export class FileService {
|
||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", this.capturedImage);
|
||||
let guid: any = await this.uploadFile(formData).toPromise()
|
||||
let guid: any = await this.uploadFile(this.capturedImage).toPromise()
|
||||
console.log(guid.path);
|
||||
|
||||
let body = {
|
||||
@@ -355,6 +357,8 @@ export class FileService {
|
||||
|
||||
addPictureToChat(roomId) {
|
||||
|
||||
console.log('add picture to chat')
|
||||
|
||||
const input = this.fileLoaderService.createInput({
|
||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
||||
})
|
||||
@@ -377,7 +381,7 @@ export class FileService {
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", file);
|
||||
let guid: any = await this.uploadFile(formData).toPromise()
|
||||
console.log(guid.path);
|
||||
console.log('add picture to chat',guid.path);
|
||||
|
||||
/* const imageData = await this.fileToBase64Service.convert(file)
|
||||
this.capturedImage = imageData; */
|
||||
@@ -407,8 +411,9 @@ export class FileService {
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
|
||||
//console.log(res);
|
||||
console.log('Msg after send image',res);
|
||||
},(error) => {
|
||||
console.log('Msg after send image error',error);
|
||||
});
|
||||
//console.log(this.capturedImage)
|
||||
};
|
||||
|
||||
@@ -261,7 +261,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
|
||||
getMessageDB() {
|
||||
this.storage.get('chatmsg').then((msg) => {
|
||||
this.storageservice.get('chatmsg').then((msg) => {
|
||||
console.log('FROM DB WEB', msg)
|
||||
let msgArray = [];
|
||||
msgArray = msg;
|
||||
@@ -272,21 +272,29 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
|
||||
getImageFromStorage (element) {
|
||||
let image;
|
||||
if (typeof element.file != 'undefined') {
|
||||
if (typeof element.file.guid != 'undefined') {
|
||||
let imageguid = this.storageservice.get(element.file.guid);
|
||||
if (imageguid) {
|
||||
image = imageguid;
|
||||
console.log('IMAGE STORAGE', image)
|
||||
} else {
|
||||
image = "";
|
||||
console.log('IMAGE STORAGE', image)
|
||||
}
|
||||
} else {
|
||||
image = "";
|
||||
}
|
||||
}
|
||||
console.log('IMAGE STORAGE RETURN', image.__zone_symbol__value)
|
||||
return image.__zone_symbol__value;
|
||||
}
|
||||
|
||||
transformData(res) {
|
||||
let mgsArray = [];
|
||||
res.forEach(async element => {
|
||||
let image;
|
||||
|
||||
if (element.file) {
|
||||
try {
|
||||
image = await this.storage.get(element.file.guid) ?? console.log('CHECK VALUE UNDEFINE');
|
||||
console.log('IMAGE STORAGE', image)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
let chatmsg = {
|
||||
_id: element._id,
|
||||
@@ -299,7 +307,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
ts: element.ts,
|
||||
u: element.u,
|
||||
_updatedAt: element._updatedAt,
|
||||
image_url: image,
|
||||
image_url: this.getImageFromStorage(element),
|
||||
}
|
||||
|
||||
mgsArray.push(chatmsg)
|
||||
@@ -307,10 +315,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
});
|
||||
console.log('Web TRANSFORM MSG', mgsArray)
|
||||
this.storage.remove('chatmsg').then(() => {
|
||||
this.storageservice.remove('chatmsg').then(() => {
|
||||
console.log('MSG REMOVE FROM STORAGE')
|
||||
});
|
||||
this.storage.set('chatmsg', mgsArray).then(() => {
|
||||
this.storageservice.store('chatmsg', mgsArray).then(() => {
|
||||
console.log('MSG SAVED ON STORAGE')
|
||||
this.getMessageDB();
|
||||
});
|
||||
@@ -372,7 +380,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
console.log('GET FILE WEB', foo)
|
||||
});
|
||||
|
||||
this.storage.get('chatmsg').then(async (msg) => {
|
||||
this.storageservice.get('chatmsg').then(async (msg) => {
|
||||
let msgArray = [];
|
||||
msgArray = msg;
|
||||
msgArray.filter(data => data._id != this.roomId);
|
||||
@@ -403,8 +411,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
});
|
||||
await this.storage.remove('chatmsg');
|
||||
await this.storage.set('chatmsg', newmgsArray);
|
||||
await this.storageservice.remove('chatmsg');
|
||||
await this.storageservice.store('chatmsg', newmgsArray);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -700,7 +708,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
/* this.transformData(res['messages']);
|
||||
this.getMessageDB(); */
|
||||
this.transformData(res['messages']);
|
||||
this.getMessageDB();
|
||||
this.getMessageDB();
|
||||
/*
|
||||
this.messages = res['messages'].reverse();
|
||||
this.chatMessageStore.add(roomId, this.messages) */
|
||||
@@ -789,7 +797,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
console.log('TRY ARRAY BUFFER NAME', name);
|
||||
console.log('TRY ARRAY BUFFER', this.downloadFile);
|
||||
|
||||
this.storage.set(msg.file.guid, this.downloadFile);
|
||||
this.storageservice.store(msg.file.guid, this.downloadFile);
|
||||
|
||||
await Filesystem.writeFile({
|
||||
path: `${IMAGE_DIR}/${name}`,
|
||||
|
||||
Reference in New Issue
Block a user