mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
Add storage to web chat
This commit is contained in:
@@ -12,7 +12,7 @@ import { ToastService } from '../toast.service';
|
||||
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { HttpClient, HttpEventType, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -39,6 +39,8 @@ export class FileService {
|
||||
idroom: any;
|
||||
|
||||
headers: HttpHeaders;
|
||||
downloadProgess = 0;
|
||||
downloadFilename: any;
|
||||
|
||||
constructor(
|
||||
private fileLoaderService: FileLoaderService,
|
||||
@@ -57,7 +59,7 @@ export class FileService {
|
||||
alert('OIEE')
|
||||
|
||||
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
|
||||
const geturl = environment.apiURL + 'lakefs/UploadFiles';
|
||||
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
|
||||
|
||||
let options = {
|
||||
headers: this.headers
|
||||
@@ -79,6 +81,28 @@ export class FileService {
|
||||
return this.http.get<any>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
downloadFile(guid:any) {
|
||||
|
||||
let downloadUrl = 'https://equilibrium.dyndns.info/GabineteDigital.Services/V5/api/objectserver/streamfiles?path='+guid;
|
||||
var name = new Date().getTime();
|
||||
return this.http.get(downloadUrl, {
|
||||
responseType: "arraybuffer",
|
||||
reportProgress: true, observe: 'events'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
_arrayBufferToBase64( buffer ) {
|
||||
var binary = '';
|
||||
var bytes = new Uint8Array( buffer );
|
||||
var len = bytes.byteLength;
|
||||
for (var i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode( bytes[ i ] );
|
||||
}
|
||||
return window.btoa( binary );
|
||||
}
|
||||
|
||||
|
||||
async takePicture() {
|
||||
const capturedImage = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
@@ -378,6 +402,7 @@ export class FileService {
|
||||
"file":{
|
||||
"type": "application/img",
|
||||
"guid": guid.path,
|
||||
"image_url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,9 @@ export class SqliteService {
|
||||
Uids Text,
|
||||
Usernames Text,
|
||||
LastMessage Text,
|
||||
UpdatedAt varchar(255)
|
||||
UpdatedAt varchar(255),
|
||||
customFields Text,
|
||||
name varchar(255)
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess chat list room Table created: ", res)
|
||||
@@ -170,7 +172,8 @@ export class SqliteService {
|
||||
Rid varchar(255),
|
||||
Ts varchar(255),
|
||||
U Text,
|
||||
UpdatedAt varchar(255)
|
||||
UpdatedAt varchar(255),
|
||||
image_url Text
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess chat msg Table created: ", res)
|
||||
@@ -248,8 +251,8 @@ export class SqliteService {
|
||||
public addChatListRoom(data) {
|
||||
console.log('INSIDE DB CHAT LIST ROOM',data,)
|
||||
this.dbInstance.executeSql(`
|
||||
INSERT OR REPLACE INTO ${this.chatlistroom} (Id,Uids,Usernames,LastMessage,UpdatedAt)
|
||||
VALUES ('${data.id}','${JSON.stringify(data.uids)}','${JSON.stringify(data.usernames)}','${JSON.stringify(data.lastMessage)}','${data.updatedat}')`, [])
|
||||
INSERT OR REPLACE INTO ${this.chatlistroom} (Id,Uids,Usernames,LastMessage,UpdatedAt,customFields,name)
|
||||
VALUES ('${data.id}','${JSON.stringify(data.uids)}','${JSON.stringify(data.usernames)}','${JSON.stringify(data.lastMessage)}','${data.updatedat}','${JSON.stringify(data.customFields)}','${data.name}')`, [])
|
||||
.then(() => {
|
||||
console.log("chat room add with Success");
|
||||
|
||||
@@ -276,8 +279,8 @@ 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)
|
||||
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}')`, [])
|
||||
INSERT OR REPLACE 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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user