update the branch

This commit is contained in:
EQUILIBRIUM\hirondino.van-dunem
2022-06-15 15:36:20 +01:00
31 changed files with 33535 additions and 1249 deletions
-3
View File
@@ -19,9 +19,6 @@ export class LoginGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
// console.log(SessionStore.exist, SessionStore.user.Inactivity, SessionStore.user.LoginPreference)
console.log(SessionStore.exist, SessionStore.user.Inactivity, SessionStore.user.LoginPreference)
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
this.router.navigate(['/home/events']);
return false
@@ -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 { environment } from 'src/environments/environment';
import { ThemeService } from 'src/app/services/theme.service'
import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-chat-options-features',
@@ -47,7 +48,7 @@ export class ChatOptionsFeaturesPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
}
notImplemented() {
@@ -117,8 +118,6 @@ export class ChatOptionsFeaturesPage implements OnInit {
this.chatService.sendMessage(body).subscribe(res=> {
//
},(error) => {
});
//
};
@@ -144,8 +143,6 @@ export class ChatOptionsFeaturesPage implements OnInit {
this.chatService.sendMessage(body).subscribe(res=> {
},(error) => {
});
}
@@ -33,7 +33,7 @@ export class SetRoomOwnerPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
}
async close(){
+1 -1
View File
@@ -128,7 +128,7 @@
<ion-label>{{group.name.split('-').join(' ')}}</ion-label>
</div>
<div class="item-date" [class.item-date-active]="group.id ==idSelected" *ngIf="group.lastMessage && !group.customFields.countDownDate">{{group.duration}}</div>
<div class="item-date" [class.item-date-active]="group.id ==idSelected" *ngIf="group.customFields.countDownDate">{{countDownDate(group.customFields.countDownDate, group.id)}}</div>
<div class="item-date" [class.item-date-active]="group.id ==idSelected" *ngIf="group.customFields.countDownDate">{{group.countDownTime}}</div>
</div>
<div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.id ==idSelected">
<div class="item-message" *ngIf="group.otherUserType == false">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div>
+16 -44
View File
@@ -1,4 +1,4 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
import {
Component,
OnInit,
@@ -44,7 +44,6 @@ export class ChatPage implements OnInit {
X_Auth_Token: any;
loggedUser: any;
/* Set segment variable */
segment: string;
allGroups: any[];
privateGroups: any[];
@@ -90,8 +89,6 @@ export class ChatPage implements OnInit {
"support": ["1"]
};
/* Fim websockets variables*/
loggedUserChat: any;
hideRefreshBtn = true;
@@ -128,11 +125,22 @@ export class ChatPage implements OnInit {
this.showLoader = true;
//this.load()
}
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.authService.userData$.subscribe((res: any) => {
@@ -497,16 +505,11 @@ export class ChatPage implements OnInit {
}
async getChatMembers() {
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res => {
//
this.transformDataUserList(res['users'])
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
//
}*/
});
}
@@ -563,23 +566,6 @@ export class ChatPage implements OnInit {
})
/* this.sqlservice.getAllChatUsers().then((userslist: any) => {
let chatusersArray = [];
userslist.forEach(element => {
let userListDB = {
_id: element.Id,
name: element.Name,
username: element.Username
}
chatusersArray.push(userListDB);
});
this.dmUsers = chatusersArray.filter(data => data.username != this.loggedUserChat.me.username);
}) */
}
}
@@ -635,16 +621,7 @@ export class ChatPage implements OnInit {
this.privateGroups = res.groups;
/* this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{
this.publicGroups = res.channels; */
//let all = this.privateGroups.concat(this.publicGroups);
/* this.allGroups = this.privateGroups.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
}); */
//
/* }); */
if (this.route.url != "/home/chat") {
//
}
@@ -735,10 +712,5 @@ export class ChatPage implements OnInit {
modal.onDidDismiss();
}
// this.crop.crop('path/to/image.jpg', {quality: 75})
// .then(
// newImage =>
// error => console.error('Error cropping image', error)
// );
}
@@ -1,3 +1,4 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PickerController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
@@ -28,6 +29,7 @@ export class EditGroupPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
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 { ModalController, NavParams } from '@ionic/angular';
import * as _ from 'lodash';
@@ -56,6 +56,7 @@ export class GroupContactsPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
this.loadUsers();
this.getMembers();
@@ -31,6 +31,7 @@ import { MessageService } from 'src/app/services/chat/message.service';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-group-messages',
@@ -132,6 +133,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
ngOnInit() {
this.chatService.refreshtoken();
this.loggedUser = this.loggedUserChat;
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 { ModalController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
@@ -43,6 +43,7 @@ export class ContactsPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
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 { DomSanitizer } from '@angular/platform-browser';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorResponse } from '@angular/common/http';
const IMAGE_DIR = 'stored-images';
@@ -156,6 +157,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
ngOnInit() {
this.chatService.refreshtoken();
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
})
@@ -43,6 +43,7 @@ export class NewGroupPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
console.log(this.documents)
}
@@ -28,15 +28,14 @@
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
min="{{minDate}}"
max="2025"
class="d-block d-md-none">
max="2025">
</ion-datetime>
<mat-form-field appearance="none" class="width-100 date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date*"
[formControl]="dateControlStart"
[formControl]="folder.DateBegin"
[min]="minDate"
[disabled]="disabled"
>
@@ -68,18 +67,18 @@
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
min="{{minDate}}"
max="2022">
max="2025">
</ion-datetime>
<mat-form-field class="width-100 date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date*"
[formControl]="dateControlEnd"
[min]="minDate"
[formControl]="folder.DateEnd"
[min]="maxDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker1
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #fim
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute"
+1 -1
View File
@@ -58,7 +58,7 @@ export class AlertService {
handler: () => {
//const loader = this.toastService.loading();
this.wsChatMethodsService.deleteMessage(msgId).then(()=>{
this.wsChatMethodsService.deleteMessage(msgId).then(() => {
room.deleteMessage(msgId)
})
//this.wsChatMethodsService.subscribeToRoomUpdate(room._id, room);
+345 -315
View File
@@ -14,26 +14,338 @@ import { SessionStore } from '../store/session.service';
})
export class ChatService {
headers: HttpHeaders;
options:any;
options1:any;
X_User_Id:any;
X_Auth_Token:any;
loggedUserChat:any;
options: any;
options1: any;
X_User_Id: any;
X_Auth_Token: any;
loggedUserChat: any;
bindOnMessage: any;
constructor(
private http:HttpClient,
private http: HttpClient,
private httpService: HttpService,
private authService: AuthService,
private storage: Storage,
private storageService:StorageService,
private storageService: StorageService,
public p: PermissionService) {
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
this.loggedUserChat = authService.ValidatedUserChat;
this.headers = new HttpHeaders();
this.setheader()
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-Auth-Token', SessionStore.user.ChatData.data.authToken);
@@ -41,313 +353,31 @@ export class ChatService {
headers: this.headers,
};
}
}
} catch (error) {
console.log(error)
}
}
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(){
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);
refreshtoken() {
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
let options = {
headers: this.headers
};
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
}
})
}
}
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
console.log(res)
console.log(SessionStore.user.ChatData)
});
}
}
+60 -6
View File
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { MessageService } from 'src/app/services/chat/message.service';
import { showDateDuration } from 'src/plugin/showDateDuration';
import { ToastsService } from '../toast.service';
import { chatHistory } from 'src/app/models/chatMethod';
import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular';
@@ -16,13 +15,14 @@ import { environment } from 'src/environments/environment';
import { ChatService } from 'src/app/services/chat.service';
import { NfService } from 'src/app/services/chat/nf.service';
import { v4 as uuidv4 } from 'uuid'
import { ChatStorageService } from './chat-storage.service'
import { ChatMethodsService } from './chat-methods.service'
import { DeleteMessageModel, MessageModel } from '../../models/beast-orm'
import { AESEncrypt } from '../aesencrypt.service'
import { ChatStorageService } from './chat-storage.service';
import { ChatMethodsService } from './chat-methods.service';
import { DeleteMessageModel, MessageModel } from '../../models/beast-orm';
import { AESEncrypt } from '../aesencrypt.service';
import { IncomingChatMessage, ChatMessageInterface, falseTypingMethod } from 'src/app/models/message.model';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { ConnectionStatus, NetworkServiceService} from 'src/app/services/network-service.service';
import { WsChatMethodsService } from './ws-chat-methods.service';
@Injectable({
providedIn: 'root'
@@ -52,6 +52,7 @@ export class RoomService {
members = []
u
sessionStore = SessionStore
countDownTime = ''
scrollDown = () => { }
@@ -80,7 +81,8 @@ export class RoomService {
private ChatMethodsService: ChatMethodsService,
private AESEncrypt: AESEncrypt,
private AttachmentsService: AttachmentsService,
private NetworkServiceService: NetworkServiceService
private NetworkServiceService: NetworkServiceService,
private wsChatMethodsService: WsChatMethodsService
) {
this.NativeNotificationService.askForPermission()
@@ -157,6 +159,58 @@ export class RoomService {
this.calDateDuration()
this.restoreMessageFromDB()
if(this.customFields?.countDownDate) {
this.countDownDate(this.customFields.countDownDate);
}
}
countDownDate(date) {
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0) {
this.deleteRoom()
} else {
setTimeout(() => {
this.countDownDate(date)
}, 1000)
}
}
addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
deleteRoom() {
this.countDownTime = "Expired";
let body = { "roomId": this.id }
this.chatService.getRoomInfo(this.id).subscribe(room=>{
if(this.t === 'p') {
this.chatService.deleteGroup(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(this.id)
});
}
else {
this.chatService.deleteChannel(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(this.id)
});
}
});
}
@@ -60,7 +60,7 @@ export class WsChatMethodsService {
private ChatMethodsService:ChatMethodsService,
private AESEncrypt: AESEncrypt,
private AttachmentsService:AttachmentsService,
private NetworkServiceService: NetworkServiceService
private NetworkServiceService: NetworkServiceService,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
@@ -106,14 +106,14 @@ export class WsChatMethodsService {
}
async ReLoadChat() {
await this.restoreRooms()
await this.restoreRooms();
await this.getAllRooms();
this.subscribeToRoom()
this.subscribeToRoom();
//
await this.getUser()
this.getUserStatus()
await this.getUser();
this.getUserStatus();
}
clearChat() {
@@ -321,11 +321,11 @@ export class WsChatMethodsService {
members: roomData.members
}
let roomId = this.getRoomId(roomData)
let roomId = this.getRoomId(roomData);
// create room
if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService , this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService)
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService , this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this)
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
@@ -365,10 +365,7 @@ export class WsChatMethodsService {
deleteRoom(roomId) {
delete this.group[roomId];
const index = this._group.findIndex((e)=> e.id == roomId);
this._group = this._group.splice(index, 1);
this._group = this._group.filter((e)=> e.id != roomId);
}
roomExist(roomId) {
@@ -463,7 +460,7 @@ export class WsChatMethodsService {
}
addRoomOwner(roomid, userId){
addRoomOwner(roomid, userId) {
return this.WsChatService.addRoomOwner(roomid, userId);
}
+38 -37
View File
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
import { WsChatMethodsService } from '../chat/ws-chat-methods.service';
@Injectable({
providedIn: 'root'
@@ -8,14 +9,13 @@ export class TimeService {
countDownTime: any;
room: any;
constructor(private chatService: ChatService) { }
constructor(private chatService: ChatService,
public wsChatMethodsService: WsChatMethodsService,) { }
showDateDuration(start:any){
showDateDuration(start:any) {
let end;
end = new Date();
start = new Date(start);
let customizedDate;
const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60);
@@ -26,51 +26,51 @@ export class TimeService {
const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
if(totalDays == 0){
if(start.getDate() == new Date().getDate()){
if(totalDays == 0) {
if(start.getDate() == new Date().getDate()) {
let time = start.getHours() + ":" + this.addZero(start.getUTCMinutes());
return time;
}
else{
else {
return 'Ontem';
}
}
else{
else {
let date = this.addZero(start.getDate()) + "/" + this.addZero(start.getMonth()+1) + "/" + start.getFullYear();
return date;
}
}
countDownDate(date:any, roomId:string){
/* let timer = setInterval(() =>{ */
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0){
//clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
if(difference < 0){
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
});
}
});
}
//})
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
});
}
});
}
return this.countDownTime;
}
@@ -84,7 +84,7 @@ export class TimeService {
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0){
if(difference < 0) {
clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
@@ -93,12 +93,13 @@ export class TimeService {
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(roomId)
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(roomId)
});
}
});
@@ -1,3 +1,4 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ModalController, PickerController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
@@ -33,6 +34,7 @@ export class EditGroupPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
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 { ModalController, NavParams } from '@ionic/angular';
import * as _ from 'lodash';
@@ -57,6 +57,7 @@ export class GroupContactsPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
//this.getRoomInfo();
this.loadUsers();
@@ -34,6 +34,7 @@ import { AlertController } from '@ionic/angular';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
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;
roomCountDownDate: string;
roomCountDownTime: string;
isAdmin = false;
@Input() roomId: string;
@Output() closeAllDesktopComponents: EventEmitter<any> = new EventEmitter<any>();
@@ -159,10 +161,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
ngOnInit() {
this.chatService.refreshtoken();
console.log(this.roomId)
this.loggedUser = this.loggedUserChat;
//setTimeout(() => {
this.getRoomInfo();
this.getRoomInfo()
//}, 1000);
this.getChatMembers();
//this.getMessageDB();
@@ -399,10 +402,18 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async getRoomInfo() {
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
console.log('ROOM',room)
this.room = room['room'];
if (this.room.name) {
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) {
this.roomCountDownDate = this.room.customFields.countDownDate;
@@ -501,82 +512,84 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
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');
}
/* 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 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');
}
/* 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,
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) {
@@ -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 { ModalController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
@@ -42,7 +42,9 @@ export class ContactsPage implements OnInit {
}
ngOnInit() {
this.loadUsers();
this.chatService.refreshtoken();
}
onChange(event){
@@ -31,6 +31,7 @@ import { AlertController, Platform } from '@ionic/angular';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorResponse } from '@angular/common/http';
const IMAGE_DIR = 'stored-images';
@@ -154,6 +155,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
ngOnInit() {
this.chatService.refreshtoken();
this.scrollToBottom();
this.getChatMembers();
@@ -7,9 +7,9 @@
</div>
<div class="buttons">
<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>
<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 (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round" >Cancelar</button>
<button *ngIf="isAdmin" (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
</div>
</ion-content>
@@ -5,6 +5,8 @@ import { ToastService } from 'src/app/services/toast.service';
import { ThemeService } from 'src/app/services/theme.service'
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 { HttpErrorResponse } from '@angular/common/http';
import { SessionStore } from 'src/app/store/session.service';
@Component({
@@ -16,6 +18,7 @@ export class ChatPopoverPage implements OnInit {
roomId:string;
room: any;
members:any;
isAdmin = false;
constructor(
private popoverController: PopoverController,
@@ -28,10 +31,11 @@ export class ChatPopoverPage implements OnInit {
) {
this.roomId = this.navParams.get('roomId');
this.members = this.navParams.get('members');
this.isAdmin = this.navParams.get('isAdmin');
}
ngOnInit() {
this.chatService.refreshtoken();
}
close(action:any){
@@ -62,6 +66,7 @@ export class ChatPopoverPage implements OnInit {
componentProps: {
roomId: this.roomId,
members: this.members,
isAdmin: this.isAdmin
}
});
await modal.present();
@@ -79,9 +84,6 @@ export class ChatPopoverPage implements OnInit {
let res:any = await this.wsChatMethodsService.leaveRoom(this.roomId);
this.wsChatMethodsService.deleteRoom(this.roomId)
if(res.error){
if(res.error.error = "error-you-are-last-owner"){
@@ -101,55 +103,7 @@ export class ChatPopoverPage implements OnInit {
}
this.close('leave');
//this.wsChatMethodsService.subscribeToRoomUpdate(this.roomId, res.result);
/* this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.leaveGroup(body).subscribe(res=>{
this.close('leave');
},
(e)=>{
if(e.error.errorType = "error-you-are-last-owner"){
this.toastService._badRequest("Você é o último administrador do grupo. Por favor, defina o novo administrador antes de sair da grupo.");
this.close('cancel');
this.setRoomOwner();
}
else{
this.toastService._badRequest("Não foi possível sair do grupo");
this.close('cancel');
}
},
()=>{
//loader.remove()
});
}
else{
this.chatService.leaveChannel(body).subscribe(res=>{
this.close('leave');
},
(e)=>{
if(e.error.errorType = "error-you-are-last-owner"){
this.toastService._badRequest("Você é o último administrador do grupo. Por favor, defina o novo administrador antes de sair da grupo.");
this.close('cancel');
}
else{
this.toastService._badRequest("Não foi possível sair do grupo");
this.close('cancel');
}
},
()=>{
//loader.remove()
});
}
}); */
}
//Delete
@@ -160,12 +114,12 @@ export class ChatPopoverPage implements OnInit {
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(this.roomId)
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(this.roomId)
});
}
});
@@ -1,3 +1,4 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
@@ -24,6 +25,7 @@ export class MessagesOptionsPage implements OnInit {
}
ngOnInit() {
this.chatService.refreshtoken();
}
close(){
@@ -28,15 +28,14 @@
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
min="{{minDate}}"
max="2025"
class="d-block d-md-none">
max="2025">
</ion-datetime>
<mat-form-field appearance="none" class="width-100 date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date*"
[formControl]="dateControlEnd"
[(ngModel)]="folder.DateBegin"
[min]="minDate"
[disabled]="disabled"
>
@@ -67,19 +66,19 @@
displayFormat="D MMM YYYY H:mm"
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
min="{{minDate}}"
max="2022">
min="{{endMinDate}}"
max="2025">
</ion-datetime>
<mat-form-field appearance="none" class="width-100 date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date*"
[formControl]="dateControlEnd"
[min]="minDate"
[(ngModel)]="folder.DateEnd"
[min]="endMinDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker1
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #fim
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute"
@@ -87,6 +87,9 @@ export class EditActionPage implements OnInit {
}
async save() {
this.injectValidation();
this.runValidation();
let body = {
ProcessId: this.folderId,
Description: this.folder.Description,
@@ -95,7 +98,7 @@ export class EditActionPage implements OnInit {
DateEnd: this.folder.DateEnd,
ActionType: this.folder.ActionType,
}
console.log(this.folder.DateEnd);
const loader = this.toastService.loading()