Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. <!--
  2. Virtual Media Manager
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: vmm.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <table id='vboxVirtualMediaManager' style='height: 100%; border:0px;margin:0px;padding:0px;width:100%;border-spacing:0px;border-width:0px;'>
  7. <!-- Top menu -->
  8. <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMMenu' style='margin:0px;'></div></td></tr>
  9. <!-- Toolbar Created by JavaScript below -->
  10. <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMToolbar' style='padding:0px; margin:0px;' class='vboxToolbarGrad'></div></td></tr>
  11. <!-- Tab Placeholder -->
  12. <tr style='vertical-align: top;'><td id='vboxVMMContainerTopCell' style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxVMMContainerTop' style='border:0px;margin-bottom:0px;padding-bottom:0px;'></div></td></tr>
  13. <!-- Tabs for Media -->
  14. <tr style='vertical-align: top;'>
  15. <td style='padding:0px;margin:0px;border:0px;' id='vboxVMMContainer'>
  16. <div id='vboxVMMTabs'>
  17. <ul id='vboxVMMTabList'>
  18. <li><a href="#vmmDisks"><span><img id='vmmDisksIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/hd_16px.png" border="0" /> <span class='translate'>Hard disks</span></span></a></li>
  19. <li><a href="#vmmCDs"><span><img id='vmmCDsIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/cd_16px.png" border="0" /> <span class='translate'>Optical disks</span></span></a></li>
  20. <li><a href="#vmmFloppys"><span><img id='vmmFloppysIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/fd_16px.png" border="0" /> <span class='translate'>Floppy disks</span></span></a></li>
  21. </ul>
  22. <!--
  23. HARD DISKS
  24. -->
  25. <div id='vmmDisks'>
  26. <div class='vboxBordered vboxVMMList'>
  27. <div class='vmmTableHead'>
  28. <table style='border-spacing: 0px; border: 0px; width:100%;' class='vboxHorizontal vboxListTable vboxVMMList'>
  29. <thead>
  30. <tr>
  31. <th style='width: 100%;'><span class='translate'>Name</span></th>
  32. <th style='width: auto'><span class='translate'>Virtual Size</span></th>
  33. <th style='width: auto'><span class='translate'>Actual Size</span></th>
  34. <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
  35. </tr>
  36. </thead>
  37. </table>
  38. </div>
  39. <div class='vmmTableBody'>
  40. <table class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
  41. <tbody id='vboxVMMHDList' class='vboxHover'>
  42. <tr>
  43. <td>Item 1</td>
  44. <td>Item 2</td>
  45. <td>Item 3</td>
  46. </tr>
  47. <tr>
  48. <td>Item 1</td>
  49. <td>Item 2</td>
  50. <td>Item 3</td>
  51. </tr>
  52. </tbody>
  53. </table>
  54. </div>
  55. </div>
  56. <div class='vboxVMMMediumInfo'>
  57. <table>
  58. <tr>
  59. <th><span class='translate'>Type:</span></th>
  60. <td><input id='vmmMediumType' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
  61. </tr>
  62. <tr>
  63. <th><span class='translate'>Location:</span></th>
  64. <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
  65. </tr>
  66. <tr>
  67. <th><span class='translate'>Format:</span></th>
  68. <td><input class='vmmMediumFormat' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  69. </tr>
  70. <tr>
  71. <th><span class='translate'>Storage details:</span></th>
  72. <td><input class='vmmMediumHDDetails' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  73. </tr>
  74. <tr>
  75. <th><span class='translate'>Attached to:</span></th>
  76. <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  77. </tr>
  78. <tr>
  79. <th><span class='translate'>UUID:</span></th>
  80. <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  81. </tr>
  82. <tr class='vmmAccessErr'>
  83. <td colspan='2'></td>
  84. </tr>
  85. </table>
  86. </div>
  87. </div>
  88. <!--
  89. CD / DVD IMAGES
  90. -->
  91. <div id='vmmCDs'>
  92. <div class='vboxVMMList vboxBordered'>
  93. <div class='vmmTableHead'>
  94. <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
  95. <thead>
  96. <tr>
  97. <th style='width: 100%'><span class='translate'>Name</span></th>
  98. <th style='width: auto'><span class='translate'>Size</span></th>
  99. <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
  100. </tr>
  101. </thead>
  102. </table>
  103. </div>
  104. <div class='vmmTableBody'>
  105. <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
  106. <tbody id='vboxVMMCDList' class='vboxHover'>
  107. <tr>
  108. <td>Item 1</td>
  109. <td>Item 3</td>
  110. </tr>
  111. <tr>
  112. <td>Item 1</td>
  113. <td>Item 3</td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. </div>
  118. </div>
  119. <div class='vboxVMMMediumInfo'>
  120. <table>
  121. <tr>
  122. <th><span class='translate'>Location:</span></th>
  123. <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
  124. </tr>
  125. <tr>
  126. <th><span class='translate'>Attached to:</span></th>
  127. <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  128. </tr>
  129. <tr>
  130. <th><span class='translate'>UUID:</span></th>
  131. <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  132. </tr>
  133. <tr class='vmmAccessErr'>
  134. <td colspan='2'></td>
  135. </tr>
  136. </table>
  137. </div>
  138. </div>
  139. <!--
  140. FLOPPY IMAGES
  141. -->
  142. <div id='vmmFloppys'>
  143. <div class='vboxVMMList vboxBordered'>
  144. <div class='vmmTableHead'>
  145. <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
  146. <thead>
  147. <tr>
  148. <th style='width: 100%'><span class='translate'>Name</span></th>
  149. <th style='width: auto'><span class='translate'>Size</span></th>
  150. <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
  151. </tr>
  152. </thead>
  153. </table>
  154. </div>
  155. <div class='vmmTableBody'>
  156. <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
  157. <tbody id='vboxVMMFDList' class='vboxHover'>
  158. <tr>
  159. <td>Item 1</td>
  160. <td>Item 2</td>
  161. </tr>
  162. </tbody>
  163. </table>
  164. </div>
  165. </div>
  166. <div class='vboxVMMMediumInfo'>
  167. <table>
  168. <tr>
  169. <th><span class='translate'>Location:</span></th>
  170. <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  171. </tr>
  172. <tr>
  173. <th><span class='translate'>Attached to:</span></th>
  174. <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  175. </tr>
  176. <tr>
  177. <th><span class='translate'>UUID:</span></th>
  178. <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
  179. </tr>
  180. <tr class='vmmAccessErr'>
  181. <td colspan='2'></td>
  182. </tr>
  183. </table>
  184. </div>
  185. </div>
  186. </div></td>
  187. </tr>
  188. </table>
  189. <script type='text/javascript'>
  190. /*
  191. * Translate
  192. */
  193. // These are translated under a different context for some reason
  194. $('#vboxVMMTabList').find(".translate").html(function(i,h){return trans(h,'UIMediumManager');}).removeClass('translate');
  195. $("#vboxVMMTabs").find(".translate").html(function(i,h){return trans(h,'VBoxMediaManagerDlg');}).removeClass('translate');
  196. /*
  197. * Keypress events
  198. */
  199. $('div.vmmTableBody table').click(function(){$(this).focus();}).keydown(function(e){
  200. var keynum = 0;
  201. if(e.keyCode)
  202. keynum = e.keyCode;
  203. else if(e.which)
  204. keynum = e.which;
  205. switch(keynum) {
  206. // up
  207. case 38:
  208. $(this).find('tr.vboxListItemSelected').prevAll('tr:not([class~="vboxHidden"]):first').children().first().click();
  209. break;
  210. // right / expand
  211. case 39:
  212. $(this).find('tr.vboxListItemSelected.collapsed').find('input').click();
  213. break;
  214. // left / contract
  215. case 37:
  216. $(this).find('tr.vboxListItemSelected:not(.collapsed)').find('input').click();
  217. break;
  218. // down
  219. case 40:
  220. $(this).find('tr.vboxListItemSelected').nextAll('tr:not([class~="vboxHidden"]):first').children().first().click();
  221. break;
  222. }
  223. return false;
  224. }).css('outline','none');
  225. /*
  226. * Setup Tabs
  227. */
  228. $("#vboxVMMTabs").tabs().on("tabsactivate",function(ev,ui){
  229. // Resize table
  230. vboxVMMSizeTable(ui.newPanel);
  231. // Medium selection
  232. if(!$(ui.newPanel).find('tbody').children('tr.vboxListItemSelected').first().children().first().click().length) {
  233. $('#vboxVirtualMediaManager').trigger('mediumselect',[null]);
  234. }
  235. });
  236. /*
  237. * Toolbar Buttons
  238. */
  239. var vmmButtons = new Array(
  240. {
  241. /*
  242. * Create new HardDisk
  243. */
  244. 'name' : 'vmmnew',
  245. 'label' : 'New',
  246. 'icon' : 'hd_new',
  247. 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
  248. 'click' : function () {
  249. $.when(new vboxWizardNewHDDialog({'path':$('#vboxVirtualMediaManager').data('vmPath')}).run()).done(function(id){
  250. vboxVMMFillMedia(id);
  251. });
  252. }
  253. },
  254. {
  255. /*
  256. * Add existing medium to virtualbox
  257. */
  258. 'name' : 'vmmadd',
  259. 'label' : 'Add',
  260. 'icon' : 'hd_add',
  261. 'click' : function () {
  262. var type = '';
  263. switch($("#vboxVMMTabs").tabs('option','active')) {
  264. case 1: type = 'DVD'; break;
  265. case 2: type = 'Floppy'; break;
  266. default: type = 'HardDisk'; break;
  267. }
  268. vboxMedia.actions.choose(null,type,function(ret){
  269. vboxVMMFillMedia((ret && ret.id ? ret.id : null));
  270. });
  271. }
  272. },
  273. {
  274. /*
  275. * Add iSCSI medium to virtualbox
  276. */
  277. 'name' : 'vmmaddiscsi',
  278. 'label' : 'Add iSCSI',
  279. 'icon' : 'hd_add',
  280. 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
  281. 'click' : function () {
  282. var d = $('<div />').attr({'id':'vboxVMMAddMediumImageDialog'});
  283. var buttons = {};
  284. buttons[trans('OK','QIMessageBox')] = function() {
  285. var frm = document.forms.vboxISCSIForm;
  286. var server = $(frm.vboxISCSIServer).val();
  287. var port = $(frm.vboxISCSIPort).val();
  288. var intnet = frm.vboxISCSIIntnet.checked;
  289. var target = $(frm.vboxISCSITarget).val();
  290. var lun = $(frm.vboxISCSILun).val();
  291. var enclun = frm.vboxISCSILunEnc.checked;
  292. var user = $(frm.vboxISCSIUser).val();
  293. var pass = $(frm.vboxISCSIPass).val();
  294. if(server && target) {
  295. if(!lun) lun = '0';
  296. var l = new vboxLoader('addiscsi');
  297. l.add('mediumAddISCSI',function(ret){
  298. if(ret && ret.responseData && ret.responseData.id) {
  299. var nl = new vboxLoader('getMedia');
  300. nl.add('vboxGetMedia',function(dat){$('#vboxPane').data('vboxMedia',dat.responseData);});
  301. nl.onLoad = function() {
  302. vboxVMMFillMedia(ret.responseData.id);
  303. };
  304. nl.run();
  305. }
  306. },{'server':server,'port':port,'intnet':intnet,'target':target,'lun':lun,'enclun':enclun,'targetUser':user,'targetPass':pass});
  307. l.run();
  308. }
  309. $(this).empty().remove();
  310. };
  311. buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
  312. var l = new vboxLoader();
  313. l.addFileToDOM("panes/vmmISCSI.html",$(d));
  314. l.onLoad = function() {
  315. $(d).dialog({'width':400,'height':350,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':trans('Add iSCSI')});
  316. };
  317. l.run();
  318. }
  319. },
  320. {
  321. /*
  322. * Copy Medium
  323. */
  324. 'name' : 'vmmcopy',
  325. 'label' : 'Copy...',
  326. 'icon' : 'vdm_add',
  327. 'separator' : $('#vboxPane').data('vboxConfig').enableAdvancedConfig,
  328. 'enabled' : function (item) {
  329. if(!item) return false;
  330. if($("#vboxVMMTabs").tabs('option','active')) return false;
  331. if(!$(item).data('medium')) return false;
  332. var m = vboxMedia.getMediumById($(item).data('medium'));
  333. return (!m || !m.parent);
  334. },
  335. 'click' : function () {
  336. var elm = null;
  337. switch($("#vboxVMMTabs").tabs('option','active')) {
  338. case 1:
  339. elm = $('#vboxVMMCDList');
  340. break;
  341. case 2:
  342. elm = $('#vboxVMMFDList');
  343. break;
  344. default:
  345. elm = $('#vboxVMMHDList');
  346. break;
  347. }
  348. $.when(new vboxWizardCopyHDDialog({'medium':$(elm).find('tr.vboxListItemSelected').first().data('medium')}).run()).done(function(id){
  349. vboxVMMFillMedia(id);
  350. });
  351. }
  352. },
  353. {
  354. /*
  355. * Modify Medium
  356. */
  357. 'name' : 'vmmmodify',
  358. 'label' : 'Modify...',
  359. 'icon' : 'vdm_new',
  360. 'enabled' : function (item) {
  361. if(!item) return false;
  362. if($("#vboxVMMTabs").tabs('option','active')) return false;
  363. var m = vboxMedia.getMediumById($(item).data('medium'));
  364. return (m && !m.parent);
  365. },
  366. 'click' : function () {
  367. var d = $('<div />').attr({'id':'vboxVMMModifyDialog'});
  368. var med = $('#vboxVMMHDList').find('tr.vboxListItemSelected').first();
  369. med = vboxMedia.getMediumById(med.data('medium'));
  370. var buttons = {};
  371. buttons[trans('OK','QIMessageBox')] = function() {
  372. var mtype = document.forms.vboxVMMModifyForm.vmmMType;
  373. for(var i = 0; i < mtype.length; i++) {
  374. if(mtype[i].checked) {
  375. mtype = mtype[i].value;
  376. break;
  377. }
  378. }
  379. $.when(vboxAjaxRequest('mediumSetType',{'medium':med.location,'type':mtype})).done(function(ret){
  380. if(ret && ret.success) {
  381. var l = new vboxLoader();
  382. l.add('vboxGetMedia',function(data){$('#vboxPane').data('vboxMedia',data.responseData);});
  383. l.onLoad = function() {
  384. if($('#vboxVirtualMediaManager').data('hideDiff')) {
  385. var d = vboxMedia.getMediumById(med.id);
  386. if(d.readOnly) $('#vboxVMMMediaTitle-'+d.id).addClass('vboxMediumReadOnly');
  387. else $('#vboxVMMMediaTitle-'+d.id).removeClass('vboxMediumReadOnly');
  388. }
  389. $('#vmmMediumType').val(trans(mtype,'VBoxGlobal'));
  390. };
  391. l.run();
  392. $('#vboxVMMModifyDialog').empty().remove();
  393. }
  394. });
  395. };
  396. buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
  397. var l = new vboxLoader();
  398. l.addFileToDOM("panes/vmmModify.html",$(d));
  399. l.onLoad = function() {
  400. var msg = trans('<p>You are about to change the settings of the disk image file <b>%1</b>.</p><p>Please choose one of the following modes and press <b>%2</b> to proceed or <b>%3</b> otherwise.</p>','UIMediumTypeChangeDialog');
  401. var title = trans('Modify medium attributes','UIMediumTypeChangeDialog');
  402. msg = msg.replace('%1',med.location).replace('%2',trans('OK','QIMessageBox')).replace('%3',trans('Cancel','QIMessageBox'));
  403. $(d).dialog({'width':400,'height':370,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/diskimage_16px.png" /> '+title});
  404. // Translations
  405. $('#vboxVMMModifyInstructions').html(msg);
  406. $('#vboxVMMModify').find(".translate").html(function(i,h){return trans(h,'UIMediumTypeChangeDialog');}).removeClass('translate');
  407. $('#vboxVMMModify').find('table.vboxOptions').find('span').html(function(i,h){return trans(h,'VBoxGlobal', 'MediumType');});
  408. // Set correct option
  409. $('#vboxVMMModify').find('input').prop('checked',false);
  410. $('#vboxVMMModify').find('input[value='+med.type+']').prop('checked',true);
  411. };
  412. l.run();
  413. }
  414. },
  415. {
  416. /*
  417. * Remove a medium
  418. */
  419. 'name' : 'vmmremove',
  420. 'label' : 'Remove',
  421. 'icon' : 'hd_remove',
  422. 'enabled' : function (item) {
  423. if(!item || item.target) return false;
  424. var m = vboxMedia.getMediumById($(item).data('medium'));
  425. return (m && m.attachedTo.length == 0 && m.children.length == 0);
  426. },
  427. 'click' : function () {
  428. var mtype = null;
  429. var elm = null;
  430. switch($("#vboxVMMTabs").tabs('option','active')) {
  431. case 1:
  432. elm = $('#vboxVMMCDList');
  433. mtype = 'CD/DVD image';
  434. break;
  435. case 2:
  436. elm = $('#vboxVMMFDList');
  437. mtype = 'floppy image';
  438. break;
  439. default:
  440. elm = $('#vboxVMMHDList');
  441. mtype = 'hard disk';
  442. break;
  443. }
  444. var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
  445. var buttons = {};
  446. var q = '';
  447. // If we are removing a hard disk and configured to allow deletions
  448. if(m.deviceType == 'HardDisk' && $('#vboxPane').data('vboxConfig').deleteOnRemove && m.format != 'iSCSI') {
  449. q = trans('<p>Do you want to delete the storage unit of the virtual hard disk <nobr><b>%1</b></nobr>?'+
  450. '</p><p>If you select <b>Delete</b> then the specified storage unit will be permanently deleted. '+
  451. 'This operation <b>cannot be undone</b>.</p><p>If you select <b>Keep</b> then the hard disk will '+
  452. 'be only removed from the list of known hard disks, but the storage unit will be left untouched '+
  453. 'which makes it possible to add this hard disk to the list later again.</p>','UIMessageCenter').replace('%1',m.location);
  454. buttons[trans('Delete','UIMessageCenter')] = function(){
  455. $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType,'delete':1})).done(function(ret){
  456. if(ret && ret.responseData && ret.responseData.progress) {
  457. vboxProgress(ret.responseData,function(){
  458. var l = new vboxLoader();
  459. l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
  460. l.onLoad = function() {vboxVMMFillMedia(); };
  461. l.run();
  462. },'progress_media_delete_90px.png',trans('Delete','UIMessageCenter'),
  463. vboxBasename(m.location));
  464. }
  465. });
  466. $(this).empty().remove();
  467. };
  468. buttons[trans('Keep','UIMessageCenter')] = function(){
  469. $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
  470. var l = new vboxLoader();
  471. l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
  472. l.onLoad = function() {vboxVMMFillMedia(); };
  473. l.run();
  474. });
  475. $(this).empty().remove();
  476. };
  477. } else {
  478. q = trans('<p>Are you sure you want to remove the %1 <nobr><b>%2</b></nobr> from the list of known media?</p>','UIMessageCenter').replace('%1',trans(mtype,'UIMessageCenter')).replace('%2',m.location);
  479. q+= trans('<p>Note that the storage unit of this medium will not be deleted and that it will be possible to use it later again.</p>','UIMessageCenter');
  480. buttons[trans('Remove','UIMessageCenter')] = function(){
  481. var b = this;
  482. $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
  483. var l = new vboxLoader();
  484. l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
  485. l.onLoad = function() {vboxVMMFillMedia(); };
  486. $(b).empty().remove();
  487. l.run();
  488. });
  489. };
  490. }
  491. vboxConfirm(q,buttons);
  492. }
  493. },
  494. {
  495. /*
  496. * Release a medium from all attachments
  497. */
  498. 'name' : 'vmmrelease',
  499. 'label' : 'Release',
  500. 'icon' : 'hd_release',
  501. 'enabled' : function (item) {
  502. if(!item || item.target) return false;
  503. var m = vboxMedia.getMediumById($(item).data('medium'));
  504. return (m && m.attachedTo.length > 0 && m.children.length == 0 && m.hasSnapshots == 0);
  505. },
  506. 'click' : function () {
  507. var elm = null;
  508. var mtype = null;
  509. switch($("#vboxVMMTabs").tabs('option','active')) {
  510. case 1:
  511. elm = $('#vboxVMMCDList');
  512. mtype = 'CD/DVD image';
  513. break;
  514. case 2:
  515. elm = $('#vboxVMMFDList');
  516. mtype = 'floppy image';
  517. break;
  518. default:
  519. elm = $('#vboxVMMHDList');
  520. mtype = 'hard disk';
  521. break;
  522. }
  523. var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
  524. var q = trans('<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p><p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>','UIMessageCenter');
  525. q = q.replace('%1',m.location);
  526. var buttons = {};
  527. buttons[trans('Release','UIMessageCenter')] = function(){
  528. var b = this;
  529. $.when(vboxAjaxRequest('mediumRelease',{'medium':m.location,'type':m.deviceType})).done(function(ret){
  530. var l = new vboxLoader();
  531. l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
  532. l.onLoad = function(){
  533. vboxVMMFillMedia(m.id);
  534. };
  535. $(b).empty().remove();
  536. l.run();
  537. });
  538. };
  539. if(m.attachedTo.length) {
  540. var machines = new Array();
  541. for(var i = 0; i < m.attachedTo.length; i++) {
  542. machines[machines.length] = m.attachedTo[i].machine;
  543. }
  544. q = q.replace('%2','<b>'+machines.join('</b>, <b>') + '</b>');
  545. };
  546. vboxConfirm(q,buttons);
  547. }
  548. },
  549. {
  550. 'name' : 'vmmrefresh',
  551. 'label' : 'Refresh',
  552. 'icon' : 'refresh',
  553. 'click' : function () {
  554. // Force a refresh of media
  555. var l = new vboxLoader();
  556. l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
  557. l.onLoad = function() {vboxVMMFillMedia(); };
  558. l.run();
  559. }
  560. }
  561. );
  562. // Check for advanced config
  563. if(!$('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
  564. vmmButtons.shift();
  565. vmmButtons.shift();
  566. vmmButtons.shift();
  567. }
  568. /* Toolbar */
  569. var vmmToolbar = new vboxToolbar({buttons: vmmButtons,
  570. language_context: 'VBoxMediaManagerDlg',
  571. renderTo: 'vboxMMToolbar'});
  572. /* Actions Menu */
  573. var vmmMenu = new vboxMenuBar({name: 'vboxMMMenu', language_context: 'VBoxMediaManagerDlg'});
  574. vmmMenu.addMenu({
  575. 'name':'vboxMMactions',
  576. 'label':'Actions',
  577. 'menu': vmmButtons
  578. });
  579. vmmMenu.renderTo('vboxMMMenu');
  580. /* Context menu for media */
  581. var vmmCMButtons;
  582. // Check for advanced config. We don't want these in our context menu
  583. if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
  584. vmmCMButtons = vmmButtons.slice(3,-1);
  585. } else {
  586. vmmCMButtons = vmmButtons.slice(0,-1);
  587. }
  588. var vmmCMenu = new vboxMenu({name: 'vboxVMMMediaContextMenu', menuItems: vmmCMButtons,
  589. language_context: 'VBoxMediaManagerDlg'});
  590. /**
  591. * Displays medium info
  592. * @param {HTMLElement} med selected medium row
  593. */
  594. function vboxVMMMediaInfo(med) {
  595. var m = (med ? vboxMedia.getMediumById($(med).data('medium')) : null);
  596. $('#vboxVirtualMediaManager').find('.vmmMediumLocation').val((m && m.location ? m.location : '--'));
  597. $('#vboxVirtualMediaManager').find('.vmmMediumFormat').val(m ? m.format.toUpperCase() : '--');
  598. $('#vboxVirtualMediaManager').find('.vmmMediumHDDetails').val(m ? vboxMedia.getHardDiskVariant(m) : '--');
  599. $('#vmmMediumType').val(m ? trans(m.type,'VBoxGlobal') : '--');
  600. if(m && m.parent) {
  601. $('#vmmMediumType').val(trans('Differencing','VBoxGlobal'));
  602. }
  603. // Attached To val
  604. var attch = null;
  605. var attchElm = $('#vboxVirtualMediaManager').find('.vmmMediumAttachedTo');
  606. attchElm.css({'font-style':''});
  607. if(m) {
  608. attch = vboxMedia.attachedTo(m,true);
  609. if(!attch) {
  610. attch = trans('Not Attached','UIGDetails','details (storage)');
  611. attchElm.css({'font-style':'italic'});
  612. }
  613. attchElm.val(attch);
  614. } else {
  615. attchElm.val('--');
  616. }
  617. // UUID
  618. $('#vboxVirtualMediaManager').find('.vmmMediumUUID').val(m ? m.id : '--');
  619. if(m && m.state == 'Inaccessible' && m.lastAccessError) {
  620. $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':''}).children().html(m.lastAccessError);
  621. } else {
  622. $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':'none'}).children().html('');
  623. }
  624. }
  625. // Update items on mediumselect
  626. $('#vboxVirtualMediaManager').on('mediumselect',function(e,m){
  627. vmmToolbar.update(m);
  628. vboxVMMMediaInfo(m);
  629. vmmMenu.update(m);
  630. vmmCMenu.update(m);
  631. });
  632. /*
  633. * Add medium to a table
  634. */
  635. function vboxVMMAddMedium(d,depth,hideDiff,topLevelParent) {
  636. var tr = $('<tr />').data({'medium':d.id,'mediumname':d.name,'mediumsize':d.size,'mediumlogicalSize':d.logicalSize})
  637. .attr({'id':'vboxVMMMedium'+(d.id),'class':'vboxListItem collapsed','title':d.id})
  638. .hover(function(){
  639. if(!$(this).hasClass('vboxListItemSelected'))
  640. $(this).addClass('vboxHover');
  641. },function(){
  642. $(this).removeClass('vboxHover');
  643. }
  644. )
  645. .addClass('vboxVMMTopLevel'+(topLevelParent ? topLevelParent : '0')+' vboxVMMChildOf'+(d.parent ? d.parent : '0') +' vboxVMMChildDepth'+depth)
  646. .contextMenu({
  647. menu: vmmCMenu.menuId(),
  648. menusetup : function(el) {
  649. if(!$(el).hasClass('vboxListItemSelected')) $(el).children().first().trigger('click');
  650. }
  651. },vmmCMenu.menuClickCallback);
  652. if(d.children && d.children.length && !hideDiff) $(tr).addClass('vboxVMMParent');
  653. if(d.parent) $(tr).addClass('vboxHidden').attr('style','display: none');
  654. /* Expand / collapse button and/or spacers */
  655. var td = $('<td />').addClass('vboxHoverFirst');
  656. // Add spacer image to pad for depth
  657. if(depth) {
  658. for(var i = 0; i < depth; i++) {
  659. $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
  660. }
  661. }
  662. // Show / hide children button
  663. if(d.children && d.children.length && !hideDiff) {
  664. $('<input />').attr({'type':'button','class':'vboxImgButton vboxVMMMediaExpand','style':'background-image: url(images/vbox/arrow_right_10px.png)'}).click(function(){
  665. if(!$(this).data('toggleClicked')) {
  666. $(this).data('toggleClicked', true);
  667. $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
  668. $(this).closest('tr').toggleClass('collapsed').trigger('showChildren',true);
  669. } else {
  670. $(this).data('toggleClicked', false);
  671. $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
  672. $(this).closest('tr').toggleClass('collapsed').trigger('hideChildren',true);
  673. }
  674. return false;
  675. }).appendTo(td);
  676. } else if(depth) {
  677. $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
  678. }
  679. // Title div
  680. var span = $('<span />').attr({'id':'vboxVMMMediaTitle-'+d.id}).html($('<div />').html(d.name).text());
  681. // Add read-only or inaccessible class?
  682. if(d.state == 'Inaccessible') {
  683. $(span).addClass('vboxMediumInaccessible');
  684. } else if(hideDiff !== undefined && d.readOnly) {
  685. $(span).addClass('vboxMediumReadOnly');
  686. }
  687. $(td).append(span).appendTo(tr);
  688. // Set target list
  689. //////////////////////
  690. var target = '';
  691. switch(d.deviceType) {
  692. case 'HardDisk':
  693. // Logical size column
  694. $('<td />').addClass('vboxHoverMid').append($('<span />').html(vboxMbytesConvert(d.logicalSize))).appendTo(tr);
  695. target = '#vboxVMMHDList';
  696. break;
  697. case 'DVD':
  698. target = '#vboxVMMCDList';
  699. break;
  700. case 'Floppy':
  701. target = '#vboxVMMFDList';
  702. break;
  703. }
  704. // Size column
  705. $('<td />').addClass('vboxHoverLast').append($('<div />').html(vboxBytesConvert(d.size))).appendTo(tr);
  706. /* Show / hide children of this medium */
  707. $(tr).on('showChildren',function(e,first){
  708. var thisid = $(this).data('medium');
  709. var trTarget = this;
  710. if($(this).hasClass('collapsed') || !$(this).hasClass('vboxVMMParent')) return;
  711. $(trTarget).siblings('tr.vboxVMMChildOf'+thisid).show().removeClass('vboxHidden').trigger('showChildren',false);
  712. // Only set by original button click
  713. if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks')); }
  714. }).on('hideChildren',function(e,first){
  715. if(!$(this).hasClass('vboxVMMParent')) return;
  716. $(this).siblings('tr.vboxVMMChildOf'+$(this).data('medium')).hide().addClass('vboxHidden').trigger('hideChildren',false);
  717. // Only set by original button click
  718. if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks'));}
  719. }).children().click(function(){
  720. $(this).parent().removeClass('vboxListItem vboxHover').addClass('vboxListItemSelected')
  721. .siblings().removeClass('vboxListItemSelected').addClass('vboxListItem');
  722. $('#vboxVirtualMediaManager').trigger('mediumselect',[$(this).parent()]);
  723. });
  724. $(target).append(tr);
  725. if(d.children && d.children.length) {
  726. if(depth) depth++;
  727. else depth = 1;
  728. for(var i = 0; i < d.children.length; i++) {
  729. vboxVMMAddMedium(d.children[i],depth,hideDiff,(topLevelParent ? topLevelParent : d.id));
  730. }
  731. }
  732. }
  733. /* Fill medium tables and info with Medium info */
  734. function vboxVMMFillMedia(sel) {
  735. // Remove stub items
  736. $('#vboxVMMHDList').children().remove();
  737. $('#vboxVMMCDList').children().remove();
  738. $('#vboxVMMFDList').children().remove();
  739. // Set icons
  740. $('#vmmDisksIcon').attr('src','images/vbox/hd_16px.png');
  741. $('#vmmCDsIcon').attr('src','images/vbox/cd_16px.png');
  742. $('#vmmFloppysIcon').attr('src','images/vbox/fd_16px.png');
  743. var media = $('#vboxPane').data('vboxMedia').sort(function(a,b) {
  744. return strnatcasecmp(a.name,b.name);
  745. });
  746. var hideDiff = $('#vboxVirtualMediaManager').data('hideDiff');
  747. for(var i in media) {
  748. vboxVMMAddMedium(media[i],0,hideDiff,media[i].parent);
  749. if(media[i].state == 'Inaccessible') {
  750. var elm = null;
  751. switch(media[i].deviceType) {
  752. case 'HardDisk':
  753. elm = $('#vmmDisksIcon');
  754. break;
  755. case 'DVD':
  756. elm = $('#vmmCDsIcon');
  757. break;
  758. default:
  759. elm = $('#vmmFloppysIcon');
  760. }
  761. elm.attr('src','images/vbox/state_aborted_16px.png');
  762. }
  763. }
  764. vboxVMMTableHeaderSetup($('#vmmDisks'));
  765. vboxVMMTableHeaderSetup($('#vmmCDs'));
  766. vboxVMMTableHeaderSetup($('#vmmFloppys'));
  767. // Select medium?
  768. if(sel) {
  769. $('#vboxVMMMedium'+sel).children().first().click();
  770. } else {
  771. $('#vboxVirtualMediaManager').trigger('mediumselect',null);
  772. }
  773. vboxVMMTableSort($('#vboxVMMHDList'));
  774. vboxVMMTableSort($('#vboxVMMFDList'));
  775. vboxVMMTableSort($('#vboxVMMCDList'));
  776. }
  777. /*
  778. *
  779. * Sort table according to selected items
  780. *
  781. */
  782. function vboxVMMTableSort(t) {
  783. // Get Selected Heading and sort order
  784. ////////////////////////////////////////
  785. var ths = $(t).closest('div').siblings('div.vmmTableHead').find('thead').find('th');
  786. var cthIndex = 0;
  787. var sortOrder = null;
  788. for(var i = 0; i < ths.length; i++) {
  789. if($(ths[i]).data('sorted')) {
  790. cthIndex = i;
  791. sortOrder = $(ths[i]).data('sorted');
  792. break;
  793. }
  794. }
  795. ths =null;
  796. // Sort table
  797. ///////////////////////
  798. $(t).each(function(){
  799. // Sort function (vboxVMMChildOf0 are top-level)
  800. var rows = $(this).find('tr.vboxVMMChildOf0').get();
  801. switch(cthIndex) {
  802. // Name
  803. case 0:
  804. rows.sort(function(a,b){
  805. return strnatcasecmp($(a).data('mediumname'),$(b).data('mediumname'));
  806. });
  807. break;
  808. // size or logical size
  809. default:
  810. // HD has an extra column for logical size
  811. // size
  812. var sortOpt = ($("#vboxVMMTabs").tabs('option','active') ? '' : 'HD');
  813. if(sortOpt == 'HD' && cthIndex == 2 || (sortOpt != 'HD')) {
  814. rows.sort(function(a,b){
  815. if($(a).data('mediumsize') == $(b).data('mediumsize')) return 0;
  816. return (parseInt($(a).data('mediumsize')) > parseInt($(b).data('mediumsize')) ? 1 : -1);
  817. });
  818. // logical size
  819. } else {
  820. rows.sort(function(a,b){
  821. if($(a).data('mediumlogicalSize') == $(b).data('mediumlogicalSize')) return 0;
  822. return (parseInt($(a).data('mediumlogicalSize')) > parseInt($(b).data('mediumlogicalSize')) ? 1 : -1);
  823. });
  824. }
  825. break;
  826. }
  827. // reverse?
  828. if(sortOrder == 'asc') rows.reverse();
  829. // Append rows and children
  830. var target = $(this);
  831. $(rows).each(function(){
  832. // top-level (parent) medium
  833. $(this).detach().appendTo($(target));
  834. // Children
  835. $(target).find('tr.vboxVMMTopLevel'+($(this).data('medium'))).detach().appendTo($(target));
  836. });
  837. vboxColorRows(target);
  838. });
  839. }
  840. /*
  841. *
  842. * Resizing and setup
  843. *
  844. */
  845. function vboxVMMSizeTable(elm) {
  846. // Hide table body
  847. var TB = $(elm).find('div.vmmTableBody');
  848. TB.css({'display':'none'});
  849. // Get height
  850. var cH = $(elm).parent().innerHeight() - $(elm).outerHeight(true);
  851. // Apply to difference in height to table body
  852. TB.height(cH-4).css({'display':'','overflow':'auto'});
  853. // Set table head width
  854. vboxVMMTableHeaderSetup(elm);
  855. }
  856. /* Setup tables */
  857. function vboxVMMTableHeaderSetup(elm) {
  858. // Set column width
  859. // Get each column width
  860. var hCols = $(elm).find('div.vmmTableHead').find('tr:eq(0)').children();
  861. var tCols = $(elm).find('div.vmmTableBody').find('tbody tr:eq(0)').children();
  862. for(var i = 0; i < tCols.length; i++) {
  863. $(hCols[i]).width($(tCols[i]).width());
  864. }
  865. }
  866. /* Init virtual media manager */
  867. function vboxVMMInit(hideDiff,vmPath) {
  868. // SEVERE hack-fooery ensues..
  869. /////////////////////////////////
  870. $('#vboxVirtualMediaManager').parent().on( "dialogresizestart",function(e){
  871. $('#vboxVMMTabs').css({'height':'auto'});
  872. $('#vboxVMMContainer').css({'height':'auto'});
  873. }).on("dialogresizestop",function(e){
  874. $('#vmmDisks .vmmTableBody').css({'display':'none'});
  875. $('#vmmCDs .vmmTableBody').css({'display':'none'});
  876. $('#vmmFloppys .vmmTableBody').css({'display':'none'});
  877. $('#vboxVMMContainer').height($('#vboxVMMContainer').height());
  878. $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight());
  879. vboxVMMSizeTable($('#vmmDisks'));
  880. vboxVMMSizeTable($('#vmmCDs'));
  881. vboxVMMSizeTable($('#vmmFloppys'));
  882. });
  883. $('#vboxVMMTabList').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMMContainerTop').attr({'class':$('#vboxVMMTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')}));
  884. $('#vboxVMMContainer').height($('#vboxVMMContainer').height()).css({'padding':'0px','margin':'0px'});
  885. $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight()).css({'padding-top':'0px','padding-bottom':'0px','margin-top':'0px','margin-bottom':'0px'});
  886. // Resize disks table body
  887. vboxVMMSizeTable($('#vmmDisks'));
  888. // Save options for later
  889. $('#vboxVirtualMediaManager').data('hideDiff', hideDiff);
  890. $('#vboxVirtualMediaManager').data('vmPath', vmPath);
  891. // Column sorting
  892. ////////////////////////////
  893. $("#vboxVirtualMediaManager div.vmmTableHead thead th").each(function(thIndex){
  894. // Skip last column header. It is just kept for spacing
  895. if($(this).children('img').length) return true;
  896. $(this).hover(function(){
  897. $(this).children('img').css({'visibility':'visible'});
  898. },function(){
  899. if($(this).data('sorted')) return;
  900. $(this).children('img').css({'visibility':'hidden'});
  901. }).addClass('vboxVMMSortImgFaded').append(' ').append($('<img />').attr({'src':'images/upArrow.png','style':'visibility:hidden;cursor:pointer'}).click(function(e,sortDefault){
  902. var p = $(this).parent();
  903. // Get current sort order and set accordingly
  904. //////////////////////////////////////////////
  905. switch(p.data('sorted')) {
  906. case 'asc':
  907. $(this).attr({'src':'images/upArrow.png'}).css({'visibility':'visible'});
  908. p.data('sorted','desc');
  909. break;
  910. case 'desc':
  911. $(this).attr({'src':'images/downArrow.png'}).css({'visibility':'visible'});
  912. p.data('sorted','asc');
  913. break;
  914. default:
  915. p.data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').siblings().data({'sorted':null}).addClass('vboxVMMSortImgFaded').children('img').attr({'src':'images/upArrow.png'}).css({'visibility':'hidden'});
  916. break;
  917. }
  918. vboxVMMTableSort($(p).closest('div').siblings('div.vmmTableBody').find('tbody').first());
  919. }));
  920. // Default is sort by name
  921. if($(this).index() == 0) {
  922. $(this).data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').children('img').css({'visibility':'visible'});
  923. }
  924. });
  925. vboxVMMFillMedia();
  926. }
  927. </script>