From 735d456cc2e02318232eb26bf8c8d72ef5a1831b Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 19 Jan 2016 17:39:17 +0100 Subject: [PATCH] feature #4210: Add groups panel --- src/sunstone/etc/sunstone-views/admin.yaml | 1 + .../etc/sunstone-views/admin_vcenter.yaml | 1 + src/sunstone/etc/sunstone-views/user.yaml | 1 + src/sunstone/public/app/tabs/users-tab.js | 1 + .../app/tabs/users-tab/dialogs/groups.js | 2 +- .../app/tabs/users-tab/panels/groups.js | 90 +++++++++++++++++++ .../tabs/users-tab/panels/groups/panelId.js | 19 ++++ 7 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/sunstone/public/app/tabs/users-tab/panels/groups.js create mode 100644 src/sunstone/public/app/tabs/users-tab/panels/groups/panelId.js diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 27e4623f0b..05ca6c5d06 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -50,6 +50,7 @@ tabs: panel_tabs: user_info_tab: true user_quotas_tab: true + user_groups_tab: true user_accounting_tab: true user_showback_tab: true table_columns: diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index af83c08207..f6639fc712 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -50,6 +50,7 @@ tabs: panel_tabs: user_info_tab: true user_quotas_tab: true + user_groups_tab: true user_accounting_tab: true user_showback_tab: true table_columns: diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 39d1ab84e4..b1249c2856 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -51,6 +51,7 @@ tabs: panel_tabs: user_info_tab: true user_quotas_tab: true + user_groups_tab: true user_accounting_tab: true user_showback_tab: true table_columns: diff --git a/src/sunstone/public/app/tabs/users-tab.js b/src/sunstone/public/app/tabs/users-tab.js index ff846dca59..bf8cac6fee 100644 --- a/src/sunstone/public/app/tabs/users-tab.js +++ b/src/sunstone/public/app/tabs/users-tab.js @@ -32,6 +32,7 @@ define(function(require) { var _panels = [ require('./users-tab/panels/info'), + require('./users-tab/panels/groups'), require('./users-tab/panels/quotas'), require('./users-tab/panels/accounting'), require('./users-tab/panels/showback') diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js b/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js index 5fd889dab2..9307ab1abb 100644 --- a/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js +++ b/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js @@ -109,7 +109,7 @@ define(function(require) { function _setParams(params) { this.element = params.element; - if (this.element.GROUPS !== undefined && this.element.GROUPS !== undefined) { + if (this.element.GROUPS !== undefined && this.element.GROUPS.ID !== undefined) { if ($.isArray(this.element.GROUPS.ID)) { this.originalGroupIds = this.element.GROUPS.ID; } else { diff --git a/src/sunstone/public/app/tabs/users-tab/panels/groups.js b/src/sunstone/public/app/tabs/users-tab/panels/groups.js new file mode 100644 index 0000000000..361b43e5eb --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/panels/groups.js @@ -0,0 +1,90 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* 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. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var GroupsTable = require('tabs/groups-tab/datatable'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./groups/panelId'); + var GROUPS_TABLE_ID = PANEL_ID + "GroupsTable"; + var RESOURCE = "User"; + var XML_ROOT = "USER"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Groups"); + this.icon = "fa-users"; + + this.element = info[XML_ROOT]; + + return this; + } + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + var groups; + + if (this.element.GROUPS !== undefined && this.element.GROUPS.ID !== undefined) { + if ($.isArray(this.element.GROUPS.ID)) { + groups = this.element.GROUPS.ID; + } else { + groups = [this.element.GROUPS.ID]; + } + } else { + groups = []; + } + + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: groups + } + }; + + this.GroupsTable = new GroupsTable(GROUPS_TABLE_ID, opts); + + return this.GroupsTable.dataTableHTML; + } + + function _setup(context) { + this.GroupsTable.initialize(); + this.GroupsTable.refreshResourceTableSelect(); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/groups/panelId.js b/src/sunstone/public/app/tabs/users-tab/panels/groups/panelId.js new file mode 100644 index 0000000000..3c89fc60e9 --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/panels/groups/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* 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. */ +/* -------------------------------------------------------------------------- */ + +define(function(require){ + return 'user_groups_tab'; +})