/[projects]/misc/xenconsole/index.php
ViewVC logotype

Diff of /misc/xenconsole/index.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1956 by torben, Tue Mar 26 08:32:05 2013 UTC revision 2014 by torben, Wed Jul 17 17:47:49 2013 UTC
# Line 1  Line 1 
1  <?php  <?php
2  include("config.php");  require("config.php");
3    
4  function format_memory($size) {  function format_memory($size) {
5    if (1024 > $size) {    if (1024 > $size) {
# Line 58  $namelabel = $host["name_label"]; Line 58  $namelabel = $host["name_label"];
58    
59  <script type='text/javascript'>  <script type='text/javascript'>
60  var menu = 0;  var menu = 0;
61    var menu_uuid = '';
62    
63  $(document).ready( function() {  $(document).ready( function() {
64          $("#menu").hide();          $("#menu").hide();
# Line 67  $(document).ready( function() { Line 68  $(document).ready( function() {
68                  var session = $(this).data('session');                  var session = $(this).data('session');
69                  var conurl = $(this).data('conurl');                  var conurl = $(this).data('conurl');
70                  var name = $(this).data('name');                  var name = $(this).data('name');
71                  console(conurl,session,name);                  openConsole(conurl,session,name);
72          });          });
73    
74          $('#logo').click( function(event) {          $('#logo').click( function() {
75                  //refreshData();                  refreshData();
76                  $('#menu').show().position( {my: "left top", of: event} );          });
77    
78            $('.settings').click( function(event) {
79                    menu_uuid = $(this).attr('uuid');
80    
81                  $('#menu').menu( {                  $('#menu').menu( {
82                          select: function(event2,ui) {                          select: function(event2,ui) {
83                                          alert( ui.item.text() );                                          var action = $(ui.item).attr("action");
84                                          //closeMenu();                                          if (action == "memory") {
85                                                    doAction("setMemory", menu_uuid, "");  
86                                            }
87                                            if (action == "cpu") {
88                                                    doAction("setCPU", menu_uuid, "");      
89                                            }
90                                  },                                  },
91                          create: function(event3,ui) {                          create: function(event3,ui) {
92                                  menu = 1;                                  menu = 1;
# Line 86  $(document).ready( function() { Line 95  $(document).ready( function() {
95                                  my: "left", of: event                                  my: "left", of: event
96                          }*/                          }*/
97                  });                  });
98                    $('#menu').show().position( {my: "left top", of: event} );
99                  event.stopPropagation();                  event.stopPropagation();
100          });          });
101    
# Line 140  function refreshData() { Line 150  function refreshData() {
150                          var cpuavg = $(this).find('cpuavg').text();                          var cpuavg = $(this).find('cpuavg').text();
151                          var curmem = $(this).find('curmem').text();                          var curmem = $(this).find('curmem').text();
152                          var maxmem = $(this).find('maxmem').text();                          var maxmem = $(this).find('maxmem').text();
153                            var cpus = $(this).find('cpus').text();
154    
155                          var mempercent = Math.round( (curmem*100) / maxmem );                          var mempercent = Math.round( (curmem*100) / maxmem );
156    
157                          name = name.replace(" ", "_");                          name = name.replace(/ /g, "_");
158                          name = name.replace(".", "_");                          name = name.replace(/\./g, "_");
159                            name = name.replace(/\(/g, "_");
160                            name = name.replace(/\)/g, "_");
161                                                    
162                          var id = "#vm_" + name;                          var id = "#vm_" + name;
163    
# Line 155  function refreshData() { Line 168  function refreshData() {
168                          }                          }
169    
170                          vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB");                          vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB");
171                            vm.find('.vps_cpu_usage_txt_UID').text( cpus + " VCPU");
172    
173                          if (state == "Running") {                          if (state == "Running") {
174                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");
# Line 164  function refreshData() { Line 178  function refreshData() {
178                                  vm.find('.console').data('conurl', conurl);                                  vm.find('.console').data('conurl', conurl);
179                                  vm.find('.console').data('session', session);                                  vm.find('.console').data('session', session);
180                                  vm.find('.console').data('name', name);                                  vm.find('.console').data('name', name);
181                                    vm.find('.settings').hide();
182                                  vm.find('.actionstop').show();                                  vm.find('.actionstop').show();
183                                  vm.find('.actionstart').hide();                                  vm.find('.actionstart').hide();
184                                  vm.find('.os').text(' - ' + os);                                  vm.find('.os').text(' - ' + os);
# Line 186  function refreshData() { Line 201  function refreshData() {
201    
202                                  vm.find('.network').hide();                                  vm.find('.network').hide();
203                                  vm.find('.console').hide();                                  vm.find('.console').hide();
204                                    vm.find('.settings').show();
205                                  vm.find('.actionstop').hide();                                  vm.find('.actionstop').hide();
206                                  vm.find('.actionstart').show();                                  vm.find('.actionstart').show();
207                                  vm.find('.cpu_graph').hide();                                  vm.find('.cpu_graph').hide();
# Line 209  function doAction(action, uuid, vm) { Line 225  function doAction(action, uuid, vm) {
225    
226          if (action == "setMemory") {          if (action == "setMemory") {
227                  val = prompt("Set memory target");                  val = prompt("Set memory target");
228                    val *= (1024*1024);
229                    if (val == "" || val == null) {
230                            return;
231                    }
232            }
233            if (action == "setCPU") {
234                    val = prompt("Set CPU count");
235                  if (val == "" || val == null) {                  if (val == "" || val == null) {
                         alert("" + val);  
236                          return;                          return;
237                  }                  }
238          }          }
# Line 226  function doAction(action, uuid, vm) { Line 248  function doAction(action, uuid, vm) {
248          });          });
249  }  }
250    
251  function console(url, session, name) {  function openConsole(url, session, name) {
252          if (url == '')          if (url == '')
253                  return;                  return;
254    
# Line 322  foreach($vms_array as $vm) { Line 344  foreach($vms_array as $vm) {
344    
345          $clean_name = str_replace(" ", "_", $name);          $clean_name = str_replace(" ", "_", $name);
346          $clean_name = str_replace(".", "_", $clean_name);          $clean_name = str_replace(".", "_", $clean_name);
347            $clean_name = str_replace("(", "_", $clean_name);
348            $clean_name = str_replace(")", "_", $clean_name);
349                    
350    
351          foreach ($vm["VBDs"] as $vbds) {          foreach ($vm["VBDs"] as $vbds) {
# Line 345  foreach($vms_array as $vm) { Line 369  foreach($vms_array as $vm) {
369                                  <a href='#' style='display:none;' class='console'>                                  <a href='#' style='display:none;' class='console'>
370                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>
371                                  </a>                                  </a>
372                                    <a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'>
373                                            <img src='gfx/icon-settings16.png' style='vertical-align: middle;'>
374                                    </a>
375                          </td>                          </td>
376                  </tr>                  </tr>
377    
# Line 355  foreach($vms_array as $vm) { Line 382  foreach($vms_array as $vm) {
382                          <span class="actionstop" style='display:none'>                          <span class="actionstop" style='display:none'>
383                                  start |                                  start |
384                                  <a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> |                                  <a href='#' onclick="doAction('shutdown','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >stop</a> |
385                                  <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>
                                 set memory  
386                          </span>                          </span>
387                                                    
388                          <span class="actionstart">                                                <span class="actionstart">                      
389                                  <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> |
390                                  stop |                                  stop |
391                                  force shutdown |                                  force shutdown
   
                                 <a href='#' onclick="doAction('setMemory','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >set memory</a>  
392                          </span>                          </span>
393    
394                  </td>                  </td>
# Line 372  foreach($vms_array as $vm) { Line 396  foreach($vms_array as $vm) {
396                  <td width='100' align='right' class='small' valign='top'>                  <td width='100' align='right' class='small' valign='top'>
397                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='cpu_graph'><br>                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='cpu_graph'><br>
398                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>
399                          <span id='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span>                          <span class='vps_cpu_usage_txt_UID'><?php echo $cpu_count; ?> VCPU</span>
400                  </td>                  </td>
401                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
402                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='mem_graph'><br>                          <img src='usagebar.php?usage=1' width='102' height='16' title='static dummy data' class='mem_graph'><br>
# Line 398  foreach($vms_array as $vm) { Line 422  foreach($vms_array as $vm) {
422  <?PHP } ?>  <?PHP } ?>
423  </td></tr></table>  </td></tr></table>
424    
425    <br>
426    
427  <ul id="menu">  <ul id="menu">
428          <li><a href="#">Item 1</a></li>          <li action="memory"><a href="#">Set Memory Size</a></li>
429          <li><a href="#">Item 2</a></li>          <li action="cpu"><a href="#">Set CPU Count</a></li>
430          <li><a href="#">Item 3</a>  
431    
432    <!--    <li><a href="#">Item 3</a>
433                  <ul>                  <ul>
434                          <li><a href="#">Item 3-1</a></li>                          <li><a href="#">Item 3-1</a></li>
435                          <li><a href="#">Item 3-2</a></li>                          <li><a href="#">Item 3-2</a></li>
# Line 411  foreach($vms_array as $vm) { Line 439  foreach($vms_array as $vm) {
439                  </ul>                  </ul>
440          </li>          </li>
441          <li><a href="#">Item 4</a></li>          <li><a href="#">Item 4</a></li>
442          <li><a href="#">Item 5</a></li>          <li><a href="#">Item 5</a></li>-->
443  </ul>  </ul>
444    
445  </body></html>  </body></html>

Legend:
Removed from v.1956  
changed lines
  Added in v.2014

  ViewVC Help
Powered by ViewVC 1.1.20