mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
merge
This commit is contained in:
@@ -159,11 +159,6 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
let t = this.showDateDuration(new Date());
|
let t = this.showDateDuration(new Date());
|
||||||
|
|
||||||
this.setStatus('away');
|
|
||||||
/* if(this.dataService.get("newGroup")){
|
|
||||||
this.openNewGroupPage();
|
|
||||||
} */
|
|
||||||
|
|
||||||
this.router.events.forEach((event) => {
|
this.router.events.forEach((event) => {
|
||||||
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
|
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
|
||||||
if (this.dataService.get("newGroup")) {
|
if (this.dataService.get("newGroup")) {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
<ion-label *ngIf="msg.file">
|
<ion-label *ngIf="msg.file">
|
||||||
<span *ngIf="file.description">{{file.description}}</span>
|
<span *ngIf="file.description">{{file.description}}</span>
|
||||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,12 +20,18 @@ import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
|||||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service'
|
||||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
|
||||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||||
import { HttpEventType } from '@angular/common/http';
|
import { HttpEventType } from '@angular/common/http';
|
||||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||||
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
|
import { FileType } from 'src/app/models/fileType';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
|
||||||
|
import { CameraService } from 'src/app/services/camera.service';
|
||||||
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||||
|
import { ProcessesService } from 'src/app/services/processes.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-messages',
|
selector: 'app-group-messages',
|
||||||
@@ -87,7 +93,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
private platform: Platform,
|
private platform: Platform,
|
||||||
public wsChatMethodsService: WsChatMethodsService
|
public wsChatMethodsService: WsChatMethodsService,
|
||||||
|
private AttachmentsService: AttachmentsService,
|
||||||
|
private storage: Storage,
|
||||||
|
private processesService: ProcessesService,
|
||||||
|
|
||||||
|
private CameraService: CameraService,
|
||||||
) {
|
) {
|
||||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||||
this.isGroupCreated = true;
|
this.isGroupCreated = true;
|
||||||
@@ -240,7 +251,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
|
this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
|
||||||
}
|
}
|
||||||
this.getGroupContacts(this.room);
|
this.getGroupContacts(this.room);
|
||||||
this.loadGroupMessages(this.room);
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -289,27 +299,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadGroupMessages(room:any){
|
|
||||||
this.showLoader = true;
|
|
||||||
//If group is private call getGroupMembers
|
|
||||||
if(this.room.t === 'p'){
|
|
||||||
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res=>{
|
|
||||||
console.log(res);
|
|
||||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
|
||||||
//this.messages = msgOnly.reverse();
|
|
||||||
this.transformDataMSG(msgOnly.reverse());
|
|
||||||
this.getRoomMessageDB(this.roomId);
|
|
||||||
this.showLoader = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//Otherwise call getChannelMembers for públic groups
|
|
||||||
/* else{
|
|
||||||
this.chatService.getPublicGroupMessages(this.roomId).subscribe(res=>{
|
|
||||||
console.log(res);
|
|
||||||
this.messages = res['messages'].reverse();
|
|
||||||
});
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
|
|
||||||
showDateDuration(start:any){
|
showDateDuration(start:any){
|
||||||
return this.timeService.showDateDuration(start);
|
return this.timeService.showDateDuration(start);
|
||||||
@@ -330,7 +319,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
|
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
|
||||||
}
|
}
|
||||||
|
|
||||||
async openOptions() {
|
async openOptions() {
|
||||||
@@ -357,42 +346,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPicture() {
|
|
||||||
const input = this.fileLoaderService.createInput({
|
|
||||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
|
||||||
})
|
|
||||||
|
|
||||||
input.onchange = async () => {
|
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
|
||||||
|
|
||||||
console.log(file);
|
|
||||||
|
|
||||||
const imageData = await this.fileToBase64Service.convert(file)
|
|
||||||
this.capturedImage = imageData;
|
|
||||||
this.capturedImageTitle = file.name;
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": this.roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
//"title": this.capturedImageTitle ,
|
|
||||||
//"text": "description",
|
|
||||||
"title_link_download": false,
|
|
||||||
"image_url": this.capturedImage,
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
|
||||||
console.log(res);
|
|
||||||
},(error) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
//console.log(this.capturedImage)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
viewDocument(file:any, url?:string){
|
viewDocument(file:any, url?:string){
|
||||||
|
|
||||||
@@ -484,8 +437,183 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async takePicture() {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const image = await this.CameraService.takePicture();
|
||||||
|
await this.fileService.saveImage(image)
|
||||||
|
const lastphoto: any = await this.fileService.loadFiles();
|
||||||
|
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(this.roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": capturedImage
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": capturedImageTitle ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const base64 = await fetch(capturedImage);
|
||||||
|
const blob = await base64.blob();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
console.log('ALL IMAGE', formData)
|
||||||
|
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: capturedImage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat', capturedImage);
|
||||||
|
await this.storage.set(guid.path, capturedImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async addImage() {
|
||||||
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
|
}
|
||||||
|
|
||||||
|
async addFile() {
|
||||||
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||||
|
}
|
||||||
|
|
||||||
|
async addFileWebtrix() {
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: SearchPage,
|
||||||
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
||||||
|
componentProps: {
|
||||||
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
||||||
|
select: true,
|
||||||
|
showSearchInput: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then(async res=>{
|
||||||
|
const data = res.data;
|
||||||
|
|
||||||
|
if(data.selected) {
|
||||||
|
const loader = this.toastService.loading();
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(this.roomId).send({
|
||||||
|
file:{
|
||||||
|
"name": res.data.selected.Assunto,
|
||||||
|
"type": "application/webtrix",
|
||||||
|
"ApplicationId": res.data.selected.ApplicationType,
|
||||||
|
"DocId": res.data.selected.Id,
|
||||||
|
"Assunto": res.data.selected.Assunto,
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
// "title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
// "message_link": url_no_options,
|
||||||
|
"type": "webtrix"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
||||||
|
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
||||||
|
console.log(url_no_options);
|
||||||
|
|
||||||
|
updateMessage({
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
"title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
"message_link": url_no_options,
|
||||||
|
"type": "webtrix",
|
||||||
|
"text": res.data.selected.DocTypeDesc,
|
||||||
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
loader.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", file);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(this.roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": imageData
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": file.name ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: imageData
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat',fileImage);
|
||||||
|
await this.storage.set(guid.path, fileImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async openChatOptions(ev?: any) {
|
async openChatOptions(ev?: any) {
|
||||||
console.log(this.members);
|
console.log(this.members);
|
||||||
|
const roomId = this.roomId;
|
||||||
|
|
||||||
const popover = await this.popoverController.create({
|
const popover = await this.popoverController.create({
|
||||||
component: ChatOptionsPopoverPage,
|
component: ChatOptionsPopoverPage,
|
||||||
@@ -499,29 +627,25 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
translucent: true
|
translucent: true
|
||||||
});
|
});
|
||||||
await popover.present();
|
await popover.present();
|
||||||
await popover.onDidDismiss().then((res)=>{
|
await popover.onDidDismiss().then( async(res)=>{
|
||||||
console.log(res['data']);
|
console.log(res['data']);
|
||||||
if(res['data'] == 'meeting'){
|
if (res['data'] == 'meeting') {
|
||||||
this.bookMeeting();
|
this.bookMeeting();
|
||||||
}
|
}
|
||||||
else if(res['data'] == 'take-picture'){
|
else if (res['data'] == 'take-picture') {
|
||||||
this.fileService.addCameraPictureToChat(this.roomId);
|
this.takePicture()
|
||||||
//this.loadPicture();
|
|
||||||
}
|
}
|
||||||
else if(res['data'] == 'add-picture'){
|
else if (res['data'] == 'add-picture') {
|
||||||
this.fileService.addPictureToChatMobile(this.roomId);
|
this.addImage()
|
||||||
//this.loadPicture();
|
|
||||||
}
|
|
||||||
else if(res['data'] == 'add-document'){
|
|
||||||
this.fileService.addDocumentToChat(this.roomId);
|
|
||||||
//this.loadDocument();
|
|
||||||
}
|
|
||||||
else if(res['data'] == 'documentoGestaoDocumental'){
|
|
||||||
|
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
|
||||||
//this.addDocGestaoDocumental();
|
|
||||||
}
|
}
|
||||||
this.loadGroupMessages(this.roomId);
|
else if (res['data'] == 'add-document') {
|
||||||
|
this.addFile()
|
||||||
|
}
|
||||||
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
||||||
|
|
||||||
|
this.addFileWebtrix()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +869,7 @@ downloadFileMsg(msg) {
|
|||||||
console.log('FILE TYPE', msg.file.type)
|
console.log('FILE TYPE', msg.file.type)
|
||||||
this.downloadFile = "";
|
this.downloadFile = "";
|
||||||
if (msg.file.type == "application/img") {
|
if (msg.file.type == "application/img") {
|
||||||
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||||
console.log('FILE TYPE 22', msg.file.guid)
|
console.log('FILE TYPE 22', msg.file.guid)
|
||||||
var name = msg.file.guid;
|
var name = msg.file.guid;
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
<ion-label *ngIf="msg.file && msg.file != ''">
|
<ion-label *ngIf="msg.file && msg.file != ''">
|
||||||
<span *ngIf="file.description">{{file.description}}</span>
|
<span *ngIf="file.description">{{file.description}}</span>
|
||||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { GestureController, Gesture, ModalController, NavParams, PopoverController, IonSlides, Platform } from '@ionic/angular';
|
import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||||
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
|
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
|
||||||
import { SearchDocumentDetails, SearchFolderDetails } from 'src/app/models/search-document';
|
|
||||||
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
||||||
import { AlertService } from 'src/app/services/alert.service';
|
import { AlertService } from 'src/app/services/alert.service';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
@@ -31,6 +30,14 @@ import { HttpEventType } from '@angular/common/http';
|
|||||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
|
||||||
import { MessageService } from 'src/app/services/chat/message.service';
|
import { MessageService } from 'src/app/services/chat/message.service';
|
||||||
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
|
|
||||||
|
import { CameraService } from 'src/app/services/camera.service';
|
||||||
|
import { element } from 'protractor';
|
||||||
|
import { FileType } from 'src/app/models/fileType';
|
||||||
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||||
|
import { Storage } from '@ionic/storage';
|
||||||
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
|
|
||||||
@@ -98,7 +105,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private platform: Platform,
|
private platform: Platform,
|
||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
public wsChatMethodsService: WsChatMethodsService
|
public wsChatMethodsService: WsChatMethodsService,
|
||||||
|
private AttachmentsService: AttachmentsService,
|
||||||
|
|
||||||
|
private CameraService: CameraService,
|
||||||
|
private processesService: ProcessesService,
|
||||||
|
private storage: Storage,
|
||||||
|
private fileToBase64Service: FileToBase64Service,
|
||||||
) {
|
) {
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||||
this.roomId = this.navParams.get('roomId');
|
this.roomId = this.navParams.get('roomId');
|
||||||
@@ -121,11 +134,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
//this.load();
|
|
||||||
this.setStatus('online');
|
|
||||||
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
||||||
console.log('MEMBER', value)
|
console.log('MEMBER', value)
|
||||||
})
|
})
|
||||||
|
|
||||||
//this.loadFiles();
|
//this.loadFiles();
|
||||||
VoiceRecorder.requestAudioRecordingPermission();
|
VoiceRecorder.requestAudioRecordingPermission();
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
@@ -256,15 +268,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.selectedMsgId = "";
|
this.selectedMsgId = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(status: string) {
|
|
||||||
let body = {
|
|
||||||
message: '',
|
|
||||||
status: status,
|
|
||||||
}
|
|
||||||
this.chatService.setUserStatus(body).subscribe(res => {
|
|
||||||
console.log(res);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
notImplemented() {
|
notImplemented() {
|
||||||
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
||||||
@@ -275,7 +278,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
this.serverLongPull();
|
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +352,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
this.wsChatMethodsService.getDmRoom(this.roomId).send()
|
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -518,6 +520,183 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async takePicture() {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const image = await this.CameraService.takePicture();
|
||||||
|
await this.fileService.saveImage(image)
|
||||||
|
const lastphoto: any = await this.fileService.loadFiles();
|
||||||
|
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": capturedImage
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": capturedImageTitle ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const base64 = await fetch(capturedImage);
|
||||||
|
const blob = await base64.blob();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
console.log('ALL IMAGE', formData)
|
||||||
|
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: capturedImage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat', capturedImage);
|
||||||
|
await this.storage.set(guid.path, capturedImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async addImage() {
|
||||||
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
|
}
|
||||||
|
|
||||||
|
async addFile() {
|
||||||
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||||
|
}
|
||||||
|
|
||||||
|
async addFileWebtrix() {
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: SearchPage,
|
||||||
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
||||||
|
componentProps: {
|
||||||
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
||||||
|
select: true,
|
||||||
|
showSearchInput: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then(async res=>{
|
||||||
|
const data = res.data;
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
if(data.selected) {
|
||||||
|
const loader = this.toastService.loading();
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file:{
|
||||||
|
"name": res.data.selected.Assunto,
|
||||||
|
"type": "application/webtrix",
|
||||||
|
"ApplicationId": res.data.selected.ApplicationType,
|
||||||
|
"DocId": res.data.selected.Id,
|
||||||
|
"Assunto": res.data.selected.Assunto,
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
// "title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
// "message_link": url_no_options,
|
||||||
|
"type": "webtrix"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
||||||
|
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
||||||
|
console.log(url_no_options);
|
||||||
|
|
||||||
|
updateMessage({
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
"title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
"message_link": url_no_options,
|
||||||
|
"type": "webtrix",
|
||||||
|
"text": res.data.selected.DocTypeDesc,
|
||||||
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
loader.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", file);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": imageData
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": file.name ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: imageData
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat',fileImage);
|
||||||
|
await this.storage.set(guid.path, fileImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async openChatOptions(ev?: any) {
|
async openChatOptions(ev?: any) {
|
||||||
const roomId = this.roomId
|
const roomId = this.roomId
|
||||||
console.log('MOBILE CHAT OPTION',this.members);
|
console.log('MOBILE CHAT OPTION',this.members);
|
||||||
@@ -534,66 +713,29 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
translucent: true
|
translucent: true
|
||||||
});
|
});
|
||||||
await popover.present();
|
await popover.present();
|
||||||
popover.onDidDismiss().then((res) => {
|
popover.onDidDismiss().then( async (res) => {
|
||||||
console.log(res['data']);
|
console.log(res['data']);
|
||||||
if (res['data'] == 'meeting') {
|
if (res['data'] == 'meeting') {
|
||||||
this.bookMeeting();
|
this.bookMeeting();
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'take-picture') {
|
else if (res['data'] == 'take-picture') {
|
||||||
this.fileService.addCameraPictureToChat(roomId);
|
this.takePicture()
|
||||||
//this.loadPicture();
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-picture') {
|
else if (res['data'] == 'add-picture') {
|
||||||
//this.fileService.addPictureToChat(roomId);
|
this.addImage()
|
||||||
this.fileService.loadPicture(this.roomId);
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-document') {
|
else if (res['data'] == 'add-document') {
|
||||||
this.fileService.addDocumentToChat(this.roomId);
|
this.addFile()
|
||||||
//this.loadDocument();
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'documentoGestaoDocumental') {
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
||||||
|
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
this.addFileWebtrix()
|
||||||
//this.addDocGestaoDocumental();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
this.fileService.downloadFile(element.file.guid).subscribe(async (event) => {
|
|
||||||
var name = element.file.guid;
|
|
||||||
if (event.type === HttpEventType.DownloadProgress) {
|
|
||||||
|
|
||||||
} else if (event.type === HttpEventType.Response) {
|
|
||||||
var base64 = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('TRY ARRAY BUFFER NAME', name);
|
|
||||||
console.log('TRY ARRAY BUFFER', base64);
|
|
||||||
|
|
||||||
await Filesystem.writeFile({
|
|
||||||
path: `${IMAGE_DIR}/${name}`,
|
|
||||||
data: base64,
|
|
||||||
directory: Directory.Data
|
|
||||||
}).then((foo) => {
|
|
||||||
|
|
||||||
console.log('LSKE FS FILE SAVED', foo)
|
|
||||||
|
|
||||||
}).catch((error) => {
|
|
||||||
console.log('error LAKE FS FILE', error)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const readFile = await Filesystem.readFile({
|
|
||||||
path: `${IMAGE_DIR}/${name}`,
|
|
||||||
directory: Directory.Data,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});*/
|
|
||||||
|
|
||||||
getRoomMessageDB(roomId) {
|
getRoomMessageDB(roomId) {
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||||
@@ -669,108 +811,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async serverLongPull() {
|
|
||||||
|
|
||||||
const roomId = this.roomId
|
|
||||||
|
|
||||||
/* this.chatService.getRoomMessages(roomId).subscribe(res=>{
|
|
||||||
console.log(res);
|
|
||||||
|
|
||||||
}) */
|
|
||||||
|
|
||||||
|
|
||||||
this.chatService.getRoomMessages(roomId).subscribe(async res => {
|
|
||||||
console.log("Chat message", res)
|
|
||||||
|
|
||||||
this.transformDataMSG(res['messages'])
|
|
||||||
this.getRoomMessageDB(this.roomId);
|
|
||||||
|
|
||||||
|
|
||||||
if (res == 502) {
|
|
||||||
// Connection timeout
|
|
||||||
// happens when the synchro was pending for too long
|
|
||||||
// let's reconnect
|
|
||||||
await this.serverLongPull();
|
|
||||||
}
|
|
||||||
else if (res != 200) {
|
|
||||||
// Show Error
|
|
||||||
//showMessage(response.statusText);
|
|
||||||
//this.loadMessages()
|
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//console.log(this.messages);
|
|
||||||
// Reconnect in one second
|
|
||||||
if (this.route.url != "/home/chat") {
|
|
||||||
console.log("Timer message stop")
|
|
||||||
} else {
|
|
||||||
//Check if modal is opened
|
|
||||||
if (document.querySelector('.isMessagesChatOpened')) {
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
||||||
await this.serverLongPull();
|
|
||||||
//console.log('Timer message running')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Got message
|
|
||||||
//let message = await response.text();
|
|
||||||
//this.loadMessages()
|
|
||||||
await this.serverLongPull();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sliderOpts = {
|
|
||||||
zoom: false,
|
|
||||||
slidesPerView: 1.5,
|
|
||||||
spaceBetween: 20,
|
|
||||||
centeredSlides: true
|
|
||||||
};
|
|
||||||
zoomActive = false;
|
|
||||||
zoomScale = 1;
|
|
||||||
|
|
||||||
sliderZoomOpts = {
|
|
||||||
allowSlidePrev: false,
|
|
||||||
allowSlideNext: false,
|
|
||||||
zoom: {
|
|
||||||
maxRatio: 5
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
zoomChange: (scale, imageEl, slideEl) => {
|
|
||||||
this.zoomActive = true;
|
|
||||||
this.zoomScale = scale / 5;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async touchEnd(zoomslides: IonSlides, card) {
|
|
||||||
// Zoom back to normal
|
|
||||||
const slider = await zoomslides.getSwiper();
|
|
||||||
const zoom = slider.zoom;
|
|
||||||
zoom.out();
|
|
||||||
|
|
||||||
// Card back to normal
|
|
||||||
card.el.style['z-index'] = 9;
|
|
||||||
|
|
||||||
this.zoomActive = false;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
touchStart(card) {
|
|
||||||
// Make card appear above backdrop
|
|
||||||
card.el.style['z-index'] = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadFileMsg(msg: MessageService) {
|
downloadFileMsg(msg: MessageService) {
|
||||||
console.log('FILE TYPE', msg.file.type)
|
console.log('FILE TYPE', msg.file.type)
|
||||||
this.downloadFile = "";
|
this.downloadFile = "";
|
||||||
if (msg.file.type == "application/img") {
|
if (msg.file.type == "application/img") {
|
||||||
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||||
console.log('FILE TYPE 22', msg.file.guid)
|
console.log('FILE TYPE 22', msg.file.guid)
|
||||||
var name = msg.file.guid;
|
var name = msg.file.guid;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,47 @@ export class AttachmentsService {
|
|||||||
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadFile(formData:any) {
|
||||||
|
|
||||||
|
console.log('UPLOAD file', formData)
|
||||||
|
|
||||||
|
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
|
||||||
|
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
headers: this.headers
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.http.post(`${geturl}`, formData, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getFile(guid:any) {
|
||||||
|
const geturl = environment.apiURL + 'lakefs/StreamFile';
|
||||||
|
let params = new HttpParams();
|
||||||
|
|
||||||
|
params = params.set("path", guid);
|
||||||
|
|
||||||
|
this.headers = this.headers.set('responseType', 'blob');
|
||||||
|
this.headers = this.headers.set('Content-Type', 'application/octet-stream');
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
};
|
||||||
|
return this.http.get<any>(`${geturl}`, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadFile(guid:any) {
|
||||||
|
|
||||||
|
let downloadUrl = environment.apiURL +'objectserver/streamfiles?path='+guid;
|
||||||
|
var name = new Date().getTime();
|
||||||
|
return this.http.get(downloadUrl, {
|
||||||
|
responseType: "arraybuffer",
|
||||||
|
reportProgress: true, observe: 'events'
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]>{
|
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]>{
|
||||||
let geturl = environment.apiURL + 'attachments/GetAttachments';
|
let geturl = environment.apiURL + 'attachments/GetAttachments';
|
||||||
let params = new HttpParams();
|
let params = new HttpParams();
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CameraService } from './camera.service';
|
||||||
|
|
||||||
|
describe('CameraService', () => {
|
||||||
|
let service: CameraService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(CameraService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CameraService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
|
||||||
|
async takePicture(){
|
||||||
|
|
||||||
|
return new Promise<Photo>(async (resolve, reject)=>{
|
||||||
|
|
||||||
|
console.log('add camera to picture')
|
||||||
|
|
||||||
|
const image = await Camera.getPhoto({
|
||||||
|
quality: 50,
|
||||||
|
allowEditing: false,
|
||||||
|
resultType: CameraResultType.Uri,
|
||||||
|
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||||
|
});
|
||||||
|
|
||||||
|
if (image) {
|
||||||
|
resolve(image)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
reject('Error saving image')
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.capturedImage = this.capturedImage;
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Message } from 'src/app/models/chatMethod';
|
import { Message } from 'src/app/models/chatMethod';
|
||||||
import { chatHistory, ChatMessage, File } from 'src/app/models/chatMethod'
|
import { chatHistory, ChatMessage, File } from 'src/app/models/chatMethod'
|
||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
import { capitalizeTxt } from 'src/plugin/text'
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -17,54 +19,77 @@ export class MessageService {
|
|||||||
u = {}
|
u = {}
|
||||||
t = ''
|
t = ''
|
||||||
_id =''
|
_id =''
|
||||||
_updatedAt = ''
|
_updatedAt
|
||||||
file
|
file
|
||||||
attachments
|
attachments
|
||||||
offline = false
|
offline = true
|
||||||
|
displayType = ''
|
||||||
|
|
||||||
constructor(private storage: Storage) {
|
constructor(private storage: Storage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments}:Message) {
|
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments}:Message) {
|
||||||
this.customFields = customFields
|
this.customFields = customFields
|
||||||
this.channels = channels
|
this.channels = channels || []
|
||||||
this.mentions = mentions
|
this.mentions = mentions || []
|
||||||
this.msg = msg
|
this.msg = msg || ""
|
||||||
this.rid = rid
|
this.rid = rid
|
||||||
this.ts = ts
|
this.ts = ts
|
||||||
this.u = u
|
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.RochetChatUser), username: SessionStore.user.RochetChatUser, _id: ""}
|
||||||
this.t = t
|
this.t = t
|
||||||
this._id = _id
|
this._id = _id
|
||||||
this._updatedAt = _updatedAt
|
this._updatedAt = _updatedAt || new Date().getTime()
|
||||||
this.file = file
|
this.file = file
|
||||||
this.attachments = attachments
|
this.attachments = attachments
|
||||||
|
|
||||||
|
if(!this.ts) {
|
||||||
if (this.file) {
|
|
||||||
if (this.file.guid) {
|
|
||||||
this.storage.get(this.file.guid).then((image) => {
|
|
||||||
// console.log('IMAGE FROM STORAGE', image)
|
|
||||||
this.file.image_url = image
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(this.rid == 'offline') {
|
|
||||||
this.offline = true
|
this.offline = true
|
||||||
} else {
|
} else {
|
||||||
this.offline = false
|
this.offline = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.file) {
|
||||||
|
this.getFileFromDb()
|
||||||
|
if(this.file.type) {
|
||||||
|
if(this.file.type != 'application/webtrix' && typeof(this.file.type) == 'string') {
|
||||||
|
this.displayType = this.file.type.replace('application/','').toUpperCase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() {}
|
delete() {}
|
||||||
|
|
||||||
showDateDuration() {}
|
showDateDuration() {}
|
||||||
|
|
||||||
|
|
||||||
resend() {
|
resend() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private usernameToDisplayName(username) {
|
||||||
|
|
||||||
|
const firstName = capitalizeTxt(username.split('.')[0])
|
||||||
|
const lastName = capitalizeTxt(username.split('.')[1])
|
||||||
|
return firstName + ' ' + lastName
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getFileFromDb() {
|
||||||
|
if (this.file) {
|
||||||
|
if (this.file.guid) {
|
||||||
|
this.storage.get(this.file.guid).then((image) => {
|
||||||
|
if(image != null) {
|
||||||
|
this.file.image_url = image
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { capitalizeTxt } from 'src/plugin/text'
|
|||||||
import { SortService } from '../functions/sort.service';
|
import { SortService } from '../functions/sort.service';
|
||||||
import { chatUser } from 'src/app/models/chatMethod';
|
import { chatUser } from 'src/app/models/chatMethod';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
|
import { ChatService } from 'src/app/services/chat.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -53,6 +54,7 @@ export class RoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sortRoomList = () => {}
|
sortRoomList = () => {}
|
||||||
|
uploadAttachment = (formData) => {}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public WsChatService: WsChatService,
|
public WsChatService: WsChatService,
|
||||||
@@ -62,6 +64,7 @@ export class RoomService {
|
|||||||
private sqlservice: SqliteService,
|
private sqlservice: SqliteService,
|
||||||
private NativeNotificationService: NativeNotificationService,
|
private NativeNotificationService: NativeNotificationService,
|
||||||
private sortService: SortService,
|
private sortService: SortService,
|
||||||
|
private chatService: ChatService,
|
||||||
) {
|
) {
|
||||||
this.NativeNotificationService.askForPermission()
|
this.NativeNotificationService.askForPermission()
|
||||||
}
|
}
|
||||||
@@ -88,9 +91,10 @@ export class RoomService {
|
|||||||
this.id,
|
this.id,
|
||||||
"stream-room-messages",
|
"stream-room-messages",
|
||||||
(ChatMessage) => {
|
(ChatMessage) => {
|
||||||
|
ChatMessage = ChatMessage.fields.args[0]
|
||||||
|
|
||||||
if(environment.chatOffline == false || this.isSenderIsNotMe(ChatMessage)) {
|
if(environment.chatOffline == false || this.isSenderIsNotMe(ChatMessage)) {
|
||||||
ChatMessage = ChatMessage.fields.args[0]
|
|
||||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||||
console.log('recivemessage', ChatMessage)
|
console.log('recivemessage', ChatMessage)
|
||||||
|
|
||||||
@@ -201,61 +205,67 @@ export class RoomService {
|
|||||||
/**
|
/**
|
||||||
* @description sen text message
|
* @description sen text message
|
||||||
*/
|
*/
|
||||||
send() {
|
send({file = null, attachments = null}) {
|
||||||
|
|
||||||
if(environment.chatOffline == false) {
|
|
||||||
this.WsChatService.send(this.id, this.message)
|
let offlineChatMessage = {
|
||||||
this.message= ''
|
rid: this.id,
|
||||||
|
msg: this.message,
|
||||||
|
attachments,
|
||||||
|
file,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addMessageDB(offlineChatMessage)
|
||||||
|
const message: MessageService = this.prepareMessage(offlineChatMessage)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.scrollDown()
|
||||||
|
}, 150)
|
||||||
|
|
||||||
|
this.lastMessage = message
|
||||||
|
|
||||||
|
|
||||||
|
if(file == null && attachments == null) {
|
||||||
|
console.log('simple send')
|
||||||
|
this.WsChatService.send({roomId:this.id, msg:message.msg}).then((data: any) => {
|
||||||
|
let ChatMessage = data.result
|
||||||
|
this.redefinedMessage(message, ChatMessage)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
|
console.log('complex send')
|
||||||
const offlineChatMessage = {
|
return {
|
||||||
channels: [],
|
message: message,
|
||||||
mentions: [],
|
updateMessage: (update)=> {
|
||||||
rid: 'offline',
|
offlineChatMessage = Object.assign(offlineChatMessage, update)
|
||||||
msg: this.message,
|
|
||||||
ts: { $date: new Date().getTime() },
|
this.WsChatService.send({roomId:this.id, msg:message.msg,attachments:offlineChatMessage.attachments, file:offlineChatMessage.file}).then((data: any) => {
|
||||||
u: {
|
console.log('send sucees', data.result)
|
||||||
name: this.usernameToDisplayName(SessionStore.user.RochetChatUser),
|
let ChatMessage = data.result
|
||||||
username: SessionStore.user.RochetChatUser,
|
this.redefinedMessage(message, ChatMessage)
|
||||||
_id: ""
|
})
|
||||||
},
|
|
||||||
_updatedAt: new Date().getTime()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addMessageDB(offlineChatMessage)
|
|
||||||
const message: MessageService = this.prepareMessage(offlineChatMessage)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.scrollDown()
|
|
||||||
}, 150)
|
|
||||||
|
|
||||||
this.lastMessage = message
|
|
||||||
|
|
||||||
this.redefinedMessage(message)
|
|
||||||
|
|
||||||
this.calDateDuration(message._updatedAt)
|
|
||||||
this.sortRoomList()
|
|
||||||
|
|
||||||
|
|
||||||
this.message= ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.calDateDuration(message._updatedAt)
|
||||||
|
this.sortRoomList()
|
||||||
|
|
||||||
|
this.message= ''
|
||||||
}
|
}
|
||||||
|
|
||||||
redefinedMessage = (message: MessageService) => {
|
redefinedMessage (message: MessageService, ChatMessage) {
|
||||||
this.WsChatService.send(this.id, message.msg).then((data: any) => {
|
|
||||||
let ChatMessage = data.result
|
|
||||||
|
|
||||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||||
|
|
||||||
message.setData(ChatMessage)
|
message.setData(ChatMessage)
|
||||||
|
|
||||||
if( new Date(this.lastMessage._updatedAt).getTime() < new Date(message._updatedAt).getTime()) {
|
if( new Date(this.lastMessage._updatedAt).getTime() < new Date(message._updatedAt).getTime()) {
|
||||||
this.lastMessage = message
|
this.lastMessage = message
|
||||||
this.calDateDuration(message._updatedAt)
|
this.calDateDuration(message._updatedAt)
|
||||||
}
|
}
|
||||||
this.sortRoomList()
|
this.sortRoomList()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -330,11 +340,17 @@ export class RoomService {
|
|||||||
|
|
||||||
let localMessages = []
|
let localMessages = []
|
||||||
|
|
||||||
messages.forEach((message = []) => {
|
if(messages==null) messages = []
|
||||||
const wewMessage = this.prepareMessage(message)
|
|
||||||
|
|
||||||
if(wewMessage.rid == 'offline') {
|
messages.reverse().forEach((ChatMessage, index) => {
|
||||||
this.redefinedMessage(wewMessage)
|
const wewMessage = this.prepareMessage(ChatMessage)
|
||||||
|
|
||||||
|
if(wewMessage.offline == true) {
|
||||||
|
this.WsChatService.send({roomId:this.id, msg:wewMessage.msg, attachments:wewMessage.attachments, file: wewMessage.file}).then((data: any) => {
|
||||||
|
let _ChatMessage = data.result
|
||||||
|
this.redefinedMessage(wewMessage, _ChatMessage)
|
||||||
|
this.storage.set('chatmsg' + this.id, messages)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
localMessages.push(wewMessage)
|
localMessages.push(wewMessage)
|
||||||
@@ -381,7 +397,7 @@ export class RoomService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
prepareMessage(message) {
|
prepareMessage(message): MessageService {
|
||||||
message = this.fix_updatedAt(message)
|
message = this.fix_updatedAt(message)
|
||||||
const wewMessage = new MessageService(this.storage)
|
const wewMessage = new MessageService(this.storage)
|
||||||
wewMessage.setData(message)
|
wewMessage.setData(message)
|
||||||
@@ -412,9 +428,11 @@ export class RoomService {
|
|||||||
if (message.result) {
|
if (message.result) {
|
||||||
//console.log('FIX UPDATE ', message.result)
|
//console.log('FIX UPDATE ', message.result)
|
||||||
message.result._updatedAt = message.result._updatedAt['$date']
|
message.result._updatedAt = message.result._updatedAt['$date']
|
||||||
} else if(message._updatedAt.hasOwnProperty('$date')) {
|
} else if(message._updatedAt) {
|
||||||
// console.log('FIX UPDATE 11', message)
|
if(message._updatedAt.hasOwnProperty('$date')) {
|
||||||
message._updatedAt = message._updatedAt['$date']
|
// console.log('FIX UPDATE 11', message)
|
||||||
|
message._updatedAt = message._updatedAt['$date']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ export class WsChatMethodsService {
|
|||||||
prepareRoom(roomData) {
|
prepareRoom(roomData) {
|
||||||
let room:RoomService;
|
let room:RoomService;
|
||||||
|
|
||||||
room = new RoomService(this.WsChatService, new MessageService(this.storage), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService)
|
room = new RoomService(this.WsChatService, new MessageService(this.storage), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService)
|
||||||
|
|
||||||
room.setData({
|
room.setData({
|
||||||
customFields: roomData.customFields,
|
customFields: roomData.customFields,
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export class WsChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send message to room
|
// send message to room
|
||||||
send(roomId, msg) {
|
send({roomId, msg, attachments = null, file = null}) {
|
||||||
|
|
||||||
const requestId = uuidv4()
|
const requestId = uuidv4()
|
||||||
|
|
||||||
@@ -171,9 +171,10 @@ export class WsChatService {
|
|||||||
method: "sendMessage",
|
method: "sendMessage",
|
||||||
id: requestId,
|
id: requestId,
|
||||||
params: [{
|
params: [{
|
||||||
_id: uuidv4(),
|
|
||||||
rid: roomId,
|
rid: roomId,
|
||||||
msg: msg
|
msg: msg,
|
||||||
|
attachments,
|
||||||
|
file
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +182,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -232,7 +233,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -255,7 +256,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -310,7 +311,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -337,7 +338,7 @@ export class WsChatService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -565,7 +566,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -592,7 +593,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
if(message.id == requestId ) { // same request send
|
||||||
resolve(message)
|
resolve(message)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { FileLoaderService } from '../file/file-loader.service';
|
import { FileLoaderService } from '../file/file-loader.service';
|
||||||
import { FileToBase64Service } from '../file/file-to-base64.service';
|
|
||||||
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
||||||
|
import { LoadingController, Platform } from '@ionic/angular';
|
||||||
import { ChatService } from '../chat.service';
|
import {Photo} from '@capacitor/camera';
|
||||||
import { ModalController, Platform,LoadingController } from '@ionic/angular';
|
import { FileType } from 'src/app/models/fileType';
|
||||||
import { SearchPage } from 'src/app/pages/search/search.page';
|
|
||||||
import { SearchList } from 'src/app/models/search-document';
|
|
||||||
import { ProcessesService } from '../processes.service';
|
|
||||||
import { ToastService } from '../toast.service';
|
|
||||||
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
|
|
||||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||||
import { environment } from 'src/environments/environment';
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
import { HttpClient, HttpEventType, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
||||||
import { Storage } from '@ionic/storage';
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
|
||||||
|
|
||||||
|
const IMAGE_DIR = 'stored-images';
|
||||||
|
|
||||||
interface LocalFile {
|
interface LocalFile {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -31,112 +23,24 @@ export class FileService {
|
|||||||
images: LocalFile[] = [];
|
images: LocalFile[] = [];
|
||||||
capturedImage:any;
|
capturedImage:any;
|
||||||
capturedImageTitle:any;
|
capturedImageTitle:any;
|
||||||
documents:SearchList[] = [];
|
|
||||||
showLoader: boolean;
|
showLoader: boolean;
|
||||||
|
|
||||||
files: Set<File>;
|
files: Set<File>;
|
||||||
photos: any[] = [];
|
photos: any[] = [];
|
||||||
idroom: any;
|
idroom: any;
|
||||||
|
|
||||||
headers: HttpHeaders;
|
|
||||||
downloadProgess = 0;
|
downloadProgess = 0;
|
||||||
downloadFilename: any;
|
downloadFilename: any;
|
||||||
convertBlobToBase64Worker;
|
convertBlobToBase64Worker;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private fileLoaderService: FileLoaderService,
|
private fileLoaderService: FileLoaderService,
|
||||||
private fileToBase64Service: FileToBase64Service,
|
|
||||||
private iab: InAppBrowser,
|
private iab: InAppBrowser,
|
||||||
private chatService: ChatService,
|
|
||||||
private modalController: ModalController,
|
|
||||||
private processesService: ProcessesService,
|
|
||||||
private toastService: ToastService,
|
|
||||||
private platform: Platform,
|
|
||||||
private loadingCtrl: LoadingController,
|
private loadingCtrl: LoadingController,
|
||||||
private http: HttpClient,
|
private platform: Platform,
|
||||||
private storage: Storage
|
private fileToBase64Service: FileToBase64Service
|
||||||
) {
|
) {}
|
||||||
this.headers = new HttpHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadFile(formData:any){
|
|
||||||
|
|
||||||
console.log('UPLOAD file', formData)
|
|
||||||
|
|
||||||
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
|
|
||||||
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
|
|
||||||
|
|
||||||
let options = {
|
|
||||||
headers: this.headers
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.http.post(`${geturl}`, formData, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getFile(guid:any){
|
|
||||||
const geturl = environment.apiURL + 'lakefs/StreamFile';
|
|
||||||
let params = new HttpParams();
|
|
||||||
|
|
||||||
params = params.set("path", guid);
|
|
||||||
|
|
||||||
this.headers = this.headers.set('responseType', 'blob');
|
|
||||||
this.headers = this.headers.set('Content-Type', 'application/octet-stream');
|
|
||||||
|
|
||||||
let options = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
};
|
|
||||||
return this.http.get<any>(`${geturl}`, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadFile(guid:any) {
|
|
||||||
|
|
||||||
let downloadUrl = environment.apiURL +'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,
|
|
||||||
// allowEditing: true,
|
|
||||||
resultType: CameraResultType.Uri,
|
|
||||||
source: CameraSource.Camera
|
|
||||||
|
|
||||||
});
|
|
||||||
const response = await fetch(capturedImage.webPath!);
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
this.photos.unshift({
|
|
||||||
filepath: "soon...",
|
|
||||||
webviewPath: capturedImage.webPath
|
|
||||||
});
|
|
||||||
|
|
||||||
this.capturedImage = await this.convertBlobToBase64(blob);
|
|
||||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
|
||||||
|
|
||||||
let data = {
|
|
||||||
image:this.capturedImage,
|
|
||||||
name: this.capturedImageTitle
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
||||||
const reader = new FileReader;
|
const reader = new FileReader;
|
||||||
@@ -147,68 +51,9 @@ export class FileService {
|
|||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
});
|
});
|
||||||
|
|
||||||
async loadPicture(roomid) {
|
|
||||||
const capturedImage = await Camera.getPhoto({
|
|
||||||
quality: 90,
|
|
||||||
// allowEditing: true,
|
|
||||||
resultType: CameraResultType.Uri,
|
|
||||||
source: CameraSource.Photos
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await fetch(capturedImage.webPath!);
|
|
||||||
const blob = await response.blob();
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("blobFile", blob);
|
|
||||||
console.log('ALL IMAGE', formData)
|
|
||||||
let guid: any = await this.uploadFile(formData).toPromise()
|
|
||||||
console.log(guid.path);
|
|
||||||
|
|
||||||
|
|
||||||
this.downloadFile(guid.path).subscribe(async (event) => {
|
async saveImage(photo: Photo) {
|
||||||
|
|
||||||
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) {
|
|
||||||
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
||||||
console.log('add picture to chat',fileImage);
|
|
||||||
await this.storage.set(guid.path, fileImage).then(() => {
|
|
||||||
console.log('add picture to chat IMAGE SAVED')
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": roomid,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
"title": this.capturedImageTitle,
|
|
||||||
"title_link_download": false,
|
|
||||||
"image_url": fileImage,
|
|
||||||
}],
|
|
||||||
"file":{
|
|
||||||
"type": "application/img",
|
|
||||||
"guid": guid.path,
|
|
||||||
"image_url": fileImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log('BODY TAKE PICTURE CHAT', body)
|
|
||||||
const loader = this.toastService.loading();
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
|
||||||
console.log(res);
|
|
||||||
loader.remove();
|
|
||||||
},(error) => {
|
|
||||||
loader.remove();
|
|
||||||
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//new method1
|
|
||||||
async saveImage(photo: Photo, roomid: any) {
|
|
||||||
const base64Data = await this.readAsBase64(photo);
|
const base64Data = await this.readAsBase64(photo);
|
||||||
|
|
||||||
const fileName = new Date().getTime() + '.jpeg';
|
const fileName = new Date().getTime() + '.jpeg';
|
||||||
@@ -217,10 +62,43 @@ export class FileService {
|
|||||||
data: base64Data,
|
data: base64Data,
|
||||||
directory: Directory.Data
|
directory: Directory.Data
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loadFiles(roomid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//new method 3
|
||||||
|
async loadFiles() {
|
||||||
|
|
||||||
|
const loading = await this.loadingCtrl.create({
|
||||||
|
message: 'Loading data...',
|
||||||
|
});
|
||||||
|
await loading.present();
|
||||||
|
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
Filesystem.readdir({
|
||||||
|
path: IMAGE_DIR,
|
||||||
|
directory: Directory.Data,
|
||||||
|
}).then(result => {
|
||||||
|
console.log('ALL RESULTS', result.files[0])
|
||||||
|
let lastphoto = result.files[result.files.length - 1]
|
||||||
|
resolve(lastphoto)
|
||||||
|
},
|
||||||
|
async (err) => {
|
||||||
|
console.log('ERROR FILE DOSENT EXIST', err)
|
||||||
|
reject('ERROR FILE DOSENT EXIST')
|
||||||
|
// Folder does not yet exists!
|
||||||
|
await Filesystem.mkdir({
|
||||||
|
path: IMAGE_DIR,
|
||||||
|
directory: Directory.Data,
|
||||||
|
recursive: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
).then(_ => {
|
||||||
|
loading.dismiss();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//new method 2
|
//new method 2
|
||||||
private async readAsBase64(photo: Photo) {
|
private async readAsBase64(photo: Photo) {
|
||||||
if (this.platform.is('hybrid')) {
|
if (this.platform.is('hybrid')) {
|
||||||
@@ -239,343 +117,61 @@ export class FileService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//new method 3
|
|
||||||
async loadFiles(roomid) {
|
|
||||||
this.images = [];
|
|
||||||
|
|
||||||
const loading = await this.loadingCtrl.create({
|
async readFile(filePath) {
|
||||||
message: 'Loading data...',
|
return await Filesystem.readFile({
|
||||||
});
|
path: filePath,
|
||||||
await loading.present();
|
|
||||||
|
|
||||||
Filesystem.readdir({
|
|
||||||
path: IMAGE_DIR,
|
|
||||||
directory: Directory.Data,
|
directory: Directory.Data,
|
||||||
}).then(result => {
|
|
||||||
console.log('ALL RESULTS', result.files[0])
|
|
||||||
let lastphoto = result.files[result.files.length - 1]
|
|
||||||
this.loadFileData(lastphoto,roomid);
|
|
||||||
},
|
|
||||||
async (err) => {
|
|
||||||
console.log('ERROR FILE DOSENT EXIST', err)
|
|
||||||
// Folder does not yet exists!
|
|
||||||
await Filesystem.mkdir({
|
|
||||||
path: IMAGE_DIR,
|
|
||||||
directory: Directory.Data,
|
|
||||||
recursive: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
).then(_ => {
|
|
||||||
loading.dismiss();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//new method 4
|
//new method 4
|
||||||
async loadFileData(fileName: string, roomid: any) {
|
async loadFileData(fileName: string) {
|
||||||
console.log('ALL PHOTOT FILE', fileName)
|
console.log('ALL PHOTOT FILE', fileName)
|
||||||
// for (let f of fileNames) {
|
// for (let f of fileNames) {
|
||||||
const filePath = `${IMAGE_DIR}/${fileName}`;
|
const filePath = `${IMAGE_DIR}/${fileName}`;
|
||||||
|
|
||||||
const readFile = await Filesystem.readFile({
|
const readFile = await this.readFile(filePath)
|
||||||
path: filePath,
|
|
||||||
directory: Directory.Data,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.images.push({
|
const image ={
|
||||||
name: fileName,
|
name: fileName,
|
||||||
path: filePath,
|
path: filePath,
|
||||||
data: `data:image/jpeg;base64,${readFile.data}`,
|
data: `data:image/jpeg;base64,${readFile.data}`,
|
||||||
});
|
};
|
||||||
|
|
||||||
console.log('ALL IMAGE', this.images)
|
console.log('ALL IMAGE', image)
|
||||||
|
|
||||||
this.capturedImage = this.images[0].data
|
const capturedImage = image.data
|
||||||
|
|
||||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
const capturedImageTitle = new Date().getTime() + '.jpeg';
|
||||||
const base64 = await fetch(this.capturedImage);
|
|
||||||
const blob = await base64.blob();
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("blobFile", blob);
|
|
||||||
console.log('ALL IMAGE', formData)
|
|
||||||
let guid: any = await this.uploadFile(formData).toPromise()
|
|
||||||
console.log(guid.path);
|
|
||||||
|
|
||||||
|
|
||||||
this.downloadFile(guid.path).subscribe(async (event) => {
|
return { capturedImage, capturedImageTitle}
|
||||||
|
|
||||||
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) {
|
|
||||||
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
||||||
console.log('add picture to chat',fileImage);
|
|
||||||
await this.storage.set(guid.path, fileImage).then(() => {
|
|
||||||
console.log('add picture to chat IMAGE SAVED')
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": roomid,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
"title": this.capturedImageTitle,
|
|
||||||
"title_link_download": false,
|
|
||||||
"image_url": fileImage,
|
|
||||||
}],
|
|
||||||
"file":{
|
|
||||||
"type": "application/img",
|
|
||||||
"guid": guid.path,
|
|
||||||
"image_url": fileImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log('BODY TAKE PICTURE CHAT', body)
|
|
||||||
const loader = this.toastService.loading();
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
|
||||||
console.log(res);
|
|
||||||
loader.remove();
|
|
||||||
},(error) => {
|
|
||||||
loader.remove();
|
|
||||||
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async addCameraPictureToChat(roomId){
|
|
||||||
|
|
||||||
console.log('add camera to picture')
|
|
||||||
|
|
||||||
const image = await Camera.getPhoto({
|
|
||||||
quality: 50,
|
|
||||||
allowEditing: false,
|
|
||||||
resultType: CameraResultType.Uri,
|
|
||||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
|
||||||
});
|
|
||||||
|
|
||||||
if (image) {
|
|
||||||
await this.saveImage(image,roomId)
|
|
||||||
} else {
|
|
||||||
console.log('Error saving image')
|
|
||||||
}
|
|
||||||
|
|
||||||
//this.capturedImage = this.capturedImage;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addPictureToChatMobile(roomId) {
|
|
||||||
|
|
||||||
const capturedImage = await Camera.getPhoto({
|
|
||||||
quality: 50,
|
|
||||||
// allowEditing: true,
|
|
||||||
resultType: CameraResultType.Uri,
|
|
||||||
source: CameraSource.Photos
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (capturedImage) {
|
|
||||||
await this.saveImage(capturedImage,roomId)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* const response = await fetch(capturedImage.webPath!);
|
getFileFromDevice(types: typeof FileType[]) {
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
this.photos.unshift({
|
|
||||||
filepath: "soon...",
|
|
||||||
webviewPath: capturedImage.webPath
|
|
||||||
});
|
|
||||||
|
|
||||||
this.capturedImage = await this.convertBlobToBase64(blob);
|
|
||||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
|
||||||
|
|
||||||
//const loader = this.toastService.loading();
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
//"title": this.capturedImageTitle ,
|
|
||||||
//"text": "description",
|
|
||||||
"title_link_download": false,
|
|
||||||
"image_url": this.capturedImage,
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
|
||||||
//loader.remove();
|
|
||||||
//console.log(res);
|
|
||||||
},(error) => {
|
|
||||||
//loader.remove();
|
|
||||||
});
|
|
||||||
*/ }
|
|
||||||
addPictureToChat(roomId) {
|
|
||||||
|
|
||||||
console.log('add picture to chat')
|
|
||||||
|
|
||||||
const input = this.fileLoaderService.createInput({
|
|
||||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
|
||||||
})
|
|
||||||
|
|
||||||
input.onchange = async () => {
|
|
||||||
|
|
||||||
//alert('Onchange AQUI')
|
|
||||||
|
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
|
||||||
|
|
||||||
console.log('first file',file);
|
|
||||||
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("blobFile", file);
|
|
||||||
let guid: any = await this.uploadFile(formData).toPromise()
|
|
||||||
console.log('ADD IMAGE FORM DATA', formData)
|
|
||||||
console.log('add picture to chat', guid.path);
|
|
||||||
this.downloadFile(guid.path).subscribe(async (event) => {
|
|
||||||
|
|
||||||
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) {
|
|
||||||
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
||||||
console.log('add picture to chat',fileImage);
|
|
||||||
await this.storage.set(guid.path, fileImage).then(() => {
|
|
||||||
console.log('add picture to chat IMAGE SAVED')
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
//"title": this.capturedImageTitle ,
|
|
||||||
//"text": "description",
|
|
||||||
"title_link_download": false,
|
|
||||||
//"image_url": this.capturedImage,
|
|
||||||
}],
|
|
||||||
"file": {
|
|
||||||
"type": "application/img",
|
|
||||||
"guid": guid.path,
|
|
||||||
"image_url": fileImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('SELECT PICTURE GALLERY', body)
|
|
||||||
console.log(this.capturedImage)
|
|
||||||
|
|
||||||
this.chatService.sendMessage(body).subscribe(res => {
|
|
||||||
|
|
||||||
console.log('Msg after send image', res);
|
|
||||||
}, (error) => {
|
|
||||||
console.log('Msg after send image error', error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/* const imageData = await this.fileToBase64Service.convert(file)
|
|
||||||
this.capturedImage = imageData; */
|
|
||||||
|
|
||||||
//console.log(this.capturedImage)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
addDocumentToChat(roomId:string) {
|
|
||||||
const input = this.fileLoaderService.createInput({
|
const input = this.fileLoaderService.createInput({
|
||||||
accept: ['.doc', '.docx', '.pdf']
|
accept: types
|
||||||
})
|
})
|
||||||
|
|
||||||
input.onchange = async () => {
|
return new Promise((resolve, reject)=>{
|
||||||
const loader = this.toastService.loading();
|
input.onchange = async () => {
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
const file = this.fileLoaderService.getFirstFile(input)
|
||||||
|
|
||||||
|
resolve(file);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
console.log(file);
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('file', file, file.name);
|
|
||||||
|
|
||||||
this.chatService.uploadFile(formData, roomId).subscribe(res=> {
|
|
||||||
console.log(res);
|
|
||||||
loader.remove();
|
|
||||||
},(error) => {
|
|
||||||
loader.remove();
|
|
||||||
});
|
|
||||||
//console.log(this.capturedImage)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addDocGestaoDocumentalToChat(roomId:string){
|
|
||||||
const modal = await this.modalController.create({
|
|
||||||
component: SearchPage,
|
|
||||||
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
|
||||||
componentProps: {
|
|
||||||
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
||||||
select: true,
|
|
||||||
showSearchInput: true,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await modal.present();
|
|
||||||
modal.onDidDismiss().then(async res=>{
|
|
||||||
const data = res.data;
|
|
||||||
|
|
||||||
if(data.selected){
|
|
||||||
const loader = this.toastService.loading();
|
|
||||||
|
|
||||||
this.documents.push(data.selected);
|
|
||||||
console.log(res.data.selected);
|
|
||||||
console.log(res.data.selected.Id);
|
|
||||||
console.log(res.data.selected.ApplicationType);
|
|
||||||
|
|
||||||
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
|
||||||
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
|
||||||
console.log(url_no_options);
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": roomId,
|
|
||||||
"msg": "",
|
|
||||||
"alias": "documento",
|
|
||||||
"attachments": [{
|
|
||||||
"title": res.data.selected.Assunto,
|
|
||||||
"description": res.data.selected.DocTypeDesc,
|
|
||||||
"title_link": url_no_options,
|
|
||||||
"title_link_download": true,
|
|
||||||
//"thumb_url": "assets/images/webtrix-logo.png",
|
|
||||||
"message_link": url_no_options,
|
|
||||||
"type": "webtrix"
|
|
||||||
}],
|
|
||||||
"file":{
|
|
||||||
"name": res.data.selected.Assunto,
|
|
||||||
"type": "application/webtrix",
|
|
||||||
"ApplicationId": res.data.selected.ApplicationType,
|
|
||||||
"DocId": res.data.selected.Id,
|
|
||||||
"Assunto": res.data.selected.Assunto,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
|
||||||
loader.remove();
|
|
||||||
console.log(res);
|
|
||||||
},(error) => {
|
|
||||||
loader.remove();
|
|
||||||
});
|
|
||||||
loader.remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
viewDocumentByUrl(url) {
|
viewDocumentByUrl(url) {
|
||||||
const browser = this.iab.create(url,"_parent");
|
const browser = this.iab.create(url,"_parent");
|
||||||
browser.show();
|
browser.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
<ion-label *ngIf="msg.file">
|
<ion-label *ngIf="msg.file">
|
||||||
<span *ngIf="file.description">{{file.description}}</span>
|
<span *ngIf="file.description">{{file.description}}</span>
|
||||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ import { HttpEventType } from '@angular/common/http';
|
|||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||||
import { MessageService } from 'src/app/services/chat/message.service';
|
import { MessageService } from 'src/app/services/chat/message.service';
|
||||||
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
|
|
||||||
|
import { CameraService } from 'src/app/services/camera.service';
|
||||||
|
import { element } from 'protractor';
|
||||||
|
import { FileType } from 'src/app/models/fileType';
|
||||||
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
import * as pdfjsLib from 'pdfjs-dist';
|
import * as pdfjsLib from 'pdfjs-dist';
|
||||||
@@ -96,6 +102,10 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
public ThemeService: ThemeService,
|
public ThemeService: ThemeService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
|
private AttachmentsService: AttachmentsService,
|
||||||
|
|
||||||
|
private CameraService: CameraService,
|
||||||
|
private toastService: ToastService,
|
||||||
|
|
||||||
) {
|
) {
|
||||||
console.log('OnCONSTRUCTOR');
|
console.log('OnCONSTRUCTOR');
|
||||||
@@ -129,7 +139,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
this.setStatus('online');
|
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
//this.getMessageDB();
|
//this.getMessageDB();
|
||||||
|
|
||||||
@@ -216,7 +225,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.setStatus('away');
|
|
||||||
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,17 +305,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadGroupMessages(roomId) {
|
|
||||||
this.showLoader = true;
|
|
||||||
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res => {
|
|
||||||
console.log(res);
|
|
||||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
|
||||||
this.showLoader = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
|
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMessage(msgId: string, room:any) {
|
deleteMessage(msgId: string, room:any) {
|
||||||
@@ -388,10 +387,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
else {
|
else {
|
||||||
this.roomName = res.data.name.split('-').join(' ');
|
this.roomName = res.data.name.split('-').join(' ');
|
||||||
console.log(this.roomName);
|
console.log(this.roomName);
|
||||||
|
|
||||||
//this.getRoomInfo();
|
|
||||||
this.loadGroupMessages(this.roomId);
|
|
||||||
//this.modalController.dismiss();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -423,7 +418,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
popover.onDidDismiss().then(res => {
|
popover.onDidDismiss().then(res => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
this.loadGroupMessages(this.roomId);
|
|
||||||
//this.getRoomInfo();
|
//this.getRoomInfo();
|
||||||
//this.modalController.dismiss();
|
//this.modalController.dismiss();
|
||||||
};
|
};
|
||||||
@@ -464,89 +458,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
|
|
||||||
modal.onDidDismiss().then(() => {
|
modal.onDidDismiss().then(() => {
|
||||||
//this.getRoomInfo();
|
//this.getRoomInfo();
|
||||||
this.loadGroupMessages(this.roomId)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPicture() {
|
|
||||||
const input = this.fileLoaderService.createInput({
|
|
||||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
|
||||||
})
|
|
||||||
|
|
||||||
input.onchange = async () => {
|
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
|
||||||
|
|
||||||
console.log(file);
|
|
||||||
|
|
||||||
const imageData = await this.fileToBase64Service.convert(file)
|
|
||||||
this.capturedImage = imageData;
|
|
||||||
this.capturedImageTitle = file.name;
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": this.roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
//"title": this.capturedImageTitle ,
|
|
||||||
//"text": "description",
|
|
||||||
"title_link_download": false,
|
|
||||||
"image_url": this.capturedImage,
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.chatService.sendMessage(body).subscribe(res => {
|
|
||||||
console.log(res);
|
|
||||||
}, (error) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
//console.log(this.capturedImage)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
loadDocument() {
|
|
||||||
const input = this.fileLoaderService.createInput({
|
|
||||||
accept: ['.doc', '.docx', '.pdf']
|
|
||||||
})
|
|
||||||
|
|
||||||
input.onchange = async () => {
|
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
|
||||||
|
|
||||||
console.log(file);
|
|
||||||
|
|
||||||
const imageData = await this.fileToBase64Service.convert(file)
|
|
||||||
this.capturedImage = imageData;
|
|
||||||
this.capturedImageTitle = file.name;
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": this.roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
"title": this.capturedImageTitle,
|
|
||||||
"text": "",
|
|
||||||
"title_link": this.capturedImage,
|
|
||||||
"title_link_download": true,
|
|
||||||
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
|
||||||
"message_link": this.capturedImage,
|
|
||||||
}],
|
|
||||||
"file": {
|
|
||||||
"name": this.capturedImageTitle,
|
|
||||||
"type": "application/pdf",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.chatService.sendMessage(body).subscribe(res => {
|
|
||||||
//console.log(res);
|
|
||||||
}, (error) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
//console.log(this.capturedImage)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async addDocGestaoDocumental() {
|
async addDocGestaoDocumental() {
|
||||||
const modal = await this.modalController.create({
|
const modal = await this.modalController.create({
|
||||||
@@ -563,36 +477,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
if (res) {
|
if (res) {
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
this.documents.push(data.selected);
|
this.documents.push(data.selected);
|
||||||
console.log(res.data.selected);
|
|
||||||
console.log(res.data.selected.Id);
|
this.addFileWebtrix()
|
||||||
console.log(res.data.selected.ApplicationType);
|
|
||||||
|
|
||||||
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
|
||||||
let url_no_options: string = url.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
|
|
||||||
console.log(url_no_options);
|
|
||||||
//console.log('Oie');
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
"message":
|
|
||||||
{
|
|
||||||
"rid": this.roomId,
|
|
||||||
"msg": "",
|
|
||||||
"attachments": [{
|
|
||||||
"title": res.data.selected.Assunto,
|
|
||||||
"text": res.data.selected.DocTypeDesc,
|
|
||||||
"title_link": url_no_options,
|
|
||||||
"title_link_download": true,
|
|
||||||
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
|
||||||
"message_link": url_no_options,
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.chatService.sendMessage(body).subscribe(res => {
|
|
||||||
console.log(res);
|
|
||||||
}, (error) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -656,18 +542,183 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
await modal.present();
|
await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
takePicture() {
|
async takePicture() {
|
||||||
this.fileService.addCameraPictureToChat(this.roomId);
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const image = await this.CameraService.takePicture();
|
||||||
|
await this.fileService.saveImage(image)
|
||||||
|
const lastphoto: any = await this.fileService.loadFiles();
|
||||||
|
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": capturedImage
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": capturedImageTitle ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const base64 = await fetch(capturedImage);
|
||||||
|
const blob = await base64.blob();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
console.log('ALL IMAGE', formData)
|
||||||
|
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: capturedImage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat', capturedImage);
|
||||||
|
await this.storage.set(guid.path, capturedImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
addImage() {
|
|
||||||
this.fileService.addPictureToChat(this.roomId);
|
async addImage() {
|
||||||
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
}
|
}
|
||||||
addFile() {
|
|
||||||
this.fileService.addDocumentToChat(this.roomId);
|
async addFile() {
|
||||||
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||||
}
|
}
|
||||||
addFileWebtrix() {
|
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
async addFileWebtrix() {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: SearchPage,
|
||||||
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
||||||
|
componentProps: {
|
||||||
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
||||||
|
select: true,
|
||||||
|
showSearchInput: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then(async res=>{
|
||||||
|
const data = res.data;
|
||||||
|
|
||||||
|
if(data.selected) {
|
||||||
|
const loader = this.toastService.loading();
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file:{
|
||||||
|
"name": res.data.selected.Assunto,
|
||||||
|
"type": "application/webtrix",
|
||||||
|
"ApplicationId": res.data.selected.ApplicationType,
|
||||||
|
"DocId": res.data.selected.Id,
|
||||||
|
"Assunto": res.data.selected.Assunto,
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
// "title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
// "message_link": url_no_options,
|
||||||
|
"type": "webtrix"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
||||||
|
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
||||||
|
console.log(url_no_options);
|
||||||
|
|
||||||
|
updateMessage({
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
"title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
"message_link": url_no_options,
|
||||||
|
"type": "webtrix",
|
||||||
|
"text": res.data.selected.DocTypeDesc,
|
||||||
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
loader.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", file);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": imageData
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": file.name ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: imageData
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat',fileImage);
|
||||||
|
await this.storage.set(guid.path, fileImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bookMeeting() {
|
bookMeeting() {
|
||||||
let data = {
|
let data = {
|
||||||
roomId: this.roomId,
|
roomId: this.roomId,
|
||||||
@@ -693,7 +744,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
return this.animationController.create()
|
return this.animationController.create()
|
||||||
.addElement(baseEl)
|
.addElement(baseEl)
|
||||||
.easing('ease-out')
|
.easing('ease-out')
|
||||||
.duration(5000)
|
.duration(500)
|
||||||
.addAnimation([backdropAnimation, wrapperAnimation]);
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,10 +762,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
members: this.members,
|
members: this.members,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss().then((res) => {
|
modal.onDidDismiss().then( async (res) => {
|
||||||
//console.log(res['data']);
|
console.log(res['data']);
|
||||||
|
const roomId = this.roomId;
|
||||||
|
|
||||||
if (res['data'] == 'meeting') {
|
if (res['data'] == 'meeting') {
|
||||||
//this.closeAllDesktopComponents.emit();
|
//this.closeAllDesktopComponents.emit();
|
||||||
let data = {
|
let data = {
|
||||||
@@ -724,73 +776,36 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
this.openNewEventPage.emit(data);
|
this.openNewEventPage.emit(data);
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'take-picture') {
|
else if (res['data'] == 'take-picture') {
|
||||||
this.fileService.addCameraPictureToChat(this.roomId);
|
|
||||||
//this.loadPicture();
|
this.takePicture()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-picture') {
|
else if (res['data'] == 'add-picture') {
|
||||||
this.fileService.addPictureToChat(this.roomId);
|
|
||||||
//this.loadPicture();
|
this.addImage()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-document') {
|
else if (res['data'] == 'add-document') {
|
||||||
this.loadDocument();
|
|
||||||
|
this.addFile()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'documentoGestaoDocumental') {
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
|
||||||
//this.addDocGestaoDocumental();
|
this.addFileWebtrix()
|
||||||
|
|
||||||
|
this.showLoader = false;
|
||||||
}
|
}
|
||||||
this.loadGroupMessages(this.roomId);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sliderOpts = {
|
|
||||||
zoom: false,
|
|
||||||
slidesPerView: 1.5,
|
|
||||||
spaceBetween: 20,
|
|
||||||
centeredSlides: true
|
|
||||||
};
|
|
||||||
zoomActive = false;
|
|
||||||
zoomScale = 1;
|
|
||||||
|
|
||||||
sliderZoomOpts = {
|
|
||||||
allowSlidePrev: false,
|
|
||||||
allowSlideNext: false,
|
|
||||||
zoom: {
|
|
||||||
maxRatio: 5
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
zoomChange: (scale, imageEl, slideEl) => {
|
|
||||||
this.zoomActive = true;
|
|
||||||
this.zoomScale = scale / 5;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async touchEnd(zoomslides: IonSlides, card) {
|
|
||||||
// Zoom back to normal
|
|
||||||
const slider = await zoomslides.getSwiper();
|
|
||||||
const zoom = slider.zoom;
|
|
||||||
zoom.out();
|
|
||||||
|
|
||||||
// Card back to normal
|
|
||||||
card.el.style['z-index'] = 9;
|
|
||||||
|
|
||||||
this.zoomActive = false;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
touchStart(card) {
|
|
||||||
// Make card appear above backdrop
|
|
||||||
card.el.style['z-index'] = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadFileMsg(msg: MessageService) {
|
downloadFileMsg(msg: MessageService) {
|
||||||
console.log('FILE TYPE', msg.file.type)
|
console.log('FILE TYPE', msg.file.type)
|
||||||
this.downloadFile = "";
|
this.downloadFile = "";
|
||||||
if (msg.file.type == "application/img") {
|
if (msg.file.type == "application/img") {
|
||||||
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||||
console.log('FILE TYPE 22', msg.file.guid)
|
console.log('FILE TYPE 22', msg.file.guid)
|
||||||
var name = msg.file.guid;
|
var name = msg.file.guid;
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
<span *ngIf="file.description">{{file.description}}</span>
|
<span *ngIf="file.description">{{file.description}}</span>
|
||||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||||
<span
|
<span
|
||||||
*ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
*ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,10 +13,9 @@ import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
|||||||
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||||
import { TimeService } from 'src/app/services/functions/time.service';
|
import { TimeService } from 'src/app/services/functions/time.service';
|
||||||
import { FileService } from 'src/app/services/functions/file.service';
|
import { FileService } from 'src/app/services/functions/file.service';
|
||||||
import { HttpClient, HttpEventType, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpEventType } from '@angular/common/http';
|
||||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service'
|
||||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
|
||||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||||
import { StorageService } from 'src/app/services/storage.service';
|
import { StorageService } from 'src/app/services/storage.service';
|
||||||
@@ -26,7 +25,13 @@ import { Storage } from '@ionic/storage';
|
|||||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
|
||||||
import { WsChatService } from 'src/app/services/chat/ws-chat.service'
|
import { WsChatService } from 'src/app/services/chat/ws-chat.service'
|
||||||
import { MessageService } from 'src/app/services/chat/message.service';
|
import { MessageService } from 'src/app/services/chat/message.service';
|
||||||
import { element } from 'protractor';
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
|
|
||||||
|
import { CameraService } from 'src/app/services/camera.service';
|
||||||
|
import { FileType } from 'src/app/models/fileType';
|
||||||
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||||
|
import { ProcessesService } from 'src/app/services/processes.service';
|
||||||
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
@Component({
|
@Component({
|
||||||
@@ -92,7 +97,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
public wsChatMethodsService: WsChatMethodsService,
|
public wsChatMethodsService: WsChatMethodsService,
|
||||||
public WsChatService: WsChatService
|
public WsChatService: WsChatService,
|
||||||
|
private AttachmentsService: AttachmentsService,
|
||||||
|
|
||||||
|
private CameraService: CameraService,
|
||||||
|
private processesService: ProcessesService,
|
||||||
|
private fileToBase64Service: FileToBase64Service,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||||
@@ -104,6 +114,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||||
|
|
||||||
this.wsChatMethodsService.openRoom(this.roomId)
|
this.wsChatMethodsService.openRoom(this.roomId)
|
||||||
|
|
||||||
|
this.wsChatMethodsService.getDmRoom(this.roomId).uploadAttachment = async (formData) => {
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottomClicked()
|
this.scrollToBottomClicked()
|
||||||
}, 150)
|
}, 150)
|
||||||
@@ -113,7 +128,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
this.setStatus('online');
|
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -134,15 +149,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(status: string) {
|
|
||||||
let body = {
|
|
||||||
message: '',
|
|
||||||
status: status,
|
|
||||||
}
|
|
||||||
this.chatService.setUserStatus(body).subscribe(res => {
|
|
||||||
console.log(res);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
notImplemented() {
|
notImplemented() {
|
||||||
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
||||||
@@ -150,7 +156,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
load = () => {
|
load = () => {
|
||||||
this.checktimeOut = true;
|
this.checktimeOut = true;
|
||||||
this.serverLongPull();
|
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +210,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.checktimeOut = false;
|
this.checktimeOut = false;
|
||||||
this.setStatus('away');
|
|
||||||
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +246,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
this.wsChatMethodsService.getDmRoom(this.roomId).send()
|
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMessage(msgId: string, room:any) {
|
deleteMessage(msgId: string, room:any) {
|
||||||
@@ -251,7 +255,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
async viewDocument(msg: any, url?: string) {
|
async viewDocument(msg: any, url?: string) {
|
||||||
if (msg.file.type == "application/img") {
|
if (msg.file.type == "application/img") {
|
||||||
let response: any = await this.fileService.getFile(msg.file.guid).toPromise();
|
let response: any = await this.AttachmentsService.getFile(msg.file.guid).toPromise();
|
||||||
console.log(response);
|
console.log(response);
|
||||||
alert(response);
|
alert(response);
|
||||||
|
|
||||||
@@ -267,7 +271,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
|
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
|
||||||
|
|
||||||
this.frameUrl = fullUrl;
|
this.frameUrl = fullUrl;
|
||||||
//this.fileService.viewDocumentByUrl(fullUrl);
|
|
||||||
this.chatService.getDocumentDetails(fullUrl);
|
this.chatService.getDocumentDetails(fullUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,22 +443,183 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
takePicture() {
|
async takePicture() {
|
||||||
const roomId = this.roomId
|
const roomId = this.roomId
|
||||||
this.fileService.addCameraPictureToChat(roomId);
|
|
||||||
|
const image = await this.CameraService.takePicture();
|
||||||
|
await this.fileService.saveImage(image)
|
||||||
|
const lastphoto: any = await this.fileService.loadFiles();
|
||||||
|
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": capturedImage
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": capturedImageTitle ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const base64 = await fetch(capturedImage);
|
||||||
|
const blob = await base64.blob();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
console.log('ALL IMAGE', formData)
|
||||||
|
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: capturedImage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat', capturedImage);
|
||||||
|
await this.storage.set(guid.path, capturedImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
addImage() {
|
|
||||||
const roomId = this.roomId;
|
async addImage() {
|
||||||
this.fileService.addPictureToChat(roomId);
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
//this.fileService.loadPicture();
|
|
||||||
//this.fileService.addPictureToChat(roomId);
|
|
||||||
}
|
}
|
||||||
addFile() {
|
|
||||||
this.fileService.addDocumentToChat(this.roomId);
|
async addFile() {
|
||||||
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||||
}
|
}
|
||||||
addFileWebtrix() {
|
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
async addFileWebtrix() {
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: SearchPage,
|
||||||
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
||||||
|
componentProps: {
|
||||||
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
||||||
|
select: true,
|
||||||
|
showSearchInput: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then(async res=>{
|
||||||
|
const data = res.data;
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
if(data.selected) {
|
||||||
|
const loader = this.toastService.loading();
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file:{
|
||||||
|
"name": res.data.selected.Assunto,
|
||||||
|
"type": "application/webtrix",
|
||||||
|
"ApplicationId": res.data.selected.ApplicationType,
|
||||||
|
"DocId": res.data.selected.Id,
|
||||||
|
"Assunto": res.data.selected.Assunto,
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
// "title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
// "message_link": url_no_options,
|
||||||
|
"type": "webtrix"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
||||||
|
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
||||||
|
console.log(url_no_options);
|
||||||
|
|
||||||
|
updateMessage({
|
||||||
|
attachments: [{
|
||||||
|
"title": res.data.selected.Assunto,
|
||||||
|
"description": res.data.selected.DocTypeDesc,
|
||||||
|
"title_link": url_no_options,
|
||||||
|
"title_link_download": true,
|
||||||
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
||||||
|
"message_link": url_no_options,
|
||||||
|
"type": "webtrix",
|
||||||
|
"text": res.data.selected.DocTypeDesc,
|
||||||
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
loader.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", file);
|
||||||
|
|
||||||
|
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": imageData
|
||||||
|
},
|
||||||
|
attachments: [{
|
||||||
|
"title": file.name ,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
|
updateMessage({
|
||||||
|
file: {
|
||||||
|
type: "application/img",
|
||||||
|
guid: guid.path,
|
||||||
|
image_url: imageData
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('add picture to chat',fileImage);
|
||||||
|
await this.storage.set(guid.path, fileImage).then(() => {
|
||||||
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
|
message.getFileFromDb()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bookMeeting() {
|
bookMeeting() {
|
||||||
let data = {
|
let data = {
|
||||||
roomId: this.roomId,
|
roomId: this.roomId,
|
||||||
@@ -464,7 +629,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
chatsend() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async _openChatOptions() {
|
async _openChatOptions() {
|
||||||
|
const roomId = this.roomId;
|
||||||
|
|
||||||
|
|
||||||
const enterAnimation = (baseEl: any) => {
|
const enterAnimation = (baseEl: any) => {
|
||||||
const backdropAnimation = this.animationController.create()
|
const backdropAnimation = this.animationController.create()
|
||||||
@@ -500,8 +671,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss().then((res) => {
|
modal.onDidDismiss().then( async (res) => {
|
||||||
console.log(res['data']);
|
console.log(res['data']);
|
||||||
|
|
||||||
|
|
||||||
if (res['data'] == 'meeting') {
|
if (res['data'] == 'meeting') {
|
||||||
//this.closeAllDesktopComponents.emit();
|
//this.closeAllDesktopComponents.emit();
|
||||||
let data = {
|
let data = {
|
||||||
@@ -511,111 +684,38 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.openNewEventPage.emit(data);
|
this.openNewEventPage.emit(data);
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'take-picture') {
|
else if (res['data'] == 'take-picture') {
|
||||||
this.fileService.addCameraPictureToChat(this.roomId);
|
|
||||||
//this.loadPicture();
|
this.takePicture()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-picture') {
|
else if (res['data'] == 'add-picture') {
|
||||||
this.fileService.addPictureToChat(this.roomId);
|
|
||||||
//this.loadPicture();
|
this.addImage()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-document') {
|
else if (res['data'] == 'add-document') {
|
||||||
this.fileService.addDocumentToChat(this.roomId);
|
|
||||||
//this.loadDocument();
|
this.addFile()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'documentoGestaoDocumental') {
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
||||||
|
|
||||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
this.addFileWebtrix()
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
//this.addDocGestaoDocumental();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async serverLongPull() {
|
|
||||||
|
|
||||||
const roomId = this.roomId;
|
|
||||||
|
|
||||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
|
||||||
console.log('serverLongPull', res['success']);
|
|
||||||
|
|
||||||
|
|
||||||
if (res['success'] == true) {
|
|
||||||
// Show Error
|
|
||||||
//showMessage(response.statusText);
|
|
||||||
/* this.messages = res['messages'].reverse();
|
|
||||||
this.chatMessageStore.add(roomId, this.messages) */
|
|
||||||
console.log('MSG FROM ROCKET ', res['messages'].reverse())
|
|
||||||
/* this.transformData(res['messages'].reverse());
|
|
||||||
this.getMessageDB(); */
|
|
||||||
|
|
||||||
//console.log(this.messages);
|
|
||||||
// Reconnect in one second
|
|
||||||
if (this.route.url != "/home/chat") {
|
|
||||||
console.log("Timer message stop")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (document.querySelector('app-messages')) {
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
||||||
// await this.serverLongPull();
|
|
||||||
this.getDirectMessages.emit();
|
|
||||||
console.log('Timer message running')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, (error) => {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sliderOpts = {
|
|
||||||
zoom: false,
|
|
||||||
slidesPerView: 1.5,
|
|
||||||
spaceBetween: 20,
|
|
||||||
centeredSlides: true
|
|
||||||
};
|
|
||||||
zoomActive = false;
|
|
||||||
zoomScale = 1;
|
|
||||||
|
|
||||||
sliderZoomOpts = {
|
|
||||||
allowSlidePrev: false,
|
|
||||||
allowSlideNext: false,
|
|
||||||
zoom: {
|
|
||||||
maxRatio: 5
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
zoomChange: (scale, imageEl, slideEl) => {
|
|
||||||
this.zoomActive = true;
|
|
||||||
this.zoomScale = scale / 5;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async touchEnd(zoomslides: IonSlides, card) {
|
|
||||||
// Zoom back to normal
|
|
||||||
const slider = await zoomslides.getSwiper();
|
|
||||||
const zoom = slider.zoom;
|
|
||||||
zoom.out();
|
|
||||||
|
|
||||||
// Card back to normal
|
|
||||||
card.el.style['z-index'] = 9;
|
|
||||||
|
|
||||||
this.zoomActive = false;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
touchStart(card) {
|
|
||||||
// Make card appear above backdrop
|
|
||||||
card.el.style['z-index'] = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadFileMsg(msg: MessageService) {
|
downloadFileMsg(msg: MessageService) {
|
||||||
console.log('FILE TYPE', msg.file.type)
|
console.log('FILE TYPE', msg.file.type)
|
||||||
this.downloadFile = "";
|
this.downloadFile = "";
|
||||||
if (msg.file.type == "application/img") {
|
if (msg.file.type == "application/img") {
|
||||||
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
|
||||||
console.log('FILE TYPE 22', msg.file.guid)
|
console.log('FILE TYPE 22', msg.file.guid)
|
||||||
var name = msg.file.guid;
|
var name = msg.file.guid;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user