From bcf4bf9639b98cfa56b6bd921c01c8c6b44f078a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 21 May 2015 12:27:53 +0200 Subject: [PATCH] Feature #3748: Group quotas panel --- src/sunstone/public/app/tabs/groups-tab.js | 3 +- .../public/app/tabs/groups-tab/actions.js | 17 +++--- .../app/tabs/groups-tab/panels/quotas.js | 59 ++++++++++++++++++ .../tabs/groups-tab/panels/quotas/panelId.js | 3 + .../app/tabs/users-tab/panels/quotas.js | 6 +- .../app/tabs/users-tab/panels/quotas/html.hbs | 61 ------------------- 6 files changed, 77 insertions(+), 72 deletions(-) create mode 100644 src/sunstone/public/app/tabs/groups-tab/panels/quotas.js create mode 100644 src/sunstone/public/app/tabs/groups-tab/panels/quotas/panelId.js delete mode 100644 src/sunstone/public/app/tabs/users-tab/panels/quotas/html.hbs diff --git a/src/sunstone/public/app/tabs/groups-tab.js b/src/sunstone/public/app/tabs/groups-tab.js index d5199518ac..e60455f073 100644 --- a/src/sunstone/public/app/tabs/groups-tab.js +++ b/src/sunstone/public/app/tabs/groups-tab.js @@ -11,7 +11,8 @@ define(function(require) { ]; var _panels = [ - require('./groups-tab/panels/info') + require('./groups-tab/panels/info'), + require('./groups-tab/panels/quotas') ]; var Tab = { diff --git a/src/sunstone/public/app/tabs/groups-tab/actions.js b/src/sunstone/public/app/tabs/groups-tab/actions.js index 64f590ba41..74c8b1dbfa 100644 --- a/src/sunstone/public/app/tabs/groups-tab/actions.js +++ b/src/sunstone/public/app/tabs/groups-tab/actions.js @@ -121,17 +121,20 @@ define(function(require) { type: "custom", call: popUpGroupQuotasDialog }, + */ "Group.set_quota" : { type: "multiple", - call: OpenNebula.Group.set_quota, - elements: groupElements, - callback: function(request,response) { - Sunstone.runAction('Group.show',request.request.data[0]); - }, - error: onError + call: OpenNebulaGroup.set_quota, + elements: function() { + return Sunstone.getDataTable(TAB_ID).elements(); + }, + callback: function(request) { + Sunstone.runAction('Group.show',request.request.data[0]); + }, + error: Notifier.onError }, - + /* TODO "Group.accounting" : { type: "monitor", call: OpenNebula.Group.accounting, diff --git a/src/sunstone/public/app/tabs/groups-tab/panels/quotas.js b/src/sunstone/public/app/tabs/groups-tab/panels/quotas.js new file mode 100644 index 0000000000..d4f4ab089a --- /dev/null +++ b/src/sunstone/public/app/tabs/groups-tab/panels/quotas.js @@ -0,0 +1,59 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var Config = require('sunstone-config'); + var QuotaDefaults = require('utils/quotas/quota-defaults'); + var QuotaWidgets = require('utils/quotas/quota-widgets'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./quotas/panelId'); + var RESOURCE = "Group"; + var XML_ROOT = "GROUP"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Quotas"); + this.icon = "fa-align-left"; + + 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() { + return QuotaWidgets.initQuotasPanel( + this.element, + QuotaDefaults.getDefaultQuotas(RESOURCE), + Config.isTabActionEnabled(TAB_ID, RESOURCE+".quotas_dialog")); + } + + function _setup(context) { + QuotaWidgets.setupQuotasPanel( + this.element, + context, + Config.isTabActionEnabled(TAB_ID, RESOURCE+".quotas_dialog"), + RESOURCE); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/groups-tab/panels/quotas/panelId.js b/src/sunstone/public/app/tabs/groups-tab/panels/quotas/panelId.js new file mode 100644 index 0000000000..772a1598e7 --- /dev/null +++ b/src/sunstone/public/app/tabs/groups-tab/panels/quotas/panelId.js @@ -0,0 +1,3 @@ +define(function(require){ + return 'group_quotas_tab'; +}) \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/users-tab/panels/quotas.js b/src/sunstone/public/app/tabs/users-tab/panels/quotas.js index 89e313cec6..accf89f58b 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/quotas.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/quotas.js @@ -43,15 +43,15 @@ define(function(require) { function _html() { return QuotaWidgets.initQuotasPanel( this.element, - QuotaDefaults.getDefaultUserQuotas(), - Config.isTabActionEnabled(TAB_ID, "User.quotas_dialog")); + QuotaDefaults.getDefaultQuotas(RESOURCE), + Config.isTabActionEnabled(TAB_ID, RESOURCE+".quotas_dialog")); } function _setup(context) { QuotaWidgets.setupQuotasPanel( this.element, context, - Config.isTabActionEnabled(TAB_ID, "User.quotas_dialog"), + Config.isTabActionEnabled(TAB_ID, RESOURCE+".quotas_dialog"), RESOURCE); return false; diff --git a/src/sunstone/public/app/tabs/users-tab/panels/quotas/html.hbs b/src/sunstone/public/app/tabs/users-tab/panels/quotas/html.hbs deleted file mode 100644 index aa9a487ef4..0000000000 --- a/src/sunstone/public/app/tabs/users-tab/panels/quotas/html.hbs +++ /dev/null @@ -1,61 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - {{{groupTrHTML}}} - - - - - - - - - - - -
{{tr "Information"}}
{{tr "ID"}}{{element.ID}}
{{tr "Name"}}{{element.NAME}}
{{tr "Secondary groups"}}{{secondaryGroups}}
{{tr "Authentication driver"}}{{element.AUTH_DRIVER}}
-
-
- - - - - - - -
{{tr "Public SSH Key"}} - -
- -

- {{#if element.TEMPLATE.SSH_PUBLIC_KEY}} - {{element.TEMPLATE.SSH_PUBLIC_KEY}} - {{else}} - {{tr "You can provide a SSH Key for this User clicking on the edit button"}} - {{/if}} -

-
-
-
-
- {{{templateTableHTML}}} -
-
\ No newline at end of file