diff --git a/src/sunstone/public/app/tabs/vms-tab.js b/src/sunstone/public/app/tabs/vms-tab.js index 7b96c7dd1a..56d5d10d72 100644 --- a/src/sunstone/public/app/tabs/vms-tab.js +++ b/src/sunstone/public/app/tabs/vms-tab.js @@ -16,6 +16,7 @@ define(function(require) { var _panels = [ require('./vms-tab/panels/info'), require('./vms-tab/panels/capacity'), + require('./vms-tab/panels/storage'), // require('./vms-tab/panels/template') ]; diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/storage.js b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js new file mode 100644 index 0000000000..328f40ea48 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/storage.js @@ -0,0 +1,237 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var Config = require('sunstone-config'); + var Sunstone = require('sunstone'); + var Humanize = require('utils/humanize'); + var StateActions = require('../utils/state-actions'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./storage/panelId'); + var ATTACH_DISK_DIALOG_ID = require('../dialogs/attach-disk/dialogId'); + var RESOURCE = "VM" + var XML_ROOT = "VM" + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.panelId = PANEL_ID; + this.title = Locale.tr("Storage"); + this.icon = "fa-tasks"; + + 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 that = this; + var html = '
'; + + return html; + } + + function _setup(context) { + var that = this; + /* TODO if (Config.isTabActionEnabled("vms-tab", "VM.saveas")) { + setupSaveAsDialog(); + + $('a.saveas').live('click', function(){ + var b = $(this); + var vm_id = b.parents('form').attr('vmid'); + var disk_id = b.parents('tr').attr('disk_id'); + + popUpSaveAsDialog(vm_id, disk_id); + + //b.html(spinner); + return false; + }); + } */ + + /* TODO if (Config.isTabActionEnabled("vms-tab", "VM.disk_snapshot_cancel")) { + $('a.disk_snapshot_cancel').live('click', function(){ + var b = $(this); + var vm_id = b.parents('form').attr('vmid'); + var disk_id = b.parents('tr').attr('disk_id'); + + Sunstone.runAction('VM.disk_snapshot_cancel', vm_id, disk_id); + + return false; + }); + } */ + + if (Config.isTabActionEnabled("vms-tab", "VM.attachdisk")) { + context.off('click', '#attach_disk'); + context.on('click', '#attach_disk', function() { + var dialog = Sunstone.getDialog(ATTACH_DISK_DIALOG_ID); + dialog.setElement(that.element); + dialog.show(); + return false; + }); + } + + if (Config.isTabActionEnabled("vms-tab", "VM.detachdisk")) { + context.off('click', '.detachdisk'); + context.on('click', '.detachdisk', function() { + var disk_id = $(this).parents('tr').attr('disk_id'); + Sunstone.runAction('VM.detachdisk', that.element.ID, disk_id); + return false; + }); + } + } +}); diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/storage/panelId.js b/src/sunstone/public/app/tabs/vms-tab/panels/storage/panelId.js new file mode 100644 index 0000000000..ba4488619b --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/storage/panelId.js @@ -0,0 +1,3 @@ +define(function(require){ + return 'vm_hotplugging_tab'; +}); \ No newline at end of file