mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
Merge branch 'chatSessonExpire' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -10,6 +10,7 @@ import { FileLoaderService } from 'src/app/services/file/file-loader.service';
|
|||||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service'
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-chat-options-features',
|
selector: 'app-chat-options-features',
|
||||||
@@ -47,7 +48,7 @@ export class ChatOptionsFeaturesPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
}
|
}
|
||||||
|
|
||||||
notImplemented() {
|
notImplemented() {
|
||||||
@@ -117,8 +118,6 @@ export class ChatOptionsFeaturesPage implements OnInit {
|
|||||||
|
|
||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
this.chatService.sendMessage(body).subscribe(res=> {
|
||||||
//
|
//
|
||||||
},(error) => {
|
|
||||||
|
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
@@ -144,8 +143,6 @@ export class ChatOptionsFeaturesPage implements OnInit {
|
|||||||
this.chatService.sendMessage(body).subscribe(res=> {
|
this.chatService.sendMessage(body).subscribe(res=> {
|
||||||
|
|
||||||
|
|
||||||
},(error) => {
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class SetRoomOwnerPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
}
|
}
|
||||||
|
|
||||||
async close(){
|
async close(){
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
OnInit,
|
OnInit,
|
||||||
@@ -129,6 +129,18 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
|
/* let data = {
|
||||||
|
status: "success",
|
||||||
|
data: {
|
||||||
|
userId: "CqYSKR5hrAumZihs7",
|
||||||
|
authToken: "bvh5BH98Av5ShMnEW94Cwm1Hf-yHEHbl121ijq5Odc_sdvs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SessionStore.user.ChatData = data
|
||||||
|
SessionStore.save() */
|
||||||
|
console.log(SessionStore.user.ChatData.data.authToken)
|
||||||
|
this.chatService.refreshtoken();
|
||||||
|
|
||||||
this.segment = "Contactos";
|
this.segment = "Contactos";
|
||||||
|
|
||||||
this.authService.userData$.subscribe((res: any) => {
|
this.authService.userData$.subscribe((res: any) => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController, NavParams, PickerController } from '@ionic/angular';
|
import { ModalController, NavParams, PickerController } from '@ionic/angular';
|
||||||
import { ChatService } from 'src/app/services/chat.service';
|
import { ChatService } from 'src/app/services/chat.service';
|
||||||
@@ -28,6 +29,7 @@ export class EditGroupPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController, NavParams } from '@ionic/angular';
|
import { ModalController, NavParams } from '@ionic/angular';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -56,6 +56,7 @@ export class GroupContactsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.loadUsers();
|
this.loadUsers();
|
||||||
this.getMembers();
|
this.getMembers();
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { MessageService } from 'src/app/services/chat/message.service';
|
|||||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-group-messages',
|
selector: 'app-group-messages',
|
||||||
@@ -132,6 +133,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
|
|
||||||
this.loggedUser = this.loggedUserChat;
|
this.loggedUser = this.loggedUserChat;
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController } from '@ionic/angular';
|
import { ModalController } from '@ionic/angular';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
@@ -43,6 +43,7 @@ export class ContactsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.loadUsers();
|
this.loadUsers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import { FileToBase64Service } from 'src/app/services/file/file-to-base64.servic
|
|||||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
@@ -156,6 +157,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class NewGroupPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
console.log(this.documents)
|
console.log(this.documents)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+345
-315
@@ -14,26 +14,338 @@ import { SessionStore } from '../store/session.service';
|
|||||||
})
|
})
|
||||||
export class ChatService {
|
export class ChatService {
|
||||||
headers: HttpHeaders;
|
headers: HttpHeaders;
|
||||||
options:any;
|
options: any;
|
||||||
options1:any;
|
options1: any;
|
||||||
X_User_Id:any;
|
X_User_Id: any;
|
||||||
X_Auth_Token:any;
|
X_Auth_Token: any;
|
||||||
loggedUserChat:any;
|
loggedUserChat: any;
|
||||||
bindOnMessage: any;
|
bindOnMessage: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http:HttpClient,
|
private http: HttpClient,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private storage: Storage,
|
private storage: Storage,
|
||||||
private storageService:StorageService,
|
private storageService: StorageService,
|
||||||
public p: PermissionService) {
|
public p: PermissionService) {
|
||||||
|
|
||||||
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
|
this.setheader()
|
||||||
this.loggedUserChat = authService.ValidatedUserChat;
|
|
||||||
this.headers = new HttpHeaders();
|
|
||||||
|
|
||||||
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
|
}
|
||||||
|
|
||||||
|
getDocumentDetails(url: string) {
|
||||||
|
let headersc = new HttpHeaders();
|
||||||
|
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
|
||||||
|
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
||||||
|
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
||||||
|
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
||||||
|
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
||||||
|
headersc = headersc.set('Cookie', 'rc_token=MLbhikLQI4xo9_vL43HqheKPPbxjag7hKfwxe9AjcvY');
|
||||||
|
// headersc = headersc.set("Host", "www.tabularium.pt");
|
||||||
|
// headersc = headersc.set("Origin", "http://localhost:8100");
|
||||||
|
headersc = headersc.set('Referer', 'http://localhost:8100/');
|
||||||
|
let optionsc = {
|
||||||
|
headers: headersc,
|
||||||
|
withCredentials: true
|
||||||
|
};
|
||||||
|
// let fullUrl = "https://www.tabularium.pt/" + url;
|
||||||
|
return this.http.get(url, optionsc).subscribe(() => {
|
||||||
|
// this.fileService.viewDocumentByUrl(url)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllChannels() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'channels.list', this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllUserChannels() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'channels.list.joined', this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllRooms() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'rooms.get', this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRoomInfo(roomId: any) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'rooms.info', opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
customsRooms(params: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'rooms.get', opts);
|
||||||
|
}
|
||||||
|
getAllPrivateGroups() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'groups.list', this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllUsers() {
|
||||||
|
console.log(this.options)
|
||||||
|
return this.http.get(environment.apiChatUrl + 'users.list', this.options);
|
||||||
|
}
|
||||||
|
getAllConnectedUsers() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'users.presence', this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load messages from roomId
|
||||||
|
getAllDirectMessages() {
|
||||||
|
return this.http.get(environment.apiChatUrl + 'im.list', this.options);
|
||||||
|
}
|
||||||
|
//Load messages from roomId
|
||||||
|
getRoomMessages(roomId: any) {
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params,
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'im.history', opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'chat.sendMessage', body, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadFile(formData: any, rid: string) {
|
||||||
|
let url = environment.apiChatUrl + 'rooms.upload/' + rid;
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(url, formData, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteMessage(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'chat.delete', body, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
leaveRoom(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'rooms.leave', body, opts);
|
||||||
|
}
|
||||||
|
//Load members from a chat
|
||||||
|
getMembers(roomId: any) {
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'im.members', opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
getMemberInfo(userId: string) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("userId", userId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'users.info', opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
setUserStatus(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'users.setStatus', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeChatRoom(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'im.delete', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
createRoom(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'im.create', body, this.options);
|
||||||
|
}
|
||||||
|
getDirectMessage(roomId: string) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'im.messages', opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GROUPS */
|
||||||
|
addGroup(body: any) {
|
||||||
|
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.create', body, this.options);
|
||||||
|
}
|
||||||
|
setGroupCustomFields(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.setCustomFields', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getGroupMembers(roomId: string) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
let url = environment.apiChatUrl + 'groups.members';
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(url, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
getChannelMembers(roomId: string) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
let url = environment.apiChatUrl + 'channels.members';
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(url, opts);
|
||||||
|
}
|
||||||
|
/* GROUP MESSAGES */
|
||||||
|
getPrivateGroupMessages(roomId: any) {
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'groups.history', opts);
|
||||||
|
}
|
||||||
|
getPublicGroupMessages(roomId: any) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'channels.history', opts);
|
||||||
|
}
|
||||||
|
closeGroup(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.close', body, this.options);
|
||||||
|
}
|
||||||
|
closeChannel(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'channels.close', body, this.options);
|
||||||
|
}
|
||||||
|
leaveGroup(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.leave', body, this.options);
|
||||||
|
}
|
||||||
|
leaveChannel(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'channels.leave', body, this.options);
|
||||||
|
}
|
||||||
|
removeChannelMember(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'channels.kick', body, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
addChannelOwner(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'channels.addOwner', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
addGroupOwner(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.addOwner', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteGroup(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.delete', body, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteChannel(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'channels.delete', body, this.options);
|
||||||
|
}
|
||||||
|
addUserToGroup(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.invite', body, this.options);
|
||||||
|
}
|
||||||
|
getGroupInfo(roomId: any) {
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
return this.http.get(environment.apiChatUrl + 'groups.info', opts);
|
||||||
|
}
|
||||||
|
renameGroup(body: any) {
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.rename', body, this.options);
|
||||||
|
}
|
||||||
|
removeGroupMember(body: any) {
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
}
|
||||||
|
return this.http.post(environment.apiChatUrl + 'groups.kick', body, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
async subscribe(roomId: any) {
|
||||||
|
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.set("roomId", roomId);
|
||||||
|
let opts = {
|
||||||
|
headers: this.headers,
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
|
||||||
|
this.http.get(environment.apiChatUrl + 'im.messages', opts).subscribe(async res => {
|
||||||
|
|
||||||
|
|
||||||
|
if (res == 502) {
|
||||||
|
// Connection timeout
|
||||||
|
// happens when the connection was pending for too long
|
||||||
|
// let's reconnect
|
||||||
|
await this.subscribe(roomId);
|
||||||
|
} else if (res != 200) {
|
||||||
|
// Show Error
|
||||||
|
//showMessage(response.statusText);
|
||||||
|
this.getRoomMessages(roomId)
|
||||||
|
// Reconnect in one second
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
await this.subscribe(roomId);
|
||||||
|
} else {
|
||||||
|
// Got message
|
||||||
|
//let message = await response.text();
|
||||||
|
this.getRoomMessages(roomId)
|
||||||
|
await this.subscribe(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setheader() {
|
||||||
|
try {
|
||||||
|
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||||
|
this.loggedUserChat = this.authService.ValidatedUserChat;
|
||||||
|
this.headers = new HttpHeaders();
|
||||||
|
|
||||||
|
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
|
||||||
//
|
//
|
||||||
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
|
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
|
||||||
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
|
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
|
||||||
@@ -41,313 +353,31 @@ export class ChatService {
|
|||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocumentDetails(url:string) {
|
refreshtoken() {
|
||||||
let headersc = new HttpHeaders();
|
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
|
||||||
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
|
let options = {
|
||||||
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
|
headers: this.headers
|
||||||
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
|
};
|
||||||
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
|
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
|
||||||
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
|
let data = {
|
||||||
headersc = headersc.set('Cookie', 'rc_token=MLbhikLQI4xo9_vL43HqheKPPbxjag7hKfwxe9AjcvY');
|
status: res['status'],
|
||||||
// headersc = headersc.set("Host", "www.tabularium.pt");
|
data: {
|
||||||
// headersc = headersc.set("Origin", "http://localhost:8100");
|
userId: res['data'].userId,
|
||||||
headersc = headersc.set('Referer', 'http://localhost:8100/');
|
authToken: res['data'].authToken
|
||||||
let optionsc = {
|
|
||||||
headers: headersc,
|
|
||||||
withCredentials: true
|
|
||||||
};
|
|
||||||
// let fullUrl = "https://www.tabularium.pt/" + url;
|
|
||||||
return this.http.get(url, optionsc).subscribe(()=>{
|
|
||||||
// this.fileService.viewDocumentByUrl(url)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllChannels() {
|
|
||||||
return this.http.get(environment.apiChatUrl+'channels.list', this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllUserChannels() {
|
|
||||||
return this.http.get(environment.apiChatUrl+'channels.list.joined', this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllRooms() {
|
|
||||||
return this.http.get(environment.apiChatUrl+'rooms.get', this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getRoomInfo(roomId:any) {
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'rooms.info', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
customsRooms(params:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'rooms.get', opts);
|
|
||||||
}
|
|
||||||
getAllPrivateGroups(){
|
|
||||||
return this.http.get(environment.apiChatUrl+'groups.list', this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAllUsers(){
|
|
||||||
return this.http.get(environment.apiChatUrl+'users.list', this.options);
|
|
||||||
}
|
|
||||||
getAllConnectedUsers(){
|
|
||||||
return this.http.get(environment.apiChatUrl+'users.presence', this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Load messages from roomId
|
|
||||||
getAllDirectMessages(){
|
|
||||||
return this.http.get(environment.apiChatUrl+'im.list', this.options);
|
|
||||||
}
|
|
||||||
//Load messages from roomId
|
|
||||||
getRoomMessages(roomId:any){
|
|
||||||
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params,
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'im.history', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(body:any) {
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadFile(formData:any, rid:string){
|
|
||||||
let url = environment.apiChatUrl+'rooms.upload/'+rid;
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(url, formData, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteMessage(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'chat.delete', body, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
leaveRoom(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'rooms.leave', body, opts);
|
|
||||||
}
|
|
||||||
//Load members from a chat
|
|
||||||
getMembers(roomId:any){
|
|
||||||
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'im.members', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
getMemberInfo(userId:string){
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("userId", userId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'users.info', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
setUserStatus(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'users.setStatus', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeChatRoom(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'im.delete', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
createRoom(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'im.create', body, this.options);
|
|
||||||
}
|
|
||||||
getDirectMessage(roomId:string){
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'im.messages', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GROUPS */
|
|
||||||
addGroup(body:any){
|
|
||||||
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.create', body, this.options);
|
|
||||||
}
|
|
||||||
setGroupCustomFields(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.setCustomFields', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
getGroupMembers(roomId:string){
|
|
||||||
let params = new HttpParams();
|
|
||||||
let url=environment.apiChatUrl+'groups.members';
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(url, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
getChannelMembers(roomId:string){
|
|
||||||
let params = new HttpParams();
|
|
||||||
let url=environment.apiChatUrl+'channels.members';
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(url, opts);
|
|
||||||
}
|
|
||||||
/* GROUP MESSAGES */
|
|
||||||
getPrivateGroupMessages(roomId:any){
|
|
||||||
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'groups.history', opts);
|
|
||||||
}
|
|
||||||
getPublicGroupMessages(roomId:any){
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'channels.history', opts);
|
|
||||||
}
|
|
||||||
closeGroup(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.close', body, this.options);
|
|
||||||
}
|
|
||||||
closeChannel(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'channels.close', body, this.options);
|
|
||||||
}
|
|
||||||
leaveGroup(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.leave', body, this.options);
|
|
||||||
}
|
|
||||||
leaveChannel(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'channels.leave', body, this.options);
|
|
||||||
}
|
|
||||||
removeChannelMember(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'channels.kick', body, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
addChannelOwner(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'channels.addOwner', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
addGroupOwner(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.addOwner', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteGroup(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.delete', body, this.options);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteChannel(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'channels.delete', body, this.options);
|
|
||||||
}
|
|
||||||
addUserToGroup(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.invite', body, this.options);
|
|
||||||
}
|
|
||||||
getGroupInfo(roomId:any){
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
return this.http.get(environment.apiChatUrl+'groups.info', opts);
|
|
||||||
}
|
|
||||||
renameGroup(body:any){
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.rename', body, this.options);
|
|
||||||
}
|
|
||||||
removeGroupMember(body:any){
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
}
|
|
||||||
return this.http.post(environment.apiChatUrl+'groups.kick', body, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
async subscribe(roomId:any) {
|
|
||||||
|
|
||||||
let params = new HttpParams();
|
|
||||||
params = params.set("roomId", roomId);
|
|
||||||
let opts = {
|
|
||||||
headers: this.headers,
|
|
||||||
params: params
|
|
||||||
}
|
|
||||||
|
|
||||||
this.http.get(environment.apiChatUrl+'im.messages', opts).subscribe(async res => {
|
|
||||||
|
|
||||||
|
|
||||||
if (res == 502) {
|
|
||||||
// Connection timeout
|
|
||||||
// happens when the connection was pending for too long
|
|
||||||
// let's reconnect
|
|
||||||
await this.subscribe(roomId);
|
|
||||||
} else if (res != 200) {
|
|
||||||
// Show Error
|
|
||||||
//showMessage(response.statusText);
|
|
||||||
this.getRoomMessages(roomId)
|
|
||||||
// Reconnect in one second
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
||||||
await this.subscribe(roomId);
|
|
||||||
} else {
|
|
||||||
// Got message
|
|
||||||
//let message = await response.text();
|
|
||||||
this.getRoomMessages(roomId)
|
|
||||||
await this.subscribe(roomId);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
SessionStore.user.ChatData = data
|
||||||
|
SessionStore.save()
|
||||||
|
this.setheader()
|
||||||
}
|
console.log(res)
|
||||||
|
console.log(SessionStore.user.ChatData)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { ModalController, PickerController } from '@ionic/angular';
|
import { ModalController, PickerController } from '@ionic/angular';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
@@ -33,6 +34,7 @@ export class EditGroupPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.getRoomInfo();
|
this.getRoomInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { ModalController, NavParams } from '@ionic/angular';
|
import { ModalController, NavParams } from '@ionic/angular';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -57,6 +57,7 @@ export class GroupContactsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
//this.getRoomInfo();
|
//this.getRoomInfo();
|
||||||
this.loadUsers();
|
this.loadUsers();
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import { AlertController } from '@ionic/angular';
|
|||||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -74,6 +75,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
scrollToBottomBtn = false;
|
scrollToBottomBtn = false;
|
||||||
roomCountDownDate: string;
|
roomCountDownDate: string;
|
||||||
roomCountDownTime: string;
|
roomCountDownTime: string;
|
||||||
|
isAdmin = false;
|
||||||
|
|
||||||
@Input() roomId: string;
|
@Input() roomId: string;
|
||||||
@Output() closeAllDesktopComponents: EventEmitter<any> = new EventEmitter<any>();
|
@Output() closeAllDesktopComponents: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@@ -159,10 +161,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
console.log(this.roomId)
|
console.log(this.roomId)
|
||||||
this.loggedUser = this.loggedUserChat;
|
this.loggedUser = this.loggedUserChat;
|
||||||
//setTimeout(() => {
|
//setTimeout(() => {
|
||||||
this.getRoomInfo();
|
this.getRoomInfo()
|
||||||
//}, 1000);
|
//}, 1000);
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
//this.getMessageDB();
|
//this.getMessageDB();
|
||||||
@@ -399,10 +402,18 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
async getRoomInfo() {
|
async getRoomInfo() {
|
||||||
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
||||||
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
|
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
|
||||||
|
console.log('ROOM',room)
|
||||||
this.room = room['room'];
|
this.room = room['room'];
|
||||||
if (this.room.name) {
|
if (this.room.name) {
|
||||||
this.roomName = this.room.name.split('-').join(' ');
|
this.roomName = this.room.name.split('-').join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(SessionStore.user.ChatData.data.userId == this.room.u._id){
|
||||||
|
this.isAdmin = true
|
||||||
|
} else {
|
||||||
|
this.isAdmin = false
|
||||||
|
}
|
||||||
|
|
||||||
if (this.room.customFields.countDownDate) {
|
if (this.room.customFields.countDownDate) {
|
||||||
this.roomCountDownDate = this.room.customFields.countDownDate;
|
this.roomCountDownDate = this.room.customFields.countDownDate;
|
||||||
@@ -501,82 +512,84 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
async openGroupMessagesOptions() {
|
async openGroupMessagesOptions() {
|
||||||
|
const enterAnimation = (baseEl: any) => {
|
||||||
const enterAnimation = (baseEl: any) => {
|
const backdropAnimation = this.animationController.create()
|
||||||
const backdropAnimation = this.animationController.create()
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
||||||
.addElement(baseEl.querySelector('ion-backdrop')!)
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
||||||
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
||||||
|
const wrapperAnimation = this.animationController.create()
|
||||||
const wrapperAnimation = this.animationController.create()
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
||||||
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
.keyframes([
|
||||||
.keyframes([
|
{ offset: 0, opacity: '1', right: '-100%' },
|
||||||
{ offset: 0, opacity: '1', right: '-100%' },
|
{ offset: 1, opacity: '1', right: '0px' }
|
||||||
{ offset: 1, opacity: '1', right: '0px' }
|
]);
|
||||||
]);
|
|
||||||
|
return this.animationController.create()
|
||||||
return this.animationController.create()
|
.addElement(baseEl)
|
||||||
.addElement(baseEl)
|
.easing('ease-out')
|
||||||
.easing('ease-out')
|
.duration(500)
|
||||||
.duration(500)
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
||||||
.addAnimation([backdropAnimation, wrapperAnimation]);
|
}
|
||||||
}
|
|
||||||
|
const leaveAnimation = (baseEl: any) => {
|
||||||
const leaveAnimation = (baseEl: any) => {
|
return enterAnimation(baseEl).direction('reverse');
|
||||||
return enterAnimation(baseEl).direction('reverse');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/* const popover = await this.popoverController.create({
|
||||||
/* const popover = await this.popoverController.create({
|
component: MessagesOptionsPage,
|
||||||
component: MessagesOptionsPage,
|
componentProps: {
|
||||||
componentProps: {
|
roomId: this.dm._id,
|
||||||
roomId: this.dm._id,
|
},
|
||||||
},
|
cssClass: 'messages-options',
|
||||||
cssClass: 'messages-options',
|
event: ev,
|
||||||
event: ev,
|
translucent: true,
|
||||||
translucent: true,
|
});
|
||||||
});
|
return await popover.present(); */
|
||||||
return await popover.present(); */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
enterAnimation,
|
||||||
|
leaveAnimation,
|
||||||
|
component: ChatPopoverPage,
|
||||||
|
cssClass: 'model profile-modal search-submodal',
|
||||||
|
componentProps: {
|
||||||
|
roomId: this.roomId,
|
||||||
|
members: this.members,
|
||||||
|
isAdmin: this.isAdmin
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await modal.present();
|
||||||
|
modal.onDidDismiss().then(res => {
|
||||||
|
|
||||||
|
if (res.data == 'leave') {
|
||||||
|
this.getRoomInfo();
|
||||||
|
this.closeAllDesktopComponents.emit();
|
||||||
|
this.showEmptyContainer.emit();
|
||||||
|
this.wsChatMethodsService.hidingRoom(this.roomId);
|
||||||
|
}
|
||||||
|
else if (res.data == 'delete') {
|
||||||
|
this.closeAllDesktopComponents.emit();
|
||||||
|
this.showEmptyContainer.emit();
|
||||||
|
}
|
||||||
|
else if (res.data == 'cancel') {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (res.data == 'edit') {
|
||||||
|
|
||||||
|
//this.closeAllDesktopComponents.emit();
|
||||||
|
this.openEditGroupPage.emit(this.roomId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.roomName = res.data.name.split('-').join(' ');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const modal = await this.modalController.create({
|
|
||||||
enterAnimation,
|
|
||||||
leaveAnimation,
|
|
||||||
component: ChatPopoverPage,
|
|
||||||
cssClass: 'model profile-modal search-submodal',
|
|
||||||
componentProps: {
|
|
||||||
roomId: this.roomId,
|
|
||||||
members: this.members,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await modal.present();
|
|
||||||
modal.onDidDismiss().then(res => {
|
|
||||||
|
|
||||||
if (res.data == 'leave') {
|
|
||||||
this.getRoomInfo();
|
|
||||||
this.closeAllDesktopComponents.emit();
|
|
||||||
this.showEmptyContainer.emit();
|
|
||||||
this.wsChatMethodsService.hidingRoom(this.roomId);
|
|
||||||
}
|
|
||||||
else if (res.data == 'delete') {
|
|
||||||
this.closeAllDesktopComponents.emit();
|
|
||||||
this.showEmptyContainer.emit();
|
|
||||||
}
|
|
||||||
else if (res.data == 'cancel') {
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (res.data == 'edit') {
|
|
||||||
|
|
||||||
//this.closeAllDesktopComponents.emit();
|
|
||||||
this.openEditGroupPage.emit(this.roomId);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.roomName = res.data.name.split('-').join(' ');
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openSendGroupMessageOptions(ev?: any) {
|
openSendGroupMessageOptions(ev?: any) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { ModalController } from '@ionic/angular';
|
import { ModalController } from '@ionic/angular';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
@@ -42,7 +42,9 @@ export class ContactsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.loadUsers();
|
this.loadUsers();
|
||||||
|
this.chatService.refreshtoken();
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(event){
|
onChange(event){
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { AlertController, Platform } from '@ionic/angular';
|
|||||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
@@ -154,6 +155,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
|
|
||||||
this.getChatMembers();
|
this.getChatMembers();
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button (click)="leaveGroup()" class="btn-cancel" shape="round" >Sair do Grupo</button>
|
<button (click)="leaveGroup()" class="btn-cancel" shape="round" >Sair do Grupo</button>
|
||||||
<button (click)="openChangeGroupName()" class="btn-cancel" shape="round" >Alterar nome do grupo</button>
|
<button *ngIf="isAdmin" (click)="openChangeGroupName()" class="btn-cancel" shape="round" >Alterar nome do grupo</button>
|
||||||
<div class="solid"></div>
|
<div class="solid"></div>
|
||||||
<button (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round" >Cancelar</button>
|
<button (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round" >Cancelar</button>
|
||||||
<button (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
|
<button *ngIf="isAdmin" (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { ToastService } from 'src/app/services/toast.service';
|
|||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service'
|
||||||
import { SetRoomOwnerPage } from 'src/app/modals/set-room-owner/set-room-owner.page';
|
import { SetRoomOwnerPage } from 'src/app/modals/set-room-owner/set-room-owner.page';
|
||||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -16,6 +18,7 @@ export class ChatPopoverPage implements OnInit {
|
|||||||
roomId:string;
|
roomId:string;
|
||||||
room: any;
|
room: any;
|
||||||
members:any;
|
members:any;
|
||||||
|
isAdmin = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private popoverController: PopoverController,
|
private popoverController: PopoverController,
|
||||||
@@ -28,10 +31,11 @@ export class ChatPopoverPage implements OnInit {
|
|||||||
) {
|
) {
|
||||||
this.roomId = this.navParams.get('roomId');
|
this.roomId = this.navParams.get('roomId');
|
||||||
this.members = this.navParams.get('members');
|
this.members = this.navParams.get('members');
|
||||||
|
this.isAdmin = this.navParams.get('isAdmin');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
}
|
}
|
||||||
|
|
||||||
close(action:any){
|
close(action:any){
|
||||||
@@ -62,6 +66,7 @@ export class ChatPopoverPage implements OnInit {
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
roomId: this.roomId,
|
roomId: this.roomId,
|
||||||
members: this.members,
|
members: this.members,
|
||||||
|
isAdmin: this.isAdmin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
||||||
import { ChatService } from 'src/app/services/chat.service';
|
import { ChatService } from 'src/app/services/chat.service';
|
||||||
@@ -24,6 +25,7 @@ export class MessagesOptionsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.chatService.refreshtoken();
|
||||||
}
|
}
|
||||||
|
|
||||||
close(){
|
close(){
|
||||||
|
|||||||
Reference in New Issue
Block a user