mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Download file from lake fs in progress
This commit is contained in:
@@ -148,6 +148,7 @@ export class ChatPage implements OnInit {
|
||||
this.load();
|
||||
|
||||
this.getDirectMessagesDB();
|
||||
this.getGroupsDB()
|
||||
});
|
||||
|
||||
/* websocket functions */
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<div (click)="handleClick()" class="messages" #scrollMe>
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last"
|
||||
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)">
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="downloadFileMsg(msg)">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
@@ -59,16 +59,15 @@
|
||||
<div>
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<img *ngIf="msg.image_url" src="{{msg.image_url}}" alt="image">
|
||||
<div *ngFor="let file of msg.attachments let i = index">
|
||||
<div (click)="openPreview(msg)">
|
||||
<img *ngIf="msg.image_url" src="{{downloadfile}}" alt="image">
|
||||
<div (click)="downloadFileMsg(msg)">
|
||||
<img *ngIf="msg.image_url" src="{{msg.image_url}}" alt="image">
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="docIndex(i); viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<div (click)="docIndex(i); downloadFileMsg(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
|
||||
@@ -78,6 +78,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
@ViewChild('recordbtn', { read: ElementRef }) recordBtn: ElementRef;
|
||||
myAudio: any;
|
||||
downloadfile: any;
|
||||
downloadFile: any;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -343,7 +344,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
viewDocument(file: any, url?: string) {
|
||||
console.log(file);
|
||||
|
||||
if (file.type == "application/webtrix") {
|
||||
this.openViewDocumentModal(file);
|
||||
@@ -757,18 +757,68 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
card.el.style['z-index'] = 11;
|
||||
}
|
||||
|
||||
downloadFileMsg(msg) {
|
||||
console.log('FILE TYPE', msg.file.type)
|
||||
this.downloadFile = "";
|
||||
if (msg.file.type == "application/img") {
|
||||
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||
console.log('FILE TYPE 22', msg.file.guid)
|
||||
var name = msg.file.guid;
|
||||
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
console.log('FILE TYPE 44', this.downloadFile)
|
||||
|
||||
console.log('TRY ARRAY BUFFER NAME', name);
|
||||
console.log('TRY ARRAY BUFFER', this.downloadFile);
|
||||
|
||||
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
|
||||
|
||||
await Filesystem.writeFile({
|
||||
path: `${IMAGE_DIR}/${name}`,
|
||||
data: this.downloadFile,
|
||||
directory: Directory.Data
|
||||
}).then((foo) => {
|
||||
console.log('SAVED FILE WEB', foo)
|
||||
}).catch((error) => {
|
||||
console.log('SAVED FILE WEB error ', error)
|
||||
});
|
||||
|
||||
const readFile = await Filesystem.readdir({
|
||||
path: `${IMAGE_DIR}/${name}`,
|
||||
directory: Directory.Data,
|
||||
}).then((foo) => {
|
||||
console.log('GET FILE WEB', foo)
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
console.log('FILE TYPE 44', this.downloadFile)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewMediaPage,
|
||||
cssClass: 'modal modal-desktop',
|
||||
componentProps: {
|
||||
image: msg.attachments[0].image_url,
|
||||
username: msg.u.name,
|
||||
_updatedAt: msg._updatedAt,
|
||||
}
|
||||
});
|
||||
modal.present();
|
||||
if(msg.image_url != "") {
|
||||
this.downloadFile();
|
||||
} else {
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewMediaPage,
|
||||
cssClass: 'modal modal-desktop',
|
||||
componentProps: {
|
||||
image: msg.attachments[0].image_url,
|
||||
username: msg.u.name,
|
||||
_updatedAt: msg._updatedAt,
|
||||
}
|
||||
});
|
||||
modal.present();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export class FileService {
|
||||
|
||||
downloadFile(guid:any) {
|
||||
|
||||
let downloadUrl = 'https://equilibrium.dyndns.info/GabineteDigital.Services/V5/api/objectserver/streamfiles?path='+guid;
|
||||
let downloadUrl = environment.apiURL +'objectserver/streamfiles?path='+guid;
|
||||
var name = new Date().getTime();
|
||||
return this.http.get(downloadUrl, {
|
||||
responseType: "arraybuffer",
|
||||
|
||||
@@ -279,7 +279,7 @@ export class SqliteService {
|
||||
public addChatMSG(data) {
|
||||
console.log('INSIDE DB CHAT MSG',data,)
|
||||
this.dbInstance.executeSql(`
|
||||
INSERT OR REPLACE INTO ${this.chatmsg} (Id,Attachments,Channels,File,Mentions,Msg,Rid, Ts ,U, UpdatedAt,image_url)
|
||||
INSERT OR IGNORE INTO ${this.chatmsg} (Id,Attachments,Channels,File,Mentions,Msg,Rid, Ts ,U, UpdatedAt,image_url)
|
||||
VALUES ('${data._id}','${JSON.stringify(data.attachments)}','${JSON.stringify(data.channels)}','${JSON.stringify(data.file)}','${JSON.stringify(data.mentions)}','${data.msg}','${data.rid}','${data.ts}','${JSON.stringify(data.u)}','${data._updatedAt}','${JSON.stringify(data.image_url)}')`, [])
|
||||
.then(() => {
|
||||
console.log("chat msg add with Success");
|
||||
@@ -319,6 +319,22 @@ export class SqliteService {
|
||||
|
||||
}
|
||||
|
||||
//updateChatMsg
|
||||
public updateChatMsg(id, data) {
|
||||
try {
|
||||
console.log("update action data", data)
|
||||
this.dbInstance.executeSql(`
|
||||
UPDATE ${this.chatmsg} SET image_url = ? WHERE Id = ${id}`, [data])
|
||||
.then(() => {
|
||||
console.log("ChatMsg update with Success");
|
||||
|
||||
}, (e) => {
|
||||
console.log(JSON.stringify(e.err));
|
||||
});
|
||||
} catch(error) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//updateprocess
|
||||
public updateProcess(data) {
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
<img src="{{msg.image_url}}" alt="image">
|
||||
<img src="{{downloadFile}}" alt="image">
|
||||
</div>
|
||||
<div>
|
||||
<div class="file">
|
||||
|
||||
Reference in New Issue
Block a user