Blame view
app/partials/main/main.controller.js
2.89 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) { |
dd378d69f
|
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')); |
429786996
|
12 |
|
f62f8940f
|
13 14 15 |
if(User.type === 'ADDITIONAL'){ $scope.companyName = $scope.currentUserName; } |
e33b4556c
|
16 |
|
3c77051a2
|
17 18 |
$scope.testFunction = function(){ $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); |
8041a48e1
|
19 |
$scope.companyName = JSON.parse(localStorage.getItem('companyName')); |
3c77051a2
|
20 |
} |
f62f8940f
|
21 22 23 24 25 26 27 |
$scope.logout = function(){ $state.go('login'); localStorage.clear(); $rootScope.isAuthenticated = false; } |
e33b4556c
|
28 29 |
/** |
24fce0949
|
30 |
Automatic logout session after 2 hours |
e33b4556c
|
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
**/ 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
|
45 |
}, 7200000); |
e33b4556c
|
46 47 48 49 50 51 52 53 54 55 56 57 |
$(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
|
58 |
}, 7200000); |
e33b4556c
|
59 60 61 |
}) |
3c77051a2
|
62 |
|
da40330c8
|
63 |
// Flight Tracking page code |
1b71872b2
|
64 65 |
/*$scope.reloadPage = function(){ console.log("if",$state) |
429786996
|
66 |
console.log("=========state name",$state.current.name); |
1b71872b2
|
67 68 69 |
// $state.go('app.flightTracking', {}, {reload: 'app.flightTracking'}) //$state.go($state.current, {}, {reload: true}); |
429786996
|
70 |
if($state.current.name != "app.flightTracking"){ |
bfb1a2a46
|
71 |
$window.location.href = '/#!/flightTracking'; |
429786996
|
72 73 74 75 |
setInterval(function(){ console.log("come") $window.location.reload() },10); |
1b71872b2
|
76 |
}else{ |
429786996
|
77 78 79 |
console.log("flight tracking state found====="); $window.location.reload(); } |
1b71872b2
|
80 |
}*/ |
bfb1a2a46
|
81 |
|
e33b4556c
|
82 |
// Set timeout variables. |
bfb1a2a46
|
83 |
|
feacde5ff
|
84 |
} |
e33b4556c
|
85 86 87 88 |
//var timoutWarning = 840000; // Display warning in 14 Mins. //var timoutNow = 900000; // Timeout in 15 mins. |
da40330c8
|
89 |
|
feacde5ff
|
90 |
})(); |
da40330c8
|
91 |