Files
doneit-web/src/app/shared/chat/group-messages/group-messages.page.ts
T

830 lines
23 KiB
TypeScript
Raw Normal View History

2021-11-22 13:53:37 +01:00
import { Component, OnChanges, OnInit, Input, SimpleChanges,ChangeDetectorRef,Output, EventEmitter, ViewChild, ElementRef, AfterViewChecked, AfterViewInit, OnDestroy} from '@angular/core';
import { ActionSheetController, AnimationController, IonSlides, MenuController, ModalController, PopoverController } from '@ionic/angular';
2021-04-13 14:14:55 +01:00
import { AlertService } from 'src/app/services/alert.service';
2021-03-04 18:50:26 +01:00
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popover.page';
import { ContactsPage } from '../new-group/contacts/contacts.page';
import { NewGroupPage } from '../new-group/new-group.page';
import { GroupContactsPage } from './group-contacts/group-contacts.page';
2021-07-26 19:31:19 +01:00
import { Router } from '@angular/router'
2021-08-18 16:40:58 +01:00
import { ChatOptionsPopoverPage } from '../../popover/chat-options-popover/chat-options-popover.page';
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
2021-09-06 16:53:58 +01:00
import { TimeService } from 'src/app/services/functions/time.service';
2021-09-13 12:37:58 +01:00
import { FileLoaderService } from 'src/app/services/file/file-loader.service';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
2021-09-14 15:57:24 +01:00
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from 'src/app/models/search-document';
import { ProcessesService } from 'src/app/services/processes.service';
import { FileService } from 'src/app/services/functions/file.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
2021-10-23 09:53:21 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2021-11-22 13:53:37 +01:00
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
2021-09-21 14:05:59 +01:00
/*
import * as pdfjsLib from 'pdfjs-dist';
if( pdfjsLib !== undefined ){
console.log( "set worker...");
pdfjsLib.GlobalWorkerOptions.workerSrc = "https://npmcdn.com/pdfjs-dist@2.4.456/build/pdf.worker.js";
}
*/
2021-03-04 18:50:26 +01:00
@Component({
selector: 'app-group-messages',
templateUrl: './group-messages.page.html',
styleUrls: ['./group-messages.page.scss'],
})
2021-08-23 16:31:06 +01:00
export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy {
2021-03-04 18:50:26 +01:00
showLoader: boolean;
isGroupCreated:boolean;
loggedUser: any;
2021-07-26 12:12:59 +01:00
message:any;
2021-03-04 18:50:26 +01:00
messages:any;
2021-09-09 11:47:49 +01:00
allUsers:any[] = [];
2021-09-14 15:57:24 +01:00
documents:SearchList[] = [];
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
2021-07-26 12:12:59 +01:00
room:any = new Array();
2021-04-15 23:57:14 +01:00
roomName:any;
2021-03-04 18:50:26 +01:00
members:any;
2021-03-12 11:56:54 +01:00
2021-09-13 12:37:58 +01:00
capturedImage:any;
capturedImageTitle:any;
2021-07-23 14:43:51 +01:00
loggedUserChat:any;
2021-08-23 16:31:06 +01:00
scrollingOnce:boolean = true;
private scrollChangeCallback: () => void;
currentPosition: any;
startPosition: number;
2021-09-24 15:39:25 +01:00
scrollToBottomBtn = false;
2021-11-03 15:35:01 +01:00
roomCountDownDate:string;
roomCountDownTime:string;
2021-08-23 16:31:06 +01:00
2021-03-12 11:56:54 +01:00
@Input() roomId:string;
2021-04-15 23:57:14 +01:00
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
@Output() showEmptyContainer:EventEmitter<any> = new EventEmitter<any>();
@Output() openGroupContacts:EventEmitter<any> = new EventEmitter<any>();
2021-04-16 11:25:10 +01:00
@Output() openEditGroupPage:EventEmitter<any> = new EventEmitter<any>();
2021-08-18 16:40:58 +01:00
@Output() openNewEventPage:EventEmitter<any> = new EventEmitter<any>();
2021-08-30 18:56:37 +01:00
@Output() getGroups:EventEmitter<any> = new EventEmitter<any>();
2021-03-04 18:50:26 +01:00
2021-07-26 09:44:11 +01:00
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
2021-09-21 14:05:59 +01:00
pdfurl = "http://www.africau.edu/images/default/sample.pdf";
2021-03-04 18:50:26 +01:00
constructor(
private menu: MenuController,
private modalController: ModalController,
private actionSheetController: ActionSheetController,
public popoverController: PopoverController,
private chatService: ChatService,
private authService: AuthService,
2021-03-18 09:25:59 +01:00
private animationController: AnimationController,
2021-04-13 14:14:55 +01:00
private alertService: AlertService,
2021-09-06 16:53:58 +01:00
private route: Router,
private timeService: TimeService,
2021-09-13 12:37:58 +01:00
private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service,
2021-09-14 15:57:24 +01:00
private processesService: ProcessesService,
private fileService: FileService,
2021-11-22 13:53:37 +01:00
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef
2021-03-04 18:50:26 +01:00
) {
2021-07-23 14:43:51 +01:00
this.loggedUserChat = authService.ValidatedUserChat['data'];
2021-03-04 18:50:26 +01:00
this.isGroupCreated = true;
2021-11-03 15:35:01 +01:00
this.roomCountDownDate = "";
this.roomCountDownTime = "";
2021-09-21 14:05:59 +01:00
2021-03-12 11:56:54 +01:00
}
ngOnChanges(changes: SimpleChanges): void {
2021-10-07 09:42:18 +01:00
this.getRoomInfo();
2021-08-23 16:31:06 +01:00
//this.scrollToBottom();
2021-03-04 18:50:26 +01:00
}
ngOnInit() {
2021-07-23 14:43:51 +01:00
this.loggedUser=this.loggedUserChat;
2021-03-12 11:56:54 +01:00
this.getRoomInfo();
2021-07-26 19:31:19 +01:00
this.serverLongPull();
2021-08-23 16:31:06 +01:00
this.setStatus('online');
2021-09-09 11:47:49 +01:00
this.getChatMembers();
2021-11-03 15:35:01 +01:00
}
2021-09-21 14:05:59 +01:00
2021-11-03 15:35:01 +01:00
showDateDuration(start:any){
return this.timeService.showDateDuration(start);
}
2021-11-03 15:35:01 +01:00
countDownDate(){
//this.roomCountDownTime = this.timeService.countDownDateTimer(this.roomCountDownDate, this.room._id);
return this.timeService.countDownDateTimer(this.roomCountDownDate, this.roomId);
}
2021-09-21 14:05:59 +01:00
2021-08-23 16:31:06 +01:00
setStatus(status:string){
let body = {
message: '',
status: status,
}
this.chatService.setUserStatus(body).subscribe(res => {
2021-09-21 14:05:59 +01:00
//console.log(res);
2021-08-23 16:31:06 +01:00
})
2021-07-26 09:44:11 +01:00
}
scrollToBottom(): void {
try {
2021-08-23 16:31:06 +01:00
if(this.scrollingOnce){
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
}
2021-07-26 09:44:11 +01:00
} catch(err) { }
2021-08-23 16:31:06 +01:00
}
2021-09-24 15:39:25 +01:00
scrollToBottomClicked(): void {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
}
2021-08-23 16:31:06 +01:00
ngAfterViewInit() {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
}
2021-09-24 15:39:25 +01:00
onContentScrolled(e) {
2021-08-23 16:31:06 +01:00
this.startPosition = e.srcElement.scrollTop;
let scroll = e.srcElement.scrollTop;
2021-09-24 15:39:25 +01:00
let windowHeight = e.srcElement.scrollHeight;
2021-09-24 16:10:24 +01:00
let containerHeight = windowHeight - e.srcElement.clientHeight;
2021-09-24 15:39:25 +01:00
2021-08-23 16:31:06 +01:00
if (scroll > this.currentPosition) {
2021-09-24 15:39:25 +01:00
//alert('BOTTOM');
2021-08-23 16:31:06 +01:00
} else {
2021-09-24 15:39:25 +01:00
//alert('UP');
2021-08-23 16:31:06 +01:00
this.scrollingOnce = false;
2021-07-26 09:44:11 +01:00
}
2021-09-24 15:39:25 +01:00
if((containerHeight - 100) > scroll){
this.scrollToBottomBtn = true;
}
else{
this.scrollToBottomBtn = false;
}
2021-08-23 16:31:06 +01:00
this.currentPosition = scroll;
}
ngOnDestroy() {
this.setStatus('away');
window.removeEventListener('scroll', this.scrollChangeCallback, true);
2021-04-13 14:14:55 +01:00
}
2021-09-09 11:47:49 +01:00
async getChatMembers(){
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> {
2021-09-21 14:05:59 +01:00
//console.log(res);
2021-09-09 11:47:49 +01:00
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
2021-09-21 14:05:59 +01:00
//console.log(this.allUsers);
2021-09-09 11:47:49 +01:00
});
}
openGroupContactsPage(){
this.openGroupContacts.emit(this.roomId);
2021-03-04 18:50:26 +01:00
}
2021-08-18 16:40:58 +01:00
openBookMeetingComponent(){
let data = {
roomId: this.roomId,
members: this.members
}
this.openNewEventPage.emit(data);
}
2021-03-04 18:50:26 +01:00
close(){
this.modalController.dismiss();
}
doRefresh(ev:any){
2021-03-12 11:56:54 +01:00
this.getRoomInfo();
2021-03-04 18:50:26 +01:00
ev.target.complete();
}
2021-07-26 09:44:11 +01:00
2021-03-12 11:56:54 +01:00
get watch(){
this.getRoomInfo();
console.log('here watching');
return this.roomId;
}
2021-08-23 16:31:06 +01:00
2021-11-03 15:35:01 +01:00
async getRoomInfo(){
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
this.room=room['room'];
if(this.room.name){
this.roomName = this.room.name.split('-').join(' ');
}
2021-10-27 08:45:37 +01:00
2021-11-03 15:35:01 +01:00
if(this.room.customFields.countDownDate){
this.roomCountDownDate = this.room.customFields.countDownDate;
}
2021-10-27 08:45:37 +01:00
2021-11-03 15:35:01 +01:00
this.getGroupContacts(this.room);
2021-03-12 11:56:54 +01:00
}
2021-03-04 18:50:26 +01:00
2021-03-12 11:56:54 +01:00
getGroupContacts(room:any){
2021-03-04 18:50:26 +01:00
this.showLoader = true;
//If group is private call getGroupMembers
2021-03-12 11:56:54 +01:00
if(room.t === 'p'){
this.chatService.getGroupMembers(this.roomId).subscribe(res=>{
2021-09-21 14:05:59 +01:00
//console.log(res);
2021-03-04 18:50:26 +01:00
this.members = res['members'];
this.showLoader = false;
});
}
//Otherwise call getChannelMembers for públic groups
else{
2021-03-12 11:56:54 +01:00
this.chatService.getChannelMembers(this.roomId).subscribe(res=>{
2021-03-04 18:50:26 +01:00
console.log(res);
this.members = res['members'];
this.showLoader = false;
});
}
}
2021-08-23 16:31:06 +01:00
loadGroupMessages(roomId){
//console.log('here'+room.t);
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
this.showLoader = true;
//If group is private call getGroupMembers
2021-08-23 16:31:06 +01:00
/* if(room.t === 'p'){
console.log('private'); */
2021-07-23 14:43:51 +01:00
2021-03-12 11:56:54 +01:00
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res=>{
2021-03-04 18:50:26 +01:00
console.log(res);
let msgOnly = res['messages'].filter(data => data.t != 'au');
this.messages = msgOnly.reverse();
2021-09-21 14:05:59 +01:00
//console.log(res);
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
this.showLoader = false;
});
2021-08-23 16:31:06 +01:00
/* } */
2021-03-04 18:50:26 +01:00
//Otherwise call getChannelMembers for públic groups
2021-08-23 16:31:06 +01:00
/* else{
2021-03-12 11:56:54 +01:00
this.chatService.getPublicGroupMessages(this.roomId).subscribe(res=>{
2021-03-04 18:50:26 +01:00
console.log(res);
this.messages = res['messages'].reverse();
});
2021-08-23 16:31:06 +01:00
} */
2021-03-04 18:50:26 +01:00
}
2021-08-23 16:31:06 +01:00
2021-03-04 18:50:26 +01:00
sendMessage(){
let body = {
2021-07-23 14:43:51 +01:00
"message":
{
2021-09-09 11:47:49 +01:00
"rid": this.roomId,
"msg": this.message,
2021-09-13 12:37:58 +01:00
/* "attachments": [{
2021-09-09 11:47:49 +01:00
"color": "#ff0000",
"text": "Yay for gruggy!",
"title": "Attachment Example",
"title_link": "https://youtube.com",
"title_link_download": false,
2021-09-13 12:37:58 +01:00
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ee/Chain_link_icon.png",
}] */
2021-03-04 18:50:26 +01:00
}
}
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
this.chatService.sendMessage(body).subscribe(res=> {
2021-07-23 14:43:51 +01:00
/* this.loadGroupMessages(); */
2021-08-23 16:31:06 +01:00
//this.getRoomInfo();
this.scrollingOnce = true;
2021-03-04 18:50:26 +01:00
});
this.message = "";
}
2021-09-28 15:23:51 +01:00
deleteMessage(msgId:string){
let body = {
"roomId": this.roomId,
"msgId": msgId,
"asUser": false,
}
this.alertService.confirmDeleteMessage(body);
}
2021-03-18 09:25:59 +01:00
async openGroupMessagesOptions() {
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
}
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
2021-07-23 14:43:51 +01:00
2021-03-18 09:25:59 +01:00
/* const popover = await this.popoverController.create({
component: MessagesOptionsPage,
componentProps: {
roomId: this.dm._id,
},
cssClass: 'messages-options',
event: ev,
translucent: true,
});
return await popover.present(); */
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
component: ChatPopoverPage,
cssClass: 'model profile-modal search-submodal',
componentProps: {
roomId: this.roomId,
}
});
2021-04-15 23:57:14 +01:00
await modal.present();
modal.onDidDismiss().then(res=>{
console.log(res);
if(res.data == 'leave'){
2021-09-08 14:36:49 +01:00
this.getRoomInfo();
this.closeAllDesktopComponents.emit();
this.showEmptyContainer.emit();
2021-04-15 23:57:14 +01:00
}
else if(res.data == 'delete'){
this.closeAllDesktopComponents.emit();
this.showEmptyContainer.emit();
}
else if(res.data == 'cancel'){
console.log('CANCEL');
}
2021-04-16 09:57:08 +01:00
else if(res.data == 'edit'){
2021-04-16 11:25:10 +01:00
console.log(this.roomId);
//this.closeAllDesktopComponents.emit();
this.openEditGroupPage.emit(this.roomId);
2021-04-16 09:57:08 +01:00
}
2021-04-15 23:57:14 +01:00
else{
this.roomName = res.data.name.split('-').join(' ');
console.log(this.roomName);
2021-07-23 14:43:51 +01:00
2021-08-23 16:31:06 +01:00
//this.getRoomInfo();
this.loadGroupMessages(this.roomId);
2021-04-15 23:57:14 +01:00
//this.modalController.dismiss();
};
2021-07-23 14:43:51 +01:00
2021-04-15 23:57:14 +01:00
});
2021-03-18 09:25:59 +01:00
}
2021-06-03 14:56:53 +01:00
openSendGroupMessageOptions(ev?: any){
2021-08-18 09:23:53 +01:00
if(window.innerWidth <= 701){
2021-03-18 16:30:03 +01:00
console.log('mobile');
this.openChatOptions(ev);
}
else{
console.log('desktop');
this._openChatOptions();
}
}
2021-03-04 18:50:26 +01:00
2021-03-18 16:30:03 +01:00
async openOptions(ev: any) {
2021-03-04 18:50:26 +01:00
const popover = await this.popoverController.create({
component: ChatPopoverPage,
2021-04-23 14:30:18 +01:00
cssClass: 'chat-popover modal-desktop',
2021-03-04 18:50:26 +01:00
event: ev,
componentProps: {
room: this.room,
},
translucent: true
});
await popover.present();
popover.onDidDismiss().then(res=>{
console.log(res);
if(res.data){
2021-08-23 16:31:06 +01:00
this.loadGroupMessages(this.roomId);
//this.getRoomInfo();
2021-07-23 14:43:51 +01:00
//this.modalController.dismiss();
2021-03-04 18:50:26 +01:00
};
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
});
}
async openChatOptions(ev: any) {
const popover = await this.popoverController.create({
component: ChatOptionsPopoverPage,
cssClass: 'chat-options-popover',
event: ev,
componentProps: {
room: this.room,
2021-08-18 16:40:58 +01:00
members: this.members,
2021-03-04 18:50:26 +01:00
},
translucent: true
});
2021-09-13 12:37:58 +01:00
await popover.present();
await popover.onDidDismiss().then(()=>{
});
2021-03-04 18:50:26 +01:00
}
async addContacts(){
console.log(this.members);
2021-07-23 14:43:51 +01:00
2021-03-04 18:50:26 +01:00
const modal = await this.modalController.create({
component: GroupContactsPage,
componentProps: {
isCreated: this.isGroupCreated,
room: this.room,
members: this.members,
name: this.room.name,
2021-07-23 14:43:51 +01:00
},
2021-03-04 18:50:26 +01:00
cssClass: 'contacts',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then(()=>{
2021-08-23 16:31:06 +01:00
//this.getRoomInfo();
this.loadGroupMessages(this.roomId)
2021-03-04 18:50:26 +01:00
});
}
2021-03-18 16:30:03 +01:00
2021-09-13 12:37:58 +01:00
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)
};
}
2021-09-21 14:05:59 +01:00
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)
};
}
2021-09-14 15:57:24 +01:00
async addDocGestaoDocumental(){
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=>{
if(res){
const data = res.data;
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);
2021-12-01 15:11:54 +01:00
//console.log('Oie');
2021-09-14 15:57:24 +01:00
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) => {
});
}
});
}
2021-10-09 20:55:05 +01:00
viewDocument(file:any, url?:string){
if(file.type == "application/webtrix") {
this.openViewDocumentModal(file);
}
else{
let fullUrl = "https://www.tabularium.pt" + url;
this.fileService.viewDocumentByUrl(fullUrl);
}
}
async openViewDocumentModal(file:any){
2021-10-09 20:24:34 +01:00
let task = {
serialNumber: '',
taskStartDate: '',
isEvent: true,
workflowInstanceDataFields: {
FolderID: '',
Subject: file.Assunto,
SourceSecFsID: file.ApplicationId,
SourceType: 'DOC',
SourceID: file.DocId,
DispatchNumber: ''
}
}
let doc = {
"Id": "",
"ParentId": "",
"Source": 1,
"ApplicationId": file.ApplicationId,
"CreateDate": "",
"Data": null,
"Description":"",
"Link": null,
"SourceId": file.DocId,
"SourceName": file.Assunto,
"Stakeholders": "",
}
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
2021-10-09 20:24:34 +01:00
trustedUrl: '',
file: {
title: file.Assunto,
url: '',
title_link: '',
},
Document: doc,
applicationId: file.ApplicationId,
docId: file.DocId,
folderId: '',
task: task
},
2021-10-09 20:24:34 +01:00
cssClass: 'modal modal-desktop'
});
await modal.present();
2021-09-14 15:57:24 +01:00
}
2021-10-06 17:27:49 +01:00
takePicture(){
this.fileService.addCameraPictureToChat(this.roomId);
}
addImage(){
this.fileService.addPictureToChat(this.roomId);
}
addFile(){
this.fileService.addDocumentToChat(this.roomId);
}
addFileWebtrix(){
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
}
bookMeeting(){
let data = {
roomId: this.roomId,
members: this.members
}
this.openNewEventPage.emit(data);
}
2021-03-18 16:30:03 +01:00
async _openChatOptions() {
2021-08-18 16:40:58 +01:00
2021-03-18 16:30:03 +01:00
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
2021-08-18 16:40:58 +01:00
.duration(5000)
2021-03-18 16:30:03 +01:00
.addAnimation([backdropAnimation, wrapperAnimation]);
}
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
2021-08-18 16:40:58 +01:00
component: ChatOptionsFeaturesPage,
cssClass: 'model profile-modal search-submodal',
2021-03-18 16:30:03 +01:00
componentProps: {
roomId: this.roomId,
2021-08-18 16:40:58 +01:00
members: this.members,
}
});
await modal.present();
modal.onDidDismiss().then((res)=>{
2021-09-21 14:05:59 +01:00
//console.log(res['data']);
2021-08-18 16:40:58 +01:00
if(res['data'] == 'meeting'){
//this.closeAllDesktopComponents.emit();
let data = {
roomId: this.roomId,
members: this.members
}
this.openNewEventPage.emit(data);
2021-03-18 16:30:03 +01:00
}
2021-09-23 12:13:20 +01:00
else if(res['data'] == 'take-picture'){
this.fileService.addCameraPictureToChat(this.roomId);
//this.loadPicture();
}
2021-09-21 14:05:59 +01:00
else if(res['data'] == 'add-picture'){
2021-09-23 12:13:20 +01:00
this.fileService.addPictureToChat(this.roomId);
//this.loadPicture();
2021-09-13 12:37:58 +01:00
}
2021-09-21 14:05:59 +01:00
else if(res['data'] == 'add-document'){
this.loadDocument();
}
2021-09-14 15:57:24 +01:00
else if(res['data'] == 'documentoGestaoDocumental'){
2021-09-23 12:13:20 +01:00
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
//this.addDocGestaoDocumental();
2021-09-14 15:57:24 +01:00
}
2021-09-23 12:37:30 +01:00
this.loadGroupMessages(this.roomId);
2021-08-18 16:40:58 +01:00
2021-03-18 16:30:03 +01:00
});
}
2021-07-26 19:31:19 +01:00
async serverLongPull(){
2021-08-20 11:24:42 +01:00
2021-09-23 12:13:20 +01:00
if(this.route.url != "/home/chat" && document.querySelector('app-group-messages')){
console.log("Timer message stop")
}
else
{
2021-07-26 20:52:03 +01:00
2021-09-23 12:13:20 +01:00
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res =>
{
if(res['success'] == true) {
// Show Error
//showMessage(response.statusText);
//this.loadMessages()
let msgOnly = res['messages'].filter(data => data.t != 'au');
this.messages = msgOnly.reverse();
console.log(this.messages);
// Reconnect in one second
if(document.querySelector('app-group-messages')){
await new Promise(resolve => setTimeout(resolve,5000));
this.getGroups.emit();
console.log('Timer message running')
await this.serverLongPull();
}
}
else {
alert('HEY2')
// Got message
//let message = await response.text();
//this.loadMessages()
await this.serverLongPull();
}
}, (error)=>{
console.log(error);
this.serverLongPull();
});
2021-07-26 19:31:19 +01:00
}
}
2021-11-22 13:53:37 +01:00
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;
}
2021-09-23 12:13:20 +01:00
2021-11-22 13:53:37 +01:00
async openPreview(img) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
cssClass: 'transparent-modal',
componentProps: {
image: img.attachments[0].image_url,
username: img.u.username,
_updatedAt: img._updatedAt
}
});
modal.present();
}
2021-09-23 12:13:20 +01:00
2021-03-04 18:50:26 +01:00
}
2021-03-12 11:56:54 +01:00