Revision bfb4de0a
src/sunstone/public/js/plugins/vms-tab.js | ||
---|---|---|
193 | 193 |
error: onError |
194 | 194 |
}, |
195 | 195 |
|
196 |
"VM.showdisks" : { |
|
197 |
type: "single", |
|
198 |
call: OpenNebula.VM.show, |
|
199 |
callback: function(request, vm){ |
|
200 |
updateVMachineElement(request, vm); |
|
201 |
updateVMDisksInfo(request, vm); |
|
202 |
}, |
|
203 |
error: onError |
|
204 |
}, |
|
205 |
|
|
196 | 206 |
"VM.refresh" : { |
197 | 207 |
type: "custom", |
198 | 208 |
call : function (){ |
... | ... | |
328 | 338 |
"VM.saveas" : { |
329 | 339 |
type: "single", |
330 | 340 |
call: OpenNebula.VM.saveas, |
331 |
callback: vmShow, |
|
341 |
callback: function(request) { |
|
342 |
Sunstone.runAction("VM.showdisks", request.request.data[0]); |
|
343 |
}, |
|
332 | 344 |
error:onError, |
333 | 345 |
notify: true |
334 | 346 |
}, |
... | ... | |
523 | 535 |
"VM.attachdisk" : { |
524 | 536 |
type: "single", |
525 | 537 |
call: OpenNebula.VM.attachdisk, |
526 |
callback: vmShow, |
|
538 |
callback: function(request) { |
|
539 |
Sunstone.runAction("VM.showdisks", request.request.data[0]); |
|
540 |
}, |
|
527 | 541 |
error: onError, |
528 | 542 |
notify: true |
529 | 543 |
}, |
530 | 544 |
"VM.detachdisk" : { |
531 | 545 |
type: "single", |
532 | 546 |
call: OpenNebula.VM.detachdisk, |
533 |
//callback: function(req,res){ |
|
534 |
// setTimeout(vmShow,1000,req); |
|
535 |
//}, |
|
536 |
callback: vmShow, |
|
547 |
callback: function(request) { |
|
548 |
Sunstone.runAction("VM.showdisks", request.request.data[0]); |
|
549 |
}, |
|
537 | 550 |
error: onError, |
538 | 551 |
notify: true |
539 | 552 |
}, |
... | ... | |
1351 | 1364 |
setPermissionsTable(vm_info,''); |
1352 | 1365 |
} |
1353 | 1366 |
|
1367 |
function updateVMDisksInfo(request,vm){ |
|
1368 |
$("li#vm_hotplugging_tabTab").html(printDisks(vm.VM)); |
|
1369 |
} |
|
1370 |
|
|
1354 | 1371 |
// Generates the HTML for the hotplugging tab |
1355 | 1372 |
// This is a list of disks with the save_as, detach options. |
1356 | 1373 |
// And a form to attach a new disk to the VM, if it is running. |
1357 | 1374 |
function printDisks(vm_info){ |
1358 |
//var im_sel = makeSelectOptions(dataTable_images, |
|
1359 |
// 1, //id col - trick -> reference by name! |
|
1360 |
// 4, //name col |
|
1361 |
// [10,10,10], |
|
1362 |
// [tr("DISABLED"),tr("LOCKED"),tr("ERROR")] |
|
1363 |
// ); |
|
1364 | 1375 |
var html ='\ |
1365 |
<div class="">\ |
|
1366 |
<div id="datatable_cluster_vnets_info_div columns twelve">\ |
|
1367 |
<form id="hotplugging_form" vmid="'+vm_info.ID+'" >\ |
|
1368 |
<div class="twelve columns">\ |
|
1369 |
<div id="attach_disk" class="button small secondary radius" >' + tr("Attach new disk") +'</div>\ |
|
1370 |
</div>\ |
|
1371 |
<br>\ |
|
1372 |
<br>\ |
|
1373 |
<div class="twelve columns">\ |
|
1374 |
<table class="info_table twelve extended_table">\ |
|
1375 |
<thead>\ |
|
1376 |
<tr>\ |
|
1377 |
<th>'+tr("ID")+'</th>\ |
|
1378 |
<th>'+tr("Target")+'</th>\ |
|
1379 |
<th>'+tr("Image / Format-Size")+'</th>\ |
|
1380 |
<th>'+tr("Persistent")+'</th>\ |
|
1381 |
<th>'+tr("Save as")+'</th>\ |
|
1382 |
<th colspan="">'+tr("Actions")+'</th>\ |
|
1383 |
</tr>\ |
|
1384 |
</thead>\ |
|
1385 |
<tbody>'; |
|
1376 |
<div class="">\ |
|
1377 |
<div id="datatable_cluster_vnets_info_div columns twelve">\ |
|
1378 |
<form id="hotplugging_form" vmid="'+vm_info.ID+'" >' |
|
1379 |
|
|
1380 |
// If VM is not RUNNING, then we forget about the attach disk form. |
|
1381 |
if (vm_info.STATE == "3"){ |
|
1382 |
html += '\ |
|
1383 |
<div class="twelve columns">\ |
|
1384 |
<div id="attach_disk" class="button small secondary radius" >' + tr("Attach new disk") +'</div>\ |
|
1385 |
</div>\ |
|
1386 |
<br>\ |
|
1387 |
<br>' |
|
1388 |
} |
|
1389 |
|
|
1390 |
html += '\ |
|
1391 |
<div class="twelve columns">\ |
|
1392 |
<table class="info_table twelve extended_table">\ |
|
1393 |
<thead>\ |
|
1394 |
<tr>\ |
|
1395 |
<th>'+tr("ID")+'</th>\ |
|
1396 |
<th>'+tr("Target")+'</th>\ |
|
1397 |
<th>'+tr("Image / Format-Size")+'</th>\ |
|
1398 |
<th>'+tr("Persistent")+'</th>\ |
|
1399 |
<th>'+tr("Save as")+'</th>\ |
|
1400 |
<th colspan="">'+tr("Actions")+'</th>\ |
|
1401 |
</tr>\ |
|
1402 |
</thead>\ |
|
1403 |
<tbody>'; |
|
1386 | 1404 |
|
1387 | 1405 |
|
1388 | 1406 |
var disks = [] |
... | ... | |
1392 | 1410 |
disks = [vm_info.TEMPLATE.DISK] |
1393 | 1411 |
|
1394 | 1412 |
if (!disks.length){ |
1395 |
html += '<tr id="no_disks_tr"><td colspan="6">\ |
|
1396 |
'+tr("No disks to show")+'\ |
|
1397 |
</td></tr>'; |
|
1413 |
html += '\ |
|
1414 |
<tr id="no_disks_tr">\ |
|
1415 |
<td colspan="6">' + tr("No disks to show") + '</td>\ |
|
1416 |
</tr>'; |
|
1398 | 1417 |
} |
1399 | 1418 |
else { |
1400 | 1419 |
|
... | ... | |
1412 | 1431 |
<a href="VM.detachdisk" class="detachdisk" ><i class="icon-remove"/>'+tr("Detach")+'</a>\ |
1413 | 1432 |
</td>\ |
1414 | 1433 |
</tr>'; |
1415 |
|
|
1416 |
// html += '<tr disk_id="'+(disk.DISK_ID)+'"><td class="key_td">'; |
|
1417 |
// html += disk.DISK_ID + ' - ' + |
|
1418 |
// (disk.IMAGE ? disk.IMAGE : "Volatile") + '</td>'; |
|
1419 |
// html += '<td class="value_td">\ |
|
1420 |
//'+(vm_info.STATE == "3" ? '\ |
|
1421 |
// <button value="VM.detachdisk" class="detachdisk" style="float:right;color:#555555;height:26px;">'+tr("Detach")+' <i class="icon-remove icon-large"></i></button>\ |
|
1422 |
//' : '')+'\ |
|
1423 |
// <button value="VM.saveas" class="saveas" style="float:right;margin-right:10px;color:#555555;height:26px;">'+tr("Save")+' <i class="icon-download icon-large"></i></button>\ |
|
1424 |
// <input style="float:right;width:9em;margin-right:10px;margin-top:3px;" type="text" value="saveas_'+vm_info.ID+'_'+disk.DISK_ID+'" name="saveas_name"></input>\ |
|
1425 |
// <label style="float:right;margin-top:4px;">'+tr("Save_as name")+':</label>' |
|
1426 |
// +'\ |
|
1427 |
//</td>'; |
|
1428 | 1434 |
} |
1429 | 1435 |
} |
1430 | 1436 |
|
1431 |
html += '</tbody>\ |
|
1437 |
html += '\ |
|
1438 |
</tbody>\ |
|
1432 | 1439 |
</table>\ |
1433 |
</div>'; |
|
1434 |
|
|
1435 |
// If VM is not RUNNING, then we forget about the attach disk form. |
|
1436 |
if (vm_info.STATE != "3"){ |
|
1437 |
html +='</form>'; |
|
1438 |
return html; |
|
1439 |
} |
|
1440 |
// |
|
1441 |
// // Attach disk form |
|
1442 |
// html += '<table class="info_table">\ |
|
1443 |
// <thead>\ |
|
1444 |
// <tr><th colspan="2">'+tr("Attach disk to running VM")+'</th></tr>\ |
|
1445 |
// </thead>\ |
|
1446 |
// <tbody>\ |
|
1447 |
// <tr><td class="key_td"><label>'+tr("Type")+':</label></td>\ |
|
1448 |
// <td class="value_td">\ |
|
1449 |
// <select id="attach_disk_type" style="width:12em;">\ |
|
1450 |
// <option value="image">'+tr("Existing image")+'</option>\ |
|
1451 |
// <option value="volatile">'+tr("Volatile disk")+'</option>\ |
|
1452 |
// </select>\ |
|
1453 |
// </td>\ |
|
1454 |
// </tr>\ |
|
1455 |
// <tr class="at_image"><td class="key_td"><label>'+tr("Select image")+':</label></td>\ |
|
1456 |
// <td class="value_td">\ |
|
1457 |
// <select name="IMAGE_ID" style="width:12em;">\ |
|
1458 |
// '+im_sel+'\ |
|
1459 |
// </select>\ |
|
1460 |
// </td>\ |
|
1461 |
// </tr>\ |
|
1462 |
// <tr class="at_volatile"><td class="key_td"><label>'+tr("Size")+' (MB):</label></td>\ |
|
1463 |
// <td class="value_td">\ |
|
1464 |
// <input type="text" name="SIZE" style="width:8em;"></input>\ |
|
1465 |
// </td>\ |
|
1466 |
// </tr>\ |
|
1467 |
// <tr class="at_volatile"><td class="key_td"><label>'+tr("Format")+':</label></td>\ |
|
1468 |
// <td class="value_td">\ |
|
1469 |
// <input type="text" name="FORMAT" style="width:8em;"></input>\ |
|
1470 |
// </td>\ |
|
1471 |
// </tr>\ |
|
1472 |
// <tr class="at_volatile"><td class="key_td"><label>'+tr("Type")+':</label></td>\ |
|
1473 |
// <td class="value_td">\ |
|
1474 |
// <select name="TYPE" style="width:12em;">\ |
|
1475 |
// <option value="swap">'+tr("swap")+'</option>\ |
|
1476 |
// <option value="fs">'+tr("fs")+'</option>\ |
|
1477 |
// </select>\ |
|
1478 |
// </td>\ |
|
1479 |
// </tr>\ |
|
1480 |
// <tr class="at_volatile at_image"><td class="key_td"><label>'+tr("Device prefix")+':</label></td>\ |
|
1481 |
// <td class="value_td">\ |
|
1482 |
// <input type="text" name="DEV_PREFIX" value="sd" style="width:8em;"></input>\ |
|
1483 |
// </td>\ |
|
1484 |
// </tr>\ |
|
1485 |
//<!--\ |
|
1486 |
// <tr class="at_volatile"><td class="key_td"><label>'+tr("Readonly")+':</label></td>\ |
|
1487 |
// <td class="value_td">\ |
|
1488 |
// <select name="READONLY" style="width:12em;">\ |
|
1489 |
// <option value="NO">'+tr("No")+'</option>\ |
|
1490 |
// <option value="YES">'+tr("Yes")+'</option>\ |
|
1491 |
// </select>\ |
|
1492 |
// </td>\ |
|
1493 |
// </tr>\ |
|
1494 |
// <tr class="at_volatile"><td class="key_td"><label>'+tr("Save")+':</label></td>\ |
|
1495 |
// <td class="value_td">\ |
|
1496 |
// <select name="SAVE" style="width:12em;">\ |
|
1497 |
// <option value="NO">'+tr("No")+'</option>\ |
|
1498 |
// <option value="YES">'+tr("Yes")+'</option>\ |
|
1499 |
// </select>\ |
|
1500 |
// </td>\ |
|
1501 |
// </tr>\ |
|
1502 |
//-->\ |
|
1503 |
// <tr><td class="key_td"></td>\ |
|
1504 |
// <td class="value_td">\ |
|
1505 |
// <button type="submit" value="VM.attachdisk">'+tr("Attach")+'</button>\ |
|
1506 |
// </td>\ |
|
1507 |
// </tr>\ |
|
1508 |
// </tbody>\ |
|
1509 |
// </table></form>'; |
|
1440 |
</div>\ |
|
1441 |
</form>'; |
|
1510 | 1442 |
|
1511 | 1443 |
return html; |
1512 | 1444 |
} |
1513 | 1445 |
|
1514 |
function popUpSaveAsDialog(vm_id, disk_id){ |
|
1515 |
$('#vm_id',$save_as_dialog).val(vm_id); |
|
1516 |
$('#disk_id',$save_as_dialog).val(disk_id); |
|
1517 |
$save_as_dialog.reveal(); |
|
1518 |
} |
|
1519 |
|
|
1520 | 1446 |
function setupSaveAsDialog(){ |
1521 | 1447 |
dialogs_context.append('<div id="save_as_dialog"></div>'); |
1522 | 1448 |
$save_as_dialog = $('#save_as_dialog',dialogs_context); |
... | ... | |
1585 | 1511 |
<a class="close-reveal-modal">×</a>\ |
1586 | 1512 |
</form>') |
1587 | 1513 |
|
1588 |
//Prepare jquery dialog |
|
1589 |
//dialog.dialog({ |
|
1590 |
// autoOpen: false, |
|
1591 |
// modal:true, |
|
1592 |
// width: 400 |
|
1593 |
//}); |
|
1594 |
|
|
1595 | 1514 |
dialog.addClass("reveal-modal"); |
1596 | 1515 |
setupTips(dialog); |
1597 | 1516 |
|
1598 |
//$('button',dialog).button(); |
|
1599 |
|
|
1600 | 1517 |
$('#save_as_form',dialog).submit(function(){ |
1601 | 1518 |
var vm_id = $('#vm_id', this).val(); |
1602 | 1519 |
var image_name = $('#image_name', this).val(); |
... | ... | |
1619 | 1536 |
}); |
1620 | 1537 |
}; |
1621 | 1538 |
|
1539 |
function popUpSaveAsDialog(vm_id, disk_id){ |
|
1540 |
$('#vm_id',$save_as_dialog).val(vm_id); |
|
1541 |
$('#disk_id',$save_as_dialog).val(disk_id); |
|
1542 |
$save_as_dialog.reveal(); |
|
1543 |
} |
|
1622 | 1544 |
|
1623 | 1545 |
|
1624 | 1546 |
|
1625 | 1547 |
|
1626 | 1548 |
|
1627 | 1549 |
|
1628 |
|
|
1629 |
function popUpAttachDiskDialog(vm_id){ |
|
1630 |
$('#vm_id',$attach_disk_dialog).val(vm_id); |
|
1631 |
$attach_disk_dialog.reveal(); |
|
1632 |
} |
|
1633 |
|
|
1634 | 1550 |
function setupAttachDiskDialog(){ |
1635 | 1551 |
dialogs_context.append('<div id="attach_disk_dialog"></div>'); |
1636 | 1552 |
$attach_disk_dialog = $('#attach_disk_dialog',dialogs_context); |
... | ... | |
1662 | 1578 |
<a class="close-reveal-modal">×</a>\ |
1663 | 1579 |
</form>') |
1664 | 1580 |
|
1665 |
//Prepare jquery dialog |
|
1666 |
//dialog.dialog({ |
|
1667 |
// autoOpen: false, |
|
1668 |
// modal:true, |
|
1669 |
// width: 400 |
|
1670 |
//}); |
|
1671 |
|
|
1672 | 1581 |
dialog.addClass("reveal-modal large"); |
1673 | 1582 |
setupTips(dialog); |
1674 | 1583 |
|
1675 | 1584 |
setup_disk_tab_content(dialog, "attach_disk", "attach_disk") |
1676 | 1585 |
|
1677 |
//$('button',dialog).button(); |
|
1678 |
|
|
1679 | 1586 |
$('#attach_disk_form',dialog).submit(function(){ |
1680 | 1587 |
var vm_id = $('#vm_id', this).val(); |
1681 | 1588 |
|
... | ... | |
1690 | 1597 |
}); |
1691 | 1598 |
}; |
1692 | 1599 |
|
1600 |
function popUpAttachDiskDialog(vm_id){ |
|
1601 |
$('#vm_id',$attach_disk_dialog).val(vm_id); |
|
1602 |
$attach_disk_dialog.reveal(); |
|
1603 |
} |
|
1604 |
|
|
1605 |
|
|
1693 | 1606 |
// Listeners to the disks operations (detach, saveas, attach) |
1694 | 1607 |
function hotpluggingOps(){ |
1695 | 1608 |
setupSaveAsDialog(); |
Also available in: Unified diff