mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
improve
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StorageService } from './storage.service';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
||||
import { LoginUserRespose, UserForm, UserSession } from '../models/user.model';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { HttpService } from './http.service';
|
||||
@@ -18,6 +18,7 @@ import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { RoomService } from './chat/room.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -187,6 +188,43 @@ export class AuthService {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
|
||||
|
||||
console.log('FILE TYPE', message.file.type)
|
||||
let downloadFile = "";
|
||||
if (message.file.type == "application/img") {
|
||||
const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise();
|
||||
|
||||
console.log('FILE TYPE 22', message.file.guid)
|
||||
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
console.log('FILE TYPE 33', message.file.type)
|
||||
return true
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
|
||||
message.file = {
|
||||
guid: message.file.guid,
|
||||
image_url: downloadFile,
|
||||
type: message.file.type
|
||||
}
|
||||
|
||||
await this.storage.set(message.file.guid, downloadFile).then(() => {
|
||||
console.log('IMAGE SAVED')
|
||||
});
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}, 1)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user