You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vmlogs.html 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!--
  2. VM Log dialog
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: vmlogs.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <table id='vboxVMLogContainer' class='vboxInvisible' style='width:100%;height:100%'>
  7. <tr style='vertical-align:bottom'>
  8. <td style='height: 1%;' id='vboxVMLogsTabsList'></td>
  9. </tr>
  10. <tr id='vboxVMLogsTabsRow' style='vertical-align:top'>
  11. <td id='vboxVMLogTabsContainer'></td>
  12. </tr>
  13. </table>
  14. <script type='text/javascript'>
  15. function vboxShowLogsInit(vm) {
  16. $('#vboxVMLogsTabsList').empty();
  17. $('#vboxVMLogTabsContainer').empty();
  18. $('<div />').attr({'id':'vboxVMLogTabs','style':'margin: 0px; padding: 0px;'}).appendTo($('#vboxVMLogTabsContainer'));
  19. var logs = $('#vboxVMLogsDialog').data('logs');
  20. if(!logs || !logs.length) {
  21. $('#vboxVMLogTabs').html(trans('<p>No log files found. Press the <b>Refresh</b> button to rescan the log folder <nobr><b>%1</b></nobr>.</p>','UIVMLogViewer').replace('%1',$('#vboxVMLogsDialog').data('logpath')));
  22. return;
  23. }
  24. // Pattern for regexp replacement
  25. var preg = new RegExp('.*'+$('#vboxPane').data('vboxConfig').DSEP.replace('\\','\\\\'));
  26. var ul = $('<ul />').attr({'id':'vboxVMLogsUL'});
  27. for(var i = 0; i < logs.length; i++) {
  28. // Replace path with just file name
  29. logs[i] = logs[i].replace(preg,'');
  30. // Tab link
  31. $('<li />').html('<a href="#vboxVMLog'+i+'"><span>'+logs[i]+'</span></a>').appendTo(ul);
  32. // Tab content
  33. $('<div />').css({'padding':'4px','margin':'0px'}).attr({'id':'vboxVMLog'+i,'class':'vboxVMLog vboxDialogContent'}).data('logIndex',i).one('show',function(){
  34. $(this).html('<img src="images/spinner.gif" />');
  35. $.when({'logIndex':$(this).data('logIndex')}, vboxAjaxRequest('machineGetLogFile',{'vm':vm.id,'log':$(this).data('logIndex')})).done(function(x,d){
  36. // -8 for padding set above + parent's padding
  37. var pHeight = $('#vboxVMLogTabs').innerHeight() - 10;
  38. var frm = $('<form />');
  39. $(frm).height(pHeight);
  40. $('<textarea />').attr({'id':'vboxLogText'+x.logIndex,'spellcheck':'false','wrap':'off','readonly':'true'}).height(pHeight).val(d.responseData).appendTo(frm);
  41. $('#vboxVMLog'+x.logIndex).html('').append(frm);
  42. $('#vboxLogText'+x.logIndex).attr('scrollTop',$('#vboxLogText'+x.logIndex).attr('scrollHeight'));
  43. });
  44. }).appendTo($('#vboxVMLogTabs'));
  45. }
  46. $('#vboxVMLogTabs').prepend(ul);
  47. $('#vboxVMLogTabs').tabs({'activate':function(e,i){
  48. $('#vboxVMLogTabs').children('div:eq('+$('#vboxVMLogTabs').tabs('option','active')+')').trigger('show');
  49. }});
  50. // Move tabs to table
  51. $('#vboxVMLogsUL').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMLogsTabsList').addClass($('#vboxVMLogTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')));
  52. // Set height
  53. $('#vboxVMLogTabs').css({'display':'none'});
  54. // -6 to account for padding and leave a small buffer
  55. $('#vboxVMLogTabs').css({'padding':'0px 2px 2px 2px','margin':'0px','display':''}).height($('#vboxVMLogTabsContainer').css({'padding':'0px','margin':'0px'}).innerHeight()-6);
  56. // Resize dialog resizes these elemtns
  57. $('#vboxVMLogContainer').parent().on("dialogresizestop",function(e){
  58. // Set height
  59. $('#vboxVMLogTabs').css({'display':'none'});
  60. var pHeight = $('#vboxVMLogTabsContainer').innerHeight();
  61. // -4 to account for padding
  62. // -12 to account for vboxVMLogTabs 2px padding and pane's 4px padding (8 + 4)
  63. $('#vboxVMLogTabs').css({'display':''}).height(pHeight-4).find('form').height(pHeight-12).find('textarea').height(pHeight-12);
  64. });
  65. $('#vboxVMLogTabs').children('div:eq(0)').trigger('show');
  66. }
  67. </script>