Commit 26b31a034e51ea485c1f04e8f52c269daa2a5c4f

Authored by Birendra
1 parent 4af0958c

add session setting in API config

400-SOURCECODE/AIAHTML5.API/Controllers/ConfigurationController.cs
... ... @@ -18,6 +18,9 @@ namespace AIAHTML5.API.Controllers
18 18 dynamic responseData;
19 19 MyConfig mconfig = new MyConfig();
20 20 mconfig.current_year= DateTime.Now.Year;
  21 + mconfig.idleTime = Int32.Parse(ConfigurationManager.AppSettings["IDLE_TIME"]);
  22 + mconfig.idelTimeOut = Int32.Parse(ConfigurationManager.AppSettings["IDLE_TIME_OUT"]);
  23 + mconfig.pingInterval = Int32.Parse(ConfigurationManager.AppSettings["PING_INTERVAL"]);
21 24 mconfig.serverPath = ConfigurationManager.AppSettings["ANIMATION_HOSTING_SERVER"];
22 25 mconfig.fileSize = Int32.Parse(ConfigurationManager.AppSettings["UploadMaxFileSize"]);
23 26  
... ... @@ -30,6 +33,9 @@ namespace AIAHTML5.API.Controllers
30 33 public class MyConfig
31 34 {
32 35 public int current_year { get; set; }
  36 + public int idleTime { get; set; }
  37 + public int idelTimeOut { get; set; }
  38 + public int pingInterval { get; set; }
33 39 public string serverPath { get; set; }
34 40 public int fileSize { get; set; }
35 41 }
36 42 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.API/Web.config
... ... @@ -31,9 +31,16 @@
31 31 </log4net>
32 32  
33 33 <appSettings>
  34 + <!-- set Idel time 20 minute -->
  35 + <add key="IDLE_TIME" value="1200" />
  36 + <!-- set idle timeout 30 seconds -->
  37 + <add key="IDLE_TIME_OUT" value="30" />
  38 + <!-- set ping time interval 30 seconds -->
  39 + <add key="PING_INTERVAL" value="10" />
  40 +
34 41 <add key="ANIMATION_HOSTING_SERVER" value="~/../content/data/AnimationMp4/" />
35   - <!-- set to 10mb upload file size for single file at a time -->
36   - <add key="UploadMaxFileSize" value="10485760" />
  42 + <!-- set to 10mb upload file size for single file at a time -->
  43 + <add key="UploadMaxFileSize" value="10485760" />
37 44  
38 45 <add key="SenderEmailAddress" value="support@interactiveanatomy.com" />
39 46 <!--<add key="SenderEmailAddress" value="support@interactiveanatomy.com" />-->
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -688,7 +688,19 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
688 688 //get user is already loggedin or not
689 689 $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
690 690 if ($scope.currentUserDetails != undefined) {
691   - AuthenticateAlreadyLoggedInUser();
  691 + $rootScope.isVisibleLogin = false;
  692 + ConfigurationService.getCofigValue()
  693 + .then(
  694 + function (configresult) {
  695 + $rootScope.current_year = configresult.current_year;
  696 + $rootScope.aiaIdleTime = configresult.idleTime;
  697 + $rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
  698 + $rootScope.aiaPingInterval = configresult.pingInterval;
  699 + $rootScope.aiaAnimationPath = configresult.serverPath;
  700 + $rootScope.MaxOneFileSize = configresult.fileSize;
  701 + AuthenticateAlreadyLoggedInUser();
  702 + });
  703 +
692 704 }
693 705  
694 706 var isRememberChecked = $rootScope.getLocalStorageValue('isRememberMeChecked');
... ... @@ -704,7 +716,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
704 716 }
705 717 }
706 718 }
707   -
708 719 else {
709 720  
710 721 $rootScope.isVisibleLogin = true;
... ... @@ -712,7 +723,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
712 723 $rootScope.promptUserForCookies();
713 724 }
714 725  
  726 + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
  727 + if ($scope.currentUserDetails == undefined) {
715 728 $rootScope.getConfigurationValues();
  729 + }
716 730 }
717 731  
718 732 $timeout(function () {
... ... @@ -725,6 +739,9 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
725 739 .then(
726 740 function (configresult) {
727 741 $rootScope.current_year = configresult.current_year;
  742 + $rootScope.aiaIdleTime = configresult.idleTime;
  743 + $rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
  744 + $rootScope.aiaPingInterval = configresult.pingInterval;
728 745 $rootScope.aiaAnimationPath = configresult.serverPath;
729 746 $rootScope.MaxOneFileSize = configresult.fileSize;
730 747  
... ... @@ -760,6 +777,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
760 777 .then(
761 778  
762 779 function (result) {
  780 + // update result with session detail
  781 + result.aiaIdleTime=$rootScope.aiaIdleTime;
  782 + result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
  783 + result.aiaPingInterval=$rootScope.aiaPingInterval;
763 784  
764 785 if (result == LoginConstants.USER_NOT_FOUND) {
765 786 $rootScope.LoginEnableUI();
... ... @@ -923,10 +944,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
923 944 $rootScope.userData = result;
924 945 $rootScope.userModules = result.Modules;
925 946  
926   - if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
927   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
928   - }
929   -
  947 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  948 +
930 949 if (isCommingSoonModel == true) {
931 950  
932 951 // ShowAssignedModulesPopup(result.Modules);
... ... @@ -993,7 +1012,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
993 1012  
994 1013  
995 1014 if (result.LicenseInfo.IsTermAccepted) {
996   -
997 1015 //0.
998 1016 $rootScope.userData = result;
999 1017 $rootScope.userModules = result.Modules;
... ... @@ -1001,11 +1019,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1001 1019 $("#modestyDiv").css("pointer-events", "none");
1002 1020 $("#modestyDiv").css("opacity", 0.5);
1003 1021 //2.
1004   - if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
1005   -
1006   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
1007   - }
1008   -
  1022 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  1023 +
1009 1024 // 3.ShowAssignedModulesPopup
1010 1025 //isCommingSoonModel =true only when user comes first time on application and login
1011 1026 if (isCommingSoonModel == true) {
... ... @@ -1232,6 +1247,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1232 1247  
1233 1248 function (result) {
1234 1249 console.log(result);
  1250 + // update result with session detail
  1251 + result.aiaIdleTime=$rootScope.aiaIdleTime;
  1252 + result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
  1253 + result.aiaPingInterval=$rootScope.aiaPingInterval;
1235 1254 if (result != null) {
1236 1255 console.log(result);
1237 1256 if (result == LoginConstants.INVALID_CLIENT) {
... ... @@ -1329,10 +1348,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1329 1348 $rootScope.userData = result;
1330 1349 $rootScope.userModules = result.Modules;
1331 1350  
1332   - if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
1333   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
1334   - }
1335   -
  1351 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  1352 +
1336 1353 if (isCommingSoonModel == true) {
1337 1354  
1338 1355 ShowAssignedModulesPopup(result.Modules);
... ... @@ -1377,11 +1394,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1377 1394 $rootScope.haveRoleAdmin = false;
1378 1395  
1379 1396 //2.
1380   - if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
1381   -
1382   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
1383   - }
1384   -
  1397 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
1385 1398  
1386 1399 //5.
1387 1400 sessionStorage.setItem("loginSession", "true");
... ... @@ -1554,6 +1567,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1554 1567 }
1555 1568  
1556 1569 $rootScope.loadUserSession = function () {
  1570 + //update session config from API
  1571 + Idle.setIdle($rootScope.aiaIdleTime);
  1572 + Idle.setTimeout($rootScope.aiaIdleTimeOut);
  1573 + Keepalive.setInterval($rootScope.aiaPingInterval);
  1574 +
1557 1575 Idle.watch();// start the session
1558 1576 $rootScope.isSessionTimeout=false;
1559 1577 $rootScope.isRedirectToAdmin=false;
... ...
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... ... @@ -573,6 +573,8 @@ AIA.config(function ($routeProvider, pages, $locationProvider) {
573 573 }
574 574 });
575 575 AIA.config(function(IdleProvider, KeepaliveProvider) {
  576 +
  577 + //default configuration
576 578 IdleProvider.idle(20*60); // 20 minutes idle
577 579 IdleProvider.timeout(30); // after 30 seconds idle, time the user out
578 580 KeepaliveProvider.interval(10); // 10 seconds keep-alive ping
... ...
400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js
... ... @@ -15,7 +15,7 @@
15 15 console.log('error')
16 16 deferred.reject(data);
17 17 $rootScope.isVisibleLogin = true;
18   - $scope.LoginEnableUI();
  18 + $rootScope.LoginEnableUI();
19 19 $rootScope.errorMessage = data;
20 20 $("#messageModal").modal('show');
21 21  
... ...
400-SOURCECODE/Admin/src/app/app.component.ts
... ... @@ -35,14 +35,14 @@ export class AppComponent implements OnInit {
35 35 constructor(private idle: Idle, private keepalive: Keepalive,private titleService: Title,private userservice: UserService,private _loadingService: LoadingService, public global: GlobalService, private router: Router,) {
36 36 const projectTitle= this.titleService.getTitle();
37 37  
38   - // sets an idle timeout of 20 minutes.
39   - this.idle.setIdle(20*60);
  38 + // sets an idle timeout of 20 minutes.
  39 + this.idle.setIdle(this.global.aiaIdleTime);
40 40  
41 41 // sets a timeout period of 30 seconds. after 30 seconds of inactivity, the user will be considered timed out.
42   - this.idle.setTimeout(30);
  42 + this.idle.setTimeout(this.global.aiaIdleTimeOut);
43 43  
44 44 // sets the ping interval to 10 seconds
45   - this.keepalive.interval(10);
  45 + this.keepalive.interval(this.global.aiaPingInterval);
46 46  
47 47 // sets the default interrupts, in this case, things like clicks, scrolls,mousemove touches to the document
48 48 this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
... ... @@ -139,11 +139,14 @@ export class AppComponent implements OnInit {
139 139 {
140 140 this._loadingService.HideLoading("global-loading");
141 141 }
142   -
143   - // comments below statement while unit testing on 'ng serve --open' command
  142 +
  143 + if(window.location.hostname!="localhost")
  144 + {
  145 + localStorage.removeItem('loggedInUserDetails');
  146 + window.location.href = window.location.origin;
144 147  
145   - // localStorage.removeItem('loggedInUserDetails');
146   - // window.location.href = window.location.origin;
  148 + }
  149 +
147 150 }
148 151  
149 152 },error => console.log(error));
... ...
400-SOURCECODE/Admin/src/app/shared/global.ts
... ... @@ -24,6 +24,9 @@ export class GlobalService {
24 24 AccLicId: number = 0;
25 25 LoginId:string="";
26 26 ProtocolType:string="";
  27 + aiaIdleTime:number=0;
  28 + aiaIdleTimeOut:number=0;
  29 + aiaPingInterval:number=0;
27 30 RemoveColumns: Array<string> = ["Serial_No", "LicenseId","RowNum"]
28 31 error;
29 32 public href: string = "";
... ... @@ -35,6 +38,10 @@ export class GlobalService {
35 38 this.UserTypeName = this.loggedInUser.UserType;
36 39 this.DisplayName = this.loggedInUser.FirstName + " " + this.loggedInUser.LastName;
37 40 this.LoginId=this.loggedInUser.LoginId;
  41 + this.aiaIdleTime=this.loggedInUser.aiaIdleTime;
  42 + this.aiaIdleTimeOut=this.loggedInUser.aiaIdleTimeOut;
  43 + this.aiaPingInterval=this.loggedInUser.aiaPingInterval;
  44 +
38 45 }
39 46  
40 47 this.NoRecords = 'No Record Found.';
... ... @@ -49,6 +56,7 @@ export class GlobalService {
49 56  
50 57 if(window.location.hostname=="localhost")
51 58 {
  59 + // for 'ng serve --open' command
52 60 //**** for localhost:4200 *****//
53 61 this.resourceBaseUrl = this.hostURL;
54 62 }
... ... @@ -62,6 +70,7 @@ export class GlobalService {
62 70 if (this.resourceBaseUrl == this.ProtocolType+"192.168.81.63:92/API/Adminapi/") {
63 71 if(window.location.hostname=="localhost")
64 72 {
  73 + // for 'ng serve --open' command
65 74 //**** for localhost:4200 *****//
66 75 localStorage.setItem('loggedInUserDetails', JSON.stringify(
67 76 {
... ...