diff --git a/src/sunstone/public/app/tabs/vnets-tab.js b/src/sunstone/public/app/tabs/vnets-tab.js index a24b345136..c42ab45784 100644 --- a/src/sunstone/public/app/tabs/vnets-tab.js +++ b/src/sunstone/public/app/tabs/vnets-tab.js @@ -7,9 +7,9 @@ define(function(require) { var TAB_ID = require('./vnets-tab/tabId'); var DATATABLE_ID = "dataTableVNets"; - //var _dialogs = [ - // require('./vnets-tab/dialogs/create') - //]; + var _dialogs = [ + require('./vnets-tab/dialogs/add-ar') + ]; var _panels = [ require('./vnets-tab/panels/info'), @@ -37,7 +37,7 @@ define(function(require) { dataTable: new Table(DATATABLE_ID, {actions: true, info: true}), panels: _panels, formPanels: _formPanels, - //dialogs: _dialogs + dialogs: _dialogs }; return VNetsTab; diff --git a/src/sunstone/public/app/tabs/vnets-tab/actions.js b/src/sunstone/public/app/tabs/vnets-tab/actions.js index 7ab155ee35..f0c97fda73 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/actions.js +++ b/src/sunstone/public/app/tabs/vnets-tab/actions.js @@ -7,6 +7,7 @@ define(function(require) { var TAB_ID = require('./tabId'); var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); + var ADD_AR_DIALOG_ID = require('./dialogs/add-ar/dialogId'); var _actions = { "Network.create" : { @@ -129,16 +130,14 @@ define(function(require) { }, error: Notifier.onError }, - // TODO: update - /* + "Network.add_ar" : { type: "single", call: OpenNebulaNetwork.add_ar, callback: function(req) { // Reset the wizard - $add_ar_dialog.foundation('reveal', 'close'); - $add_ar_dialog.empty(); - setupAddARDialog(); + Sunstone.getDialog(ADD_AR_DIALOG_ID).hide(); + Sunstone.getDialog(ADD_AR_DIALOG_ID).reset(); Sunstone.runAction("Network.show",req.request.data[0][0]); }, @@ -149,7 +148,9 @@ define(function(require) { type: "single", call: OpenNebulaNetwork.rm_ar, callback: function(req) { + /* TODO OpenNebula.Helper.clear_cache("VNET"); + */ Sunstone.runAction("Network.show",req.request.data[0][0]); }, error: Notifier.onError @@ -159,16 +160,18 @@ define(function(require) { type: "single", call: OpenNebulaNetwork.update_ar, callback: function(req) { + /* TODO // Reset the wizard $update_ar_dialog.foundation('reveal', 'close'); $update_ar_dialog.empty(); setupUpdateARDialog(); + */ Sunstone.runAction("Network.show",req.request.data[0][0]); }, error: Notifier.onError }, - + /* TODO "Network.reserve_dialog" : { type: "custom", call: popUpReserveDialog diff --git a/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar.js b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar.js new file mode 100644 index 0000000000..62bdfa076d --- /dev/null +++ b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar.js @@ -0,0 +1,81 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var BaseDialog = require('utils/dialogs/dialog'); + var TemplateHTML = require('hbs!./add-ar/html'); + var ArTab = require('tabs/vnets-tab/utils/ar-tab'); + var Sunstone = require('sunstone'); + var Notifier = require('utils/notifier'); + var Locale = require('utils/locale'); + + /* + CONSTANTS + */ + + var DIALOG_ID = require('./add-ar/dialogId'); + + /* + CONSTRUCTOR + */ + + function Dialog() { + this.dialogId = DIALOG_ID; + + this.arTab = new ArTab(); + + BaseDialog.call(this); + } + + Dialog.DIALOG_ID = DIALOG_ID; + Dialog.prototype = Object.create(BaseDialog.prototype); + Dialog.prototype.constructor = Dialog; + Dialog.prototype.html = _html; + Dialog.prototype.onShow = _onShow; + Dialog.prototype.setup = _setup; + Dialog.prototype.setId = _setId; + + return Dialog; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateHTML({ + 'arTabHTML': this.arTab.html("add_ar") + }); + } + + function _setup(context) { + var that = this; + + that.arTab.setup(context, "add_ar"); + + $('#submit_ar_reset_button', context).click(function(){ + Sunstone.getDialog(DIALOG_ID).reset(); + Sunstone.getDialog(DIALOG_ID).show(); + }); + + $('#add_ar_form',context).on('invalid', function () { + Notifier.notifyError(Locale.tr("One or more required fields are missing.")); + }).on('valid', function () { + var data = that.arTab.retrieve(); + + var obj = {AR: data}; + Sunstone.runAction('Network.add_ar', that.vnetId, obj); + + return false; + }); + } + + function _onShow(context) { + this.arTab.onShow(); + $('#vnet_id', this.dialogElement).text(this.vnetId); + } + + function _setId(id) { + this.vnetId = id; + } +}); diff --git a/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/dialogId.js b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/dialogId.js new file mode 100644 index 0000000000..8485f82576 --- /dev/null +++ b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/dialogId.js @@ -0,0 +1,3 @@ +define(function(require){ + return 'add_ar_dialog'; +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/html.hbs b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/html.hbs new file mode 100644 index 0000000000..a11832b344 --- /dev/null +++ b/src/sunstone/public/app/tabs/vnets-tab/dialogs/add-ar/html.hbs @@ -0,0 +1,27 @@ +
+
+
+
+
+

+ {{tr "Virtual Network"}} +
+ {{tr "New Address Range"}} +

+
+
+ {{{arTabHTML}}} + + × +
+
+
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/ar.js b/src/sunstone/public/app/tabs/vnets-tab/panels/ar.js index 292897e8dd..aca1f326a3 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/panels/ar.js +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/ar.js @@ -10,6 +10,7 @@ define(function(require) { var Config = require('sunstone-config'); var Utils = require('../utils/common'); var SecurityGroupsTable = require('tabs/secgroups-tab/datatable'); + var Sunstone = require('sunstone'); /* CONSTANTS @@ -21,6 +22,8 @@ define(function(require) { var RESOURCE = "Network"; var XML_ROOT = "VNET"; + var ADD_AR_DIALOG_ID = require('../dialogs/add-ar/dialogId'); + /* CONSTRUCTOR */ @@ -159,8 +162,8 @@ define(function(require) { context.on("click", 'button#add_ar_button', function(){ var id = that.element.ID; - // TODO: Add AR dialog - //popUpAddAR(id); + Sunstone.getDialog(ADD_AR_DIALOG_ID).setId(id); + Sunstone.getDialog(ADD_AR_DIALOG_ID).show(); return false; });