main.controller.js 2.53 KB
(function() {
    'use strict'
    
    angular.module('acufuel')
        .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]);
        
    function MainController($scope, $filter, $rootScope,$state, $window, $interval) {
     
    	$scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
        $scope.companyName = JSON.parse(localStorage.getItem('companyName'));


        $scope.testFunction = function(){
            $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
            $scope.companyName = JSON.parse(localStorage.getItem('companyName'));
        }
        
        /** 
             Automatic logout session after 2 hours 
        **/

        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');
        }, 7200000);

            
        $(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');
            }, 7200000);
        })

    

// Flight Tracking page code

    	/*$scope.reloadPage = function(){
    		console.log("if",$state)
            console.log("=========state name",$state.current.name);
    		// $state.go('app.flightTracking', {}, {reload: 'app.flightTracking'})
    		//$state.go($state.current, {}, {reload: true});
    		
            if($state.current.name != "app.flightTracking"){
                $window.location.href = '/#!/flightTracking';
                setInterval(function(){
                    console.log("come")
                    $window.location.reload()
                },10);
    		}else{   
                console.log("flight tracking state found=====");
                $window.location.reload();
            }
    	}*/
    
           // Set timeout variables.

    }
        //var timoutWarning = 840000; // Display warning in 14 Mins.
        //var timoutNow = 900000; // Timeout in 15 mins.

   


})();