merge User Federation/Storage menu

This commit is contained in:
Bill Burke 2016-08-08 16:02:06 -04:00
parent 83306963e8
commit d14de43ac7
5 changed files with 93 additions and 58 deletions

View file

@ -1338,18 +1338,6 @@ module.config([ '$routeProvider', function($routeProvider) {
},
controller : 'RealmSessionStatsCtrl'
})
.when('/realms/:realm/user-storage', {
templateUrl : resourceUrl + '/partials/user-storage.html',
resolve : {
realm : function(RealmLoader) {
return RealmLoader();
},
serverInfo : function(ServerInfoLoader) {
return ServerInfoLoader();
}
},
controller : 'UserStorageCtrl'
})
.when('/create/user-storage/:realm/providers/:provider', {
templateUrl : resourceUrl + '/partials/user-storage-generic.html',
resolve : {
@ -1393,6 +1381,9 @@ module.config([ '$routeProvider', function($routeProvider) {
resolve : {
realm : function(RealmLoader) {
return RealmLoader();
},
serverInfo : function(ServerInfoLoader) {
return ServerInfoLoader();
}
},
controller : 'UserFederationCtrl'

View file

@ -592,22 +592,91 @@ module.controller('UserCredentialsCtrl', function($scope, realm, user, RequiredA
};
});
module.controller('UserStorageCtrl', function($scope, $location, $route, realm, serverInfo, Components, Notifications, Dialog) {
console.log('UserStorageCtrl ++++****');
module.controller('UserFederationCtrl', function($scope, $location, $route, realm, serverInfo, Components, UserFederationProviders, UserFederationInstances, Notifications, Dialog) {
console.log('UserFederationCtrl ++++****');
$scope.realm = realm;
$scope.providers = serverInfo.componentTypes['org.keycloak.storage.UserStorageProvider'];
for (var i = 0; i < $scope.providers.length; i++) {
$scope.providers[i].isUserFederationProvider = false;
}
UserFederationProviders.query({realm: realm.realm}, function(data) {
for (var i = 0; i < data.length; i++) {
data[i].isUserFederationProvider = true;
$scope.providers.push(data[i]);
}
});
$scope.addProvider = function(provider) {
console.log('Add provider: ' + provider.id);
if (provider.isUserFederationProvider) {
$location.url("/create/user-federation/" + realm.realm + "/providers/" + provider.id);
} else {
$location.url("/create/user-storage/" + realm.realm + "/providers/" + provider.id);
}
};
$scope.instances = Components.query({realm: realm.realm,
$scope.getInstanceLink = function(instance) {
if (instance.isUserFederationProvider) {
return "/realms/" + realm.realm + "/user-federation/providers/" + instance.providerName + "/" + instance.id;
} else {
return "/realms/" + realm.realm + "/user-storage/providers/" + instance.providerId + "/" + instance.id;
}
}
$scope.getInstanceName = function(instance) {
if (instance.isUserFederationProvider) {
return instance.displayName;
} else {
return instance.name;
}
}
$scope.getInstanceProvider = function(instance) {
if (instance.isUserFederationProvider) {
return instance.providerName;
} else {
return instance.providerId;
}
}
$scope.getInstancePriority = function(instance) {
if (instance.isUserFederationProvider) {
return instance.priority;
} else {
return instance.config['priority'][0];
}
}
Components.query({realm: realm.realm,
parent: realm.id,
type: 'org.keycloak.storage.UserStorageProvider'
}, function(data) {
$scope.instances = data;
for (var i = 0; i < data.length; i++) {
data[i].isUserFederationProvider = false;
}
UserFederationInstances.query({realm: realm.realm}, function(data) {
for (var i = 0; i < data.length; i++) {
data[i].isUserFederationProvider = true;
$scope.instances.push(data[i]);
}
});
});
$scope.removeUserStorage = function(instance) {
$scope.removeInstance = function(instance) {
if (instance.isUserFederationProvider) {
Dialog.confirmDelete(instance.displayName, 'user federation provider', function() {
UserFederationInstances.remove({
realm : realm.realm,
instance : instance.id
}, function() {
$route.reload();
Notifications.success("The provider has been deleted.");
});
});
} else {
Dialog.confirmDelete(instance.name, 'user storage provider', function() {
Components.remove({
realm : realm.realm,
@ -617,11 +686,12 @@ module.controller('UserStorageCtrl', function($scope, $location, $route, realm,
Notifications.success("The provider has been deleted.");
});
});
}
};
});
module.controller('GenericUserStorageCtrl', function($scope, $location, Notifications, $route, Dialog, realm, serverInfo, instance, providerId, Components) {
console.log('GenericUserFederationCtrl');
console.log('GenericUserStorageCtrl');
console.log('providerId: ' + providerId);
$scope.create = !instance.providerId;
console.log('create: ' + $scope.create);
@ -737,31 +807,6 @@ module.controller('GenericUserStorageCtrl', function($scope, $location, Notifica
});
module.controller('UserFederationCtrl', function($scope, $location, $route, realm, UserFederationProviders, UserFederationInstances, Notifications, Dialog) {
console.log('UserFederationCtrl ++++****');
$scope.realm = realm;
$scope.providers = UserFederationProviders.query({realm: realm.realm});
$scope.addProvider = function(provider) {
console.log('Add provider: ' + provider.id);
$location.url("/create/user-federation/" + realm.realm + "/providers/" + provider.id);
};
$scope.instances = UserFederationInstances.query({realm: realm.realm});
$scope.removeUserFederation = function(instance) {
Dialog.confirmDelete(instance.displayName, 'user federation provider', function() {
UserFederationInstances.remove({
realm : realm.realm,
instance : instance.id
}, function() {
$route.reload();
Notifications.success("The provider has been deleted.");
});
});
};
});
module.controller('UserFederationTabCtrl', function(Dialog, $scope, Current, Notifications, $location) {
$scope.removeUserFederation = function() {
Dialog.confirmDelete($scope.instance.displayName, 'user federation provider', function() {

View file

@ -27,11 +27,11 @@
</thead>
<tbody>
<tr ng-repeat="instance in instances">
<td><a href="#/realms/{{realm.realm}}/user-federation/providers/{{instance.providerName}}/{{instance.id}}">{{instance.displayName}}</a></td>
<td>{{instance.providerName|capitalize}}</td>
<td>{{instance.priority}}</td>
<td class="kc-action-cell" kc-open="/realms/{{realm.realm}}/user-federation/providers/{{instance.providerName}}/{{instance.id}}">{{:: 'edit' | translate}}</td>
<td class="kc-action-cell" data-ng-click="removeUserFederation(instance)">{{:: 'delete' | translate}}</td>
<td><a href="#{{getInstanceLink(instance)}}">{{getInstanceName(instance)}}</a></td>
<td>{{getInstanceProvider(instance)|capitalize}}</td>
<td>{{getInstancePriority(instance)}}</td>
<td class="kc-action-cell" kc-open="{{getInstanceLink(instance)}}">{{:: 'edit' | translate}}</td>
<td class="kc-action-cell" data-ng-click="removeInstance(instance)">{{:: 'delete' | translate}}</td>
</tr>
<tr data-ng-show="!instances || instances.length == 0">
<td class="text-muted">{{:: 'no-user-federation-providers-configured' | translate}}</td>

View file

@ -1,6 +1,6 @@
<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
<ol class="breadcrumb">
<li><a href="#/realms/{{realm.realm}}/user-storage">{{:: 'user-storage' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/user-federation">{{:: 'user-federation' | translate}}</a></li>
<li data-ng-hide="create">{{instance.name|capitalize}}</li>
<li data-ng-show="create">{{:: 'add-user-storage-provider' | translate}}</li>
</ol>

View file

@ -34,7 +34,6 @@
<li data-ng-show="access.viewRealm" data-ng-class="(path[2] == 'roles' || path[2] == 'default-roles' || (path[1] == 'role' && path[3] != 'clients')) && 'active'"><a href="#/realms/{{realm.realm}}/roles"><i class="fa fa-tasks"></i> {{:: 'roles' | translate}}</a></li>
<li data-ng-show="access.viewIdentityProviders" data-ng-class="(path[2] == 'identity-provider-settings' || path[2] == 'identity-provider-mappers') && 'active'"><a href="#/realms/{{realm.realm}}/identity-provider-settings"><i class="fa fa-exchange"></i> {{:: 'identity-providers' | translate}}</a></li>
<li data-ng-show="access.viewUsers" data-ng-class="(path[1] == 'user-federation' || path[2] == 'user-federation') && 'active'"><a href="#/realms/{{realm.realm}}/user-federation"><i class="fa fa-database"></i> {{:: 'user-federation' | translate}}</a></li>
<li data-ng-show="access.viewUsers" data-ng-class="(path[1] == 'user-storage' || path[2] == 'user-storage') && 'active'"><a href="#/realms/{{realm.realm}}/user-storage"><i class="fa fa-database"></i> {{:: 'user-storage' | translate}}</a></li>
<li data-ng-show="access.viewRealm" data-ng-class="(path[1] == 'authentication' || path[2] == 'authentication') && 'active'"><a href="#/realms/{{realm.realm}}/authentication/flows"><i class="fa fa-lock"></i> {{:: 'authentication' | translate}}</a></li>
</ul>
</div>