check notification and inactivity

This commit is contained in:
Peter Maquiran
2023-09-28 09:02:15 +01:00
parent b46d179dfe
commit 8de8a35bfc
11 changed files with 93 additions and 60 deletions
+4 -7
View File
@@ -14,9 +14,6 @@ export class AuthGuard implements CanActivate {
constructor(
private router:Router,
public p: PermissionService,
private RouteService: RouteService,
private FirstEnterService: FirstEnterService,
private alertController: AlertController,
){}
canActivate(
@@ -31,7 +28,7 @@ export class AuthGuard implements CanActivate {
} else {
this.router.navigate(['/']);
}
return false
} else {
@@ -39,15 +36,15 @@ export class AuthGuard implements CanActivate {
if(pathname.startsWith('/home/agenda')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
} else if ( pathname.startsWith('/home/gabinete-digital')) {
if(this.p.userPermission(this.p.permissionList.Gabinete.access)) {
return true;
+3 -4
View File
@@ -10,17 +10,16 @@ import { FirstEnterService } from 'src/app/services/first-enter.service'
providedIn: 'root'
})
export class LoginGuard implements CanActivate {
constructor(
private router:Router,
constructor(
private router:Router,
private platform: Platform,
private RouteService: RouteService,
private FirstEnterService: FirstEnterService ) {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
// enter app
this.FirstEnterService.enter()
+14 -14
View File
@@ -94,7 +94,7 @@ export class LoginPage implements OnInit {
buttons: ['OK']
});
await alert.present();
}
@@ -121,12 +121,10 @@ export class LoginPage implements OnInit {
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
const data = await this.authService.loginContenteProduction(this.userattempt, {saveSession: true})
loader.remove()
console.log('attempt', attempt)
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
@@ -135,23 +133,24 @@ export class LoginPage implements OnInit {
this.changeProfileService.run();
if(attempt.ChatData) {
await this.authService.loginToChatWs();
this.ChatService.setheader()
this.ChatSystemService.loadChat();
}
this.changeProfileService.runLogin();
this.getToken();
SessionStore.setInativity(true);
SessionStore.hasPassLogin = true;
this.goback();
} else {
this.RochetChatConnectorService.logout();
this.clearStoreService.clear();
this.ChatSystemService.clearChat();
@@ -165,9 +164,9 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt);
CPSession.save(data)
this.changeProfileService.run();
if(attempt.ChatData) {
await this.authService.loginToChatWs();
this.ChatService.setheader();
@@ -182,14 +181,15 @@ export class LoginPage implements OnInit {
} else {
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
} else {
this.router.navigate(['/home/events']);
}
SessionStore.hasPassLogin = true;
}
}/*
}/*
else{
this.toastService._badRequest('Ocorreu um problema por favor valide o username e password');
} */
@@ -9,7 +9,7 @@ import { ViewPublicationsPageRoutingModule } from './view-publications-routing.m
import { ViewPublicationsPage } from './view-publications.page';
import { Attributes, IntersectionObserverHooks, LazyLoadImageModule, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
import { ShowMorePageModule } from 'src/app/shared/publication/view-publications/show-more/show-more.module'
export class LazyLoadImageHooks extends IntersectionObserverHooks {
setup(attributes: Attributes) {
attributes.offset = 10;
@@ -26,7 +26,9 @@ setup(attributes: Attributes) {
IonicModule,
ViewPublicationsPageRoutingModule,
LazyLoadImageModule
LazyLoadImageModule,
//page
ShowMorePageModule,
],
exports: [ViewPublicationsPage],
declarations: [ViewPublicationsPage],
@@ -26,17 +26,15 @@
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<ion-refresher-content>
</ion-refresher-content>
</ion-refresher>
</ion-refresher>
<div class="main-container background-white height-100 overflow-y-auto viewport-font-size">
<ion-content *ngIf="publicationFolderService.FolderDetails[folderId]">
<p class="px-20 item-content-detail font-14-em">{{publicationFolderService.FolderDetails[folderId].Detail}}</p>
<ion-card *ngFor="let publication of publicationFolderService.publicationList[folderId] let i = index"
(click)="goToPublicationDetail(publication.DocumentId, publication.ProcessId)"
>
<ion-card *ngFor="let publication of publicationFolderService.publicationList[folderId] let i = index">
<ion-card-content>
<div class="post-img">
<div class="post-img" (click)="goToPublicationDetail(publication.DocumentId, publication.ProcessId)">
<img [lazyLoad]="publication.FileBase64">
</div>
<div class="post-content">
@@ -47,7 +45,10 @@
<div class="post-data font-13-em">{{publication.DatePublication | date: 'dd-MM-yyyy HH:mm'}}</div>
</div>
<div class="post-description ">
<pre class="text font-14-em">{{publication.Message}}</pre>
<!-- <pre class="text font-14-em">{{publication.Message}}</pre> -->
<app-show-more
[text]=publication.Message
></app-show-more>
</div>
</div>
</ion-card-content>
@@ -3,7 +3,7 @@
:host{
background: transparent;
padding: 0!important;
}
}
ion-content{
--background: transparent;
--border-radius: 30px;
@@ -123,15 +123,23 @@
padding: 0!important;
}
.post-img{
width: 100%;
//height: 400px;
margin: 0 auto;
border-radius: 0px!important;
overflow: hidden;
background-color: white;
display: flex;
justify-content: center;
width: 100%;
height: 100%;
max-height: 400px;
min-height: 350px;
min-width: 350px;
margin: 5px auto;
border-radius: 0px !important;
overflow: hidden;
background-color: white;
display: flex;
justify-content: center;
align-items: center;
background: black;
}
.post-img img{
height: 100%;
@@ -103,6 +103,7 @@ export class NotificationsService {
// this.storenotification(notification)
}
);
@@ -199,6 +199,7 @@ export class NotificationsService {
(notification: ActionPerformed) => {
this.active = true
console.log('NOtification Listener Backgroud', notification)
/* this.DataArray.push(notification.notification)
this.storageService.store("Notifications", this.DataArray)
@@ -54,6 +54,7 @@
</div>
<div class="d-block justify-space-between">
<!-- <pre *ngIf="msg.delate == false" class="message-box text ma-0 font-13-rem" style="font-size: 0.8125rem !important;" >{{msg.msg}} </pre> -->
<ion-label *ngIf="msg.delate == false" class="message-box">{{msg.msg}} </ion-label>
<ion-label *ngIf="msg.delate == true" class="flex-0">Apagou a mensagem</ion-label>
+24 -7
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, NgZone } from '@angular/core';
import { StorageService } from '../services/storage.service';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
@@ -13,6 +13,7 @@ export class NotificationHolderService {
constructor(
private storageService: StorageService,
private zone: NgZone,
) {
try {
@@ -106,19 +107,32 @@ export class NotificationHolderService {
}
}
if(this.notificationExist(notificationObject)) {
if(!this.notificationExist(notificationObject)) {
this._notificationList.push(notificationObject)
this.reverse()
this.save()
this.zone.run(()=>{
this.reverse()
this.save()
})
} else {
console.log('duplicate', notification, this._notificationList)
}
}
notificationExist(notificationObject) {
return this._notificationList.find(item => {
const notification = this._notificationList.find(item => {
return item.id === notificationObject.id;
});
if(notification?.id) {
return true
} else {
return false
}
}
@@ -136,8 +150,11 @@ export class NotificationHolderService {
return e.index != notification.index
})
this.reverse()
this.save()
this.zone.run(()=>{
this.save()
this.reverse()
})
}
}
+16 -10
View File
@@ -18,13 +18,13 @@ class SessionService {
permission = {
Agenda: {
access: false
access: false
},
Gabinete: {
access: false,
pr_tasks: false,
access: false,
pr_tasks: false,
md_tasks: false,
aprove_event: false
aprove_event: false
},
Actions: {
access : false,
@@ -40,12 +40,18 @@ class SessionService {
}
}
hasPassLogin = false
constructor() {
this.keyName = (SHA1("SessionService")).toString()
let restore = this.getDataFromLocalStorage()
this._user = restore.user || new UserSession()
if(this._user.LoginPreference == 'Pin') {
this._user.Inactivity = false
}
}
getDataFromLocalStorage() {
@@ -138,7 +144,7 @@ class SessionService {
if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
}
@@ -149,7 +155,7 @@ class SessionService {
if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
}
@@ -157,13 +163,13 @@ class SessionService {
clearPermission() {
this.permission = {
Agenda: {
access: false
access: false
},
Gabinete: {
access: false,
pr_tasks: false,
access: false,
pr_tasks: false,
md_tasks: false,
aprove_event: false
aprove_event: false
},
Actions: {
access : false,