mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
Feature #3748: Add VMs table to oneflow service roles panel
This commit is contained in:
parent
fe21d98a38
commit
2277df5b52
@ -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() {
|
||||
|
@ -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("<i class='fa fa-arrow-up'/>");
|
||||
} else if (this.disposed) {
|
||||
info.push("<i class='fa fa-arrow-down'/>");
|
||||
} else {
|
||||
info.push("");
|
||||
}
|
||||
|
||||
if (that.element.TEMPLATE.BODY.ready_status_gate) {
|
||||
if (vm_info.VM.USER_TEMPLATE.READY == "YES") {
|
||||
info.push('<span data-tooltip class="has-tip" title="'+tr("The VM is ready")+'"><i class="fa fa-check"/></span>');
|
||||
|
||||
} else {
|
||||
info.push('<span data-tooltip class="has-tip" title="'+tr("Waiting for the VM to be ready")+'"><i class="fa fa-clock-o"/></span>');
|
||||
}
|
||||
} 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': "<p>TODO</p>"
|
||||
'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);
|
||||
}
|
||||
});
|
||||
|
@ -25,11 +25,34 @@
|
||||
<fieldset>
|
||||
<legend>{{tr "Virtual Machines"}}</legend>
|
||||
<div id="role_vms_actions">
|
||||
<div class="action_blocks columns twelve">
|
||||
<div class="action_blocks large-12 columns">
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-12 columns">
|
||||
{{{vmsTableHTML}}}
|
||||
<br>
|
||||
<table id="datatable_service_vms_{{role.name}}" class="dataTable twelve ">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th class="check">
|
||||
<input type="checkbox" class="check_all" value=""></input>
|
||||
</th>
|
||||
{{#each vmsTableColumns}}
|
||||
<th>{{this}}</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each vms}}
|
||||
<tr>
|
||||
{{#each this}}
|
||||
<td>{{{this}}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class='large-12 columns'>
|
||||
|
@ -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: '<i class="fa fa-play"/>',
|
||||
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") + ' <span class="label secondary radius">hard</span>',
|
||||
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") + ' <span class="label secondary radius">hard</span>',
|
||||
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") + ' <span class="label secondary radius">hard</span>',
|
||||
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") + ' <span class="label secondary radius">hard</span>',
|
||||
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") + ' <span class="label secondary radius">recreate</span>',
|
||||
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;
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user