summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards
diff options
context:
space:
mode:
authorchen.qiaomin@99cloud.net <chen.qiaomin@99cloud.net>2016-07-22 11:32:09 +0800
committerCindy Lu <clu@us.ibm.com>2017-01-04 11:54:59 -0800
commit001c2a1879fd4e2f0dc594da4d4429be0c43c9a5 (patch)
tree7491059c19e581864957f84dae7abe04e6314e0c /openstack_dashboard/dashboards
parente5dac64cb0aac2176d5a608b155976f5375d6a7e (diff)
downloadhorizon-001c2a1879fd4e2f0dc594da4d4429be0c43c9a5.tar.gz
Adding identity ng-roles panel
This patch adds an angular roles table. To be added in subsequent patches: - Actions - filterFacets - Integration to Searchlight To test, v3 needs to be enabled in local_settings.py and set 'roles_panel' to True in settings.py Change-Id: Ie0eb168774f15536c778917abeb293e79d3b34e8 Co-Authored-By: Allen <chen.qiaomin@99cloud.net> Co-Authored-By: kenji-i <ken-ishii@sx.jp.nec.com> Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com> Partially-implements: blueprint ng-roles
Diffstat (limited to 'openstack_dashboard/dashboards')
-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
6 files changed, 199 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/');
+ });
+ });
+})();