mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -3,15 +3,20 @@ import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTr
|
||||
import { Observable } from 'rxjs';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
import { PermissionService } from '../services/permission.service';
|
||||
import { PermissionList } from '../models/permissionList';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class InactivityGuard implements CanActivate {
|
||||
|
||||
permissionList = new PermissionList();
|
||||
|
||||
constructor(
|
||||
private router:Router,
|
||||
private platform: Platform,
|
||||
public permissionService: PermissionService,
|
||||
){}
|
||||
|
||||
canActivate(
|
||||
@@ -19,17 +24,34 @@ export class InactivityGuard implements CanActivate {
|
||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.router.navigate(['/home/events']);
|
||||
if(this.permissionService.userPermission(this.permissionList.Agenda) || this.permissionService.userPermission(this.permissionList.Gabinete)){
|
||||
this.router.navigate(['/home/events']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Chat)){
|
||||
this.router.navigate(['/home/chat']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Actions)){
|
||||
this.router.navigate(['/home/publications']);
|
||||
}
|
||||
return false
|
||||
} else if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) {
|
||||
return true
|
||||
} else if(SessionStore.exist && !SessionStore.user.Inactivity) {
|
||||
return true
|
||||
} else {
|
||||
this.router.navigate(['/home/events']);
|
||||
}//Mobile or Tablet without session
|
||||
else {
|
||||
if(this.permissionService.userPermission(this.permissionList.Agenda) || this.permissionService.userPermission(this.permissionList.Gabinete)){
|
||||
this.router.navigate(['/home/events']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Chat)){
|
||||
this.router.navigate(['/home/chat']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Actions)){
|
||||
this.router.navigate(['/home/publications']);
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ion-tabs class="tab">
|
||||
<ion-tab-bar class="bottoms" slot="bottom">
|
||||
|
||||
<ion-tab-button tab="events" [class.active]="pathname === '/home/events'">
|
||||
<ion-tab-button *ngIf="p.userPermission([permissionList.Agenda]) || p.userPermission([permissionList.Gabinete])" tab="events" [class.active]="pathname === '/home/events'">
|
||||
<!-- <ion-icon name="home"></ion-icon> -->
|
||||
<ion-icon *ngIf="pathname != '/home/events'" class="nav-icon" src="assets/images/icons-nav-home.svg"></ion-icon>
|
||||
<ion-icon *ngIf="pathname == '/home/events'" class="nav-icon" src="assets/images/nav-hover/icons-nav-home-active.svg"></ion-icon>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { models } from 'beast-orm'
|
||||
import { AESEncrypt } from '../services/aesencrypt.service'
|
||||
|
||||
const _AESEncrypt = new AESEncrypt()
|
||||
const _AESEncrypt = new AESEncrypt()
|
||||
const { ArrayField, JsonField} = models.indexedDB.fields
|
||||
|
||||
export class MessageModel extends models.Model {
|
||||
@@ -36,10 +36,10 @@ export class DeleteMessageModel extends models.Model {
|
||||
|
||||
models.register({
|
||||
databaseName: 'chat-storage',
|
||||
type: 'indexedDB',
|
||||
type: 'indexedDB',
|
||||
version: 4,
|
||||
models: [MessageModel, DeleteMessageModel]
|
||||
})
|
||||
|
||||
|
||||
window['MessageModel'] = MessageModel
|
||||
window['MessageModel'] = MessageModel
|
||||
|
||||
@@ -395,7 +395,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const roomId = this.roomId
|
||||
let audioFile;
|
||||
this.storage.get('recordData').then((recordData) => {
|
||||
console.log(recordData);
|
||||
|
||||
audioFile = recordData;
|
||||
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||
@@ -404,6 +404,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
console.log(this.audioRecorded);
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
@@ -12,6 +12,8 @@ import { ChangeProfileService } from 'src/app/services/change-profile.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { PermissionList } from 'src/app/models/permissionList';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@@ -29,7 +31,8 @@ export class LoginPage implements OnInit {
|
||||
hasPin: boolean
|
||||
loginPreference: string
|
||||
|
||||
sessionStore = SessionStore
|
||||
sessionStore = SessionStore;
|
||||
permissionList = new PermissionList();
|
||||
|
||||
constructor(
|
||||
private notificatinsservice: NotificationsService,
|
||||
@@ -40,7 +43,8 @@ export class LoginPage implements OnInit {
|
||||
private clearStoreService: ClearStoreService,
|
||||
private changeProfileService: ChangeProfileService,
|
||||
public ThemeService: ThemeService,
|
||||
private storageservice: StorageService
|
||||
private storageservice: StorageService,
|
||||
public permissionService: PermissionService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -101,26 +105,29 @@ export class LoginPage implements OnInit {
|
||||
// login to API successfully
|
||||
if (attempt) {
|
||||
if (attempt.UserId == SessionStore.user.UserId) {
|
||||
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
await this.authService.loginChat();
|
||||
await this.authService.loginToChatWs()
|
||||
await this.authService.loginToChatWs();
|
||||
this.getToken();
|
||||
SessionStore.setInativity(true);
|
||||
|
||||
this.goback()
|
||||
this.goback();
|
||||
|
||||
} else {
|
||||
|
||||
this.clearStoreService.clear()
|
||||
SessionStore.delete()
|
||||
this.clearStoreService.clear();
|
||||
SessionStore.delete();
|
||||
window.localStorage.clear();
|
||||
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
|
||||
this.changeProfileService.run()
|
||||
this.changeProfileService.run();
|
||||
await this.authService.loginChat();
|
||||
await this.authService.loginToChatWs()
|
||||
await this.authService.loginToChatWs();
|
||||
this.getToken();
|
||||
this.router.navigateByUrl('/pin', { replaceUrl: true });
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -141,7 +148,15 @@ export class LoginPage implements OnInit {
|
||||
if(pathName) {
|
||||
this.router.navigate([pathName]);
|
||||
} else {
|
||||
this.router.navigate(['/home/events']);
|
||||
if(this.permissionService.userPermission(this.permissionList.Agenda) || this.permissionService.userPermission(this.permissionList.Gabinete)){
|
||||
this.router.navigate(['/home/events']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Chat)){
|
||||
this.router.navigate(['/home/chat']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Actions)){
|
||||
this.router.navigate(['/home/publications']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ export class AuthService {
|
||||
let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||
|
||||
if(responseChat) {
|
||||
|
||||
console.log('Login to Rocket chat OK', responseChat);
|
||||
this.ValidatedUserChat = responseChat;
|
||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||
|
||||
@@ -187,6 +187,7 @@ export class MessageService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
|
||||
|
||||
this.WsChatService.send(params).then(
|
||||
@@ -318,6 +319,7 @@ export class MessageService {
|
||||
|
||||
async save() {
|
||||
const message = this.getChatObj()
|
||||
console.log(message);
|
||||
|
||||
await MessageModel.update(message)
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.storage.get('fileName').then((fileName) => {
|
||||
this.lastAudioRecorded = fileName;
|
||||
})
|
||||
|
||||
|
||||
this.storage.get('recordData').then((recordData) => {
|
||||
console.log(recordData);
|
||||
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||
@@ -265,7 +265,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
});
|
||||
} catch (error) {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
startRecording() {
|
||||
@@ -389,6 +389,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
console.log(this.audioRecorded);
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
<div class="d-flex flex-1 pr-20 pl-50">
|
||||
|
||||
<div class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/events')"
|
||||
<div *ngIf="p.userPermission([permissionList.Agenda]) || p.userPermission([permissionList.Gabinete])" class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/events')"
|
||||
[class.active]="locationPathname() == '/home/events'">
|
||||
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="font-40" src='assets/images/icons-nav-home-active-black.svg'></ion-icon>
|
||||
|
||||
Reference in New Issue
Block a user