mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
merge
This commit is contained in:
@@ -159,11 +159,6 @@ export class ChatPage implements OnInit {
|
||||
|
||||
let t = this.showDateDuration(new Date());
|
||||
|
||||
this.setStatus('away');
|
||||
/* if(this.dataService.get("newGroup")){
|
||||
this.openNewGroupPage();
|
||||
} */
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
|
||||
if (this.dataService.get("newGroup")) {
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,12 +20,18 @@ import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
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 { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
import { HttpEventType } from '@angular/common/http';
|
||||
import { SqliteService } from 'src/app/services/sqlite.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({
|
||||
selector: 'app-group-messages',
|
||||
@@ -87,7 +93,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private sqlservice: SqliteService,
|
||||
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.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.getGroupContacts(this.room);
|
||||
this.loadGroupMessages(this.room);
|
||||
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){
|
||||
return this.timeService.showDateDuration(start);
|
||||
@@ -330,7 +319,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
sendMessage() {
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
|
||||
}
|
||||
|
||||
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){
|
||||
|
||||
@@ -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) {
|
||||
console.log(this.members);
|
||||
const roomId = this.roomId;
|
||||
|
||||
const popover = await this.popoverController.create({
|
||||
component: ChatOptionsPopoverPage,
|
||||
@@ -499,29 +627,25 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
translucent: true
|
||||
});
|
||||
await popover.present();
|
||||
await popover.onDidDismiss().then((res)=>{
|
||||
await popover.onDidDismiss().then( async(res)=>{
|
||||
console.log(res['data']);
|
||||
if(res['data'] == 'meeting'){
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
}
|
||||
else if(res['data'] == 'take-picture'){
|
||||
this.fileService.addCameraPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
else if (res['data'] == 'take-picture') {
|
||||
this.takePicture()
|
||||
}
|
||||
else if(res['data'] == 'add-picture'){
|
||||
this.fileService.addPictureToChatMobile(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-document'){
|
||||
this.fileService.addDocumentToChat(this.roomId);
|
||||
//this.loadDocument();
|
||||
}
|
||||
else if(res['data'] == 'documentoGestaoDocumental'){
|
||||
else if (res['data'] == 'add-picture') {
|
||||
this.addImage()
|
||||
|
||||
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)
|
||||
this.downloadFile = "";
|
||||
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)
|
||||
var name = msg.file.guid;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<ion-label *ngIf="msg.file && msg.file != ''">
|
||||
<span *ngIf="file.description">{{file.description}}</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
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 { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
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 { AlertService } from 'src/app/services/alert.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 { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.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';
|
||||
|
||||
@@ -98,7 +105,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private platform: Platform,
|
||||
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.roomId = this.navParams.get('roomId');
|
||||
@@ -121,11 +134,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
//this.load();
|
||||
this.setStatus('online');
|
||||
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
||||
console.log('MEMBER', value)
|
||||
})
|
||||
|
||||
//this.loadFiles();
|
||||
VoiceRecorder.requestAudioRecordingPermission();
|
||||
this.getChatMembers();
|
||||
@@ -256,15 +268,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.selectedMsgId = "";
|
||||
}
|
||||
|
||||
setStatus(status: string) {
|
||||
let body = {
|
||||
message: '',
|
||||
status: status,
|
||||
}
|
||||
this.chatService.setUserStatus(body).subscribe(res => {
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
|
||||
notImplemented() {
|
||||
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
||||
@@ -275,7 +278,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
load() {
|
||||
this.serverLongPull();
|
||||
this.getChatMembers();
|
||||
}
|
||||
|
||||
@@ -350,7 +352,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
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) {
|
||||
const roomId = this.roomId
|
||||
console.log('MOBILE CHAT OPTION',this.members);
|
||||
@@ -534,66 +713,29 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
translucent: true
|
||||
});
|
||||
await popover.present();
|
||||
popover.onDidDismiss().then((res) => {
|
||||
popover.onDidDismiss().then( async (res) => {
|
||||
console.log(res['data']);
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
}
|
||||
else if (res['data'] == 'take-picture') {
|
||||
this.fileService.addCameraPictureToChat(roomId);
|
||||
//this.loadPicture();
|
||||
this.takePicture()
|
||||
}
|
||||
else if (res['data'] == 'add-picture') {
|
||||
//this.fileService.addPictureToChat(roomId);
|
||||
this.fileService.loadPicture(this.roomId);
|
||||
this.addImage()
|
||||
}
|
||||
else if (res['data'] == 'add-document') {
|
||||
this.fileService.addDocumentToChat(this.roomId);
|
||||
//this.loadDocument();
|
||||
this.addFile()
|
||||
}
|
||||
else if (res['data'] == 'documentoGestaoDocumental') {
|
||||
|
||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
||||
//this.addDocGestaoDocumental();
|
||||
this.addFileWebtrix()
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
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) {
|
||||
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) {
|
||||
console.log('FILE TYPE', msg.file.type)
|
||||
this.downloadFile = "";
|
||||
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)
|
||||
var name = msg.file.guid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user