From cc4105d2590bd2cf3396a9a9e05a717b475afe41 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 12 Sep 2023 18:18:49 -0400 Subject: [PATCH] time out --- REMEMBER.txt | 2 ++ package.json | 1 + src/app/app.component.ts | 13 ++++++++++++- src/app/app.module.ts | 7 ++++--- src/app/pages/transaction/transaction.page.ts | 6 ++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/REMEMBER.txt b/REMEMBER.txt index c525d9b..ddbe64c 100644 --- a/REMEMBER.txt +++ b/REMEMBER.txt @@ -20,3 +20,5 @@ ionic generate page jobactive ionic generate component taskactivities npm install angularx-qrcode@14.0.0 --save + +npm install bn-ng-idle diff --git a/package.json b/package.json index 784f185..1e7ad21 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@capacitor/status-bar": "^5.0.0", "@ionic/angular": "^6.1.9", "angularx-qrcode": "^14.0.0", + "bn-ng-idle": "^2.0.5", "onesignal-cordova-plugin": "^5.0.0-beta-02", "rxjs": "~6.6.0", "sha.js": "^2.4.11", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d37f84a..ba8361e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,7 @@ import { Component } from '@angular/core'; +import { BnNgIdleService } from 'bn-ng-idle'; +import {SessionDataProviderService} from "./store/session-data-provider.service"; +import {Router} from "@angular/router"; // import it to your component @Component({ selector: 'app-root', @@ -6,8 +9,16 @@ import { Component } from '@angular/core'; styleUrls: ['app.component.scss'], }) export class AppComponent { - constructor() { + constructor(private bnIdle: BnNgIdleService,private sessionDataProviderService : SessionDataProviderService, public router: Router) { // this.OneSignalInit(); + this.bnIdle.startWatching(300).subscribe((res) => { + if(res) { + console.log("session expired"); + // alert('LOG OUT NOW'); + this.sessionDataProviderService.DestroySessionOnLogout(); + this.router.navigate(['login']); + } + }) } // Call this function when your app starts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 376482c..1e777ac 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,12 +8,13 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; - +import { BnNgIdleService } from 'bn-ng-idle'; // import bn-ng-idle service @NgModule({ declarations: [AppComponent], - imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule], - providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }], + imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule + ], + providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },BnNgIdleService], bootstrap: [AppComponent], }) export class AppModule { } diff --git a/src/app/pages/transaction/transaction.page.ts b/src/app/pages/transaction/transaction.page.ts index a30dd7a..f6d8d5b 100644 --- a/src/app/pages/transaction/transaction.page.ts +++ b/src/app/pages/transaction/transaction.page.ts @@ -2,6 +2,7 @@ import { Router } from '@angular/router'; import { Component, OnInit } from '@angular/core'; import { WrenchService } from 'src/app/services/wrench.service'; import {SessionDataProviderService} from "../../store/session-data-provider.service"; +import {NavController} from "@ionic/angular"; @Component({ selector: 'app-transaction', @@ -12,6 +13,7 @@ export class TransactionPage implements OnInit { constructor( private router: Router, + private navctr: NavController, public sessionDataProviderService: SessionDataProviderService, private wrenchService: WrenchService ) { } @@ -21,6 +23,10 @@ export class TransactionPage implements OnInit { // this.getPaymentHxData(); } + onBack() { + this.navctr.back(); + } + ionViewDidEnter(){ this.getWalletData(); this.getPaymentHxData();