mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add inactivity
This commit is contained in:
@@ -16,11 +16,11 @@ export class InactivityGuard implements CanActivate {
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
|
||||
if(SessionStore.exist && SessionStore.user.Inativity && !SessionStore.hasPin) {
|
||||
if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin) {
|
||||
// alert('stay set pin')
|
||||
return true
|
||||
|
||||
} else if(SessionStore.exist && !SessionStore.user.Inativity) {
|
||||
} else if(SessionStore.exist && !SessionStore.user.Inactivity) {
|
||||
// alert('stay conform')
|
||||
return true
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,8 @@ import { connection } from '../services/socket/synchro.service';
|
||||
import { DespachoService } from '../Rules/despacho.service';
|
||||
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
|
||||
import { InativityService } from '../services/inativity.service';
|
||||
// import { NetworkService } from '../services/network.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
|
||||
|
||||
|
||||
// import * as Sentry from "@sentry/browser";
|
||||
@@ -92,8 +93,14 @@ export class HomePage implements OnInit {
|
||||
|
||||
this.updateList()
|
||||
|
||||
|
||||
window['inactivity/function'] = () => {
|
||||
this.router.navigate(['/inactivity']);
|
||||
if(window.location.pathname != '/inactivity') {
|
||||
|
||||
const pathname = window.location.pathname
|
||||
SessionStore.setUrlBeforeInactivity(pathname)
|
||||
this.router.navigate(['/inactivity']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="profile-info">
|
||||
<div class="user-role">{{loggeduser.RoleDescription}}</div>
|
||||
<div class="user-role">{{SessionStore.user.RoleDescription}}</div>
|
||||
|
||||
<div class="container-div width-100">
|
||||
<div class="ion-item-class-2">
|
||||
@@ -36,7 +36,7 @@
|
||||
<ion-icon slot="start" name="person"></ion-icon>
|
||||
</div>
|
||||
<div class="ion-input-class">
|
||||
<ion-input disabled placeholder="Nome" [(ngModel)]="loggeduser.FullName"></ion-input>
|
||||
<ion-input disabled placeholder="Nome" [(ngModel)]="SessionStore.user.FullName"></ion-input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,19 +47,19 @@
|
||||
<ion-icon slot="start" name="mail"></ion-icon>
|
||||
</div>
|
||||
<div class="ion-input-class">
|
||||
<ion-input disabled placeholder="Email" [(ngModel)]="loggeduser.Email"></ion-input>
|
||||
<ion-input disabled placeholder="Email" [(ngModel)]="SessionStore.user.Email"></ion-input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div hidden class="login-preference width-100" (mouseover)="checkState()" (click)="checkState()">
|
||||
<div class="login-preference width-100" >
|
||||
<div class="preference">Preferência Login</div>
|
||||
|
||||
<ion-row>
|
||||
<ion-col class="align-center d-flex">
|
||||
<div class="d-flex align-center" (click)="LoginPreferenceMethod('pin')">
|
||||
<ion-checkbox [checked]="userLoginPreference=='pin' " class="checkBox" ></ion-checkbox>
|
||||
<div class="d-flex align-center" (click)="LoginPreferenceMethod('Pin')">
|
||||
<ion-checkbox [checked]="SessionStore.user.LoginPreference=='Pin' " class="checkBox" ></ion-checkbox>
|
||||
PIN
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AnimationController, ModalController } from '@ionic/angular';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { FingerprintPage } from 'src/app/shared/fingerprint/fingerprint.page';
|
||||
import { PinPage } from 'src/app/shared/pin/pin.page';
|
||||
import { LocalstoreService } from 'src/app/store/localstore.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-profile',
|
||||
@@ -14,22 +11,11 @@ import { LocalstoreService } from 'src/app/store/localstore.service';
|
||||
})
|
||||
export class EditProfilePage implements OnInit {
|
||||
|
||||
loggeduser: LoginUserRespose;
|
||||
userLoginPreference = ''
|
||||
SessionStore = SessionStore
|
||||
|
||||
constructor(private modalController:ModalController,
|
||||
private authService: AuthService,
|
||||
private animationController: AnimationController,
|
||||
private router: Router,
|
||||
private localstoreService: LocalstoreService
|
||||
) {
|
||||
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
|
||||
console.log(this.loggeduser.RoleDescription)
|
||||
|
||||
this.checkState()
|
||||
}
|
||||
private animationController: AnimationController
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
@@ -74,7 +60,6 @@ export class EditProfilePage implements OnInit {
|
||||
modal.present();
|
||||
}
|
||||
|
||||
|
||||
async addFingerprint() {
|
||||
const enterAnimation = (baseEl: any) => {
|
||||
const backdropAnimation = this.animationController.create()
|
||||
@@ -112,47 +97,14 @@ export class EditProfilePage implements OnInit {
|
||||
modal.present();
|
||||
}
|
||||
|
||||
logout() {
|
||||
// clear local storage
|
||||
window.localStorage.clear();
|
||||
LoginPreferenceMethod(type: 'None' | 'Password' | 'Pin' | null) {
|
||||
|
||||
setTimeout(()=>{
|
||||
window.location.pathname = '/'
|
||||
location.reload();
|
||||
}, 1000)
|
||||
|
||||
|
||||
}
|
||||
|
||||
LoginPreferenceMethod(type: string) {
|
||||
|
||||
let userData = this.localstoreService.get('UserData', {})
|
||||
|
||||
if (userData.hasOwnProperty('loginPreference')) {
|
||||
if (userData.loginPreference != type) {
|
||||
if (type) {
|
||||
userData.loginPreference = type
|
||||
}
|
||||
} else {
|
||||
userData.loginPreference = 'none'
|
||||
if (this.SessionStore.user.LoginPreference != type) {
|
||||
if (type) {
|
||||
this.SessionStore.setLoginPreference(type)
|
||||
}
|
||||
|
||||
} else {
|
||||
userData.loginPreference = 'none'
|
||||
}
|
||||
|
||||
|
||||
this.localstoreService.set('UserData', userData)
|
||||
}
|
||||
|
||||
checkState() {
|
||||
|
||||
let userData = this.localstoreService.get('UserData', {})
|
||||
|
||||
if (userData.hasOwnProperty('loginPreference')) {
|
||||
this.userLoginPreference = userData.loginPreference
|
||||
} else {
|
||||
this.userLoginPreference = ''
|
||||
this.SessionStore.setLoginPreference('None')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,5 +59,6 @@ export class UserSession {
|
||||
Profile: any;
|
||||
LoginPreference: 'None' | 'Password' | 'Pin' | null;
|
||||
PIN: string
|
||||
Inativity: boolean
|
||||
Inactivity: boolean
|
||||
UrlBeforeInactivity: string
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||
import { CalendarComponent } from 'ionic2-calendar';
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
||||
import { customTask, DailyWorkTask } from '../../../models/dailyworktask.model';
|
||||
import { customTask } from '../../../models/dailyworktask.model';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { formatDate } from '@angular/common';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
import { PendentesStore } from 'src/app/store/pendestes-store.service';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<ion-content class="text-white">
|
||||
|
||||
<div class="main-wrapper">
|
||||
|
||||
|
||||
<div class="wrapper" *ngIf="SessionStore.user.LoginPreference == 'Password' && SessionStore.hasPin || SessionStore.user.LoginPreference == null && SessionStore.hasPin ">
|
||||
<div class="wrapper" *ngIf="SessionStore.user.LoginPreference == 'Password' && SessionStore.hasPin || SessionStore.user.LoginPreference == null && SessionStore.hasPin || SessionStore.user.LoginPreference == 'None' && SessionStore.hasPin || enterWithPassword">
|
||||
|
||||
<div class="bg-1 d-flex justify-center align-center">
|
||||
<div class="bg-2 d-flex justify-center align-center">
|
||||
@@ -35,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content d-flex flex-column height-100 width" *ngIf="!SessionStore.hasPin || SessionStore.hasPin && SessionStore.user.LoginPreference == 'Pin' " >
|
||||
<div class="main-content d-flex flex-column height-100 width" *ngIf="!SessionStore.hasPin || SessionStore.hasPin && SessionStore.user.LoginPreference == 'Pin' && !enterWithPassword " >
|
||||
|
||||
<div class="div-top-header">
|
||||
|
||||
@@ -49,7 +47,6 @@
|
||||
<div *ngIf="SessionStore.hasPin" class="title">Digite o PIN</div>
|
||||
<div *ngIf="!SessionStore.hasPin" class="title">Digite o novo PIN</div>
|
||||
|
||||
|
||||
<div class="terminal">
|
||||
<div class="d-flex pt-25 align-center justify-center pin-4">
|
||||
<div class="dot" [class.dot-active]="code.length >= 1"></div>
|
||||
@@ -76,7 +73,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="SessionStore.hasPin" class="voltar d-flex align-center justify-center pt-25 clear" >
|
||||
<div *ngIf="SessionStore.hasPin" class="voltar d-flex align-center justify-center pt-25 clear" (click)="enterWithPasswordButton()" >
|
||||
Entrar com senha
|
||||
</div>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ export class InactivityPage implements OnInit {
|
||||
code = []
|
||||
setPin = false
|
||||
SessionStore = SessionStore
|
||||
enterWithPassword = false
|
||||
|
||||
constructor(
|
||||
private notificatinsservice: NotificationsService,
|
||||
@@ -78,14 +79,14 @@ export class InactivityPage implements OnInit {
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
await this.authService.loginChat(this.userattempt);
|
||||
await this.getToken();
|
||||
|
||||
this.router.navigate(['/home/events']);
|
||||
|
||||
this.goback()
|
||||
} else {
|
||||
SessionStore.delete()
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
}
|
||||
|
||||
|
||||
this.enterWithPassword = false
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -129,7 +130,7 @@ export class InactivityPage implements OnInit {
|
||||
|
||||
if( SessionStore.validatePin(code)) {
|
||||
|
||||
this.router.navigate(['/home/events']);
|
||||
this.goback()
|
||||
this.clearCode()
|
||||
} else {
|
||||
this.toastService.badRequest('Pin incorreto')
|
||||
@@ -138,6 +139,11 @@ export class InactivityPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
goback() {
|
||||
const pathName = this.SessionStore.user.UrlBeforeInactivity
|
||||
this.router.navigate([pathName]);
|
||||
}
|
||||
|
||||
storePin() {
|
||||
|
||||
const code = this.code.join('')
|
||||
@@ -148,4 +154,8 @@ export class InactivityPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
enterWithPasswordButton() {
|
||||
this.enterWithPassword = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { UserSession } from '../models/user.model';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SessionService {
|
||||
class SessionService {
|
||||
|
||||
// main data
|
||||
private _user = new UserSession()
|
||||
@@ -54,11 +54,16 @@ export class SessionService {
|
||||
}
|
||||
|
||||
needTovalidateUser() {
|
||||
return this._user.Inativity
|
||||
return this._user.Inactivity
|
||||
}
|
||||
|
||||
setInativity(value: boolean) {
|
||||
this._user.Inativity = value
|
||||
this._user.Inactivity = value
|
||||
this.save()
|
||||
}
|
||||
|
||||
setUrlBeforeInactivity(pathname: string) {
|
||||
this._user.UrlBeforeInactivity = pathname
|
||||
this.save()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user