Commit eb94ad75a12af85339f40877fdf81db6c4c81d76
1 parent
e14c243d
added new configuration for user session
Showing
4 changed files
with
61 additions
and
6 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$compile", "$timeout", "DataService", "AuthenticationService", "ConfigurationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants","ModuleService","$window", | |
4 | -function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, DataService, AuthenticationService, ConfigurationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants, AIAConstants, ModuleService,$window) { | |
3 | +AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$compile", "$timeout", "DataService", "AuthenticationService", "ConfigurationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants","ModuleService","$window","Idle", "Keepalive", | |
4 | +function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, DataService, AuthenticationService, ConfigurationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants, AIAConstants, ModuleService,$window,Idle, Keepalive) { | |
5 | 5 | |
6 | 6 | //$scope.pageToOpen = { |
7 | 7 | // name: 'MainMenu' |
... | ... | @@ -718,7 +718,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data |
718 | 718 | $scope.helpTopicLink(); |
719 | 719 | }, 2000); |
720 | 720 | |
721 | - | |
722 | 721 | } |
723 | 722 | $rootScope.getConfigurationValues = function () { |
724 | 723 | ConfigurationService.getCofigValue() |
... | ... | @@ -884,6 +883,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data |
884 | 883 | } |
885 | 884 | else { |
886 | 885 | |
886 | + // set user session time | |
887 | + $rootScope.loadUserSession(); | |
887 | 888 | |
888 | 889 | //LicenseId would be zero for admin that is why we set the haveRoleAdmin = true |
889 | 890 | if (result.LicenseId == 0 && result.IsActive) { |
... | ... | @@ -1282,6 +1283,9 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data |
1282 | 1283 | |
1283 | 1284 | $rootScope.siteId = result.siteId; |
1284 | 1285 | |
1286 | + // set user session time | |
1287 | + $rootScope.loadUserSession(); | |
1288 | + | |
1285 | 1289 | // birendra// initialize exp img detail object |
1286 | 1290 | $rootScope.initializeUserForExportImage(result.Id); |
1287 | 1291 | |
... | ... | @@ -1517,6 +1521,36 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data |
1517 | 1521 | |
1518 | 1522 | } |
1519 | 1523 | |
1524 | + $rootScope.loadUserSession = function () { | |
1525 | + | |
1526 | + Idle.watch();// start the session | |
1527 | + | |
1528 | + $scope.$on('IdleStart', function() { | |
1529 | + // this event fire when idle time finish and time out start | |
1530 | + // config set in AIA.js -:IdleProvider.idle(1*30);; | |
1531 | + //alert('start'); | |
1532 | + }); | |
1533 | + $scope.$on('IdleEnd', function() { | |
1534 | + // this event fires by user activity during timeout period | |
1535 | + // it reset idle time and timeout | |
1536 | + // config set in AIA.js -:IdleProvider.interrupt('keydown wheel mousedown touchstart touchmove scroll'); | |
1537 | + // alert('end'); | |
1538 | + }); | |
1539 | + $scope.$on('IdleTimeout', function() { | |
1540 | + // this event fire when idle time finished and time out also finished | |
1541 | + // config set in AIA.js -:IdleProvider.timeout(15); | |
1542 | + | |
1543 | + $rootScope.LogoutUser(); | |
1544 | + }); | |
1545 | + | |
1546 | + $scope.$on('Keepalive', function() { | |
1547 | + // it watch the session on perticular time interval during idle time period | |
1548 | + // config set in AIA.js -: KeepaliveProvider.interval(10); | |
1549 | + //we will use it to recieve request from databse if user logout from admin activity | |
1550 | + //alert('alive'); | |
1551 | + }); | |
1552 | + | |
1553 | + } | |
1520 | 1554 | |
1521 | 1555 | $rootScope.LogoutUser = function () { |
1522 | 1556 | localStorage.removeItem('loggedInUserDetails'); |
... | ... | @@ -7603,7 +7637,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data |
7603 | 7637 | }; |
7604 | 7638 | |
7605 | 7639 | }] |
7606 | -); | |
7640 | +) | |
7607 | 7641 | function printImagePreview(event) { |
7608 | 7642 | var scope = angular.element(document.querySelector('[ng-controller="HomeController"]')).scope(); |
7609 | 7643 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -var AIA = angular.module('AIA', ['ngSanitize', 'ngRoute', 'ngStorage', 'ui.bootstrap']); | |
3 | +var AIA = angular.module('AIA', ['ngSanitize', 'ngRoute', 'ngStorage', 'ui.bootstrap','ngIdle']); | |
4 | 4 | |
5 | 5 | |
6 | 6 | |
... | ... | @@ -571,4 +571,15 @@ AIA.config(function ($routeProvider, pages, $locationProvider) { |
571 | 571 | |
572 | 572 | } |
573 | 573 | } |
574 | -}); | |
575 | 574 | \ No newline at end of file |
575 | +}); | |
576 | +AIA.config(function(IdleProvider, KeepaliveProvider) { | |
577 | + IdleProvider.idle(1*20); // 10 minutes idle | |
578 | + IdleProvider.timeout(15); // after 30 seconds idle, time the user out | |
579 | + KeepaliveProvider.interval(10); // 5 minute keep-alive ping | |
580 | + IdleProvider.interrupt('keydown wheel mousedown touchstart touchmove scroll'); | |
581 | +}) | |
582 | +// .run(function($rootScope, Idle, $log, Keepalive){ | |
583 | +// Idle.watch(); | |
584 | + | |
585 | +// $log.debug('app started.'); | |
586 | +// }); | |
576 | 587 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.Web/index.aspx
... | ... | @@ -1515,6 +1515,7 @@ |
1515 | 1515 | <script src="libs/angular/1.4.9/angular-sanitize.min.js"></script> |
1516 | 1516 | <script src="themes/default/scripts/bootstrap/3.3.5/ui-bootstrap-tpls-0.3.0.min.js"></script> |
1517 | 1517 | <script src="libs/angular/1.4.9/ngStorage.js"></script> |
1518 | + <script src="libs/angular/1.4.9/angular-idle.min.js"></script> | |
1518 | 1519 | <script src="content/js/custom/custom.js"></script> |
1519 | 1520 | <!--Annotation Toolbar : jcanvas Library--> |
1520 | 1521 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/libs/angular/1.4.9/angular-idle.min.js
0 → 100644
1 | +/*** Directives and services for responding to idle users in AngularJS | |
2 | +* @author Mike Grabski <me@mikegrabski.com> | |
3 | +* @version v1.3.2 | |
4 | +* @link https://github.com/HackedByChinese/ng-idle.git | |
5 | +* @license MIT | |
6 | +*/ | |
7 | + | |
8 | +!function(a,b,c){"use strict";b.module("ngIdle",["ngIdle.keepalive","ngIdle.idle","ngIdle.countdown","ngIdle.title","ngIdle.localStorage"]),b.module("ngIdle.keepalive",[]).provider("Keepalive",function(){var a={http:null,interval:600};this.http=function(c){if(!c)throw new Error("Argument must be a string containing a URL, or an object containing the HTTP request configuration.");b.isString(c)&&(c={url:c,method:"GET"}),c.cache=!1,a.http=c};var c=this.interval=function(b){if(b=parseInt(b),isNaN(b)||0>=b)throw new Error("Interval must be expressed in seconds and be greater than 0.");a.interval=b};this.$get=["$rootScope","$log","$interval","$http",function(d,e,f,g){function h(a){d.$broadcast("KeepaliveResponse",a.data,a.status)}function i(){d.$broadcast("Keepalive"),b.isObject(a.http)&&g(a.http).then(h)["catch"](h)}var j={ping:null};return{_options:function(){return a},setInterval:c,start:function(){return f.cancel(j.ping),j.ping=f(i,1e3*a.interval),j.ping},stop:function(){f.cancel(j.ping)},ping:function(){i()}}}]}),b.module("ngIdle.idle",["ngIdle.keepalive","ngIdle.localStorage"]).provider("Idle",function(){var a={idle:1200,timeout:30,autoResume:"idle",interrupt:"mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll",windowInterrupt:null,keepalive:!0},c=this.timeout=function(c){if(c===!1)a.timeout=0;else{if(!(b.isNumber(c)&&c>=0))throw new Error("Timeout must be zero or false to disable the feature, or a positive integer (in seconds) to enable it.");a.timeout=c}};this.interrupt=function(b){a.interrupt=b},this.windowInterrupt=function(b){a.windowInterrupt=b};var d=this.idle=function(b){if(0>=b)throw new Error("Idle must be a value in seconds, greater than 0.");a.idle=b};this.autoResume=function(b){b===!0?a.autoResume="idle":b===!1?a.autoResume="off":a.autoResume=b},this.keepalive=function(b){a.keepalive=b===!0},this.$get=["$interval","$log","$rootScope","$document","Keepalive","IdleLocalStorage","$window",function(e,f,g,h,i,j,k){function l(){a.keepalive&&(u.running&&i.ping(),i.start())}function m(){a.keepalive&&i.stop()}function n(){u.idling=!u.idling;var b=u.idling?"IdleStart":"IdleEnd";u.idling?(g.$broadcast(b),m(),a.timeout&&(u.countdown=a.timeout,o(),u.timeout=e(o,1e3,a.timeout,!1))):(l(),g.$broadcast(b)),e.cancel(u.idle)}function o(){if(u.idling){if(u.countdown<=0)return void q();g.$broadcast("IdleWarn",u.countdown),u.countdown--}}function p(a){g.$broadcast("IdleInterrupt",a)}function q(){m(),e.cancel(u.idle),e.cancel(u.timeout),u.idling=!0,u.running=!1,u.countdown=0,g.$broadcast("IdleTimeout")}function r(a,b,c){var d=a.running();a.unwatch(),b(c),d&&a.watch()}function s(){var a=j.get("expiry");return a&&a.time?new Date(a.time):null}function t(a){a?j.set("expiry",{id:v,time:a}):j.remove("expiry")}var u={idle:null,timeout:null,idling:!1,running:!1,countdown:null},v=(new Date).getTime(),w={_options:function(){return a},_getNow:function(){return new Date},getIdle:function(){return a.idle},getTimeout:function(){return a.timeout},setIdle:function(a){r(this,d,a)},setTimeout:function(a){r(this,c,a)},isExpired:function(){var a=s();return null!==a&&a<=this._getNow()},running:function(){return u.running},idling:function(){return u.idling},watch:function(b){e.cancel(u.idle),e.cancel(u.timeout);var c=a.timeout?a.timeout:0;b||t(new Date((new Date).getTime()+1e3*(a.idle+c))),u.idling?n():u.running||l(),u.running=!0,u.idle=e(n,1e3*a.idle,0,!1)},unwatch:function(){e.cancel(u.idle),e.cancel(u.timeout),u.idling=!1,u.running=!1,t(null),m()},interrupt:function(b){if(u.running){if(a.timeout&&this.isExpired())return void q();p(b),(b||"idle"===a.autoResume||"notIdle"===a.autoResume&&!u.idling)&&this.watch(b)}}},x={clientX:null,clientY:null,swap:function(a){var b={clientX:this.clientX,clientY:this.clientY};return this.clientX=a.clientX,this.clientY=a.clientY,b},hasMoved:function(a){var b=this.swap(a);return null===this.clientX||a.movementX||a.movementY?!0:b.clientX!=a.clientX||b.clientY!=a.clientY?!0:!1}};if(h.find("html").on(a.interrupt,function(a){"mousemove"===a.type&&a.originalEvent&&0===a.originalEvent.movementX&&0===a.originalEvent.movementY||("mousemove"!==a.type||x.hasMoved(a))&&w.interrupt()}),a.windowInterrupt)for(var y=a.windowInterrupt.split(" "),z=function(){w.interrupt()},A=0;A<y.length;A++)k.addEventListener?(k.addEventListener(y[A],z,!1),g.$on("$destroy",function(){k.removeEventListener(y[A],z,!1)})):(k.attachEvent(y[A],z),g.$on("$destroy",function(){k.detachEvent(y[A],z)}));var B=function(a){if("ngIdle.expiry"===a.key&&a.newValue&&a.newValue!==a.oldValue){var c=b.fromJson(a.newValue);if(c.id===v)return;w.interrupt(!0)}};return k.addEventListener?(k.addEventListener("storage",B,!1),g.$on("$destroy",function(){k.removeEventListener("storage",B,!1)})):k.attachEvent&&(k.attachEvent("onstorage",B),g.$on("$destroy",function(){k.detachEvent("onstorage",B)})),w}]}),b.module("ngIdle.countdown",["ngIdle.idle"]).directive("idleCountdown",["Idle",function(a){return{restrict:"A",scope:{value:"=idleCountdown"},link:function(b){b.value=a.getTimeout(),b.$on("IdleWarn",function(a,c){b.$evalAsync(function(){b.value=c})}),b.$on("IdleTimeout",function(){b.$evalAsync(function(){b.value=0})})}}}]),b.module("ngIdle.title",[]).provider("Title",function(){function a(a,b,c){return new Array(b-String(a).length+1).join(c||"0")+a}var c={enabled:!0},d=this.enabled=function(a){c.enabled=a===!0};this.$get=["$document","$interpolate",function(e,f){var g={original:null,idle:"{{minutes}}:{{seconds}} until your session times out!",timedout:"Your session has expired."};return{setEnabled:d,isEnabled:function(){return c.enabled},original:function(a){return b.isUndefined(a)?g.original:void(g.original=a)},store:function(a){(a||!g.original)&&(g.original=this.value())},value:function(a){return b.isUndefined(a)?e[0].title:void(e[0].title=a)},idleMessage:function(a){return b.isUndefined(a)?g.idle:void(g.idle=a)},timedOutMessage:function(a){return b.isUndefined(a)?g.timedout:void(g.timedout=a)},setAsIdle:function(b){this.store();var c={totalSeconds:b};c.minutes=Math.floor(b/60),c.seconds=a(b-60*c.minutes,2),this.value(f(this.idleMessage())(c))},setAsTimedOut:function(){this.store(),this.value(this.timedOutMessage())},restore:function(){this.original()&&this.value(this.original())}}}]}).directive("title",["Title",function(a){return{restrict:"E",link:function(b,c,d){a.isEnabled()&&!d.idleDisabled&&(a.store(!0),b.$on("IdleStart",function(){a.original(c[0].innerText)}),b.$on("IdleWarn",function(b,c){a.setAsIdle(c)}),b.$on("IdleEnd",function(){a.restore()}),b.$on("IdleTimeout",function(){a.setAsTimedOut()}))}}}]),b.module("ngIdle.localStorage",[]).service("IdleStorageAccessor",["$window",function(a){return{get:function(){return a.localStorage}}}]).service("IdleLocalStorage",["IdleStorageAccessor",function(a){function d(){var a={};this.setItem=function(b,c){a[b]=c},this.getItem=function(b){return"undefined"!=typeof a[b]?a[b]:null},this.removeItem=function(b){a[b]=c}}function e(){try{var b=a.get();return b.setItem("ngIdleStorage",""),b.removeItem("ngIdleStorage"),b}catch(c){return new d}}var f=e();return{set:function(a,c){f.setItem("ngIdle."+a,b.toJson(c))},get:function(a){return b.fromJson(f.getItem("ngIdle."+a))},remove:function(a){f.removeItem("ngIdle."+a)},_wrapped:function(){return f}}}])}(window,window.angular); | |
9 | +//# sourceMappingURL=angular-idle.map | |
0 | 10 | \ No newline at end of file | ... | ... |