diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index f238945349..b5d741e2ba 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -582,7 +582,7 @@ define(function(require) { if (hooks) { $.each(hooks, function(i, hook){ - hook.pre(info, contextTabId); + hook.pre(info, (contextTabId||tabName)); }); } @@ -648,7 +648,7 @@ define(function(require) { if (hooks) { $.each(hooks, function(i, hook){ - hook.post(info, contextTabId); + hook.post(info, (contextTabId||tabName)); }); } } diff --git a/src/sunstone/public/app/tabs/clusters-tab.js b/src/sunstone/public/app/tabs/clusters-tab.js index 05a8f3fae6..b9d450a95b 100644 --- a/src/sunstone/public/app/tabs/clusters-tab.js +++ b/src/sunstone/public/app/tabs/clusters-tab.js @@ -33,6 +33,10 @@ define(function(require) { require('./clusters-tab/panels/datastores') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./clusters-tab/form-panels/create') ]; @@ -50,6 +54,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/clusters-tab/panels/info.js b/src/sunstone/public/app/tabs/clusters-tab/panels/info.js index 1527cdb50c..ef2f94c39f 100644 --- a/src/sunstone/public/app/tabs/clusters-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/clusters-tab/panels/info.js @@ -69,7 +69,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); diff --git a/src/sunstone/public/app/tabs/datastores-tab.js b/src/sunstone/public/app/tabs/datastores-tab.js index 98e75fdfbc..80ce09f4ac 100644 --- a/src/sunstone/public/app/tabs/datastores-tab.js +++ b/src/sunstone/public/app/tabs/datastores-tab.js @@ -35,6 +35,10 @@ define(function(require) { require('./datastores-tab/panels/images') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var DatastoresTab = { tabId: TAB_ID, title: Locale.tr("Datastores"), @@ -48,6 +52,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/info.js b/src/sunstone/public/app/tabs/datastores-tab/panels/info.js index cd86ab2958..d87e05a3b0 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/info.js @@ -96,7 +96,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); diff --git a/src/sunstone/public/app/tabs/files-tab.js b/src/sunstone/public/app/tabs/files-tab.js index 5e0f2086b7..b2cb964163 100644 --- a/src/sunstone/public/app/tabs/files-tab.js +++ b/src/sunstone/public/app/tabs/files-tab.js @@ -29,6 +29,10 @@ define(function(require) { require('./files-tab/panels/info') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./files-tab/form-panels/create') ]; @@ -49,6 +53,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/files-tab/panels/info.js b/src/sunstone/public/app/tabs/files-tab/panels/info.js index 668e9c302a..ae601a2b28 100644 --- a/src/sunstone/public/app/tabs/files-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/files-tab/panels/info.js @@ -89,7 +89,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); diff --git a/src/sunstone/public/app/tabs/groups-tab.js b/src/sunstone/public/app/tabs/groups-tab.js index 3d1fafd29d..65b52b9a6f 100644 --- a/src/sunstone/public/app/tabs/groups-tab.js +++ b/src/sunstone/public/app/tabs/groups-tab.js @@ -35,6 +35,10 @@ define(function(require) { require('./groups-tab/panels/showback') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./groups-tab/form-panels/create') ]; @@ -54,6 +58,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/groups-tab/panels/info.js b/src/sunstone/public/app/tabs/groups-tab/panels/info.js index 2771554c23..f0d7d4f732 100644 --- a/src/sunstone/public/app/tabs/groups-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/groups-tab/panels/info.js @@ -94,8 +94,6 @@ define(function(require) { function _setup(context) { var that = this; - $('.resource-info-header', '#' + TAB_ID).text(that.element.NAME); - Tips.setup(context); // Template update diff --git a/src/sunstone/public/app/tabs/hosts-tab.js b/src/sunstone/public/app/tabs/hosts-tab.js index 45f29abca0..d40a0b8a28 100644 --- a/src/sunstone/public/app/tabs/hosts-tab.js +++ b/src/sunstone/public/app/tabs/hosts-tab.js @@ -37,6 +37,10 @@ define(function(require) { require('./hosts-tab/panels/pci') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./hosts-tab/form-panels/create') ] @@ -58,6 +62,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, //dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/info.js b/src/sunstone/public/app/tabs/hosts-tab/panels/info.js index 00fb713e71..fdfbceb5c4 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/info.js @@ -113,7 +113,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context); TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate); diff --git a/src/sunstone/public/app/tabs/images-tab.js b/src/sunstone/public/app/tabs/images-tab.js index 0f6ecae07a..cbd7b6a79e 100644 --- a/src/sunstone/public/app/tabs/images-tab.js +++ b/src/sunstone/public/app/tabs/images-tab.js @@ -33,6 +33,10 @@ define(function(require) { require('./images-tab/panels/snapshots') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./images-tab/form-panels/create') ]; @@ -51,6 +55,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/images-tab/panels/info.js b/src/sunstone/public/app/tabs/images-tab/panels/info.js index ca5e5fd24e..d59b80c7b8 100644 --- a/src/sunstone/public/app/tabs/images-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/images-tab/panels/info.js @@ -90,7 +90,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); diff --git a/src/sunstone/public/app/tabs/marketplace-tab.js b/src/sunstone/public/app/tabs/marketplace-tab.js index 78e73ced14..dc7b69a1c8 100644 --- a/src/sunstone/public/app/tabs/marketplace-tab.js +++ b/src/sunstone/public/app/tabs/marketplace-tab.js @@ -31,6 +31,10 @@ define(function(require) { require('./marketplace-tab/panels/info') ]; + var _panelsHooks = [ + require('./marketplace-tab/hooks/header') + ]; + var _formPanels = [ ]; @@ -50,6 +54,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true, oneSelection: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/marketplace-tab/hooks/header.js b/src/sunstone/public/app/tabs/marketplace-tab/hooks/header.js new file mode 100644 index 0000000000..334b1caefb --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplace-tab/hooks/header.js @@ -0,0 +1,43 @@ +/* -------------------------------------------------------------------------- */ +/* 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) { + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + + /* + FUNCTION DEFINITIONS + */ + + function _pre(info, contextTabId) { + var element = info; + + $('.resource-id', '#' + TAB_ID).hide(); + $('.resource-info-header', '#' + TAB_ID).text(element.name); + } + + function _post(info, contextTabId) { + } + + return { + 'pre': _pre, + 'post': _post + }; +}); diff --git a/src/sunstone/public/app/tabs/marketplace-tab/panels/info.js b/src/sunstone/public/app/tabs/marketplace-tab/panels/info.js index 6703b6821f..92c6deaf94 100644 --- a/src/sunstone/public/app/tabs/marketplace-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/marketplace-tab/panels/info.js @@ -82,8 +82,6 @@ define(function(require) { } function _setup(context) { - $('.resource-id', '#' + TAB_ID).hide(); - $('.resource-info-header', '#' + TAB_ID).text(this.element.name); return false; } }); diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab.js b/src/sunstone/public/app/tabs/oneflow-services-tab.js index 270788a34d..69ab699f5f 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab.js @@ -34,6 +34,10 @@ define(function(require) { require('./oneflow-services-tab/panels/log') ]; + var _panelsHooks = [ + require('./oneflow-services-tab/hooks/header') + ]; + var _formPanels = [ ]; @@ -55,6 +59,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/hooks/header.js b/src/sunstone/public/app/tabs/oneflow-services-tab/hooks/header.js new file mode 100644 index 0000000000..85b2596df6 --- /dev/null +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/hooks/header.js @@ -0,0 +1,51 @@ +/* -------------------------------------------------------------------------- */ +/* 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 OpenNebulaService = require('opennebula/service'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var XML_ROOT = "DOCUMENT"; + var RESOURCE = "Service"; + /* + FUNCTION DEFINITIONS + */ + + function _pre(info, contextTabId) { + var element = info[XML_ROOT]; + + var state = OpenNebulaService.stateStr(element.TEMPLATE.BODY.state); + + $('.resource-info-header', '#' + TAB_ID).text(element.NAME); + $('.resource-info-header-small', '#' + TAB_ID).text(state); + } + + function _post(info, contextTabId) { + } + + return { + 'pre': _pre, + 'post': _post + }; +}); diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js index b0a87a00aa..26e40e1c6e 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js @@ -72,7 +72,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); } }); diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab.js b/src/sunstone/public/app/tabs/oneflow-templates-tab.js index 0333057081..e43220bcf8 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab.js @@ -32,6 +32,10 @@ define(function(require) { require('./oneflow-templates-tab/panels/roles') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./oneflow-templates-tab/form-panels/create'), require('./oneflow-templates-tab/form-panels/instantiate') @@ -55,6 +59,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/info.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/info.js index 88071140ad..b1f604e0d0 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/info.js @@ -108,7 +108,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); } }); diff --git a/src/sunstone/public/app/tabs/secgroups-tab.js b/src/sunstone/public/app/tabs/secgroups-tab.js index 3371b508ab..5629f5aabd 100644 --- a/src/sunstone/public/app/tabs/secgroups-tab.js +++ b/src/sunstone/public/app/tabs/secgroups-tab.js @@ -31,6 +31,10 @@ define(function(require) { require('./secgroups-tab/panels/info') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./secgroups-tab/form-panels/create') ]; @@ -48,6 +52,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/secgroups-tab/panels/info.js b/src/sunstone/public/app/tabs/secgroups-tab/panels/info.js index eaa687c02d..4520571d1c 100644 --- a/src/sunstone/public/app/tabs/secgroups-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/secgroups-tab/panels/info.js @@ -97,7 +97,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); diff --git a/src/sunstone/public/app/tabs/templates-tab.js b/src/sunstone/public/app/tabs/templates-tab.js index 76940e424c..ad00f796bb 100644 --- a/src/sunstone/public/app/tabs/templates-tab.js +++ b/src/sunstone/public/app/tabs/templates-tab.js @@ -32,6 +32,10 @@ define(function(require) { require('./templates-tab/panels/template') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./templates-tab/form-panels/create'), require('./templates-tab/form-panels/import'), @@ -51,6 +55,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/templates-tab/panels/info.js b/src/sunstone/public/app/tabs/templates-tab/panels/info.js index 8e7daea4ef..a75053749b 100644 --- a/src/sunstone/public/app/tabs/templates-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/templates-tab/panels/info.js @@ -76,7 +76,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); } diff --git a/src/sunstone/public/app/tabs/users-tab.js b/src/sunstone/public/app/tabs/users-tab.js index 81b22d42d7..f00f2f4bec 100644 --- a/src/sunstone/public/app/tabs/users-tab.js +++ b/src/sunstone/public/app/tabs/users-tab.js @@ -36,6 +36,10 @@ define(function(require) { require('./users-tab/panels/showback') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./users-tab/form-panels/create') ]; @@ -55,6 +59,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; 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 3a6582d07d..c84b763be0 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/info.js @@ -103,8 +103,6 @@ define(function(require) { function _setup(context) { var that = this; - $('.resource-info-header', '#' + TAB_ID).text(that.element.NAME); - // Template update // TODO: simplify interface? var strippedTemplate = $.extend({}, this.element.TEMPLATE); diff --git a/src/sunstone/public/app/tabs/vdcs-tab.js b/src/sunstone/public/app/tabs/vdcs-tab.js index 0d9d681766..3e4359742a 100644 --- a/src/sunstone/public/app/tabs/vdcs-tab.js +++ b/src/sunstone/public/app/tabs/vdcs-tab.js @@ -32,6 +32,10 @@ define(function(require) { require('./vdcs-tab/panels/resources') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./vdcs-tab/form-panels/create') ]; @@ -51,6 +55,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/vdcs-tab/panels/info.js b/src/sunstone/public/app/tabs/vdcs-tab/panels/info.js index 24512e7441..d091e84c7b 100644 --- a/src/sunstone/public/app/tabs/vdcs-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vdcs-tab/panels/info.js @@ -69,8 +69,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); - RenameTr.setup(RESOURCE, this.element.ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); diff --git a/src/sunstone/public/app/tabs/vms-tab.js b/src/sunstone/public/app/tabs/vms-tab.js index a1a81f1de6..909e98e7d1 100644 --- a/src/sunstone/public/app/tabs/vms-tab.js +++ b/src/sunstone/public/app/tabs/vms-tab.js @@ -38,6 +38,7 @@ define(function(require) { ]; var _panelsHooks = [ + require('./vms-tab/hooks/header'), require('./vms-tab/hooks/state') ]; diff --git a/src/sunstone/public/app/tabs/vms-tab/hooks/header.js b/src/sunstone/public/app/tabs/vms-tab/hooks/header.js new file mode 100644 index 0000000000..9d42fef217 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/hooks/header.js @@ -0,0 +1,57 @@ +/* -------------------------------------------------------------------------- */ +/* 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 OpenNebulaVM = require('opennebula/vm'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var RESOURCE = "VM"; + var XML_ROOT = "VM"; + + /* + FUNCTION DEFINITIONS + */ + + function _pre(info, contextTabId) { + var element = info[XML_ROOT]; + + var state; + if (element.STATE == OpenNebulaVM.STATES.ACTIVE) { + state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE); + } else { + state = OpenNebulaVM.stateStr(element.STATE); + } + + $('.resource-info-header', '#' + TAB_ID).text(element.NAME); + $('.resource-info-header-small', '#' + TAB_ID).text(state); + } + + function _post(info, contextTabId) { + } + + return { + 'pre': _pre, + 'post': _post + }; +}); diff --git a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js index 1763411953..3394e37033 100644 --- a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js +++ b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js @@ -37,16 +37,6 @@ define(function(require) { function _pre(info, contextTabId) { var element = info[XML_ROOT]; - var state; - if (element.STATE == OpenNebulaVM.STATES.ACTIVE) { - state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE); - } else { - state = OpenNebulaVM.stateStr(element.STATE); - } - - $('.resource-info-header', '#' + TAB_ID).text(element.NAME); - $('.resource-info-header-small', '#' + TAB_ID).text(state); - // Enable only action buttons for the current state StateActions.disableAllStateActions(); StateActions.enableStateActions(element.STATE, element.LCM_STATE); diff --git a/src/sunstone/public/app/tabs/vnets-tab.js b/src/sunstone/public/app/tabs/vnets-tab.js index fa4f8affde..095464034f 100644 --- a/src/sunstone/public/app/tabs/vnets-tab.js +++ b/src/sunstone/public/app/tabs/vnets-tab.js @@ -36,6 +36,10 @@ define(function(require) { require('./vnets-tab/panels/secgroups') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var _formPanels = [ require('./vnets-tab/form-panels/create'), require('./vnets-tab/form-panels/import') @@ -55,6 +59,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, formPanels: _formPanels, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/info.js b/src/sunstone/public/app/tabs/vnets-tab/panels/info.js index f58648a9bb..c87b132973 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/info.js @@ -109,7 +109,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); diff --git a/src/sunstone/public/app/tabs/zones-tab.js b/src/sunstone/public/app/tabs/zones-tab.js index e42d7d22a5..a1af2dca1a 100644 --- a/src/sunstone/public/app/tabs/zones-tab.js +++ b/src/sunstone/public/app/tabs/zones-tab.js @@ -31,6 +31,10 @@ define(function(require) { require('./zones-tab/panels/info') ]; + var _panelsHooks = [ + require('../utils/hooks/header') + ]; + var ZonesTab = { tabId: TAB_ID, title: Locale.tr("Zones"), @@ -44,6 +48,7 @@ define(function(require) { actions: Actions, dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, + panelsHooks: _panelsHooks, dialogs: _dialogs }; diff --git a/src/sunstone/public/app/tabs/zones-tab/panels/info.js b/src/sunstone/public/app/tabs/zones-tab/panels/info.js index 8ede0f498b..271283d9b6 100644 --- a/src/sunstone/public/app/tabs/zones-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/zones-tab/panels/info.js @@ -73,7 +73,6 @@ define(function(require) { } function _setup(context) { - $('.resource-info-header', '#' + TAB_ID).text(this.element.NAME); RenameTr.setup(RESOURCE, this.element.ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); return false; diff --git a/src/sunstone/public/app/utils/hooks/header.js b/src/sunstone/public/app/utils/hooks/header.js new file mode 100644 index 0000000000..0de42a8fea --- /dev/null +++ b/src/sunstone/public/app/utils/hooks/header.js @@ -0,0 +1,36 @@ +/* -------------------------------------------------------------------------- */ +/* 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) { + + /* + FUNCTION DEFINITIONS + */ + + function _pre(info, contextTabId) { + var element = info[Object.keys(info)[0]]; + + $('.resource-info-header', '#' + contextTabId).text(element.NAME); + } + + function _post(info, contextTabId) { + } + + return { + 'pre': _pre, + 'post': _post + }; +});