This commit is contained in:
Peter Maquiran
2022-02-02 20:18:45 +01:00
17 changed files with 101 additions and 53 deletions
+4 -2
View File
@@ -214,11 +214,13 @@ export class ProfilePage implements OnInit {
}
logout() {
SessionStore.setInativity(false)
this.authService.logout()
/* SessionStore.setInativity(false)
SessionStore.setUrlBeforeInactivity(this.router.url)
setTimeout(() => {
this.router.navigateByUrl('/', { replaceUrl: true });
}, 100)
}, 100) */
}
+1 -1
View File
@@ -228,7 +228,7 @@
<div class="calendar-title-container px-20 d-none d-md-flex" *ngIf="loggeduser.Profile == 'MDGPR'">
<div class="calendar-title-description flex-grow-1 text-grey d-flex justify-center align-center">
<div>Meu Calendário</div>
<div>Calendário do MDGPR</div>
</div>
<div class="calendar-title-description text-black align-center">
<div class="flex-grow-1 text-grey d-flex justify-center align-center">
@@ -32,7 +32,7 @@
Calendário do Presidente da República
</mat-option>
<mat-option value="MDGPR">
Meu calendário
Calendário do MDGPR
</mat-option>
</mat-select>
@@ -16,7 +16,7 @@
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
<ion-segment-button value="MDGPR">
Meu calendário
Calendário do MDGPR
</ion-segment-button>
<ion-segment-button value="PR">
Presidente da República
@@ -1,5 +1,4 @@
<ion-header class="ion-no-border">
<app-header></app-header>
</ion-header>
<ion-content>
@@ -1,9 +1,8 @@
:host{
}
ion-content{
--background: transparent;
transform: translate3d(0, 5px, 0);
--border-radius: 30px;
}
ion-footer{
@@ -89,4 +88,4 @@
.post-description{
margin: 0 auto;
margin-bottom: 35px;
}
}
+27 -8
View File
@@ -11,6 +11,7 @@ import { SessionStore } from '../store/session.service';
import { AESEncrypt } from '../services/aesencrypt.service';
import { CookieService } from 'ngx-cookie-service';
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
@@ -31,7 +32,8 @@ export class AuthService {
public alertController: AlertController,
private aesencrypt: AESEncrypt,
private cookieService: CookieService,
private WsChatService: WsChatService) {
private WsChatService: WsChatService,
private router: Router,) {
this.headers = new HttpHeaders();
@@ -101,12 +103,9 @@ export class AuthService {
}
}
logout() {
this.ValidatedUser = null;
}
//Login to rocketChat server
async loginChat(user: UserForm) {
const expireDate = new Date(new Date().getTime() + 60*1000);
let postData = {
"user": user.username,
"password": user.password,
@@ -128,13 +127,14 @@ export class AuthService {
}, 1)
console.log('Login to Rocket chat OK');
this.ValidatedUserChat = responseChat;
localStorage.setItem('userChat', JSON.stringify(responseChat));
this.storageService.store(AuthConnstants.AUTH, responseChat);
this.autologout(10000);
return true;
}
else{
console.log('Network error');
@@ -143,6 +143,25 @@ export class AuthService {
}
}
autologout(expirationDate:number){
setTimeout(()=>{
this.logout();
}, expirationDate)
}
logout() {
this.ValidatedUser = null;
localStorage.removeItem('userChat');
SessionStore.setInativity(false)
SessionStore.setUrlBeforeInactivity(this.router.url)
setTimeout(() => {
this.router.navigateByUrl('/', { replaceUrl: true });
}, 100)
}
//Get user data from RocketChat | global object
getUserData(){
this.storageService.get(AuthConnstants.AUTH).then(res=>{
+5 -5
View File
@@ -109,8 +109,8 @@ export class RoomService {
}
this.addMessageDB(ChatMessage)
}
}
}
)
@@ -188,7 +188,7 @@ export class RoomService {
if(message._id == id) {
messages.splice(index, 1)
}
})
this.storage.set('chatmsg' + this.id, messages).then((value) => {
@@ -308,12 +308,12 @@ export class RoomService {
open() {
// this.typing(this.message)
}
leave(rid?) {
this.WsChatService.leaveRoom(this.id)
}
isJson(str) {
try {
JSON.parse(str);
@@ -409,7 +409,7 @@ export class RoomService {
private fix_updatedAt(message) {
if (message.result) {
console.log('FIX UPDATE ', message.result)
//console.log('FIX UPDATE ', message.result)
message.result._updatedAt = message.result._updatedAt['$date']
} else if(message._updatedAt.hasOwnProperty('$date')) {
// console.log('FIX UPDATE 11', message)
@@ -156,11 +156,11 @@ export class WsChatMethodsService {
/**
* @description when a new room is create, needs to subtribe in order to receive updates
* @param id
* @param roomData
* @param id
* @param roomData
*/
subscribeToRoomUpdate(id, roomData) {
this.defaultSubtribe(id)
this.prepareRoom(roomData);
@@ -185,10 +185,10 @@ export class WsChatMethodsService {
})
}
/**
* @description create a representation of an room in these instance this.dm, this.group ...
* @param roomData
* @description create a representation of an room in these instance this.dm, this.group ...
* @param roomData
*/
prepareRoom(roomData) {
let room:RoomService;
@@ -237,12 +237,12 @@ export class WsChatMethodsService {
* @param id user ID
*/
private getUserStatus(id?:string) {
this.WsChatService.getUserStatus((d) => {
const username = d.fields.args[0][1]
const statusNum = d.fields.args[0][2]
const statusText = this.statusNumberToText(statusNum)
const user = this.getUserByName(username)
@@ -261,8 +261,8 @@ export class WsChatMethodsService {
/**
* @description convert rocketchat statues num to readable string
* @param text
* @returns
* @param text
* @returns
*/
statusNumberToText(text) {
if(text == '0') {
@@ -278,7 +278,7 @@ export class WsChatMethodsService {
return "busy"
}
}
deleteMessage(id?) {
return this.WsChatService.deleteMessage(id);
@@ -362,5 +362,9 @@ export class WsChatMethodsService {
this.users = user
}
getUserOfRoom(roomId){
return this.WsChatService.getUserOfRoom(roomId);
}
}
+34 -5
View File
@@ -119,6 +119,35 @@ export class WsChatService {
});
}
getUserOfRoom(roomId) {
const requestId = uuidv4()
const message = {
"msg": "method",
"method": "getUsersOfRoom",
"id": requestId,
"params": [
roomId,
false,
{
"limit": 100,
"skip": 0
} ]
}
this.ws.send({message, requestId})
return new Promise<Rooms>((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId) { // same request send
resolve(message)
return true
}
}})
});
}
logout() {
this.isLogin = false
this.ws.connected = false
@@ -360,7 +389,7 @@ export class WsChatService {
}
})
}
loadHistory(roomId, limit: number = 50) {
@@ -593,7 +622,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
},
onopen:()=> {
this.ws.connected = true
console.log('================== welcome to socket server =====================')
this.ws.wsMsgQueue()
@@ -602,13 +631,13 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
for (const [key, value] of Object.entries(this.wsCallbacks)) {
if(value.type== 'reConnect') {
const dontRepeat = value.funx()
if(dontRepeat) {
delete this.wsCallbacks[key]
}
}
}
}
+2 -8
View File
@@ -299,10 +299,10 @@ export class FileService {
loader.remove();
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
});
});
}
});
}
@@ -386,12 +386,6 @@ export class FileService {
accept: ['image/apng', 'image/jpeg', 'image/png']
})
setInterval(() => {
console.log(input.value)
}, 550)
input.onchange = async () => {
//alert('Onchange AQUI')
@@ -11,7 +11,7 @@
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
<ion-segment-button value="MDGPR">
Meu calendário
Calendário do MDGPR
</ion-segment-button>
<ion-segment-button value="PR">
Presidente da República
@@ -43,7 +43,7 @@
Calendário do Presidente da República
</mat-option>
<mat-option value="MDGPR">
Meu calendário
Calendário do MDGPR
</mat-option>
</mat-select>
@@ -68,7 +68,7 @@
</div>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
<span class="time">{{showDateDuration(msg.duration)}}</span>
</div>
<div>
<div *ngIf="msg.attachments" class="message-attachments">
@@ -10,7 +10,7 @@
<ion-toolbar>
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
<ion-segment-button value="MDGPR">
Meu calendário
Calendário do MDGPR
</ion-segment-button>
<ion-segment-button value="PR">
Presidente da República
@@ -66,7 +66,9 @@ export class ChatPopoverPage implements OnInit {
});
await modal.present();
modal.onDidDismiss().then((res)=>{
this.leaveGroup();
if(res.data == 'success'){
this.leaveGroup();
}
});
}