From cef95150e62426163200abe5d1c1034165d16173 Mon Sep 17 00:00:00 2001 From: disc5 Date: Mon, 13 Jul 2015 15:24:56 +0200 Subject: [PATCH] ngAdmin Timer and Reset-button added --- .../REST/apps/admin/index.php | 4 ++-- .../REST/apps/admin/js/controllers.js | 21 +++++++++++++++---- .../REST/apps/admin/js/services.js | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php index f0886f8d..8d835dc9 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/index.php @@ -73,8 +73,8 @@ diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js index 908f8fd7..b151e4b0 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/controllers.js @@ -38,6 +38,7 @@ ctrl.controller("MainCtrl", function($scope, $location, $filter, breadcrumbs, au $scope.translationData = { authentication: authentication }; + }; @@ -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(); }); @@ -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(); @@ -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(); @@ -483,7 +497,6 @@ ctrl.controller('LoginCtrl', function($scope, $location, $filter, apiKey, restAu ); }; - // Do the initialisation $scope.init(); }); diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/services.js b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/services.js index 62e754bc..10110855 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/services.js +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/apps/admin/js/services.js @@ -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 @@ -75,6 +74,7 @@ services.provider('authentication', function() { data.isAuthenticated = false; data.autoLogin = false; + // Redirect to login $location.url("/login"); }; @@ -106,6 +106,7 @@ services.provider('authentication', function() { this.getToken = function() { return data.token; } + });