/[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 1955 by torben, Mon Mar 25 20:27:58 2013 UTC revision 1958 by torben, Tue Mar 26 13:43:07 2013 UTC
# Line 48  $namelabel = $host["name_label"]; Line 48  $namelabel = $host["name_label"];
48  <title>XenServer::<?php echo $namelabel;?></title>  <title>XenServer::<?php echo $namelabel;?></title>
49    
50  <link rel="stylesheet" type="text/css" href="jquery/theme/jquery-ui.css">  <link rel="stylesheet" type="text/css" href="jquery/theme/jquery-ui.css">
51    <style>
52    .ui-menu {
53            width: 200px;
54    }
55    </style>
56  <script type='text/javascript' src="jquery/jquery-1.9.1.min.js"></script>  <script type='text/javascript' src="jquery/jquery-1.9.1.min.js"></script>
57  <script type='text/javascript' src="jquery/jquery-ui-1.10.2.min.js"></script>  <script type='text/javascript' src="jquery/jquery-ui-1.10.2.min.js"></script>
58    
59  <script type='text/javascript'>  <script type='text/javascript'>
60    var menu = 0;
61    var menu_uuid = '';
62    
63  $(document).ready( function() {  $(document).ready( function() {
64            $("#menu").hide();
65          setInterval(refreshData, 60000);                  setInterval(refreshData, 60000);        
66          refreshData();          refreshData();
67          $('.console').click( function() {          $('.console').click( 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() {          $('#logo').click( function() {
75                  refreshData();                  refreshData();
76          });          });
77    
78            $('.settings').click( function(event) {
79                    menu_uuid = $(this).attr('uuid');
80    
81                    $('#menu').menu( {
82                            select: function(event2,ui) {
83                                            var action = $(ui.item).attr("action");
84                                            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) {
92                                    menu = 1;
93                                    }
94                            /*position: {
95                                    my: "left", of: event
96                            }*/
97                    });
98                    $('#menu').show().position( {my: "left top", of: event} );
99                    event.stopPropagation();
100            });
101    
102            $(document).click( function(event) {
103                    closeMenu();
104            });
105    
106  });  });
107    
108    function closeMenu() {
109            if (menu > 0) {
110                    $("#menu").menu("destroy").hide();
111                    menu = 0;
112            }
113    }
114    
115  function refreshData() {  function refreshData() {
116          $("#logo").hide();                $("#logo").hide();      
117          $.get('ajaxdata.php', function(xml) {          $.get('ajaxdata.php', function(xml) {
# Line 106  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    
# Line 121  function refreshData() { Line 166  function refreshData() {
166                          }                          }
167    
168                          vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB");                          vm.find('.vps_memory_usage_txt_UID').text( maxmem + " MB");
169                            vm.find('.vps_cpu_usage_txt_UID').text( cpus + " VCPU");
170    
171                          if (state == "Running") {                          if (state == "Running") {
172                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");                                  vm.find('.state').css("background-image", "url('gfx/vps_topgreen.png')");
# Line 130  function refreshData() { Line 176  function refreshData() {
176                                  vm.find('.console').data('conurl', conurl);                                  vm.find('.console').data('conurl', conurl);
177                                  vm.find('.console').data('session', session);                                  vm.find('.console').data('session', session);
178                                  vm.find('.console').data('name', name);                                  vm.find('.console').data('name', name);
179                                    vm.find('.settings').hide();
180                                  vm.find('.actionstop').show();                                  vm.find('.actionstop').show();
181                                  vm.find('.actionstart').hide();                                  vm.find('.actionstart').hide();
182                                  vm.find('.os').text(' - ' + os);                                  vm.find('.os').text(' - ' + os);
# Line 152  function refreshData() { Line 199  function refreshData() {
199    
200                                  vm.find('.network').hide();                                  vm.find('.network').hide();
201                                  vm.find('.console').hide();                                  vm.find('.console').hide();
202                                    vm.find('.settings').show();
203                                  vm.find('.actionstop').hide();                                  vm.find('.actionstop').hide();
204                                  vm.find('.actionstart').show();                                  vm.find('.actionstart').show();
205                                  vm.find('.cpu_graph').hide();                                  vm.find('.cpu_graph').hide();
# Line 176  function doAction(action, uuid, vm) { Line 224  function doAction(action, uuid, vm) {
224          if (action == "setMemory") {          if (action == "setMemory") {
225                  val = prompt("Set memory target");                  val = prompt("Set memory target");
226                  if (val == "" || val == null) {                  if (val == "" || val == null) {
227                          alert("" + val);                          return;
228                    }
229            }
230            if (action == "setCPU") {
231                    val = prompt("Set CPU count");
232                    if (val == "" || val == null) {
233                          return;                          return;
234                  }                  }
235          }          }
# Line 192  function doAction(action, uuid, vm) { Line 245  function doAction(action, uuid, vm) {
245          });          });
246  }  }
247    
248  function console(url, session, name) {  function openConsole(url, session, name) {
249          if (url == '')          if (url == '')
250                  return;                  return;
251    
# Line 311  foreach($vms_array as $vm) { Line 364  foreach($vms_array as $vm) {
364                                  <a href='#' style='display:none;' class='console'>                                  <a href='#' style='display:none;' class='console'>
365                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>
366                                  </a>                                  </a>
367                                    <a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'>
368                                            <img src='gfx/icon-settings16.png' style='vertical-align: middle;'>
369                                    </a>
370                          </td>                          </td>
371                  </tr>                  </tr>
372    
# Line 321  foreach($vms_array as $vm) { Line 377  foreach($vms_array as $vm) {
377                          <span class="actionstop" style='display:none'>                          <span class="actionstop" style='display:none'>
378                                  start |                                  start |
379                                  <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> |
380                                  <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  
381                          </span>                          </span>
382                                                    
383                          <span class="actionstart">                                                <span class="actionstart">                      
384                                  <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> |
385                                  stop |                                  stop |
386                                  force shutdown |                                  force shutdown
   
                                 <a href='#' onclick="doAction('setMemory','<?php echo $uuid;?>','<?php echo $clean_name;?>')" >set memory</a>  
387                          </span>                          </span>
388    
389                  </td>                  </td>
# Line 338  foreach($vms_array as $vm) { Line 391  foreach($vms_array as $vm) {
391                  <td width='100' align='right' class='small' valign='top'>                  <td width='100' align='right' class='small' valign='top'>
392                          <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>
393                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>                          <img src='gfx/icon-cpu.png' style='vertical-align: middle;'>
394                          <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>
395                  </td>                  </td>
396                  <td width='100' align='right' class='small'>                  <td width='100' align='right' class='small'>
397                          <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 363  foreach($vms_array as $vm) { Line 416  foreach($vms_array as $vm) {
416    
417  <?PHP } ?>  <?PHP } ?>
418  </td></tr></table>  </td></tr></table>
419    
420    <br>
421    
422    <ul id="menu">
423            <li action="memory"><a href="#">Set Memory Size</a></li>
424            <li action="cpu"><a href="#">Set CPU Count</a></li>
425    
426    
427    <!--    <li><a href="#">Item 3</a>
428                    <ul>
429                            <li><a href="#">Item 3-1</a></li>
430                            <li><a href="#">Item 3-2</a></li>
431                            <li><a href="#">Item 3-3</a></li>
432                            <li><a href="#">Item 3-4</a></li>
433                            <li><a href="#">Item 3-5</a></li>
434                    </ul>
435            </li>
436            <li><a href="#">Item 4</a></li>
437            <li><a href="#">Item 5</a></li>-->
438    </ul>
439    
440  </body></html>  </body></html>
441    

Legend:
Removed from v.1955  
changed lines
  Added in v.1958

  ViewVC Help
Powered by ViewVC 1.1.20