diff --git a/400-SOURCECODE/Admin/src/app/app.component.ts b/400-SOURCECODE/Admin/src/app/app.component.ts
index 498a76f..d074b3e 100644
--- a/400-SOURCECODE/Admin/src/app/app.component.ts
+++ b/400-SOURCECODE/Admin/src/app/app.component.ts
@@ -8,6 +8,10 @@ import { UserManageRightsModel } from './components/userentity/datamodel';
//import { MyAuthService } from './shared/my-auth.service';
import { GlobalService } from './shared/global';
import { Router, NavigationEnd } from '@angular/router';
+import { LoadingService } from './shared/loading.service';
+import {Idle, DEFAULT_INTERRUPTSOURCES} from '@ng-idle/core';
+import {Keepalive} from '@ng-idle/keepalive';
+import { Title } from '@angular/platform-browser';
//import { HttpClient } from '@angular/common/http';
//import { HttpErrorResponse } from '@angular/common/http';
@@ -28,8 +32,56 @@ export class AppComponent implements OnInit {
public UpdateProfileVisible: boolean;
public UserManageRightsList: Array
;
- constructor(private userservice: UserService, public global: GlobalService, private router: Router,
- ) { }
+ constructor(private idle: Idle, private keepalive: Keepalive,private titleService: Title,private userservice: UserService,private _loadingService: LoadingService, public global: GlobalService, private router: Router,) {
+ const projectTitle= this.titleService.getTitle();
+
+ // sets an idle timeout of 20 minutes.
+ this.idle.setIdle(20*60);
+
+ // sets a timeout period of 30 seconds. after 30 seconds of inactivity, the user will be considered timed out.
+ this.idle.setTimeout(30);
+
+ // sets the ping interval to 10 seconds
+ this.keepalive.interval(10);
+
+ // sets the default interrupts, in this case, things like clicks, scrolls,mousemove touches to the document
+ this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
+
+ this.idle.onInterrupt.subscribe(() => {
+ this.titleService.setTitle(projectTitle);
+ })
+
+ this.idle.onTimeout.subscribe(() => {
+ //console.log("Timed out!");
+ this.titleService.setTitle('Your session has expired!');
+ this._loadingService.ShowLoading("global-loading");
+ this.loginManageStatus('logout');
+ });
+
+ this.idle.onTimeoutWarning.subscribe((countdown) => {
+ // console.log("You will time out in "+countdown);
+ var minute=Math.floor(countdown/60);
+ var remaining = minute+':'+(("00" + (countdown - minute * 60)).slice(-2) );
+ this.titleService.setTitle(remaining+' until your session times out!');
+ });
+
+ this.keepalive.onPing.subscribe(() =>{
+ // this.lastPing = new Date();
+ // console.log("last ping: "+this.lastPing);
+ this.loginManageStatus('update');
+ });
+
+ // this.idle.onIdleEnd.subscribe(() => {
+ // console.log("No longer idle. ");
+ // });
+ // this.idle.onIdleStart.subscribe(() =>{
+ // console.log("You\'ve gone idle!");
+ // });
+
+ this.idle.watch();
+
+ }
+
ngOnInit(): void {
this.menustaus = "True";
this.global.getJSON().subscribe(data => {
@@ -69,17 +121,38 @@ export class AppComponent implements OnInit {
}
}
}, error => console.log(error));
-
-
}
+
logout() {
- localStorage.removeItem('loggedInUserDetails');
- //window.location.href = this.global.LiveURL;
- window.location.href = window.location.origin;
+ this._loadingService.ShowLoading("global-loading");
+ this.loginManageStatus('logout');
+ }
+ loginManageStatus(tagname:string) {
+ this.userservice.ManageUserLoginStatus({
+ userId: this.global.UserId,
+ tagName: tagname
+ }).subscribe(status => {
+ console.log(status);
+ if(status=='False')
+ {
+ if(tagname=='logout')
+ {
+ this._loadingService.HideLoading("global-loading");
+ }
+
+ // comments below statement while unit testing on 'ng serve --open' command
+
+ // localStorage.removeItem('loggedInUserDetails');
+ // window.location.href = window.location.origin;
+ }
+
+ },error => console.log(error));
}
+
Product() {
//window.location.href = this.global.LiveURL;
window.location.href = window.location.origin;
//this.router.navigate([this.global.LiveURL]);
}
+
}
diff --git a/400-SOURCECODE/Admin/src/app/app.module.ts b/400-SOURCECODE/Admin/src/app/app.module.ts
index ec79704..b223e9a 100644
--- a/400-SOURCECODE/Admin/src/app/app.module.ts
+++ b/400-SOURCECODE/Admin/src/app/app.module.ts
@@ -1,5 +1,5 @@
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { BrowserModule } from '@angular/platform-browser';
+import { BrowserModule,Title } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
@@ -8,6 +8,10 @@ import { HttpModule } from '@angular/http';
//import { Ng2SmartTableModule } from 'ng2-smart-table';
import { Ng2Bs3ModalModule } from 'ng2-bs3-modal/ng2-bs3-modal';
import { CsvService } from "angular2-json2csv";
+
+import { NgIdleKeepaliveModule } from '@ng-idle/keepalive';
+import { MomentModule } from 'angular2-moment';
+
import { BsDatepickerModule, ModalModule } from 'ngx-bootstrap';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsDropdownModule } from 'ngx-bootstrap';
@@ -83,11 +87,11 @@ import { MyFilterPipe } from './shared/my-filter.pipe';
],
imports: [
BrowserModule, AppRoutingModule, HttpClientModule, FormsModule, ReactiveFormsModule, HttpModule, Ng2Bs3ModalModule,
- BsDatepickerModule.forRoot(), ModalModule.forRoot(), BsDropdownModule.forRoot(), Ng2OrderModule
+ BsDatepickerModule.forRoot(), ModalModule.forRoot(), BsDropdownModule.forRoot(), Ng2OrderModule,MomentModule,NgIdleKeepaliveModule.forRoot()
//ModalModule.forRoot()
// , AngularFireModule.initializeApp(firebaseConfig),
],
- providers: [GlobalService, ConfirmService, BsModalService, LoadingService, CsvService,
+ providers: [GlobalService, ConfirmService, BsModalService, LoadingService, CsvService,Title,
// MyAuthService, AngularFireAuth, FirebaseApp, AngularFireModule,
//AuthService,
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts
index 4478f1a..9f9aeb9 100644
--- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts
+++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts
@@ -91,7 +91,6 @@ export class UpdateUserProfile implements OnInit {
this.userservice.GetUserById()
.subscribe(x => { console.log(x); this.bindUsers(x) }, error => this.error = error);
- this._loadingService.HideLoading("global-loading");
}
UpdateUserProfile() {
this.alerts = '';
@@ -114,7 +113,7 @@ export class UpdateUserProfile implements OnInit {
if (this.userFrm.valid && this.alerts == '') {
var obj = this.userFrm.value;
-
+ this._loadingService.ShowLoading("global-loading");
return this.userservice.UpdateUserProfileById(obj)
.subscribe(
n => (this.AfterInsertData(n)),
@@ -122,7 +121,8 @@ export class UpdateUserProfile implements OnInit {
}
}
AfterInsertData(data) {
- if (data.Status == "False") {
+ if (data.Status == "False") {
+ this._loadingService.HideLoading("global-loading");
return false;
} else {
this.status = true;
@@ -132,6 +132,7 @@ export class UpdateUserProfile implements OnInit {
loggedInUser.LastName = this.userFrm.value.lastName;
localStorage.setItem("loggedInUserDetails", JSON.stringify(loggedInUser));
this.global.DisplayName = loggedInUser.FirstName + " " + loggedInUser.LastName;
+ this._loadingService.HideLoading("global-loading");
this._confirmService.activate("User Profile Updated Successfully.", "alertMsg");
}
@@ -147,7 +148,8 @@ export class UpdateUserProfile implements OnInit {
this.userFrm.controls['id'].setValue(this.user.Id)
this.userFrm.controls['firstName'].setValue(this.user.FirstName)
this.userFrm.controls['lastName'].setValue(this.user.LastName)
- this.userFrm.controls['emailId'].setValue(this.user.EmailId)
+ this.userFrm.controls['emailId'].setValue(this.user.EmailId);
+ this._loadingService.HideLoading("global-loading");
}
validationMessages = {
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts
index 7cfd01e..2bfd771 100644
--- a/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts
+++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts
@@ -54,6 +54,20 @@ export class UserService {
}
//////////// End /////////////////////
+ //////////Manage UserLogin Status///////////
+ ManageUserLoginStatus(obj: any) {
+ var jsonData = { 'userId': obj.userId, 'tagName': obj.tagName };
+ console.log(obj);
+ var headers = new Headers({
+ 'Content-Type': 'application/json'
+ });
+ return this.http.post(this.commonService.resourceBaseUrl + "User/ManageUserLoginStatus",
+ JSON.stringify(jsonData), { headers: headers })
+ .map(this.extractData)
+ .catch((res: Response) => this.handleError(res));
+ }
+ //////////// End /////////////////////
+
//////////Update User Userid///////////////
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
index b8d5759..d2470c6 100644
--- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
+++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
@@ -119,6 +119,7 @@
Account Number |
Product Edition |
Status |
+ Login Status |
@@ -143,6 +144,10 @@
Active
Inactive
+
+ Logged-In
+ Logged-Out
+ |
@@ -156,9 +161,11 @@
+
+