60 |
var menu = 0; |
var menu = 0; |
61 |
var menu_uuid = ''; |
var menu_uuid = ''; |
62 |
|
|
63 |
|
var user = ""; |
64 |
|
var password = ""; |
65 |
|
var loggedin = false; |
66 |
|
|
67 |
|
function isLoggedIn() { |
68 |
|
if (loggedin == false) { |
69 |
|
alert("You need to login to perform this operation"); |
70 |
|
} |
71 |
|
return loggedin; |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
$(document).ready( function() { |
$(document).ready( function() { |
76 |
$("#menu").hide(); |
$("#menu").hide(); |
77 |
setInterval(refreshData, 60000); |
setInterval(refreshData, 60000); |
83 |
openConsole(conurl,session,name); |
openConsole(conurl,session,name); |
84 |
}); |
}); |
85 |
|
|
86 |
|
$('#server_memory_usage').progressbar( ); |
87 |
|
$('#server_cpu_usage').progressbar( ); |
88 |
|
|
89 |
$('#logo').click( function() { |
$('#logo').click( function() { |
90 |
refreshData(); |
refreshData(); |
91 |
}); |
}); |
118 |
var uuid = $(this).attr('uuid'); |
var uuid = $(this).attr('uuid'); |
119 |
cdSelectorDialog(uuid); |
cdSelectorDialog(uuid); |
120 |
}); |
}); |
121 |
|
$('#loginlink').click( function(event) { |
122 |
|
loginDialog(); |
123 |
|
}); |
124 |
|
|
125 |
$(document).click( function(event) { |
$(document).click( function(event) { |
126 |
closeMenu(); |
closeMenu(); |
127 |
}); |
}); |
128 |
|
$('#dialog-login').keypress(function(e) { |
129 |
|
if (e.keyCode == $.ui.keyCode.ENTER) { |
130 |
|
loginDialogSubmit(); |
131 |
|
} |
132 |
|
}); |
133 |
}); |
}); |
134 |
|
|
135 |
|
function loginDialog() { |
136 |
|
$('#dialog-login').dialog({ |
137 |
|
modal: true, |
138 |
|
height: 210, |
139 |
|
width: 350, |
140 |
|
buttons: { |
141 |
|
Login: loginDialogSubmit |
142 |
|
} |
143 |
|
}); |
144 |
|
} |
145 |
|
function loginDialogSubmit() { |
146 |
|
var params = $('#loginform').serialize(); |
147 |
|
|
148 |
|
$.get('login.php?' + params, function(data) { |
149 |
|
if (data == "OK") { |
150 |
|
loggedin = true; |
151 |
|
username = $('#username').val(); |
152 |
|
password = $('#password').val(); |
153 |
|
|
154 |
|
$('#login').html("Logged in as <i>" + username + "</i>"); |
155 |
|
refreshData(); |
156 |
|
} else { |
157 |
|
alert(data); |
158 |
|
} |
159 |
|
$("#dialog-login").dialog( "close" ); |
160 |
|
}); |
161 |
|
} |
162 |
|
|
163 |
function cdSelectorDialog(uuid) { |
function cdSelectorDialog(uuid) { |
164 |
|
if (isLoggedIn() == false) |
165 |
|
return; |
166 |
|
|
167 |
$('#cdselector').html(''); |
$('#cdselector').html(''); |
168 |
$('#cdselector').load( 'getisolist.php' ); |
$('#cdselector').load( 'getisolist.php' ); |
169 |
var cddata; |
var cddata; |
172 |
cddata = data; |
cddata = data; |
173 |
if (data.ISO != '') { |
if (data.ISO != '') { |
174 |
$('#cdcurrent').html( data.ISO ); |
$('#cdcurrent').html( data.ISO ); |
175 |
|
$(":button:contains('Mount')").prop("disabled", true).addClass("ui-state-disabled"); |
176 |
} else { |
} else { |
177 |
$('#cdcurrent').html('<i>No ISO currently mounted</i>'); |
$('#cdcurrent').html('<i>No ISO currently mounted</i>'); |
178 |
|
$(":button:contains('Eject')").prop("disabled", true).addClass("ui-state-disabled"); |
179 |
} |
} |
180 |
}); |
}); |
181 |
|
|
214 |
$(xml).find('host').each(function() { |
$(xml).find('host').each(function() { |
215 |
var memtotal = $(this).find('memtotal').text(); |
var memtotal = $(this).find('memtotal').text(); |
216 |
var memfree = $(this).find('memfree').text(); |
var memfree = $(this).find('memfree').text(); |
217 |
var cpuavg = $(this).find('cpuavg').text(); |
var cpuavg = $(this).find('cpuavg').text() * 1; // *1 is used to convert the string var to an int |
218 |
|
|
219 |
memtotal = Math.round ( memtotal / (1024*1024) ); |
memtotal = Math.round ( memtotal / (1024*1024) ); |
220 |
memfree = Math.round ( memfree / (1024*1024) ); |
memfree = Math.round ( memfree / (1024*1024) ); |
223 |
|
|
224 |
//alert(memused + ' ' + mem_percentage); |
//alert(memused + ' ' + mem_percentage); |
225 |
|
|
226 |
$('#server_memory_usage').attr('src', 'usagebar.php?usage=' + mem_percentage); |
//$('#server_memory_usage').attr('src', 'usagebar.php?usage=' + mem_percentage); |
227 |
|
$('#server_memory_usage').progressbar( "value", mem_percentage ); |
228 |
$('#server_memory_usage').attr('alt', mem_percentage + '%'); |
$('#server_memory_usage').attr('alt', mem_percentage + '%'); |
229 |
$('#server_memory_usage').attr('title', mem_percentage + '%'); |
$('#server_memory_usage').attr('title', mem_percentage + '%'); |
230 |
$('#server_memory_usage_txt').text( memused + '/' + memtotal + 'MB'); |
$('#server_memory_usage_txt').text( memused + '/' + memtotal + 'MB'); |
231 |
|
|
232 |
|
|
233 |
$('#server_cpu_usage').attr('src', 'usagebar.php?usage=' + cpuavg); |
//$('#server_cpu_usage').attr('src', 'usagebar.php?usage=' + cpuavg); |
234 |
|
$('#server_cpu_usage').progressbar( "value", cpuavg ); |
235 |
$('#server_cpu_usage').attr('alt', cpuavg + '%'); |
$('#server_cpu_usage').attr('alt', cpuavg + '%'); |
236 |
$('#server_cpu_usage').attr('title', cpuavg + '%'); |
$('#server_cpu_usage').attr('title', cpuavg + '%'); |
237 |
$('#server_cpu_usage_txt').text( cpuavg+ '%'); |
$('#server_cpu_usage_txt').text( cpuavg+ '%'); |
277 |
vm.find('.console').data('session', session); |
vm.find('.console').data('session', session); |
278 |
vm.find('.console').data('name', name); |
vm.find('.console').data('name', name); |
279 |
vm.find('.settings').hide(); |
vm.find('.settings').hide(); |
280 |
vm.find('.actionstop').show(); |
if (loggedin) { |
281 |
vm.find('.actionstart').hide(); |
vm.find('.actionstop').show(); |
282 |
|
vm.find('.actionstart').hide(); |
283 |
|
} |
284 |
vm.find('.os').text(' - ' + os); |
vm.find('.os').text(' - ' + os); |
285 |
|
|
286 |
|
|
302 |
vm.find('.network').hide(); |
vm.find('.network').hide(); |
303 |
vm.find('.console').hide(); |
vm.find('.console').hide(); |
304 |
vm.find('.settings').show(); |
vm.find('.settings').show(); |
305 |
vm.find('.actionstop').hide(); |
if (loggedin) { |
306 |
vm.find('.actionstart').show(); |
vm.find('.actionstop').hide(); |
307 |
|
vm.find('.actionstart').show(); |
308 |
|
} |
309 |
vm.find('.cpu_graph').hide(); |
vm.find('.cpu_graph').hide(); |
310 |
vm.find('.mem_graph').hide(); |
vm.find('.mem_graph').hide(); |
311 |
} |
} |
318 |
function doAction(action, uuid, vm) { |
function doAction(action, uuid, vm) { |
319 |
var val=""; |
var val=""; |
320 |
|
|
321 |
var key = prompt("Key"); |
if (isLoggedIn() == false) |
|
if (key == "" || key == null) { |
|
322 |
return; |
return; |
323 |
} |
|
324 |
document.body.style.cursor = 'wait'; |
document.body.style.cursor = 'wait'; |
325 |
$('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
$('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')"); |
326 |
|
|
338 |
} |
} |
339 |
} |
} |
340 |
|
|
341 |
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key + "&val=" + val;; |
var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + password + "&val=" + val;; |
342 |
var response = $.get(url, function(data) { |
var response = $.get(url, function(data) { |
343 |
if (data != 'OK') { |
if (data != 'OK') { |
344 |
alert(data); |
alert(data); |
350 |
} |
} |
351 |
|
|
352 |
function cdAction(action, vbd,vdi) { |
function cdAction(action, vbd,vdi) { |
353 |
var key = prompt("Key"); |
if (isLoggedIn() == false) |
|
if (key == "" || key == null) { |
|
354 |
return; |
return; |
355 |
} |
|
356 |
document.body.style.cursor = 'wait'; |
document.body.style.cursor = 'wait'; |
357 |
var url = "cdaction.php?action=" + action + "&VBD=" + vbd + "&key=" + key + "&VDI=" + vdi; |
var url = "cdaction.php?action=" + action + "&VBD=" + vbd + "&key=" + password + "&VDI=" + vdi; |
358 |
var response = $.get(url, function(data) { |
var response = $.get(url, function(data) { |
359 |
if (data != 'OK') { |
if (data != 'OK') { |
360 |
alert(data); |
alert(data); |
368 |
if (url == '') |
if (url == '') |
369 |
return; |
return; |
370 |
|
|
371 |
var key = prompt("Key"); |
if (isLoggedIn() == false) |
|
if (key == "" || key == null) { |
|
372 |
return; |
return; |
373 |
} |
|
374 |
var url = "console.php?url=" + url + "&session=" + session + "&key=" + key + "&name=" + name; |
var url = "console.php?url=" + url + "&session=" + session + "&key=" + password + "&name=" + name; |
375 |
|
|
376 |
//window.location = url; |
//window.location = url; |
377 |
//$('#mainwindow').load(url); |
//$('#mainwindow').load(url); |
412 |
margin: 4; |
margin: 4; |
413 |
border: 1px solid #222; |
border: 1px solid #222; |
414 |
} |
} |
415 |
|
|
416 |
|
.ui-progressbar-value { |
417 |
|
background: #61B4F3; |
418 |
|
} |
419 |
|
|
420 |
|
.bar { |
421 |
|
width: 102px; |
422 |
|
height: 16px; |
423 |
|
} |
424 |
|
|
425 |
</style> |
</style> |
426 |
</head> |
</head> |
427 |
<body> |
<body> |
434 |
<td colspan='4' class='small' align='right'><?php echo $namelabel . " / " . $xenversion;?><br><?php echo $license;?></td> |
<td colspan='4' class='small' align='right'><?php echo $namelabel . " / " . $xenversion;?><br><?php echo $license;?></td> |
435 |
</tr> |
</tr> |
436 |
<tr> |
<tr> |
437 |
|
<td width='150'> |
438 |
|
<span id="login" class='small'><i>Not <a href="#" id="loginlink">logged in</a></i> |
439 |
|
</span> |
440 |
|
</td> |
441 |
<td width='150'></td> |
<td width='150'></td> |
442 |
<td width='150'></td> |
<td width='150' align='right' class='small'> |
443 |
<td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'> |
<div id='server_cpu_usage' class='bar'></div> |
444 |
<img id='server_cpu_usage' src='usagebar.php?usage=12' width='102' height='16' title='static dummy data'><div id='server_cpu_usage_txt'>12%</div></td> |
<img src='gfx/icon-cpu.png'> |
445 |
|
<span id='server_cpu_usage_txt'>12%</span> |
446 |
|
</td> |
447 |
|
|
448 |
<td width='150' align='right' class='small'><img src='gfx/icon-memory.png'> |
<td width='150' align='right' class='small'> |
449 |
<img id='server_memory_usage' src='usagebar.php?usage=1' width='102' height='16' title='static dummy data'><div id='server_memory_usage_txt'>0/4 MB</div></td> |
<div id='server_memory_usage' class='bar'></div> |
450 |
|
<img src='gfx/icon-memory.png'> |
451 |
|
<span id='server_memory_usage_txt'>0/4 MB</span> |
452 |
|
</td> |
453 |
<!-- |
<!-- |
454 |
<td width='150' align='right' class='small'><img src='gfx/icon-network.png'> |
<td width='150' align='right' class='small'><img src='gfx/icon-network.png'> |
455 |
<img id='server_net_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_net_usage_txt'>1%</div></td> |
<img id='server_net_usage' src='usagebar.php?usage=41' width='102' height='16' title='static dummy data'><div id='server_net_usage_txt'>1%</div></td> |
501 |
<td colspan='2' class='small' align='right'> |
<td colspan='2' class='small' align='right'> |
502 |
<span class='network'></span> |
<span class='network'></span> |
503 |
<a href='#' class='cd' uuid='<?php echo $uuid;?>' > |
<a href='#' class='cd' uuid='<?php echo $uuid;?>' > |
504 |
<img src='gfx/icon-cd.png' style='vertical-align: middle;'> |
<img src='gfx/icon-cd.gif' style='vertical-align: middle;'></a> |
|
</a> |
|
505 |
<a href='#' style='display:none;' class='console'> |
<a href='#' style='display:none;' class='console'> |
506 |
<img src='gfx/icon-terminal.png' style='vertical-align: middle;'> |
<img src='gfx/icon-terminal.png' style='vertical-align: middle;'> |
507 |
</a> |
</a> |
508 |
|
|
509 |
<a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'> |
<a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'> |
510 |
<img src='gfx/icon-settings16.png' style='vertical-align: middle;'> |
<img src='gfx/icon-settings16.png' style='vertical-align: middle;'> |
511 |
</a> |
</a> |
522 |
<a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a> |
<a href='#' onclick="doAction('hardshutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >force shutdown</a> |
523 |
</span> |
</span> |
524 |
|
|
525 |
<span class="actionstart"> |
<span class="actionstart" style='display:none'> |
526 |
<a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> | |
<a href='#' onclick="doAction('start','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >start</a> | |
527 |
stop | |
stop | |
528 |
force shutdown |
force shutdown |
563 |
|
|
564 |
<div style="display: none;"> |
<div style="display: none;"> |
565 |
|
|
566 |
|
<div id="dialog-login" title="Login"> |
567 |
|
<form id="loginform"> |
568 |
|
<table border="0"> |
569 |
|
<tr> |
570 |
|
<td>Username: </td> |
571 |
|
<td><input type="text" id="username" name="username"></td> |
572 |
|
<tr> |
573 |
|
<tr> |
574 |
|
<td>Password: </td> |
575 |
|
<td><input type="password" id="password" name="password"></td> |
576 |
|
</tr> |
577 |
|
</table> |
578 |
|
</form> |
579 |
|
</div> |
580 |
|
|
581 |
<div id="dialog-cd" title="Select CD"> |
<div id="dialog-cd" title="Select CD"> |
582 |
|
|
583 |
<table border=0> |
<table border=0> |