--- misc/xenconsole/index.php 2013/03/26 17:17:12 1960 +++ misc/xenconsole/index.php 2013/07/18 13:00:14 2018 @@ -1,5 +1,5 @@ $size) { @@ -99,12 +99,52 @@ event.stopPropagation(); }); + $('.cd').click( function(event) { + var uuid = $(this).attr('uuid'); + cdSelectorDialog(uuid); + }); + $(document).click( function(event) { closeMenu(); }); - }); +function cdSelectorDialog(uuid) { + $('#cdselector').html(''); + $('#cdselector').load( 'getisolist.php' ); + var cddata; + + $.getJSON('getcdinfo.php?uuid=' + uuid, function(data) { + cddata = data; + if (data.ISO != '') { + $('#cdcurrent').html( data.ISO ); + } else { + $('#cdcurrent').html('No ISO currently mounted'); + } + }); + + $('#dialog-cd').dialog({ + modal: true, + width: 800, + height: 300, + buttons: { + Mount: function() { + $( this ).dialog( "close" ); + var vdi = $("#cdselector").val(); + cdAction("mount", cddata.VBD, vdi); + }, + Eject: function() { + $( this ).dialog( "close" ); + cdAction("eject", cddata.VBD, ""); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + + } + }); +} + function closeMenu() { if (menu > 0) { $("#menu").menu("destroy").hide(); @@ -154,8 +194,10 @@ var mempercent = Math.round( (curmem*100) / maxmem ); - name = name.replace(" ", "_"); - name = name.replace(".", "_"); + name = name.replace(/ /g, "_"); + name = name.replace(/\./g, "_"); + name = name.replace(/\(/g, "_"); + name = name.replace(/\)/g, "_"); var id = "#vm_" + name; @@ -246,6 +288,22 @@ }); } +function cdAction(action, vbd,vdi) { + var key = prompt("Key"); + if (key == "" || key == null) { + return; + } + document.body.style.cursor = 'wait'; + var url = "cdaction.php?action=" + action + "&VBD=" + vbd + "&key=" + key + "&VDI=" + vdi; + var response = $.get(url, function(data) { + if (data != 'OK') { + alert(data); + } + document.body.style.cursor = 'default' + }); + +} + function openConsole(url, session, name) { if (url == '') return; @@ -342,6 +400,8 @@ $clean_name = str_replace(" ", "_", $name); $clean_name = str_replace(".", "_", $clean_name); + $clean_name = str_replace("(", "_", $clean_name); + $clean_name = str_replace(")", "_", $clean_name); foreach ($vm["VBDs"] as $vbds) { @@ -362,6 +422,9 @@ + + + @@ -420,6 +483,24 @@
+
+ +
+ + + + + + + + +
Current:
+ CD: +
+
+ +
+