You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by ma...@apache.org on 2016/10/05 15:21:09 UTC
syncope git commit: [SYNCOPE-941] adds dynamic configuration screens
to enduser
Repository: syncope
Updated Branches:
refs/heads/2_0_X 6e6deae5f -> 6ba24ed07
[SYNCOPE-941] adds dynamic configuration screens to enduser
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/6ba24ed0
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/6ba24ed0
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/6ba24ed0
Branch: refs/heads/2_0_X
Commit: 6ba24ed077746fe4f69595f782e1358ab23cb37c
Parents: 6e6deae
Author: Matteo Di Carlo <ma...@tirasa.net>
Authored: Wed Oct 5 17:20:24 2016 +0200
Committer: Matteo Di Carlo <ma...@tirasa.net>
Committed: Wed Oct 5 17:20:47 2016 +0200
----------------------------------------------------------------------
.../resources/META-INF/resources/app/js/app.js | 15 ++--
.../app/js/controllers/UserController.js | 41 ++++++++--
.../app/js/directives/navigationButtons.js | 84 ++++++++++----------
3 files changed, 83 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/6ba24ed0/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
index 5bffed2..5984f21 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
@@ -256,6 +256,7 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$translate
};
});
}]);
+
app.run(['$rootScope', '$location', '$state', 'AuthService',
function ($rootScope, $location, $state, AuthService) {
// main program
@@ -420,16 +421,12 @@ app.controller('ApplicationController', ['$scope', '$rootScope', 'InfoService',
$scope.$on('hideErrorMessage', function (event, popupMessage) {
$scope.hideError(popupMessage, $scope.notification);
});
- //wizard active element
- $scope.wizard = {
- "credentials": {url: "/credentials"},
- "groups": {url: "/groups"},
- "plainSchemas": {url: "/plainSchemas"},
- "derivedSchemas": {url: "/derivedSchemas"},
- "virtualSchemas": {url: "/virtualSchemas"},
- "resources": {url: "/resources"},
- "finish": {url: "/finish"}
+
+ $rootScope.wizard = {
+ "credentials": "/credentials",
+ "groups": "/groups"
};
+
$scope.clearCache = function () {
$templateCache.removeAll();
};
http://git-wip-us.apache.org/repos/asf/syncope/blob/6ba24ed0/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
index ebf5c81..5047c06 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js
@@ -17,7 +17,7 @@
* under the License.
*/
-/* global message, component, $state, rootScope */
+/* global message, component, $state, rootScope, $q */
'use strict';
@@ -73,6 +73,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
$scope.dynamicForm.groupSchemas.push(group);
//initializing user schemas values
initSchemaValues(schemas);
+ initWizard();
}, function (response) {
var errorMessage;
// parse error response
@@ -84,6 +85,26 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
});
};
+ var initWizard = function () {
+ $rootScope.wizard = {
+ "credentials": "/credentials",
+ "groups": "/groups"
+ };
+ if ($scope.dynamicForm.plainSchemas.length > 0) {
+ $rootScope.wizard["plainSchemas"] = "/plainSchemas";
+ }
+ if ($scope.dynamicForm.derSchemas.length > 0) {
+ $rootScope.wizard["derivedSchemas"] = "/derivedSchemas";
+ }
+ if ($scope.dynamicForm.virSchemas.length > 0) {
+ $rootScope.wizard["virtualSchemas"] = "/virtualSchemas";
+ }
+ if ($scope.dynamicForm.resources.length > 0) {
+ $rootScope.wizard["resources"] = "/resources";
+ }
+ $rootScope.wizard["finish"] = "/finish";
+ };
+
var initSchemaValues = function (schemas) {
// initialize plain attributes
for (var i = 0; i < schemas.plainSchemas.length; i++) {
@@ -182,6 +203,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
$scope.dynamicForm.resources.push(response[i].key);
}
$scope.dynamicForm.resources.sort();
+ initWizard();
});
};
@@ -243,11 +265,11 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
UserSelfService.read().then(function (response) {
$scope.user = UserUtil.getUnwrappedUser(response);
$scope.user.password = undefined;
-
+
$scope.initialSecurityQuestion = $scope.user.securityQuestion;
// initialize already assigned resources
$scope.dynamicForm.selectedResources = $scope.user.resources;
-
+
// initialize already assigned groups -- keeping the same structure of groups
for (var index in $scope.user.memberships) {
$scope.dynamicForm.selectedGroups.push(
@@ -333,9 +355,18 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
initUserSchemas(null, group);
});
+ $scope.$on('addFinish', function (event) {
+ $rootScope.wizard.finish = {
+ url: "/finish"
+ };
+ });
+
+
+
$scope.$on('groupRemoved', function (event, group) {
if (group)
removeUserSchemas(null, group);
+ initWizard();
});
if ($scope.createMode) {
@@ -409,7 +440,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
});
}
};
-
+
$scope.retrieveSecurityQuestion = function (user) {
if ($rootScope.pwdResetRequiringSecurityQuestions) {
if (user && user.username && user.username.length) {
@@ -431,7 +462,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
}
}
};
-
+
$scope.resetPassword = function (user) {
if (user && user.username) {
$scope.retrieveSecurityQuestion(user);
http://git-wip-us.apache.org/repos/asf/syncope/blob/6ba24ed0/client/enduser/src/main/resources/META-INF/resources/app/js/directives/navigationButtons.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/navigationButtons.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/navigationButtons.js
index d8b6986..3dcb70b 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/navigationButtons.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/navigationButtons.js
@@ -19,54 +19,52 @@
'use strict';
angular.module('self')
- .directive('navigationButtons', ['$state', 'GenericUtil', 'ValidationExecutor', function ($state, GenericUtil, ValidationExecutor) {
- return {
- restrict: 'E',
- templateUrl: 'views/navigationButtons.html',
- scope: {
+ .directive('navigationButtons', ['$state', '$rootScope', 'GenericUtil', 'ValidationExecutor', function ($state, $rootScope, GenericUtil, ValidationExecutor) {
+ return {
+ restrict: 'E',
+ templateUrl: 'views/navigationButtons.html',
+ scope: {
base: "@",
- current: "@"
- },
- link: function (scope, element, attrs) {
+ current: "@"
+ },
+ link: function (scope, element, attrs) {
var base = (scope.base && scope.base != "" ? scope.base + "." : "");
- scope.wizard = scope.$eval(attrs.wizard) || scope.$parent.wizard;
- scope.previous = "none";
- if (scope.wizard) {
- var urls = Object.keys(scope.wizard);
- var index = urls.indexOf(scope.current);
- scope.previous = (index > 0 ? base + urls[index - 1] : scope.previous = "none");
- scope.next = (index < urls.length - 1 ? base + urls[index + 1] : scope.next = "none");
+ $rootScope.wizard = scope.$eval(attrs.wizard) || scope.$parent.wizard;
+ scope.previous = "none";
+ if ($rootScope.wizard) {
+ var urls = Object.keys($rootScope.wizard);
+ var index = urls.indexOf(scope.current);
+ scope.previous = (index > 0 ? base + urls[index - 1] : scope.previous = "none");
+ scope.next = (index < urls.length - 1 ? base + urls[index + 1] : scope.next = "none");
}
- },
- controller: function ($scope) {
+ },
+ controller: function ($scope) {
$scope.validateAndNext = function (event, state) {
- //getting the enclosing form in order to access to its name
- var currentForm = GenericUtil.getEnclosingForm(event.target);
- if (currentForm != null) {
- if (ValidationExecutor.validate(currentForm, $scope.$parent)) {
- if (state) {
- $scope.nextTab(state);
- } else if ($scope.wizard) {
- $scope.nextTab($scope.next);
- }
- }
- }
-
- };
-
- $scope.nextTab = function (state) {
- //change route through parent event
- console.log("State: ", state);
- $state.go(state);
- };
+ //getting the enclosing form in order to access to its name
+ var currentForm = GenericUtil.getEnclosingForm(event.target);
+ if (currentForm != null) {
+ if (ValidationExecutor.validate(currentForm, $scope.$parent)) {
+ if (state) {
+ $scope.nextTab(state);
+ } else if ($rootScope.wizard) {
+ $scope.nextTab($scope.next);
+ }
+ }
+ }
- $scope.previousTab = function () {
- //change route through parent event
- $state.go($scope.previous);
};
- }
+ $scope.nextTab = function (state) {
+ //change route through parent event
+ console.log("State: ", state);
+ $state.go(state);
+ };
+ $scope.previousTab = function () {
+ //change route through parent event
+ $state.go($scope.previous);
+ };
+ }
- }
- ;
- }]);
+ }
+ ;
+ }]);