Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

wizardNewVMAdvanced.html 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!--
  2. Advanced panes for new virtual machine wizard. Logic in vboxWizard()
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: wizardNewVMAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <!-- Step 1 -->
  7. <div id='wizardNewVMStep1' style='display: none'>
  8. <span class='vboxTableLabel translate'>Name and operating system</span>
  9. <div class='vboxOptions'>
  10. <table class='vboxOptions vboxOSTypeOptions' style='width:100%'>
  11. <tr>
  12. <th style='width: 1%'><span class='translate'>Name:</span></th>
  13. <td colspan='2'><input type='text' class='vboxText' name='newVMName' style='width: 95%' /></td>
  14. </tr>
  15. <tr>
  16. <th><span class='translate'>Type:</span></th>
  17. <td style='width: 100%'><select name='newVMOSFamily' id='newVMOSFamily' style='width: 100%'>
  18. <option value='Linux'>Linux</option>
  19. </select></td>
  20. <td rowspan='2'><img name='vboxOSTypeImg' height='32' width='32' /></td>
  21. </tr>
  22. <tr>
  23. <th><span class='translate'>Version:</span></th>
  24. <td><select id='newVMOSType' name='newVMOSType' style='width: 100%'>
  25. <option value='Debian'>Debian</option>
  26. </select></td>
  27. </tr>
  28. </table>
  29. </div>
  30. <span class='vboxTableLabel translate'>Memory size</span>
  31. <div class='vboxOptions'>
  32. <table style='width: 100%'>
  33. <tr>
  34. <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  35. <div style='margin-top: 4px' id='wizardNewVMSize' class='slider translateglob'><div class='sliderScale'></div></div>
  36. </td>
  37. <td style='white-space: nowrap'><input type='text' class='vboxText' name='wizardNewVMSizeValue' size='5' class='sliderValue' /> <span class='translate'>MB</span></td>
  38. </tr>
  39. <tr style='vertical-align: top;'>
  40. <td style='border: 0px; margin: 0px; padding: 0px;'>
  41. <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  42. <tr style='vertical-align: top'>
  43. <td style='text-align: left;'><span id='wizardNewVMMin'>1</span> <span class='translate'>MB</span></td>
  44. <td style='text-align: right;'><span id='wizardNewVMMax'>128</span> <span class='translate'>MB</span></td>
  45. </tr>
  46. </table>
  47. </td>
  48. <td></td>
  49. </tr>
  50. </table>
  51. </div>
  52. <span class='vboxTableLabel translate'>Hard disk</span>
  53. <div class='vboxOptions'>
  54. <table class='vboxOptions' id='newVMBootDiskTable' style='width:100%;'>
  55. <tr>
  56. <td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="none" onClick="newVMToggleNewDisk(true)" /> <span class='translate vboxEnablerListen'>Do not add a virtual hard disk</span></label></td>
  57. </tr>
  58. <tr id='newVMHDTriggerBind' class='vboxEnablerTrigger'>
  59. <td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="create" onClick="newVMToggleNewDisk(true)" checked='checked' /> <span class='translate vboxEnablerListen'>Create a virtual hard disk now</span></label></td>
  60. </tr>
  61. <tr>
  62. <td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="existing" onClick="newVMToggleNewDisk(false)" /> <span class='translate vboxEnablerListen'>Use an existing virtual hard disk file</span></label></td>
  63. </tr>
  64. <tr>
  65. <td style='padding-left: 24px; white-space: nowrap'>
  66. <table class='vboxInvisible' style='width: 99%;'>
  67. <tr>
  68. <td><select id="newVMDiskSelectId" name="newVMDiskSelect" disabled='disabled'></select></td>
  69. <td style='width:1%' id='newVMDiskVMM'></td>
  70. </tr>
  71. </table>
  72. </td>
  73. </tr>
  74. </table>
  75. </div>
  76. </div>
  77. <script type='text/javascript'>
  78. /* Translations */
  79. $('#wizardNewVMStep1').find('table.vboxOSTypeOptions').find('span.translate').html(function(i,h) {
  80. return trans(h,'UINameAndSystemEditor');
  81. }).removeClass('translate');
  82. var wizardNewVMToolbar = new vboxToolbarSingle({button: {
  83. /* Add Attachment Button */
  84. 'name' : 'mselecthdbtn',
  85. 'label' : 'Choose a virtual hard disk file...',
  86. 'language_context': 'UIMachineSettingsStorage',
  87. 'icon' : 'select_file',
  88. 'click' : function () {
  89. vboxMedia.actions.choose(null,'HardDisk',function(med){
  90. if(med) vmNewFillExistingDisks(med.base);
  91. });
  92. }
  93. }});
  94. wizardNewVMToolbar.renderTo('newVMDiskVMM');
  95. /* Toggle new / existing */
  96. function newVMToggleNewDisk(dis) {
  97. if(dis) {
  98. wizardNewVMToolbar.disable();
  99. document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = true;
  100. $('#wizardNewVMStep1').find('.vboxMediumSelect').trigger('disable');
  101. } else {
  102. wizardNewVMToolbar.enable();
  103. document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = (document.forms['frmwizardNewVM'].newVMDiskSelect.options.length > 0 ? false : true);
  104. $('#wizardNewVMStep1').find('.vboxMediumSelect').trigger('enable');
  105. }
  106. }
  107. /* Mem size slider */
  108. var min = 4;
  109. var max = parseInt($('#vboxPane').data('vboxHostDetails').memorySize);
  110. $('#wizardNewVMSize').data('form','frmwizardNewVM');
  111. $('#wizardNewVMSize').slider({'min':min,'max':max,'step':1});
  112. $('#wizardNewVMSize').slider('value',4);
  113. $('#wizardNewVMMin').html(min);
  114. $('#wizardNewVMMax').html(max);
  115. /* Fill existing attachments */
  116. function vmNewFillExistingDisks(sel) {
  117. document.forms['frmwizardNewVM'].newVMDiskSelect.options.length = 0;
  118. $(document.forms['frmwizardNewVM'].newVMDiskSelect).children().remove();
  119. var s = vboxMedia.mediaForAttachmentType('HardDisk');
  120. // Sort media
  121. s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
  122. var mediumSelects = [];
  123. var selectedIndex = -1;
  124. for(var i = 0; i < s.length; i++) {
  125. document.forms['frmwizardNewVM'].newVMDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id, (sel && sel == s[i].id));
  126. if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardNewVM'].newVMDiskSelect.options[i]).addClass('vboxMediumReadOnly');
  127. mediumSelects[i] = {'attachedId':s[i].id,'id':s[i].id,'base':s[i].base,'label':vboxMedia.mediumPrint(s[i])};
  128. if(sel == s[i].id) {
  129. selectedIndex = i;
  130. }
  131. }
  132. if(selectedIndex > -1) {
  133. document.forms['frmwizardNewVM'].newVMDiskSelect.selectedIndex = selectedIndex;
  134. }
  135. $(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
  136. if(sel) {
  137. $(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'selectMedium':sel});
  138. $(document.forms['frmwizardNewVM'].newVMDiskSelect).val(sel);
  139. }
  140. }
  141. vmNewFillExistingDisks();
  142. /*
  143. *
  144. * Called when OS family type changes
  145. *
  146. */
  147. function newVMUpdateOSList(osfam) {
  148. document.forms['frmwizardNewVM'].newVMOSType.options.length = 0;
  149. $(document.forms['frmwizardNewVM'].newVMOSType).children().remove();
  150. for(var i = 0; i < newVMOSTypes[osfam].osTypes.length; i++) {
  151. document.forms['frmwizardNewVM'].newVMOSType.options[i] = new Option(newVMOSTypes[osfam].osTypes[i].description, newVMOSTypes[osfam].osTypes[i].id);
  152. }
  153. // Trigger change
  154. newVMUpdateOS(newVMOSTypes[osfam].osTypes[0].id);
  155. }
  156. function newVMUpdateOS(ostype) {
  157. document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(ostype);
  158. ostype = newVMOSTypesObj[ostype];
  159. $('#wizardNewVMSize').slider('value',ostype.recommendedRAM);
  160. $('#newVMSizeLabel').html(trans('The recommended memory size is <b>%1</b> MB.','UIWizardNewVMPage3').replace('%1',ostype.recommendedRAM));
  161. $('#newVMHDSizeLabel').html(trans('<p>If you wish you can add a virtual hard disk to the new machine. You can either create a new hard disk file or select one from the list or from another location using the folder icon.</p><p>If you need a more complex storage set-up you can skip this step and make the changes to the machine settings once the machine is created.</p><p>The recommended size of the hard disk is <b>%1</b>.</p>','UIWizardNewVMPage4').replace('%1',vboxMbytesConvert(ostype.recommendedHDD)));
  162. }
  163. var newVMOSTypes = new Array();
  164. var newVMOSTypesObj = {};
  165. // shorthand
  166. var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
  167. // Default OS Type set to my fav :) Eventually will move to config.php
  168. var vboxDefaultOSTypeId = 'Debian';
  169. var dosfam = null; // holds defaultostype family id
  170. for(var i in vboxOSTypes) {
  171. // Skip unsupported OS types
  172. if(!vboxOSTypes[i].supported) continue;
  173. // create array of os family types
  174. if(!newVMOSTypes[vboxOSTypes[i].familyId]) {
  175. newVMOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
  176. }
  177. // We're on the default os type, record family id and index number
  178. // so that we can set it later on
  179. if(vboxOSTypes[i].id == vboxDefaultOSTypeId) {
  180. dosfam = vboxOSTypes[i].familyId;
  181. vboxDefaultOSTypeId = newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length;
  182. }
  183. newVMOSTypes[vboxOSTypes[i].familyId].osTypes[newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
  184. newVMOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
  185. // Preload icons
  186. vboxOSTypes[i].icon = new Image();
  187. vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
  188. }
  189. // clear all options
  190. document.forms['frmwizardNewVM'].newVMOSFamily.options.length = 0;
  191. $(document.forms['frmwizardNewVM'].newVMOSFamily).children().remove();
  192. for(var i in newVMOSTypes) {
  193. // default os type family? record in dosfam
  194. if(i == dosfam) dosfam = document.forms['frmwizardNewVM'].newVMOSFamily.options.length;
  195. document.forms['frmwizardNewVM'].newVMOSFamily.options[document.forms['frmwizardNewVM'].newVMOSFamily.options.length] = new Option(newVMOSTypes[i].description, newVMOSTypes[i].id);
  196. }
  197. // OnChange, update os type list and icon
  198. document.getElementById('newVMOSFamily').setAttribute('onChange','newVMUpdateOSList(this.value)');
  199. document.getElementById('newVMOSType').setAttribute('onChange','newVMUpdateOS(this.value)');
  200. document.forms['frmwizardNewVM'].newVMOSFamily.selectedIndex = dosfam;
  201. newVMUpdateOSList(document.forms['frmwizardNewVM'].newVMOSFamily.value);
  202. document.forms['frmwizardNewVM'].newVMOSType.selectedIndex = vboxDefaultOSTypeId;
  203. newVMUpdateOS(document.forms['frmwizardNewVM'].newVMOSType.options[document.forms['frmwizardNewVM'].newVMOSType.selectedIndex].value);
  204. /*
  205. * END OS TYPES
  206. */
  207. /* When hard disk is enabled / disabled */
  208. $('#newVMHDTriggerBind').on('enable',function(){
  209. // Update disabled / enabled items
  210. if(document.forms['frmwizardNewVM'].newVMDisk[0].checked) {
  211. $(document.forms['frmwizardNewVM'].newVMDisk[0]).trigger('click');
  212. } else {
  213. $(document.forms['frmwizardNewVM'].newVMDisk[1]).trigger('click');
  214. }
  215. }).on('disable',function(){
  216. newVMToggleNewDisk(true);
  217. }).trigger('disable');
  218. $('#wizardNewVMStep1').on('show',function() {
  219. $(document.forms['frmwizardNewVM'].newVMName).focus();
  220. });
  221. </script>