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,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
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')
|
// alert('stay set pin')
|
||||||
return true
|
return true
|
||||||
|
|
||||||
} else if(SessionStore.exist && !SessionStore.user.Inativity) {
|
} else if(SessionStore.exist && !SessionStore.user.Inactivity) {
|
||||||
// alert('stay conform')
|
// alert('stay conform')
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ import { connection } from '../services/socket/synchro.service';
|
|||||||
import { DespachoService } from '../Rules/despacho.service';
|
import { DespachoService } from '../Rules/despacho.service';
|
||||||
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
|
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
|
||||||
import { InativityService } from '../services/inativity.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";
|
// import * as Sentry from "@sentry/browser";
|
||||||
@@ -92,9 +93,15 @@ export class HomePage implements OnInit {
|
|||||||
|
|
||||||
this.updateList()
|
this.updateList()
|
||||||
|
|
||||||
|
|
||||||
window['inactivity/function'] = () => {
|
window['inactivity/function'] = () => {
|
||||||
|
if(window.location.pathname != '/inactivity') {
|
||||||
|
|
||||||
|
const pathname = window.location.pathname
|
||||||
|
SessionStore.setUrlBeforeInactivity(pathname)
|
||||||
this.router.navigate(['/inactivity']);
|
this.router.navigate(['/inactivity']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// if (typeof Worker !== 'undefined') {
|
// if (typeof Worker !== 'undefined') {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="profile-info">
|
<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="container-div width-100">
|
||||||
<div class="ion-item-class-2">
|
<div class="ion-item-class-2">
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<ion-icon slot="start" name="person"></ion-icon>
|
<ion-icon slot="start" name="person"></ion-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="ion-input-class">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,19 +47,19 @@
|
|||||||
<ion-icon slot="start" name="mail"></ion-icon>
|
<ion-icon slot="start" name="mail"></ion-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="ion-input-class">
|
<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>
|
</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>
|
<div class="preference">Preferência Login</div>
|
||||||
|
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col class="align-center d-flex">
|
<ion-col class="align-center d-flex">
|
||||||
<div class="d-flex align-center" (click)="LoginPreferenceMethod('pin')">
|
<div class="d-flex align-center" (click)="LoginPreferenceMethod('Pin')">
|
||||||
<ion-checkbox [checked]="userLoginPreference=='pin' " class="checkBox" ></ion-checkbox>
|
<ion-checkbox [checked]="SessionStore.user.LoginPreference=='Pin' " class="checkBox" ></ion-checkbox>
|
||||||
PIN
|
PIN
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { AnimationController, ModalController } from '@ionic/angular';
|
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 { FingerprintPage } from 'src/app/shared/fingerprint/fingerprint.page';
|
||||||
import { PinPage } from 'src/app/shared/pin/pin.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({
|
@Component({
|
||||||
selector: 'app-edit-profile',
|
selector: 'app-edit-profile',
|
||||||
@@ -14,22 +11,11 @@ import { LocalstoreService } from 'src/app/store/localstore.service';
|
|||||||
})
|
})
|
||||||
export class EditProfilePage implements OnInit {
|
export class EditProfilePage implements OnInit {
|
||||||
|
|
||||||
loggeduser: LoginUserRespose;
|
SessionStore = SessionStore
|
||||||
userLoginPreference = ''
|
|
||||||
|
|
||||||
constructor(private modalController:ModalController,
|
constructor(private modalController:ModalController,
|
||||||
private authService: AuthService,
|
private animationController: AnimationController
|
||||||
private animationController: AnimationController,
|
) {}
|
||||||
private router: Router,
|
|
||||||
private localstoreService: LocalstoreService
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.loggeduser = authService.ValidatedUser;
|
|
||||||
|
|
||||||
console.log(this.loggeduser.RoleDescription)
|
|
||||||
|
|
||||||
this.checkState()
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {}
|
ngOnInit() {}
|
||||||
|
|
||||||
@@ -74,7 +60,6 @@ export class EditProfilePage implements OnInit {
|
|||||||
modal.present();
|
modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async addFingerprint() {
|
async addFingerprint() {
|
||||||
const enterAnimation = (baseEl: any) => {
|
const enterAnimation = (baseEl: any) => {
|
||||||
const backdropAnimation = this.animationController.create()
|
const backdropAnimation = this.animationController.create()
|
||||||
@@ -112,47 +97,14 @@ export class EditProfilePage implements OnInit {
|
|||||||
modal.present();
|
modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
LoginPreferenceMethod(type: 'None' | 'Password' | 'Pin' | null) {
|
||||||
// clear local storage
|
|
||||||
window.localStorage.clear();
|
|
||||||
|
|
||||||
setTimeout(()=>{
|
if (this.SessionStore.user.LoginPreference != type) {
|
||||||
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) {
|
if (type) {
|
||||||
userData.loginPreference = type
|
this.SessionStore.setLoginPreference(type)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userData.loginPreference = 'none'
|
this.SessionStore.setLoginPreference('None')
|
||||||
}
|
|
||||||
|
|
||||||
} 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 = ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,5 +59,6 @@ export class UserSession {
|
|||||||
Profile: any;
|
Profile: any;
|
||||||
LoginPreference: 'None' | 'Password' | 'Pin' | null;
|
LoginPreference: 'None' | 'Password' | 'Pin' | null;
|
||||||
PIN: string
|
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 { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||||
import { CalendarComponent } from 'ionic2-calendar';
|
import { CalendarComponent } from 'ionic2-calendar';
|
||||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
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 { ProcessesService } from 'src/app/services/processes.service';
|
||||||
import { formatDate } from '@angular/common';
|
|
||||||
import { AlertService } from 'src/app/services/alert.service';
|
import { AlertService } from 'src/app/services/alert.service';
|
||||||
import { PendentesStore } from 'src/app/store/pendestes-store.service';
|
import { PendentesStore } from 'src/app/store/pendestes-store.service';
|
||||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<ion-content class="text-white">
|
<ion-content class="text-white">
|
||||||
|
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
|
<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="wrapper" *ngIf="SessionStore.user.LoginPreference == 'Password' && SessionStore.hasPin || SessionStore.user.LoginPreference == null && SessionStore.hasPin ">
|
|
||||||
|
|
||||||
<div class="bg-1 d-flex justify-center align-center">
|
<div class="bg-1 d-flex justify-center align-center">
|
||||||
<div class="bg-2 d-flex justify-center align-center">
|
<div class="bg-2 d-flex justify-center align-center">
|
||||||
@@ -35,7 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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">
|
<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 PIN</div>
|
||||||
<div *ngIf="!SessionStore.hasPin" class="title">Digite o novo PIN</div>
|
<div *ngIf="!SessionStore.hasPin" class="title">Digite o novo PIN</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="terminal">
|
<div class="terminal">
|
||||||
<div class="d-flex pt-25 align-center justify-center pin-4">
|
<div class="d-flex pt-25 align-center justify-center pin-4">
|
||||||
<div class="dot" [class.dot-active]="code.length >= 1"></div>
|
<div class="dot" [class.dot-active]="code.length >= 1"></div>
|
||||||
@@ -76,7 +73,7 @@
|
|||||||
</div>
|
</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
|
Entrar com senha
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export class InactivityPage implements OnInit {
|
|||||||
code = []
|
code = []
|
||||||
setPin = false
|
setPin = false
|
||||||
SessionStore = SessionStore
|
SessionStore = SessionStore
|
||||||
|
enterWithPassword = false
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private notificatinsservice: NotificationsService,
|
private notificatinsservice: NotificationsService,
|
||||||
@@ -79,13 +80,13 @@ export class InactivityPage implements OnInit {
|
|||||||
await this.authService.loginChat(this.userattempt);
|
await this.authService.loginChat(this.userattempt);
|
||||||
await this.getToken();
|
await this.getToken();
|
||||||
|
|
||||||
this.router.navigate(['/home/events']);
|
this.goback()
|
||||||
} else {
|
} else {
|
||||||
SessionStore.delete()
|
SessionStore.delete()
|
||||||
await this.authService.SetSession(attempt, this.userattempt);
|
await this.authService.SetSession(attempt, this.userattempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.enterWithPassword = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -129,7 +130,7 @@ export class InactivityPage implements OnInit {
|
|||||||
|
|
||||||
if( SessionStore.validatePin(code)) {
|
if( SessionStore.validatePin(code)) {
|
||||||
|
|
||||||
this.router.navigate(['/home/events']);
|
this.goback()
|
||||||
this.clearCode()
|
this.clearCode()
|
||||||
} else {
|
} else {
|
||||||
this.toastService.badRequest('Pin incorreto')
|
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() {
|
storePin() {
|
||||||
|
|
||||||
const code = this.code.join('')
|
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({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SessionService {
|
class SessionService {
|
||||||
|
|
||||||
// main data
|
// main data
|
||||||
private _user = new UserSession()
|
private _user = new UserSession()
|
||||||
@@ -54,11 +54,16 @@ export class SessionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
needTovalidateUser() {
|
needTovalidateUser() {
|
||||||
return this._user.Inativity
|
return this._user.Inactivity
|
||||||
}
|
}
|
||||||
|
|
||||||
setInativity(value: boolean) {
|
setInativity(value: boolean) {
|
||||||
this._user.Inativity = value
|
this._user.Inactivity = value
|
||||||
|
this.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
setUrlBeforeInactivity(pathname: string) {
|
||||||
|
this._user.UrlBeforeInactivity = pathname
|
||||||
this.save()
|
this.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user