diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/actions.js b/src/sunstone/public/app/tabs/oneflow-services-tab/actions.js index 0e59391fac..d0c1a9c985 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/actions.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/actions.js @@ -28,8 +28,15 @@ define(function(require) { } function roleVMElements() { - // TODO - //return getSelectedNodes(serviceroleVMsDataTable, true); + var selected_nodes = []; + + var dataTable = $('table[id^=datatable_service_vms]', '#'+TAB_ID+' #'+ROLES_PANEL_ID); + var nodes = $('tbody input.check_item:checked', dataTable); + $.each(nodes, function() { + selected_nodes.push($(this).val()); + }); + + return selected_nodes; } function roleCallback() { diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js index 23190063e2..e7bf9226ad 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js @@ -7,8 +7,13 @@ define(function(require) { var Tips = require('utils/tips'); var OpenNebulaRole = require('opennebula/role'); var roles_buttons = require('./roles/roles-buttons'); + var roles_vm_buttons = require('./roles/roles-vm-buttons'); var Sunstone = require('sunstone'); - var RolesDataTable = require('./roles/roles-datatable'); + var DomDataTable = require('utils/dom-datatable'); + var VMsTableUtils = require('tabs/vms-tab/utils/datatable-common'); + var SunstoneConfig = require('sunstone-config'); + + var VMS_TAB_ID = require('tabs/vms-tab/tabId'); /* TEMPLATES @@ -85,7 +90,7 @@ define(function(require) { var roles = this.element.TEMPLATE.BODY.roles; if (roles && roles.length) { - this.servicerolesDataTable = new RolesDataTable( + this.servicerolesDataTable = new DomDataTable( 'datatable_service_roles', { actions: true, @@ -145,17 +150,100 @@ define(function(require) { function _roleHTML(role_index) { + var that = this; + var role = this.element.TEMPLATE.BODY.roles[role_index]; - // TODO: role VMs table + var vms = []; + + if (role.nodes) { + $.each(role.nodes, function(){ + var vm_info = this.vm_info; + + var info = []; + if (this.scale_up) { + info.push(""); + } else if (this.disposed) { + info.push(""); + } else { + info.push(""); + } + + if (that.element.TEMPLATE.BODY.ready_status_gate) { + if (vm_info.VM.USER_TEMPLATE.READY == "YES") { + info.push(''); + + } else { + info.push(''); + } + } else { + info.push(""); + } + + if (vm_info) { + vms.push(info.concat(VMsTableUtils.elementArray(vm_info))); + } else { + vms.push(info.concat(VMsTableUtils.emptyElementArray(this.deploy_id))); + } + }); + } return TemplateRoleInfo({ 'role': role, - 'vmsTableHTML': "

TODO

" + 'vmsTableColumns': VMsTableUtils.columns, + 'vms': vms }); } function _roleSetup(context, role_index) { + var role = this.element.TEMPLATE.BODY.roles[role_index]; + + // This table has 2 more columns to the left compared to the normal VM table + // The visibility index array needs to be adjusted + var visibleColumns = [0,1].concat( + SunstoneConfig.tabTableColumns(VMS_TAB_ID).map(function(n){ + return n+2; + })); + + this.serviceroleVMsDataTable = new DomDataTable( + 'datatable_service_vms_'+role.name, + { + actions: true, + info: false, + customTabContext: $('#role_vms_actions', context), + dataTableOptions: { + "bAutoWidth": false, + "bSortClasses" : false, + "bDeferRender": true, + "aoColumnDefs": [ + {"bSortable": false, "aTargets": [0,1,"check"]}, + {"bVisible": true, "aTargets": visibleColumns}, + {"bVisible": false, "aTargets": ['_all']} + ] + } + }); + + // TODO: global vars, see Service.refresh + /* + if(last_selected_row_rolevm) { + last_selected_row_rolevm.children().each(function(){ + $(this).removeClass('markrowchecked'); + }); + } + + last_selected_row_rolevm = $(this); + $(this).children().each(function(){ + $(this).addClass('markrowchecked'); + }); + */ + + this.serviceroleVMsDataTable.initialize(); + Sunstone.insertButtonsInTab( + "oneflow-services", + "service_roles_tab", + roles_vm_buttons, + $('div#role_vms_actions', context)); + Tips.setup(context); } }); diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs index b7f5cdea3f..a3892ca932 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs @@ -25,11 +25,34 @@
{{tr "Virtual Machines"}}
-
+
- {{{vmsTableHTML}}} +
+ + + + + + + {{#each vmsTableColumns}} + + {{/each}} + + + + {{#each vms}} + + {{#each this}} + + {{/each}} + + {{/each}} + +
+ + {{this}}
{{{this}}}
diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roles-vm-buttons.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roles-vm-buttons.js new file mode 100644 index 0000000000..26e24a8f59 --- /dev/null +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roles-vm-buttons.js @@ -0,0 +1,110 @@ +define(function(require) { + var Locale = require('utils/locale'); + + var Buttons = { + "RoleVM.hold" : { + type: "action", + text: Locale.tr("Hold"), + tip: Locale.tr("This will hold selected pending VMs from being deployed"), + layout: "vmsplanification_buttons", + }, + "RoleVM.release" : { + type: "action", + text: Locale.tr("Release"), + layout: "vmsplanification_buttons", + tip: Locale.tr("This will release held machines") + }, + "RoleVM.suspend" : { + type: "action", + text: Locale.tr("Suspend"), + layout: "vmspause_buttons", + tip: Locale.tr("This will suspend selected machines") + }, + "RoleVM.resume" : { + type: "action", + text: '', + layout: "vmsplay_buttons", + tip: Locale.tr("This will resume selected VMs") + }, + "RoleVM.stop" : { + type: "action", + text: Locale.tr("Stop"), + layout: "vmsstop_buttons", + tip: Locale.tr("This will stop selected VMs") + }, + "RoleVM.reboot" : { + type: "action", + text: Locale.tr("Reboot"), + layout: "vmsrepeat_buttons", + tip: Locale.tr("This will send a reboot action to running VMs") + }, + "RoleVM.reboot_hard" : { + type: "action", + text: Locale.tr("Reboot") + ' hard', + layout: "vmsrepeat_buttons", + tip: Locale.tr("This will perform a hard reboot on selected VMs") + }, + "RoleVM.poweroff" : { + type: "action", + text: Locale.tr("Power Off"), + layout: "vmspause_buttons", + tip: Locale.tr("This will send a power off signal to running VMs. They can be resumed later.") + }, + "RoleVM.poweroff_hard" : { + type: "action", + text: Locale.tr("Power Off") + ' hard', + layout: "vmspause_buttons", + tip: Locale.tr("This will send a forced power off signal to running VMs. They can be resumed later.") + }, + "RoleVM.undeploy" : { + type: "action", + text: Locale.tr("Undeploy"), + layout: "vmsstop_buttons", + tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore.") + }, + "RoleVM.undeploy_hard" : { + type: "action", + text: Locale.tr("Undeploy") + ' hard', + layout: "vmsstop_buttons", + tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore.") + }, + "RoleVM.shutdown" : { + type: "action", + text: Locale.tr("Shutdown"), + layout: "vmsdelete_buttons", + tip: Locale.tr("This will initiate the shutdown process in the selected VMs") + }, + "RoleVM.shutdown_hard" : { + type: "action", + text: Locale.tr("Shutdown") + ' hard', + layout: "vmsdelete_buttons", + tip: Locale.tr("This will initiate the shutdown-hard (forced) process in the selected VMs") + }, + "RoleVM.delete" : { + type: "action", + text: Locale.tr("Delete"), + layout: "vmsdelete_buttons", + tip: Locale.tr("This will delete the selected VMs from the database") + }, + "RoleVM.delete_recreate" : { + type: "action", + text: Locale.tr("Delete") + ' recreate', + layout: "vmsrepeat_buttons", + tip: Locale.tr("This will delete and recreate VMs to PENDING state") + }, + "RoleVM.resched" : { + type: "action", + text: Locale.tr("Reschedule"), + layout: "vmsplanification_buttons", + tip: Locale.tr("This will reschedule selected VMs") + }, + "RoleVM.unresched" : { + type: "action", + text: Locale.tr("Un-Reschedule"), + layout: "vmsplanification_buttons", + tip: Locale.tr("This will cancel the rescheduling for the selected VMs") + } + }; + + return Buttons; +}); \ No newline at end of file