/[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 2018 by torben, Thu Jul 18 13:00:14 2013 UTC revision 2026 by torben, Fri Jul 19 13:20:33 2013 UTC
# Line 60  $namelabel = $host["name_label"]; Line 60  $namelabel = $host["name_label"];
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);        
# Line 103  $(document).ready( function() { Line 115  $(document).ready( function() {
115                  var uuid = $(this).attr('uuid');                  var uuid = $(this).attr('uuid');
116                  cdSelectorDialog(uuid);                  cdSelectorDialog(uuid);
117          });          });
118            $('#loginlink').click( function(event) {
119                    loginDialog();
120            });
121    
122          $(document).click( function(event) {          $(document).click( function(event) {
123                  closeMenu();                  closeMenu();
124          });          });
125            $('#dialog-login').keypress(function(e) {
126            if (e.keyCode == $.ui.keyCode.ENTER) {
127                            loginDialogSubmit();
128            }
129            });
130  });  });
131    
132    function loginDialog() {
133            $('#dialog-login').dialog({
134                    modal: true,
135                    height: 210,
136                    width: 325,
137                    buttons: {
138                            Login: loginDialogSubmit
139                    }
140            });
141    }
142    function loginDialogSubmit() {
143            var params = $('#loginform').serialize();
144    
145            $.get('login.php?' + params, function(data) {
146                    if (data == "OK") {
147                            loggedin = true;
148                            username = $('#username').val();
149                            password = $('#password').val();
150    
151                            $('#login').html("Logged in as <i>" + username + "</i>");
152                    } else {
153                            alert(data);
154                    }
155                    $("#dialog-login").dialog( "close" );
156            });
157    }
158    
159  function cdSelectorDialog(uuid) {  function cdSelectorDialog(uuid) {
160            if (isLoggedIn() == false)
161                    return;
162    
163          $('#cdselector').html('');          $('#cdselector').html('');
164          $('#cdselector').load( 'getisolist.php' );          $('#cdselector').load( 'getisolist.php' );
165          var cddata;          var cddata;
# Line 118  function cdSelectorDialog(uuid) { Line 168  function cdSelectorDialog(uuid) {
168                  cddata = data;                  cddata = data;
169                  if (data.ISO != '') {                  if (data.ISO != '') {
170                          $('#cdcurrent').html(  data.ISO );                          $('#cdcurrent').html(  data.ISO );
171                            $(":button:contains('Mount')").prop("disabled", true).addClass("ui-state-disabled");
172                  } else {                  } else {
173                          $('#cdcurrent').html('<i>No ISO currently mounted</i>');                          $('#cdcurrent').html('<i>No ISO currently mounted</i>');
174                            $(":button:contains('Eject')").prop("disabled", true).addClass("ui-state-disabled");
175                  }                  }
176          });          });
177                    
# Line 256  function refreshData() { Line 308  function refreshData() {
308  function doAction(action, uuid, vm) {  function doAction(action, uuid, vm) {
309          var val="";          var val="";
310    
311          var key = prompt("Key");          if (isLoggedIn() == false)
         if (key == "" || key == null) {  
312                  return;                  return;
313          }  
314          document.body.style.cursor = 'wait';          document.body.style.cursor = 'wait';
315          $('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')");          $('#vm_' + vm).find('.state').css("background-image", "url('gfx/vps_topyellow.png')");
316    
# Line 277  function doAction(action, uuid, vm) { Line 328  function doAction(action, uuid, vm) {
328                  }                  }
329          }          }
330    
331          var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + key + "&val=" + val;;          var url = "action.php?action=" + action + "&uuid=" + uuid + "&key=" + password + "&val=" + val;;
332          var response = $.get(url, function(data) {          var response = $.get(url, function(data) {
333                  if (data != 'OK') {                  if (data != 'OK') {
334                          alert(data);                          alert(data);
# Line 289  function doAction(action, uuid, vm) { Line 340  function doAction(action, uuid, vm) {
340  }  }
341    
342  function cdAction(action, vbd,vdi) {  function cdAction(action, vbd,vdi) {
343          var key = prompt("Key");          if (isLoggedIn() == false)
         if (key == "" || key == null) {  
344                  return;                  return;
345          }  
346          document.body.style.cursor = 'wait';          document.body.style.cursor = 'wait';
347          var url = "cdaction.php?action=" + action + "&VBD=" + vbd + "&key=" + key + "&VDI=" + vdi;          var url = "cdaction.php?action=" + action + "&VBD=" + vbd + "&key=" + password + "&VDI=" + vdi;
348          var response = $.get(url, function(data) {          var response = $.get(url, function(data) {
349                  if (data != 'OK') {                  if (data != 'OK') {
350                          alert(data);                          alert(data);
# Line 308  function openConsole(url, session, name) Line 358  function openConsole(url, session, name)
358          if (url == '')          if (url == '')
359                  return;                  return;
360    
361          var key = prompt("Key");          if (isLoggedIn() == false)
         if (key == "" || key == null) {  
362                  return;                  return;
363          }  
364          var url = "console.php?url=" + url + "&session=" + session + "&key=" + key + "&name=" + name;          var url = "console.php?url=" + url + "&session=" + session + "&key=" + password + "&name=" + name;
365    
366          //window.location = url;          //window.location = url;
367          //$('#mainwindow').load(url);          //$('#mainwindow').load(url);
# Line 365  body { Line 414  body {
414          <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>
415  </tr>  </tr>
416  <tr>  <tr>
417  <td width='150'></td>  <td width='150'>
418            <span id="login" class='small'><i>Not <a href="#" id="loginlink">logged in</a></i>
419            </span>
420    </td>
421  <td width='150'></td>  <td width='150'></td>
422          <td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'>          <td width='150' align='right' class='small'><img src='gfx/icon-cpu.png'>
423                  <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 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>
# Line 423  foreach($vms_array as $vm) { Line 475  foreach($vms_array as $vm) {
475                          <td colspan='2' class='small' align='right'>                          <td colspan='2' class='small' align='right'>
476                                  <span class='network'></span>                                  <span class='network'></span>
477                                  <a href='#' class='cd' uuid='<?php echo $uuid;?>' >                                  <a href='#' class='cd' uuid='<?php echo $uuid;?>' >
478                                          <img src='gfx/icon-cd.png' style='vertical-align: middle;'>                                          <img src='gfx/icon-cd.gif' style='vertical-align: middle;'></a>
                                 </a>  
479                                  <a href='#' style='display:none;' class='console'>                                  <a href='#' style='display:none;' class='console'>
480                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>                                          <img src='gfx/icon-terminal.png' style='vertical-align: middle;'>
481                                  </a>                                  </a>
482    
483                                  <a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'>                                  <a href='#' style='display:none;' class='settings' uuid='<?php echo $uuid;?>'>
484                                          <img src='gfx/icon-settings16.png' style='vertical-align: middle;'>                                          <img src='gfx/icon-settings16.png' style='vertical-align: middle;'>
485                                  </a>                                  </a>
# Line 485  foreach($vms_array as $vm) { Line 537  foreach($vms_array as $vm) {
537    
538  <div style="display: none;">  <div style="display: none;">
539    
540    <div id="dialog-login" title="Login">
541            <form id="loginform">
542            <table border="0">
543                    <tr>
544                            <td>Username: </td>
545                            <td><input type="text" id="username" name="username"></td>
546                    <tr>
547                    <tr>
548                            <td>Password: </td>
549                            <td><input type="password" id="password" name="password"></td>
550                    </tr>
551            </table>
552            </form>
553    </div>
554    
555  <div id="dialog-cd" title="Select CD">  <div id="dialog-cd" title="Select CD">
556    
557          <table border=0>          <table border=0>

Legend:
Removed from v.2018  
changed lines
  Added in v.2026

  ViewVC Help
Powered by ViewVC 1.1.20