Skip to content

Commit

Permalink
ngAdmin
Browse files Browse the repository at this point in the history
Timer and Reset-button added
  • Loading branch information
disc5 committed Jul 13, 2015
1 parent 1afdf02 commit cef9515
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@

<ul class="nav navbar-nav navbar-right addRightPadding" data-ng-show="authentication.isAuthenticated()" data-ng-cloak>
<li><button class="btn btn-default navbar-btn" type="button" data-ng-click="reload()"><span class="glyphicon glyphicon-repeat"></span></button></li>

<li><span class="navbar-text">{{'INDEX_LOGGED_IN' | translate:translationData}} [<timer end-time="1451628000000">{{minutes}}:{{seconds}}</timer>]</span></li>
<!-- end-=time"10000" 1451628000000 -->
<li><span class="navbar-text">{{'INDEX_LOGGED_IN' | translate:translationData}} [<timer countdown="1800" max-time-unit="'minute'" interval="1000" finish-callback="authentication.logout()">{{mminutes}}:{{sseconds}}</timer>]</span></li>
<li><button class="btn btn-default navbar-btn" type="button" data-ng-click="authentication.logout()">{{'INDEX_LOGOUT' | translate}}</button></li>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ctrl.controller("MainCtrl", function($scope, $location, $filter, breadcrumbs, au
$scope.translationData = {
authentication: authentication
};

};


Expand All @@ -49,13 +50,24 @@ ctrl.controller("MainCtrl", function($scope, $location, $filter, breadcrumbs, au
return $location.path().toLowerCase() == '/login';
};

/*
* Reload current view
*/
$scope.reload = function() {
$route.reload();
//$location.url("/login");
//$location.url("/clientlist");
//$location.url($location.url());
}


$scope.resetTimer = function() {
$scope.$broadcast('timer-reset');
$scope.$broadcast('timer-start');
}


$scope.$on('loginPerformed', function (event) {
$scope.resetTimer();
});

// Do the initialisation
$scope.init();
});
Expand Down Expand Up @@ -423,6 +435,7 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
$scope.postVars = {};
$scope.authentication.login(response.user, response.token.access_token);
$location.url("/clientlist");
$scope.$emit('loginPerformed');
// Login didn't return an OK (Logout internally and redirdct)
} else {
$scope.authentication.logout();
Expand Down Expand Up @@ -459,6 +472,7 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
if (response.token_type == "bearer") {
$scope.authentication.login($scope.formData.userName, response.access_token);
$location.url("/clientlist");
$scope.$emit('loginPerformed');
// Authorisation failed (Logout internally and redirdct)
} else {
$scope.authentication.logout();
Expand All @@ -483,7 +497,6 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu
);
};


// Do the initialisation
$scope.init();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
var services = angular.module('myApp.services', []);


/*
* This service handles and stores user authentication,
* which mainly includes username, bearer-token, error-handling
Expand Down Expand Up @@ -75,6 +74,7 @@ services.provider('authentication', function() {
data.isAuthenticated = false;
data.autoLogin = false;


// Redirect to login
$location.url("/login");
};
Expand Down Expand Up @@ -106,6 +106,7 @@ services.provider('authentication', function() {
this.getToken = function() {
return data.token;
}

});


Expand Down

0 comments on commit cef9515

Please sign in to comment.