summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openstack_dashboard/dashboards/identity/roles/urls.py22
-rw-r--r--openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.js16
-rw-r--r--openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.spec.js41
-rw-r--r--openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/panel.html4
-rw-r--r--openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.js84
-rw-r--r--openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.spec.js40
-rw-r--r--openstack_dashboard/settings.py1
-rw-r--r--openstack_dashboard/test/settings.py1
8 files changed, 201 insertions, 8 deletions
diff --git a/openstack_dashboard/dashboards/identity/roles/urls.py b/openstack_dashboard/dashboards/identity/roles/urls.py
index e0b50ba3a..4de1216fe 100644
--- a/openstack_dashboard/dashboards/identity/roles/urls.py
+++ b/openstack_dashboard/dashboards/identity/roles/urls.py
@@ -12,13 +12,23 @@
# License for the specific language governing permissions and limitations
# under the License.
+from django.conf import settings
from django.conf.urls import url
+from django.utils.translation import ugettext_lazy as _
+from horizon.browsers.views import AngularIndexView
from openstack_dashboard.dashboards.identity.roles import views
-urlpatterns = [
- url(r'^$', views.IndexView.as_view(), name='index'),
- url(r'^(?P<role_id>[^/]+)/update/$',
- views.UpdateView.as_view(), name='update'),
- url(r'^create/$', views.CreateView.as_view(), name='create'),
-]
+if settings.ANGULAR_FEATURES.get('roles_panel', False):
+ # New angular panel
+ title = _('Roles')
+ urlpatterns = [
+ url(r'^$', AngularIndexView.as_view(title=title), name='index'),
+ ]
+else:
+ urlpatterns = [
+ url(r'^$', views.IndexView.as_view(), name='index'),
+ url(r'^(?P<role_id>[^/]+)/update/$',
+ views.UpdateView.as_view(), name='update'),
+ url(r'^create/$', views.CreateView.as_view(), name='create'),
+ ]
diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.js
index bedb1a1f4..5dcdef3d3 100644
--- a/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.js
+++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.js
@@ -27,7 +27,19 @@
angular
.module('horizon.dashboard.identity', [
'horizon.dashboard.identity.users',
- 'horizon.dashboard.identity.projects'
- ]);
+ 'horizon.dashboard.identity.projects',
+ 'horizon.dashboard.identity.roles'
+ ])
+ .config(config);
+
+ config.$inject = [
+ '$provide',
+ '$windowProvider'
+ ];
+
+ function config($provide, $windowProvider) {
+ var path = $windowProvider.$get().STATIC_URL + 'dashboard/identity/';
+ $provide.constant('horizon.dashboard.identity.basePath', path);
+ }
})();
diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.spec.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.spec.js
new file mode 100644
index 000000000..bd05556f9
--- /dev/null
+++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/identity.module.spec.js
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2015 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+(function() {
+ 'use strict';
+
+ describe('horizon.dashboard.identity', function() {
+ it('should exist', function() {
+ expect(angular.module('horizon.dashboard.identity')).toBeDefined();
+ });
+ });
+
+ describe('horizon.dashboard.identity.basePath constant', function() {
+ var identityBasePath, staticUrl;
+
+ beforeEach(module('horizon.app.core.openstack-service-api'));
+ beforeEach(module('horizon.dashboard.identity'));
+ beforeEach(module('horizon.framework'));
+ beforeEach(inject(function($injector) {
+ identityBasePath = $injector.get('horizon.dashboard.identity.basePath');
+ staticUrl = $injector.get('$window').STATIC_URL;
+ }));
+
+ it('should equal to "/static/dashboard/identity/"', function() {
+ expect(identityBasePath).toEqual(staticUrl + 'dashboard/identity/');
+ });
+ });
+
+})();
diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/panel.html b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/panel.html
new file mode 100644
index 000000000..0026ad7db
--- /dev/null
+++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/panel.html
@@ -0,0 +1,4 @@
+<hz-resource-panel resource-type-name="OS::Keystone::Role">
+ <hz-resource-table resource-type-name="OS::Keystone::Role">
+ </hz-resource-table>
+</hz-resource-panel>
diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.js
new file mode 100644
index 000000000..6ca5340fa
--- /dev/null
+++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.js
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2016 99Cloud
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+(function() {
+ 'use strict';
+
+ /**
+ * @ngdoc overview
+ * @ngname horizon.dashboard.identity.roles
+ *
+ * @description
+ * Provides all of the services and widgets required
+ * to support and display roles related content.
+ */
+ angular
+ .module('horizon.dashboard.identity.roles', [
+ 'ngRoute'
+ ])
+ .constant('horizon.dashboard.identity.roles.resourceType', 'OS::Keystone::Role')
+ .run(run)
+ .config(config);
+
+ run.$inject = [
+ 'horizon.framework.conf.resource-type-registry.service',
+ 'horizon.app.core.openstack-service-api.keystone',
+ 'horizon.dashboard.identity.roles.resourceType'
+ ];
+
+ function run(registry, keystone, roleResourceType) {
+ registry.getResourceType(roleResourceType)
+ .setNames(gettext('Role'), gettext('Roles'))
+ .setProperties(roleProperties())
+ .setListFunction(listFunction)
+ .tableColumns
+ .append({
+ id: 'name',
+ priority: 1,
+ sortDefault: true
+ })
+ .append({
+ id: 'id',
+ priority: 1
+ });
+
+ function listFunction() {
+ return keystone.getRoles();
+ }
+
+ function roleProperties() {
+ return {
+ name: { label: gettext('Name'), filters: ['noName'] },
+ id: { label: gettext('ID'), filters: ['noValue'] }
+ };
+ }
+ }
+
+ config.$inject = [
+ '$provide',
+ '$windowProvider',
+ '$routeProvider'
+ ];
+
+ function config($provide, $windowProvider, $routeProvider) {
+ var path = $windowProvider.$get().STATIC_URL + 'dashboard/identity/roles/';
+ $provide.constant('horizon.dashboard.identity.roles.basePath', path);
+
+ $routeProvider.when('/identity/roles', {
+ templateUrl: path + 'panel.html'
+ });
+ }
+})();
diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.spec.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.spec.js
new file mode 100644
index 000000000..6600511cb
--- /dev/null
+++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/roles/roles.module.spec.js
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2016 99Cloud
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+(function () {
+ 'use strict';
+
+ describe('horizon.dashboard.identity.roles', function () {
+ it('should exist', function () {
+ expect(angular.module('horizon.dashboard.identity.roles')).toBeDefined();
+ });
+ });
+
+ describe('horizon.dashboard.identity.roles.basePath constant', function() {
+ var rolesBasePath, staticUrl;
+
+ beforeEach(module('horizon.app.core.openstack-service-api'));
+ beforeEach(module('horizon.dashboard.identity'));
+ beforeEach(module('horizon.framework'));
+ beforeEach(inject(function($injector) {
+ rolesBasePath = $injector.get('horizon.dashboard.identity.roles.basePath');
+ staticUrl = $injector.get('$window').STATIC_URL;
+ }));
+
+ it('should equal to "/static/dashboard/identity/roles"', function() {
+ expect(rolesBasePath).toEqual(staticUrl + 'dashboard/identity/roles/');
+ });
+ });
+})();
diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py
index 22f9857a2..2e4e2bd4c 100644
--- a/openstack_dashboard/settings.py
+++ b/openstack_dashboard/settings.py
@@ -323,6 +323,7 @@ ANGULAR_FEATURES = {
'images_panel': True,
'flavors_panel': False,
'users_panel': False,
+ 'roles_panel': False
}
# Notice all customizable configurations should be above this line
diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py
index 0e22750eb..1d143dcc2 100644
--- a/openstack_dashboard/test/settings.py
+++ b/openstack_dashboard/test/settings.py
@@ -101,6 +101,7 @@ HORIZON_CONFIG = {
ANGULAR_FEATURES = {
'images_panel': False, # Use the legacy panel so unit tests are still run
'flavors_panel': False,
+ 'roles_panel': False,
}
STATICFILES_DIRS = settings_utils.get_xstatic_dirs(