2021-11-17 15:34:15 +01:00
|
|
|
import { Component, ElementRef, OnInit, ViewChild, AfterViewChecked, AfterViewInit, OnDestroy, ChangeDetectorRef, } from '@angular/core';
|
|
|
|
|
import { ActionSheetController, IonSlides, MenuController, ModalController, NavParams, PopoverController } from '@ionic/angular';
|
2021-04-13 14:14:55 +01:00
|
|
|
import { AlertService } from 'src/app/services/alert.service';
|
2021-01-19 16:10:40 +01:00
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
import { ChatService } from 'src/app/services/chat.service';
|
2020-12-29 12:40:19 +01:00
|
|
|
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
|
2020-12-28 10:11:00 +01:00
|
|
|
import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popover.page';
|
2020-12-29 12:40:19 +01:00
|
|
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
|
|
|
|
import { NewGroupPage } from '../new-group/new-group.page';
|
2021-01-21 16:27:04 +01:00
|
|
|
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
2021-07-26 19:31:19 +01:00
|
|
|
import {Router} from '@angular/router'
|
2021-08-17 14:17:19 +01:00
|
|
|
import { EditGroupPage } from '../edit-group/edit-group.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 10:30:13 +01:00
|
|
|
import { FileService } from 'src/app/services/functions/file.service';
|
2021-09-14 10:48:28 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-09-21 14:05:59 +01:00
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
|
|
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
2021-10-05 16:29:33 +01:00
|
|
|
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-17 15:34:15 +01:00
|
|
|
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
2020-12-28 10:11:00 +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, AfterViewInit, OnDestroy {
|
2021-11-17 15:34:15 +01:00
|
|
|
|
2021-11-18 13:01:53 +01:00
|
|
|
|
2021-11-17 15:34:15 +01:00
|
|
|
|
2021-01-27 16:01:49 +01:00
|
|
|
showLoader: boolean;
|
2021-01-21 16:27:04 +01:00
|
|
|
isGroupCreated:boolean;
|
2021-01-19 16:10:40 +01:00
|
|
|
loggedUser: any;
|
2020-12-28 10:11:00 +01:00
|
|
|
message:any;
|
2021-01-19 16:10:40 +01:00
|
|
|
messages:any;
|
2021-01-21 16:27:04 +01:00
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
room:any;
|
2021-01-26 15:18:03 +01:00
|
|
|
roomName:any;
|
2021-01-19 16:10:40 +01:00
|
|
|
members:any;
|
2021-03-12 11:56:54 +01:00
|
|
|
contacts: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
|
2021-09-09 11:47:49 +01:00
|
|
|
allUsers:any[] = [];
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
roomId: string;
|
2021-07-23 14:43:51 +01:00
|
|
|
loggedUserChat:any;
|
2021-08-18 09:23:53 +01:00
|
|
|
eventSelectedDate: Date = new Date();
|
2021-03-12 17:35:54 +01:00
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
scrollingOnce:boolean = true;
|
|
|
|
|
private scrollChangeCallback: () => void;
|
|
|
|
|
currentPosition: any;
|
|
|
|
|
startPosition: number;
|
|
|
|
|
|
2021-09-13 12:37:58 +01:00
|
|
|
capturedImage:any;
|
|
|
|
|
capturedImageTitle:any;
|
2021-09-21 14:05:59 +01:00
|
|
|
attendees: EventPerson[] = [];
|
2021-09-24 15:39:25 +01:00
|
|
|
scrollToBottomBtn = false;
|
2021-09-13 12:37:58 +01:00
|
|
|
|
2021-09-30 12:23:22 +01:00
|
|
|
longPressActive = false;
|
|
|
|
|
showMessageOptions = false;
|
|
|
|
|
selectedMsgId:string;
|
2021-10-28 16:10:42 +01:00
|
|
|
roomCountDownDate:any;
|
2021-09-30 12:23:22 +01:00
|
|
|
|
2021-07-26 14:09:26 +01:00
|
|
|
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
|
|
|
|
|
2020-12-28 10:11:00 +01:00
|
|
|
constructor(
|
|
|
|
|
private menu: MenuController,
|
2020-12-29 12:40:19 +01:00
|
|
|
private modalController: ModalController,
|
2020-12-28 10:11:00 +01:00
|
|
|
private actionSheetController: ActionSheetController,
|
|
|
|
|
public popoverController: PopoverController,
|
2021-01-19 16:10:40 +01:00
|
|
|
private chatService: ChatService,
|
2021-03-12 11:56:54 +01:00
|
|
|
private navParams: NavParams,
|
2021-01-19 16:10:40 +01:00
|
|
|
private authService: AuthService,
|
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 10:30:13 +01:00
|
|
|
private fileService: FileService,
|
2021-09-14 10:48:28 +01:00
|
|
|
private toastService: ToastService,
|
2021-11-17 15:34:15 +01:00
|
|
|
public ThemeService: ThemeService,
|
|
|
|
|
private changeDetectorRef: ChangeDetectorRef
|
2021-01-21 16:27:04 +01:00
|
|
|
) {
|
2021-07-23 14:43:51 +01:00
|
|
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
2021-01-21 16:27:04 +01:00
|
|
|
this.isGroupCreated = true;
|
2021-03-12 17:35:54 +01:00
|
|
|
this.roomId = this.navParams.get('roomId');
|
2021-09-03 17:02:42 +01:00
|
|
|
window.onresize = (event) => {
|
|
|
|
|
if( window.innerWidth > 701){
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-01-19 16:10:40 +01:00
|
|
|
}
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-07-23 14:43:51 +01:00
|
|
|
console.log(this.roomId);
|
|
|
|
|
this.loggedUser=this.loggedUserChat;
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-07-26 14:34:52 +01:00
|
|
|
this.scrollToBottom();
|
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-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setStatus(status:string){
|
|
|
|
|
let body = {
|
|
|
|
|
message: '',
|
|
|
|
|
status: status,
|
|
|
|
|
}
|
|
|
|
|
this.chatService.setUserStatus(body).subscribe(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 12:23:22 +01:00
|
|
|
deleteMessage(msgId:string){
|
|
|
|
|
let body = {
|
|
|
|
|
"roomId": this.roomId,
|
|
|
|
|
"msgId": msgId,
|
|
|
|
|
"asUser": false,
|
|
|
|
|
}
|
|
|
|
|
if(msgId){
|
|
|
|
|
this.alertService.confirmDeleteMessage(body);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.toastService.badRequest('Não foi possível apagar');
|
|
|
|
|
}
|
|
|
|
|
this.showMessageOptions = false;
|
|
|
|
|
this.selectedMsgId = "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngAfterViewInit() {
|
|
|
|
|
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
|
|
|
|
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
|
2021-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-30 12:23:22 +01:00
|
|
|
handlePress(id?:string){
|
|
|
|
|
this.selectedMsgId = id;
|
|
|
|
|
this.showMessageOptions = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleClick(){
|
|
|
|
|
this.showMessageOptions = false;
|
|
|
|
|
this.selectedMsgId = "";
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
|
|
//alert('BOTTOM');
|
|
|
|
|
} else {
|
|
|
|
|
//alert('UP');
|
|
|
|
|
this.scrollingOnce = false;
|
|
|
|
|
}
|
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;
|
2021-03-12 17:35:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
2021-07-26 14:09:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrollToBottom(): void {
|
|
|
|
|
try {
|
2021-08-23 16:31:06 +01:00
|
|
|
if(this.scrollingOnce){
|
|
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
//this.scrollingOnce = false;
|
|
|
|
|
}
|
2021-07-26 14:09:26 +01:00
|
|
|
} catch(err) { }
|
2021-04-13 14:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 15:39:25 +01:00
|
|
|
scrollToBottomClicked(): void {
|
|
|
|
|
try {
|
|
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
} catch(err) { }
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
getRoomInfo(){
|
|
|
|
|
this.showLoader = true;
|
|
|
|
|
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
|
|
|
|
this.room = room['room'];
|
|
|
|
|
this.roomName = this.room.name.split('-').join(' ');
|
2021-10-28 16:10:42 +01:00
|
|
|
if(this.room.customFields.countDownDate){
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
|
2021-10-28 16:10:42 +01:00
|
|
|
}
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getGroupContacts(this.room);
|
|
|
|
|
this.loadGroupMessages(this.room);
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
2021-03-12 11:56:54 +01:00
|
|
|
}
|
2021-03-12 17:35:54 +01:00
|
|
|
|
2021-09-09 11:47:49 +01:00
|
|
|
async getChatMembers(){
|
|
|
|
|
//return await this.chatService.getMembers(roomId).toPromise();
|
|
|
|
|
this.chatService.getAllUsers().subscribe(res=> {
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
|
|
|
|
|
console.log(this.allUsers);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
/* load(){
|
2021-03-12 11:56:54 +01:00
|
|
|
this.getGroupContacts();
|
|
|
|
|
this.loadGroupMessages();
|
2021-03-12 17:35:54 +01:00
|
|
|
} */
|
2021-01-26 15:18:03 +01:00
|
|
|
|
2021-01-22 15:28:52 +01:00
|
|
|
close(){
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
2021-01-26 15:18:03 +01:00
|
|
|
|
2021-01-27 16:01:49 +01:00
|
|
|
doRefresh(ev:any){
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-01-27 16:01:49 +01:00
|
|
|
ev.target.complete();
|
2021-01-26 15:18:03 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
getGroupContacts(room:any){
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = true;
|
2021-01-19 16:10:40 +01:00
|
|
|
//If group is private call getGroupMembers
|
2021-03-12 11:56:54 +01:00
|
|
|
if(this.room.t === 'p'){
|
2021-03-12 17:35:54 +01:00
|
|
|
this.chatService.getGroupMembers(this.roomId).subscribe(res=>{
|
2021-01-19 16:10:40 +01:00
|
|
|
console.log(res);
|
|
|
|
|
this.members = res['members'];
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = false;
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Otherwise call getChannelMembers for públic groups
|
|
|
|
|
else{
|
2021-03-12 17:35:54 +01:00
|
|
|
this.chatService.getChannelMembers(this.roomId).subscribe(res=>{
|
2021-01-19 16:10:40 +01:00
|
|
|
console.log(res);
|
|
|
|
|
this.members = res['members'];
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = false;
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-19 18:54:50 +01:00
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
loadGroupMessages(room:any){
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = true;
|
2021-01-19 16:10:40 +01:00
|
|
|
//If group is private call getGroupMembers
|
2021-03-12 11:56:54 +01:00
|
|
|
if(this.room.t === 'p'){
|
2021-03-12 17:35:54 +01:00
|
|
|
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res=>{
|
2021-01-19 16:10:40 +01:00
|
|
|
console.log(res);
|
2021-01-22 15:28:52 +01:00
|
|
|
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
|
|
|
|
this.messages = msgOnly.reverse();
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = false;
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Otherwise call getChannelMembers for públic groups
|
2021-08-17 14:17:19 +01:00
|
|
|
/* else{
|
2021-03-12 17:35:54 +01:00
|
|
|
this.chatService.getPublicGroupMessages(this.roomId).subscribe(res=>{
|
2021-01-19 16:10:40 +01:00
|
|
|
console.log(res);
|
|
|
|
|
this.messages = res['messages'].reverse();
|
|
|
|
|
});
|
2021-08-17 14:17:19 +01:00
|
|
|
} */
|
2021-01-19 16:10:40 +01:00
|
|
|
}
|
2021-08-20 17:00:48 +01:00
|
|
|
|
|
|
|
|
showDateDuration(start:any){
|
2021-09-06 16:53:58 +01:00
|
|
|
return this.timeService.showDateDuration(start);
|
2021-10-28 15:40:41 +01:00
|
|
|
}
|
|
|
|
|
countDownDate(date:any, roomId:string){
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = this.timeService.countDownDate(date, roomId);
|
|
|
|
|
return this.timeService.countDownDateTimer(date, roomId);
|
2021-08-20 17:00:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addZero(i) {
|
|
|
|
|
if (i < 10) {
|
|
|
|
|
i = "0" + i;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
sendMessage(){
|
|
|
|
|
let body = {
|
2021-07-26 14:34:52 +01:00
|
|
|
"message": { "rid": this.roomId, "msg": this.message }
|
2021-01-19 16:10:40 +01:00
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
this.chatService.sendMessage(body).subscribe(res=> {
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-08-23 16:31:06 +01:00
|
|
|
this.scrollingOnce = true;
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-05-26 10:13:13 +01:00
|
|
|
},(error) => {
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
this.message = "";
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-15 23:57:14 +01:00
|
|
|
async openOptions() {
|
2021-04-21 15:14:43 +01:00
|
|
|
const modal = await this.popoverController.create({
|
2020-12-28 10:11:00 +01:00
|
|
|
component: ChatPopoverPage,
|
|
|
|
|
cssClass: 'chat-popover',
|
2021-01-20 13:17:54 +01:00
|
|
|
componentProps: {
|
2021-04-15 23:57:14 +01:00
|
|
|
roomId: this.roomId,
|
2021-01-20 13:17:54 +01:00
|
|
|
},
|
2020-12-28 10:11:00 +01:00
|
|
|
});
|
2021-04-15 23:57:14 +01:00
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then(res=>{
|
2021-04-20 17:18:57 +01:00
|
|
|
if(res.data == 'leave'){
|
2021-09-13 12:37:58 +01:00
|
|
|
console.log('saiu do grupo');
|
2021-04-20 17:18:57 +01:00
|
|
|
}
|
2021-04-21 15:14:43 +01:00
|
|
|
else if(res.data == 'cancel'){
|
|
|
|
|
console.log('cancel');
|
|
|
|
|
}
|
2021-08-17 14:17:19 +01:00
|
|
|
else if(res.data == 'edit'){
|
|
|
|
|
this.editGroup(this.roomId);
|
|
|
|
|
}
|
2021-01-20 16:58:04 +01:00
|
|
|
});
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
2021-04-21 15:14:43 +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-10-09 20:55:05 +01:00
|
|
|
viewDocument(file:any, url?:string){
|
|
|
|
|
|
|
|
|
|
if(file.type == "application/webtrix") {
|
|
|
|
|
this.openViewDocumentModal(file);
|
2021-10-05 16:29:33 +01:00
|
|
|
}
|
|
|
|
|
else{
|
2021-10-09 20:55:05 +01:00
|
|
|
let fullUrl = "https://www.tabularium.pt" + url;
|
|
|
|
|
this.fileService.viewDocumentByUrl(fullUrl);
|
2021-10-05 16:29:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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": "",
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-05 16:29:33 +01:00
|
|
|
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-05 16:29:33 +01:00
|
|
|
},
|
2021-10-09 20:24:34 +01:00
|
|
|
cssClass: 'modal modal-desktop'
|
2021-10-05 16:29:33 +01:00
|
|
|
});
|
|
|
|
|
await modal.present();
|
2021-10-09 20:24:34 +01:00
|
|
|
|
2021-09-14 16:34:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
async bookMeeting() {
|
|
|
|
|
this.attendees = this.members.map((val)=>{
|
|
|
|
|
return {
|
|
|
|
|
Name: val.name,
|
|
|
|
|
EmailAddress: val.username+"@"+environment.domain,
|
|
|
|
|
IsRequired: "true",
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log(this.attendees);
|
|
|
|
|
this.popoverController.dismiss();
|
|
|
|
|
if( window.innerWidth <= 1024){
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: NewEventPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
attendees: this.attendees,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
|
if(data){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 15:50:12 +01:00
|
|
|
async openChatOptions(ev?: any) {
|
2021-08-18 09:23:53 +01:00
|
|
|
console.log(this.members);
|
|
|
|
|
|
2020-12-29 12:40:19 +01:00
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: ChatOptionsPopoverPage,
|
|
|
|
|
cssClass: 'chat-options-popover',
|
|
|
|
|
event: ev,
|
2021-01-20 10:23:59 +01:00
|
|
|
componentProps: {
|
2021-01-20 13:17:54 +01:00
|
|
|
room: this.room,
|
2021-08-18 09:23:53 +01:00
|
|
|
members: this.members,
|
|
|
|
|
eventSelectedDate: new Date(),
|
2021-01-20 10:23:59 +01:00
|
|
|
},
|
2020-12-29 12:40:19 +01:00
|
|
|
translucent: true
|
|
|
|
|
});
|
2021-09-13 12:37:58 +01:00
|
|
|
await popover.present();
|
|
|
|
|
await popover.onDidDismiss().then((res)=>{
|
2021-09-21 14:05:59 +01:00
|
|
|
console.log(res['data']);
|
|
|
|
|
if(res['data'] == 'meeting'){
|
|
|
|
|
this.bookMeeting();
|
2021-09-13 12:37:58 +01:00
|
|
|
}
|
2021-09-21 14:05:59 +01:00
|
|
|
else if(res['data'] == 'take-picture'){
|
|
|
|
|
this.fileService.addCameraPictureToChat(this.roomId);
|
|
|
|
|
//this.loadPicture();
|
|
|
|
|
}
|
|
|
|
|
else if(res['data'] == 'add-picture'){
|
2021-11-21 19:49:59 +01:00
|
|
|
this.fileService.addPictureToChatMobile(this.roomId);
|
2021-09-21 14:05:59 +01:00
|
|
|
//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();
|
2021-09-14 10:30:13 +01:00
|
|
|
}
|
2021-09-23 12:37:30 +01:00
|
|
|
this.loadGroupMessages(this.roomId);
|
2021-09-13 12:37:58 +01:00
|
|
|
});
|
2020-12-29 12:40:19 +01:00
|
|
|
}
|
2021-08-18 18:58:02 +01:00
|
|
|
|
2020-12-29 12:40:19 +01:00
|
|
|
async addContacts(){
|
2021-01-26 11:03:00 +01:00
|
|
|
console.log(this.members);
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2020-12-29 12:40:19 +01:00
|
|
|
const modal = await this.modalController.create({
|
2021-01-21 16:27:04 +01:00
|
|
|
component: GroupContactsPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
isCreated: this.isGroupCreated,
|
|
|
|
|
room: this.room,
|
2021-01-26 11:03:00 +01:00
|
|
|
members: this.members,
|
|
|
|
|
name: this.room.name,
|
2021-07-23 14:43:51 +01:00
|
|
|
},
|
2020-12-29 12:40:19 +01:00
|
|
|
cssClass: 'contacts',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
2021-01-26 15:18:03 +01:00
|
|
|
modal.onDidDismiss().then(()=>{
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-01-26 15:18:03 +01:00
|
|
|
});
|
2020-12-29 12:40:19 +01:00
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
|
2021-08-17 14:17:19 +01:00
|
|
|
async editGroup(roomId){
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: EditGroupPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: roomId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
console.log(res.data);
|
2021-09-21 14:28:53 +01:00
|
|
|
this.getRoomInfo();
|
|
|
|
|
//this.modalController.dismiss(res.data);
|
2021-08-17 14:17:19 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
/* async actionSheet() {
|
|
|
|
|
const actionSheet = await this.actionSheetController.create({
|
|
|
|
|
cssClass: 'my-custom-class',
|
|
|
|
|
buttons: [{
|
|
|
|
|
text: 'Sair do grupo',
|
|
|
|
|
handler: () => {
|
|
|
|
|
console.log('Delete clicked');
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
text: 'Alterar nome do grupo1',
|
|
|
|
|
handler: () => {
|
|
|
|
|
console.log('Alterar nome do grupo');
|
|
|
|
|
this.openChangeGroupName()
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
text: 'Apagar o grupo',
|
|
|
|
|
handler: () => {
|
|
|
|
|
console.log('Play clicked');
|
|
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
},
|
2021-01-27 11:23:57 +01:00
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
await actionSheet.present();
|
|
|
|
|
}
|
|
|
|
|
*/
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-07-26 19:31:19 +01:00
|
|
|
async serverLongPull(){
|
|
|
|
|
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res => {
|
|
|
|
|
|
|
|
|
|
if (res == 502) {
|
|
|
|
|
// Connection timeout
|
|
|
|
|
// happens when the connection was pending for too long
|
|
|
|
|
// let's reconnect
|
|
|
|
|
await this.serverLongPull();
|
|
|
|
|
} else if (res != 200) {
|
|
|
|
|
// Show Error
|
|
|
|
|
//showMessage(response.statusText);
|
|
|
|
|
//this.loadMessages()
|
2021-08-23 16:31:06 +01:00
|
|
|
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
|
|
|
|
this.messages = msgOnly.reverse();
|
2021-07-26 19:31:19 +01:00
|
|
|
console.log(this.messages);
|
|
|
|
|
// Reconnect in one second
|
|
|
|
|
if(this.route.url != "/home/chat"){
|
|
|
|
|
console.log("Timer message stop")
|
|
|
|
|
} else {
|
2021-08-19 18:54:50 +01:00
|
|
|
//Check if modal is opened
|
2021-08-20 11:24:42 +01:00
|
|
|
if(document.querySelector('.isGroupChatOpened')){
|
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
2021-08-19 18:54:50 +01:00
|
|
|
await this.serverLongPull();
|
|
|
|
|
console.log('Timer message running')
|
|
|
|
|
}
|
2021-07-26 19:31:19 +01:00
|
|
|
}
|
2021-07-26 20:52:03 +01:00
|
|
|
|
2021-07-26 19:31:19 +01:00
|
|
|
} else {
|
|
|
|
|
// Got message
|
|
|
|
|
//let message = await response.text();
|
|
|
|
|
//this.loadMessages()
|
|
|
|
|
await this.serverLongPull();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 15:34:15 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async openPreview(img) {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: PreviewCameraPage,
|
|
|
|
|
cssClass: 'transparent-modal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
image: img.attachments[0].image_url,
|
2021-12-03 17:27:10 +01:00
|
|
|
username: img.u.name,
|
2021-11-17 15:34:15 +01:00
|
|
|
_updatedAt: img._updatedAt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.present();
|
|
|
|
|
}
|
2021-03-12 13:10:20 +01:00
|
|
|
}
|
2021-11-17 15:34:15 +01:00
|
|
|
|