Blame view
app/partials/main/main.controller.js
3.85 KB
feacde5ff
|
1 2 3 4 |
(function() { 'use strict' angular.module('acufuel') |
e33b4556c
|
5 |
.controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]); |
feacde5ff
|
6 |
|
e33b4556c
|
7 |
function MainController($scope, $filter, $rootScope,$state, $window, $interval) { |
9aea92263
|
8 |
|
1b71872b2
|
9 |
$scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); |
8041a48e1
|
10 |
$scope.companyName = JSON.parse(localStorage.getItem('companyName')); |
f62f8940f
|
11 |
var User = JSON.parse(localStorage.getItem('currentUser')); |
9aea92263
|
12 13 14 15 16 17 18 |
//for login userTime from GetAPI timezone var tempuserTime = JSON.parse(localStorage.getItem('userTime')); if (tempuserTime != null) { if (tempuserTime.slice(0, 1) === "P") { $scope.userTimeZone = tempuserTime.replace("P", "+"); |
938f3037d
|
19 |
// console.log("==p===",$scope.userTimeZone) |
9aea92263
|
20 21 |
} else if (tempuserTime.slice(0, 1) === "M") { $scope.userTimeZone = tempuserTime.replace("M", "-"); |
938f3037d
|
22 |
//console.log("==M===",$scope.userTimeZone) |
9aea92263
|
23 24 25 26 27 |
} } else { $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); |
938f3037d
|
28 |
//console.log("===$scope.userTimeZone==",$scope.userTimeZone) |
9aea92263
|
29 |
} |
429786996
|
30 |
|
f62f8940f
|
31 32 33 |
if(User.type === 'ADDITIONAL'){ $scope.companyName = $scope.currentUserName; } |
e33b4556c
|
34 |
|
9aea92263
|
35 |
|
3c77051a2
|
36 37 |
$scope.testFunction = function(){ $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); |
8041a48e1
|
38 |
$scope.companyName = JSON.parse(localStorage.getItem('companyName')); |
9aea92263
|
39 |
$scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); |
938f3037d
|
40 |
//console.log("===$scope.userTimeZone test==",$scope.userTimeZone) |
9aea92263
|
41 |
|
3c77051a2
|
42 |
} |
f62f8940f
|
43 44 45 46 47 48 49 |
$scope.logout = function(){ $state.go('login'); localStorage.clear(); $rootScope.isAuthenticated = false; } |
7b21cec8f
|
50 |
|
e33b4556c
|
51 |
/** |
24fce0949
|
52 |
Automatic logout session after 2 hours |
e33b4556c
|
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
**/ var resetTime; /*function warning(){ //setTimeout(function(){ $('.warning-message').delay(5000).css('display', 'block'); //}, 5000); }*/ resetTime = setInterval(function(){ // $('.warning-message').delay(5000).css('display', 'block'); //console.log('out'); localStorage.clear(); $state.go('login'); |
24fce0949
|
67 |
}, 7200000); |
e33b4556c
|
68 69 70 71 72 73 74 75 76 77 78 79 |
$(document).mousemove(function(event){ clearInterval(resetTime); //$('.warning-message').delay(5000).css('display', 'none'); // warning(); //console.log('restart'); resetTime = setInterval(function(){ //console.log('out'); //warning(); localStorage.clear(); $state.go('login'); |
24fce0949
|
80 |
}, 7200000); |
e33b4556c
|
81 82 83 |
}) |
3c77051a2
|
84 |
|
da40330c8
|
85 |
// Flight Tracking page code |
1b71872b2
|
86 87 |
/*$scope.reloadPage = function(){ console.log("if",$state) |
429786996
|
88 |
console.log("=========state name",$state.current.name); |
1b71872b2
|
89 90 91 |
// $state.go('app.flightTracking', {}, {reload: 'app.flightTracking'}) //$state.go($state.current, {}, {reload: true}); |
429786996
|
92 |
if($state.current.name != "app.flightTracking"){ |
bfb1a2a46
|
93 |
$window.location.href = '/#!/flightTracking'; |
429786996
|
94 95 96 97 |
setInterval(function(){ console.log("come") $window.location.reload() },10); |
1b71872b2
|
98 |
}else{ |
429786996
|
99 100 101 |
console.log("flight tracking state found====="); $window.location.reload(); } |
1b71872b2
|
102 |
}*/ |
bfb1a2a46
|
103 |
|
e33b4556c
|
104 |
// Set timeout variables. |
bfb1a2a46
|
105 |
|
feacde5ff
|
106 |
} |
e33b4556c
|
107 108 109 110 |
//var timoutWarning = 840000; // Display warning in 14 Mins. //var timoutNow = 900000; // Timeout in 15 mins. |
da40330c8
|
111 |
|
feacde5ff
|
112 |
})(); |
da40330c8
|
113 |