diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 72b302c87f..fbb43d0725 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -769,24 +769,23 @@ tabs: Support.create_dialog: true settings-tab: panel_tabs: - user_info_tab: true - user_config_tab: false - user_quotas_tab: true - group_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: true + settings_config_tab: false + settings_quotas_tab: true + settings_group_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false upgrade-top-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 57d9e06a8a..1f86fff369 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -767,24 +767,23 @@ tabs: Support.create_dialog: true settings-tab: panel_tabs: - user_info_tab: true - user_config_tab: false - user_quotas_tab: true - group_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: true + settings_config_tab: false + settings_quotas_tab: true + settings_group_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false upgrade-top-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 17e8f85911..00c5133b29 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -79,28 +79,23 @@ tabs: disk_resize: true settings-tab: panel_tabs: - user_info_tab: false - user_config_tab: true - user_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: false + settings_config_tab: true + settings_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false - users-tab: - actions: - User.update_password: true - User.login_token: true vms-tab: actions: *provisionactions images-tab: diff --git a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml index af66600cd7..25fcc441a0 100644 --- a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml @@ -79,23 +79,23 @@ tabs: disk_resize: false settings-tab: panel_tabs: - user_info_tab: false - user_config_tab: true - user_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: false + settings_config_tab: true + settings_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are + # The buttons inside the settings-tab panel settings_info_tab are # configured with users-tab/actions; User.update_password and # User.login_token # - # Buttons for user_config_tab + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false users-tab: actions: diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index f33120f88f..c829ef12bc 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -768,24 +768,23 @@ tabs: Support.create_dialog: true settings-tab: panel_tabs: - user_info_tab: true - user_config_tab: false - user_quotas_tab: true - group_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: true + settings_config_tab: false + settings_quotas_tab: true + settings_group_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false upgrade-top-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index b452feef9e..f3e43993b9 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -768,24 +768,23 @@ tabs: Support.create_dialog: true settings-tab: panel_tabs: - user_info_tab: true - user_config_tab: false - user_quotas_tab: true - group_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: true + settings_config_tab: false + settings_quotas_tab: true + settings_group_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false upgrade-top-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index e30aa8ddea..fa8aa2977a 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -767,24 +767,23 @@ tabs: Support.create_dialog: true settings-tab: panel_tabs: - user_info_tab: true - user_config_tab: false - user_quotas_tab: true - group_quotas_tab: true - user_accounting_tab: true - user_showback_tab: true + settings_info_tab: true + settings_config_tab: false + settings_quotas_tab: true + settings_group_quotas_tab: true + settings_accounting_tab: true + settings_showback_tab: true actions: - # The buttons inside the settings-tab panel user_info_tab are - # configured with users-tab/actions; User.update_password and - # User.login_token - # - # Buttons for user_config_tab + # Buttons for settings_info_tab + User.update_password: true + User.login_token: true + # Buttons for settings_config_tab Settings.change_language: true Settings.change_password: true Settings.change_view: true Settings.ssh_key: true Settings.login_token: true - # Edit button in user_quotas_tab + # Edit button in settings_quotas_tab User.quotas_dialog: false upgrade-top-tab: panel_tabs: diff --git a/src/sunstone/public/app/tabs/settings-tab.js b/src/sunstone/public/app/tabs/settings-tab.js index b23082df98..76342a8ef9 100644 --- a/src/sunstone/public/app/tabs/settings-tab.js +++ b/src/sunstone/public/app/tabs/settings-tab.js @@ -21,7 +21,6 @@ define(function(require) { var _actions = require('./users-tab/actions'); var TAB_ID = require('./settings-tab/tabId'); - var USERS_TAB_ID = require('tabs/users-tab/tabId'); _actions["Settings.refresh"] = { type: "custom", @@ -34,12 +33,12 @@ define(function(require) { ]; var _panels = [ - require('tabs/users-tab/panels/info'), + require('tabs/settings-tab/panels/info'), require('tabs/settings-tab/panels/user-config'), - require('tabs/users-tab/panels/quotas'), + require('tabs/settings-tab/panels/quotas'), require('tabs/settings-tab/panels/group-quotas'), - require('tabs/users-tab/panels/accounting'), - require('tabs/users-tab/panels/showback') + require('tabs/settings-tab/panels/accounting'), + require('tabs/settings-tab/panels/showback') ]; var _formPanels = [ diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/accounting.js b/src/sunstone/public/app/tabs/settings-tab/panels/accounting.js new file mode 100644 index 0000000000..e8094dfcfb --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/accounting.js @@ -0,0 +1,46 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 BasePanel = require('tabs/users-tab/panels/accounting-common'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./accounting/panelId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.tabId = TAB_ID; + + return BasePanel.call(this, info); + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; + + return Panel; +}); diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/accounting/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/accounting/panelId.js new file mode 100644 index 0000000000..c8b0571438 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/accounting/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 'settings_accounting_tab'; +}) diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/group-quotas/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/group-quotas/panelId.js index 3f7126e676..916d7d4921 100644 --- a/src/sunstone/public/app/tabs/settings-tab/panels/group-quotas/panelId.js +++ b/src/sunstone/public/app/tabs/settings-tab/panels/group-quotas/panelId.js @@ -15,5 +15,5 @@ /* -------------------------------------------------------------------------- */ define(function(require){ - return 'group_quotas_tab'; + return 'settings_group_quotas_tab'; }); diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/info.js b/src/sunstone/public/app/tabs/settings-tab/panels/info.js new file mode 100644 index 0000000000..7a0d18fe39 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/info.js @@ -0,0 +1,46 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 BasePanel = require('tabs/users-tab/panels/info-common'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./info/panelId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.tabId = TAB_ID; + + return BasePanel.call(this, info); + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; + + return Panel; +}); diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/info/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/info/panelId.js new file mode 100644 index 0000000000..2cfbd468b0 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/info/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 'settings_info_tab'; +}) diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/quotas.js b/src/sunstone/public/app/tabs/settings-tab/panels/quotas.js new file mode 100644 index 0000000000..2a829581a1 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/quotas.js @@ -0,0 +1,46 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 BasePanel = require('tabs/users-tab/panels/quotas-common'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./quotas/panelId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.tabId = TAB_ID; + + return BasePanel.call(this, info); + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; + + return Panel; +}); diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/quotas/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/quotas/panelId.js new file mode 100644 index 0000000000..4158620d45 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/quotas/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 'settings_quotas_tab'; +}) diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/showback.js b/src/sunstone/public/app/tabs/settings-tab/panels/showback.js new file mode 100644 index 0000000000..32e8a8d69a --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/showback.js @@ -0,0 +1,46 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 BasePanel = require('tabs/users-tab/panels/showback-common'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./showback/panelId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.tabId = TAB_ID; + + return BasePanel.call(this, info); + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; + + return Panel; +}); diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/showback/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/showback/panelId.js new file mode 100644 index 0000000000..c1635274a7 --- /dev/null +++ b/src/sunstone/public/app/tabs/settings-tab/panels/showback/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 'settings_showback_tab'; +}) diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/user-config/panelId.js b/src/sunstone/public/app/tabs/settings-tab/panels/user-config/panelId.js index fb4f301dd1..dc7086dd5e 100644 --- a/src/sunstone/public/app/tabs/settings-tab/panels/user-config/panelId.js +++ b/src/sunstone/public/app/tabs/settings-tab/panels/user-config/panelId.js @@ -15,5 +15,5 @@ /* -------------------------------------------------------------------------- */ define(function(require) { - return 'user_config_tab'; + return 'settings_config_tab'; }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/accounting-common.js b/src/sunstone/public/app/tabs/users-tab/panels/accounting-common.js new file mode 100644 index 0000000000..b340e6674a --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/panels/accounting-common.js @@ -0,0 +1,65 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 Accounting = require('utils/accounting'); + + /* + CONSTANTS + */ + + var RESOURCE = "User"; + var XML_ROOT = "USER"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Accounting"); + this.icon = "fa-bar-chart-o"; + + this.element = info[XML_ROOT]; + + return this; + } + + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return Accounting.html(); + } + + function _setup(context) { + Accounting.setup( + context, + { fixed_user: this.element.ID, + init_group_by: "vm" + }); + } +}); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/accounting.js b/src/sunstone/public/app/tabs/users-tab/panels/accounting.js index e4635dcb04..e8094dfcfb 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/accounting.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/accounting.js @@ -19,8 +19,7 @@ define(function(require) { DEPENDENCIES */ - var Locale = require('utils/locale'); - var Accounting = require('utils/accounting'); + var BasePanel = require('tabs/users-tab/panels/accounting-common'); /* CONSTANTS @@ -28,41 +27,20 @@ define(function(require) { var TAB_ID = require('../tabId'); var PANEL_ID = require('./accounting/panelId'); - var RESOURCE = "User"; - var XML_ROOT = "USER"; /* CONSTRUCTOR */ function Panel(info) { - this.title = Locale.tr("Accounting"); - this.icon = "fa-bar-chart-o"; + this.tabId = TAB_ID; - this.element = info[XML_ROOT]; - - return this; - } + return BasePanel.call(this, info); + }; Panel.PANEL_ID = PANEL_ID; - Panel.prototype.html = _html; - Panel.prototype.setup = _setup; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; return Panel; - - /* - FUNCTION DEFINITIONS - */ - - function _html() { - return Accounting.html(); - } - - function _setup(context) { - Accounting.setup( - context, - { fixed_user: this.element.ID, - init_group_by: "vm" - }); - } }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info-common.js b/src/sunstone/public/app/tabs/users-tab/panels/info-common.js new file mode 100644 index 0000000000..12f5bedc21 --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/panels/info-common.js @@ -0,0 +1,254 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 TemplateInfo = require('hbs!./info/html'); + var TemplateChgrpTr = require('hbs!./info/chgrp-tr'); + var ResourceSelect = require('utils/resource-select'); + var TemplateUtils = require('utils/template-utils'); + var Locale = require('utils/locale'); + var OpenNebulaUser = require('opennebula/user'); + var Sunstone = require('sunstone'); + + /* + TEMPLATES + */ + + var TemplateTable = require('utils/panel/template-table'); + + /* + CONSTANTS + */ + + var RESOURCE = "User"; + var XML_ROOT = "USER"; + var PASSWORD_DIALOG_ID = require('tabs/users-tab/dialogs/password/dialogId'); + var LOGIN_TOKEN_DIALOG_ID = require('tabs/users-tab/dialogs/login-token/dialogId'); + var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Info"); + this.icon = "fa-info-circle"; + + this.element = info[XML_ROOT]; + + return this; + } + + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + var groupTrHTML = TemplateChgrpTr({'element': this.element}); + + // TODO: simplify interface? + var strippedTemplate = $.extend({}, this.element.TEMPLATE); + delete strippedTemplate["SSH_PUBLIC_KEY"]; + delete strippedTemplate["SUNSTONE"]; + + var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, + Locale.tr("Attributes")); + //==== + + return TemplateInfo({ + 'element': this.element, + 'sunstone_template': this.element.TEMPLATE.SUNSTONE||{}, + 'groupTrHTML': groupTrHTML, + 'templateTableHTML': templateTableHTML, + 'tabId': this.tabId + }); + } + + function _setup(context) { + var that = this; + + // Template update + // TODO: simplify interface? + var strippedTemplate = $.extend({}, this.element.TEMPLATE); + delete strippedTemplate["SSH_PUBLIC_KEY"]; + delete strippedTemplate["SUNSTONE"]; + + var hiddenValues = {}; + + if (this.element.TEMPLATE.SSH_PUBLIC_KEY != undefined) { + hiddenValues.SSH_PUBLIC_KEY = this.element.TEMPLATE.SSH_PUBLIC_KEY; + } + if (this.element.TEMPLATE.SUNSTONE != undefined) { + hiddenValues.SUNSTONE = this.element.TEMPLATE.SUNSTONE; + } + + TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues); + //=== + + // Chgrp + context.off("click", "#div_edit_chg_group_link"); + context.on("click", "#div_edit_chg_group_link", function() { + ResourceSelect.insert({ + context: $('#value_td_group', context), + resourceName: 'Group', + initValue: that.element.GID + }); + }); + + context.off("change", "#value_td_group .resource_list_select"); + context.on("change", "#value_td_group .resource_list_select", function() { + var newGroupId = $(this).val(); + if (newGroupId != "") { + Sunstone.runAction(RESOURCE + ".chgrp", [that.element.ID], newGroupId); + } + }); + + // View password button + context.off("click", "#view_password"); + context.on("click", "#view_password", function(){ + Sunstone.getDialog(CONFIRM_DIALOG_ID).setParams({ + header : Locale.tr("Password"), + headerTabId: that.tabId, + body: '' + + '
'+that.element.PASSWORD+'', + question : '', + buttons : [ + Locale.tr("Close"), + ], + submit : [ + function(){ + return false; + } + ] + }); + + Sunstone.getDialog(CONFIRM_DIALOG_ID).reset(); + Sunstone.getDialog(CONFIRM_DIALOG_ID).show(); + }); + + // Edit password button + context.off("click", "#update_password"); + context.on("click", "#update_password", function(){ + Sunstone.getDialog(PASSWORD_DIALOG_ID).setParams( + {selectedElements: [that.element.ID]}); + Sunstone.getDialog(PASSWORD_DIALOG_ID).reset(); + Sunstone.getDialog(PASSWORD_DIALOG_ID).show(); + }); + + // Login token button + context.off("click", "#login_token"); + context.on("click", "#login_token", function(){ + Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).setParams({element: that.element}); + Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).reset(); + Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).show(); + }); + + // SSH input + + context.off("click", ".user_ssh_public_key_edit"); + context.on("click", ".user_ssh_public_key_edit", function() { + $("#user_ssh_public_key_text", context).hide(); + $("#user_ssh_public_key_textarea", context).show().focus(); + }); + + context.off("change", "#user_ssh_public_key_textarea"); + context.on("change", "#user_ssh_public_key_textarea", function() { + var template_str = 'SSH_PUBLIC_KEY = "'+TemplateUtils.escapeDoubleQuotes($(this).val())+'"'; + + Sunstone.runAction("User.append_template", that.element.ID, template_str); + }); + + context.off("focusout", "#user_ssh_public_key_textarea"); + context.on("focusout", "#user_ssh_public_key_textarea", function() { + $("#user_ssh_public_key_text", context).show(); + $("#user_ssh_public_key_textarea", context).hide(); + }); + + $("#user_ssh_public_key_text", context).show(); + $("#user_ssh_public_key_textarea", context).hide(); + + // Change table Order + context.off("click", "#div_edit_table_order") + context.on("click", "#div_edit_table_order", function() { + $(".value_td_table_order", context).html(''); + + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.TABLE_ORDER) { + $('#table_order_select', context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER); + } + }); + + context.off("change", "#table_order_select") + context.on("change", "#table_order_select", function() { + var sunstone_setting = {TABLE_ORDER : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); + }); + + // Change language + context.off("click", "#div_edit_language") + context.on("click", "#div_edit_language", function() { + $(".value_td_language", context).html(''); + + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.LANG) { + $('#language_select', context).val(that.element.TEMPLATE.SUNSTONE.LANG); + } + }); + + context.off("change", "#language_select") + context.on("change", "#language_select", function() { + var sunstone_setting = {LANG : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); + }); + + // Change view + context.off("click", "#div_edit_view") + context.on("click", "#div_edit_view", function() { + var options = ''; + $.each( config['available_views'], function(id, view) { + options += ''; + }); + + $(".value_td_view", context).html(''); + + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW) { + $('#view_select', context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW); + } + }); + + context.off("change", "#view_select") + context.on("change", "#view_select", function() { + var sunstone_setting = {DEFAULT_VIEW : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); + }); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info.js b/src/sunstone/public/app/tabs/users-tab/panels/info.js index fe914d9731..7a0d18fe39 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/info.js @@ -19,19 +19,7 @@ define(function(require) { DEPENDENCIES */ - var TemplateInfo = require('hbs!./info/html'); - var TemplateChgrpTr = require('hbs!./info/chgrp-tr'); - var ResourceSelect = require('utils/resource-select'); - var TemplateUtils = require('utils/template-utils'); - var Locale = require('utils/locale'); - var OpenNebulaUser = require('opennebula/user'); - var Sunstone = require('sunstone'); - - /* - TEMPLATES - */ - - var TemplateTable = require('utils/panel/template-table'); + var BasePanel = require('tabs/users-tab/panels/info-common'); /* CONSTANTS @@ -39,218 +27,20 @@ define(function(require) { var TAB_ID = require('../tabId'); var PANEL_ID = require('./info/panelId'); - var RESOURCE = "User"; - var XML_ROOT = "USER"; - var PASSWORD_DIALOG_ID = require('tabs/users-tab/dialogs/password/dialogId'); - var LOGIN_TOKEN_DIALOG_ID = require('tabs/users-tab/dialogs/login-token/dialogId'); - var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId'); /* CONSTRUCTOR */ function Panel(info) { - this.title = Locale.tr("Info"); - this.icon = "fa-info-circle"; + this.tabId = TAB_ID; - this.element = info[XML_ROOT]; - - return this; - } + return BasePanel.call(this, info); + }; Panel.PANEL_ID = PANEL_ID; - Panel.prototype.html = _html; - Panel.prototype.setup = _setup; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; return Panel; - - /* - FUNCTION DEFINITIONS - */ - - function _html() { - var groupTrHTML = TemplateChgrpTr({'element': this.element}); - - // TODO: simplify interface? - var strippedTemplate = $.extend({}, this.element.TEMPLATE); - delete strippedTemplate["SSH_PUBLIC_KEY"]; - delete strippedTemplate["SUNSTONE"]; - - var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, - Locale.tr("Attributes")); - //==== - - return TemplateInfo({ - 'element': this.element, - 'sunstone_template': this.element.TEMPLATE.SUNSTONE||{}, - 'groupTrHTML': groupTrHTML, - 'templateTableHTML': templateTableHTML - }); - } - - function _setup(context) { - var that = this; - - // Template update - // TODO: simplify interface? - var strippedTemplate = $.extend({}, this.element.TEMPLATE); - delete strippedTemplate["SSH_PUBLIC_KEY"]; - delete strippedTemplate["SUNSTONE"]; - - var hiddenValues = {}; - - if (this.element.TEMPLATE.SSH_PUBLIC_KEY != undefined) { - hiddenValues.SSH_PUBLIC_KEY = this.element.TEMPLATE.SSH_PUBLIC_KEY; - } - if (this.element.TEMPLATE.SUNSTONE != undefined) { - hiddenValues.SUNSTONE = this.element.TEMPLATE.SUNSTONE; - } - - TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues); - //=== - - // Chgrp - context.off("click", "#div_edit_chg_group_link"); - context.on("click", "#div_edit_chg_group_link", function() { - ResourceSelect.insert({ - context: $('#value_td_group', context), - resourceName: 'Group', - initValue: that.element.GID - }); - }); - - context.off("change", "#value_td_group .resource_list_select"); - context.on("change", "#value_td_group .resource_list_select", function() { - var newGroupId = $(this).val(); - if (newGroupId != "") { - Sunstone.runAction(RESOURCE + ".chgrp", [that.element.ID], newGroupId); - } - }); - - // View password button - context.off("click", "#view_password"); - context.on("click", "#view_password", function(){ - Sunstone.getDialog(CONFIRM_DIALOG_ID).setParams({ - header : Locale.tr("Password"), - headerTabId: TAB_ID, - body: '' + - '
'+that.element.PASSWORD+'', - question : '', - buttons : [ - Locale.tr("Close"), - ], - submit : [ - function(){ - return false; - } - ] - }); - - Sunstone.getDialog(CONFIRM_DIALOG_ID).reset(); - Sunstone.getDialog(CONFIRM_DIALOG_ID).show(); - }); - - // Edit password button - context.off("click", "#update_password"); - context.on("click", "#update_password", function(){ - Sunstone.getDialog(PASSWORD_DIALOG_ID).setParams( - {selectedElements: [that.element.ID]}); - Sunstone.getDialog(PASSWORD_DIALOG_ID).reset(); - Sunstone.getDialog(PASSWORD_DIALOG_ID).show(); - }); - - // Login token button - context.off("click", "#login_token"); - context.on("click", "#login_token", function(){ - Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).setParams({element: that.element}); - Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).reset(); - Sunstone.getDialog(LOGIN_TOKEN_DIALOG_ID).show(); - }); - - // SSH input - - context.off("click", ".user_ssh_public_key_edit"); - context.on("click", ".user_ssh_public_key_edit", function() { - $("#user_ssh_public_key_text", context).hide(); - $("#user_ssh_public_key_textarea", context).show().focus(); - }); - - context.off("change", "#user_ssh_public_key_textarea"); - context.on("change", "#user_ssh_public_key_textarea", function() { - var template_str = 'SSH_PUBLIC_KEY = "'+TemplateUtils.escapeDoubleQuotes($(this).val())+'"'; - - Sunstone.runAction("User.append_template", that.element.ID, template_str); - }); - - context.off("focusout", "#user_ssh_public_key_textarea"); - context.on("focusout", "#user_ssh_public_key_textarea", function() { - $("#user_ssh_public_key_text", context).show(); - $("#user_ssh_public_key_textarea", context).hide(); - }); - - $("#user_ssh_public_key_text", context).show(); - $("#user_ssh_public_key_textarea", context).hide(); - - // Change table Order - context.off("click", "#div_edit_table_order") - context.on("click", "#div_edit_table_order", function() { - $(".value_td_table_order", context).html(''); - - if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.TABLE_ORDER) { - $('#table_order_select', context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER); - } - }); - - context.off("change", "#table_order_select") - context.on("change", "#table_order_select", function() { - var sunstone_setting = {TABLE_ORDER : $(this).val()}; - Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); - }); - - // Change language - context.off("click", "#div_edit_language") - context.on("click", "#div_edit_language", function() { - $(".value_td_language", context).html(''); - - if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.LANG) { - $('#language_select', context).val(that.element.TEMPLATE.SUNSTONE.LANG); - } - }); - - context.off("change", "#language_select") - context.on("change", "#language_select", function() { - var sunstone_setting = {LANG : $(this).val()}; - Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); - }); - - // Change view - context.off("click", "#div_edit_view") - context.on("click", "#div_edit_view", function() { - var options = ''; - $.each( config['available_views'], function(id, view) { - options += ''; - }); - - $(".value_td_view", context).html(''); - - if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW) { - $('#view_select', context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW); - } - }); - - context.off("change", "#view_select") - context.on("change", "#view_select", function() { - var sunstone_setting = {DEFAULT_VIEW : $(this).val()}; - Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); - }); - - return false; - } }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs index 6231f792d6..5c3749214f 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs @@ -86,14 +86,14 @@