diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index c7f5da9c1d..d78cd0f471 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -424,6 +424,82 @@ define(function(require) { }*/ } + var _showElement = function(tabName, infoAction, elementId) { + showTab(tabName); + + var context = $('#' + tabName); + + $(".resource-id", context).html(elementId); + $(".resource-info-header", context).text(""); + + _popDialogLoading(context); + + Sunstone.runAction(infoAction, elementId); + //enable action buttons + $('.top_button, .list_button', context).attr('disabled', false); + } + + var _popDialog = function(content, context){ + $(".right-info", context).html(content); + context.foundation(); + } + + var _popDialogLoading = function(context){ + $(".right-list", context).hide(); + $(".right-form", context).hide(); + $(".right-info", context).show(); + $(".only-right-list", context).hide(); + $(".only-right-form", context).hide(); + $(".only-right-info", context).show(); + var loading = '
loading...
'; + _popDialog(loading, context); + } + + var _insertPanels = function(tabName, info) { + var panelName = tabName + '-panels'; + var activaTab = $("dd.active a", $("#" + panelName)); + if (activaTab) { + var activaTabHref = activaTab.attr('href'); + } + + var dlTabs = $('
\ +
\ +
\ +
\ +
\ + '); +console.log(tabName) +console.log(SunstoneCfg) + var tabs = SunstoneCfg['tabs'][tabName].panels; + var tab = null; + var active = false; + + for (panelTabName in tabs) { + if (Config.isTabPanelEnabled(tabName, panelTabName) == false) { + continue; + } + + tab = tabs[panelTabName]; + var dd = $('
' + (tab.icon ? '
' : '') + tab.title + '
').appendTo($('dl', dlTabs)); + var li = $('
' + tab.content(info) + '
').appendTo($('.tabs-content', dlTabs)); + + if (activaTabHref) { + if (activaTabHref == "#" + panelTabName) { + dd.addClass('active'); + li.addClass('active'); + } + } else { + if (!active) { + dd.addClass('active'); + li.addClass('active'); + active = true; + } + } + } + + _popDialog(dlTabs, $("#" + tabName)); + } + //Runs a predefined action. Wraps the calls to opennebula.js and //can be use to run action depending on conditions and notify them //if desired. Returns 1 if some problem has been detected: i.e @@ -546,48 +622,8 @@ define(function(require) { }, //Makes an info panel content pop up in the screen. - "popUpInfoPanel" : function(panelName, selectedTab) { - var activaTab = $("dd.active a", $("#" + panelName)); - if (activaTab) { - var activaTabHref = activaTab.attr('href'); - } - - var dlTabs = $('
\ -
\ -
\ -
\ -
\ - '); - - var tabs = SunstoneCfg["info_panels"][panelName]; - var tab = null; - var active = false; - - for (panelTabName in tabs) { - if (Config.isTabPanelEnabled(selectedTab, panelTabName) == false) { - continue; - } - - tab = tabs[panelTabName]; - var dd = $('
' + (tab.icon ? '
' : '') + tab.title + '
').appendTo($('dl', dlTabs)); - var li = $('
' + tab.content + '
').appendTo($('.tabs-content', dlTabs)); - - if (activaTabHref) { - if (activaTabHref == "#" + panelTabName) { - dd.addClass('active'); - li.addClass('active'); - } - } else { - if (!active) { - dd.addClass('active'); - li.addClass('active'); - active = true; - } - } - } - - popDialog(dlTabs, $("#" + selectedTab)); - }, + "showElement" : _showElement, + "insertPanels" : _insertPanels, // Replaces a tab from an info panel. Refreshes the DOM if wanted. "updateInfoPanelTab" : function(panelName, panelTabId, panelTabObj, refresh) { diff --git a/src/sunstone/public/app/tabs/zones-tab.js b/src/sunstone/public/app/tabs/zones-tab.js index 6c33df4302..235dc8bd28 100644 --- a/src/sunstone/public/app/tabs/zones-tab.js +++ b/src/sunstone/public/app/tabs/zones-tab.js @@ -3,6 +3,7 @@ define(function(require) { var Buttons = require('./zones-tab/buttons'); var Actions = require('./zones-tab/actions'); var DataTable = require('./zones-tab/datatable'); + var Panels = require('./zones-tab/panels'); var zonesTab = { title: Locale.tr("Zones"), @@ -11,9 +12,10 @@ define(function(require) { parentTab: "infra-tab", listHeader: ' ' + Locale.tr("Zones"), infoHeader: ' ' + Locale.tr("Zone"), - subheader: '  ', + subheader: '', buttons: Buttons, actions: Actions, + panels: Panels, dataTable: DataTable }; diff --git a/src/sunstone/public/app/tabs/zones-tab/actions.js b/src/sunstone/public/app/tabs/zones-tab/actions.js index 0224f03497..1597364576 100644 --- a/src/sunstone/public/app/tabs/zones-tab/actions.js +++ b/src/sunstone/public/app/tabs/zones-tab/actions.js @@ -36,9 +36,9 @@ define(function(require) { callback: function(request, response) { // TODO var tab = dataTable_zones.parents(".tab"); - if (Sunstone.rightInfoVisible(tab)) { + if (Sunstone.rightInfoVisible($('#zones-tab'))) { // individual view - // TODO updateZoneInfo(request, response); + Sunstone.insertPanels('zones-tab', response); } // datatable row diff --git a/src/sunstone/public/app/tabs/zones-tab/panels.js b/src/sunstone/public/app/tabs/zones-tab/panels.js new file mode 100644 index 0000000000..cf894c667b --- /dev/null +++ b/src/sunstone/public/app/tabs/zones-tab/panels.js @@ -0,0 +1,7 @@ +define(function(require){ + var InfoPanel = require('./panels/info'); + + return { + 'zone_info_tab': InfoPanel + } +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/zones-tab/panels/info.js b/src/sunstone/public/app/tabs/zones-tab/panels/info.js new file mode 100644 index 0000000000..084e1ea90b --- /dev/null +++ b/src/sunstone/public/app/tabs/zones-tab/panels/info.js @@ -0,0 +1,21 @@ +define(function(require){ + var TemplateInfo = require('hbs!./info/content'); + var Locale = require('utils/locale'); + + var _generateHTML = function(info) { + return TemplateInfo(info); + } + + var _initialize = function(info) { + + } + + var infoPanel = { + title : Locale.tr("Info"), + icon: "fa-info-circle", + content : _generateHTML, + initialize: _initialize + } + + return infoPanel; +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/zones-tab/panels/info/content.hbs b/src/sunstone/public/app/tabs/zones-tab/panels/info/content.hbs new file mode 100644 index 0000000000..3227c18d62 --- /dev/null +++ b/src/sunstone/public/app/tabs/zones-tab/panels/info/content.hbs @@ -0,0 +1,24 @@ +
+
+ + + + + + + + + + + + {{! TODO insert_rename_tr('zones-tab', "Zone", ID, NAME)}} + +
{{tr "Information"}}
{{tr "ID"}}{{ZONE.ID}}
+
+
+
+
+
+ {{! TODO insert_extended_template_table(zone_template, "Zone", ID, tr("Attributes"))}} +
+
\ No newline at end of file diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index c4e0b06760..3ec1695b18 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -1,6 +1,7 @@ define(function(require) { require('foundation-datatables'); - var TemplateEmptyTable = require('hbs!./tab-datatable/empty-table') + var TemplateEmptyTable = require('hbs!./tab-datatable/empty-table'); + var Sunstone = require('sunstone'); var SPINNER = 'retrieving'; @@ -16,12 +17,10 @@ define(function(require) { //Shows run a custom action when clicking on rows. var _infoListener = function(dataTable, info_action, target_tab) { - $('tbody tr', dataTable).off("click"); - $('tbody tr', dataTable).on("click", function(e) { - - if ($(e.target).is('input') || - $(e.target).is('select') || - $(e.target).is('option')) return true; + dataTable.on("click", 'tbody tr', function(e) { + if ($(e.target).is('input') ||$(e.target).is('select') || $(e.target).is('option')) { + return true; + } var aData = dataTable.fnGetData(this); if (!aData) return true; @@ -34,10 +33,10 @@ define(function(require) { $('.check_item', this).trigger('click'); } else { if (!target_tab) { - target_tab = activeTab; + target_tab = $(dataTable).parents(".tab").attr("id"); } - - showElement(target_tab, info_action, id); + console.log(target_tab) + Sunstone.showElement(target_tab, info_action, id); }; } else { $('.check_item', this).trigger('click'); @@ -146,7 +145,7 @@ define(function(require) { $(this).parents('tr').children().removeClass('markrowchecked'); } - recountCheckboxes(datatable, context); + _recountCheckboxes(datatable, context); }); } @@ -259,7 +258,7 @@ define(function(require) { var position = dataTable.fnGetPosition(tr); dataTable.fnUpdate(element, position, undefined, false); $('input.check_item', tr).attr('checked', checked_val); - recountCheckboxes(dataTable); + _recountCheckboxes(dataTable); } }