diskmg.html 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  6. <script src="../../script/jquery.min.js"></script>
  7. <script type='text/javascript' src="../../semantic/semantic.min.js"></script>
  8. <script src="../../script/ao_module.js"></script>
  9. <script src="../../script/applocale.js"></script>
  10. <title locale="diskmg/window-title">Disk Management</title>
  11. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  12. <style>
  13. *, *::before, *::after { box-sizing: border-box; }
  14. body {
  15. font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  16. font-size: 13px;
  17. color: #1d1d1f;
  18. background: #f2f2f7;
  19. margin: 0;
  20. padding: 0;
  21. height: 100vh;
  22. overflow: hidden;
  23. }
  24. .main-layout {
  25. display: flex;
  26. flex-direction: row;
  27. height: 100vh;
  28. overflow: hidden;
  29. }
  30. /* ── Sidebar ── */
  31. .sidebar {
  32. width: 210px;
  33. flex-shrink: 0;
  34. background: rgba(235,235,240,0.95);
  35. border-right: 1px solid rgba(0,0,0,0.13);
  36. display: flex;
  37. flex-direction: column;
  38. overflow: hidden;
  39. }
  40. .sidebar-header {
  41. padding: 16px 14px 6px;
  42. font-size: 11px;
  43. font-weight: 700;
  44. color: #6e6e73;
  45. letter-spacing: 0.07em;
  46. text-transform: uppercase;
  47. flex-shrink: 0;
  48. }
  49. .sidebar-list {
  50. flex: 1;
  51. overflow-y: auto;
  52. padding: 2px 6px 10px;
  53. }
  54. .sidebar-item {
  55. display: flex;
  56. align-items: center;
  57. gap: 9px;
  58. padding: 6px 8px;
  59. border-radius: 7px;
  60. cursor: pointer;
  61. transition: background 0.1s;
  62. margin-bottom: 1px;
  63. }
  64. .sidebar-item:hover { background: rgba(0,0,0,0.07); }
  65. .sidebar-item.active {
  66. background: #007AFF;
  67. color: #fff;
  68. }
  69. .sidebar-item.active .sidebar-item-sub { color: rgba(255,255,255,0.72); }
  70. .sidebar-item-icon {
  71. width: 30px;
  72. height: 30px;
  73. flex-shrink: 0;
  74. object-fit: contain;
  75. }
  76. .sidebar-item.active .sidebar-item-icon {
  77. filter: brightness(1.8);
  78. }
  79. .sidebar-item-text { min-width: 0; }
  80. .sidebar-item-name {
  81. font-size: 12px;
  82. font-weight: 500;
  83. white-space: nowrap;
  84. overflow: hidden;
  85. text-overflow: ellipsis;
  86. }
  87. .sidebar-item-sub {
  88. font-size: 11px;
  89. color: #6e6e73;
  90. white-space: nowrap;
  91. overflow: hidden;
  92. text-overflow: ellipsis;
  93. margin-top: 1px;
  94. }
  95. /* ── Detail panel ── */
  96. .detail-panel {
  97. flex: 1;
  98. overflow-y: auto;
  99. padding: 18px 18px 22px;
  100. min-width: 0;
  101. }
  102. /* ── Disk header card ── */
  103. .disk-header-card {
  104. background: #fff;
  105. border-radius: 12px;
  106. padding: 18px 22px;
  107. display: flex;
  108. align-items: flex-start;
  109. gap: 18px;
  110. box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 8px rgba(0,0,0,0.04);
  111. margin-bottom: 12px;
  112. }
  113. .disk-header-icon {
  114. width: 60px;
  115. height: 60px;
  116. flex-shrink: 0;
  117. object-fit: contain;
  118. }
  119. .disk-header-info { flex: 1; min-width: 0; }
  120. .disk-header-name {
  121. font-size: 17px;
  122. font-weight: 600;
  123. color: #1d1d1f;
  124. margin-bottom: 2px;
  125. }
  126. .disk-header-meta {
  127. font-size: 12px;
  128. color: #6e6e73;
  129. margin-bottom: 14px;
  130. }
  131. /* macOS-style multicolor storage bar */
  132. .storage-bar {
  133. height: 10px;
  134. border-radius: 5px;
  135. background: #e5e5ea;
  136. display: flex;
  137. overflow: hidden;
  138. margin-bottom: 10px;
  139. }
  140. .storage-bar-seg {
  141. height: 100%;
  142. transition: width 0.35s ease;
  143. min-width: 0;
  144. }
  145. .storage-bar-legend {
  146. display: flex;
  147. flex-wrap: wrap;
  148. gap: 6px 16px;
  149. }
  150. .legend-item {
  151. display: flex;
  152. align-items: center;
  153. gap: 5px;
  154. font-size: 11px;
  155. color: #6e6e73;
  156. }
  157. .legend-dot {
  158. width: 8px;
  159. height: 8px;
  160. border-radius: 50%;
  161. flex-shrink: 0;
  162. }
  163. .disk-header-stats {
  164. display: flex;
  165. gap: 28px;
  166. margin-top: 14px;
  167. padding-top: 13px;
  168. border-top: 1px solid rgba(0,0,0,0.07);
  169. }
  170. .stat-label { font-size: 11px; color: #6e6e73; margin-bottom: 2px; }
  171. .stat-value { font-size: 14px; font-weight: 600; color: #1d1d1f; }
  172. /* ── Partition table card ── */
  173. .partition-card {
  174. background: #fff;
  175. border-radius: 12px;
  176. overflow: hidden;
  177. box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 8px rgba(0,0,0,0.04);
  178. }
  179. .partition-card-header {
  180. padding: 11px 18px 9px;
  181. font-size: 11px;
  182. font-weight: 700;
  183. color: #6e6e73;
  184. text-transform: uppercase;
  185. letter-spacing: 0.07em;
  186. border-bottom: 1px solid rgba(0,0,0,0.07);
  187. background: #fafafa;
  188. }
  189. .partition-table {
  190. width: 100%;
  191. border-collapse: collapse;
  192. }
  193. .partition-table th {
  194. padding: 8px 16px;
  195. text-align: left;
  196. font-size: 11px;
  197. font-weight: 600;
  198. color: #6e6e73;
  199. background: #fafafa;
  200. border-bottom: 1px solid rgba(0,0,0,0.07);
  201. white-space: nowrap;
  202. }
  203. .partition-table td {
  204. padding: 11px 16px;
  205. border-bottom: 1px solid rgba(0,0,0,0.05);
  206. font-size: 12px;
  207. vertical-align: middle;
  208. }
  209. .partition-table tbody tr:last-child td { border-bottom: none; }
  210. .partition-table tbody tr:hover { background: rgba(0,122,255,0.05); cursor: default; }
  211. .partition-table tbody tr.focusedPart { background: rgba(0,122,255,0.10); }
  212. .part-color-dot {
  213. display: inline-block;
  214. width: 9px;
  215. height: 9px;
  216. border-radius: 50%;
  217. flex-shrink: 0;
  218. vertical-align: middle;
  219. margin-right: 6px;
  220. }
  221. .status-badge {
  222. display: inline-flex;
  223. align-items: center;
  224. gap: 4px;
  225. font-size: 11px;
  226. font-weight: 500;
  227. }
  228. .status-dot {
  229. width: 6px;
  230. height: 6px;
  231. border-radius: 50%;
  232. flex-shrink: 0;
  233. }
  234. .dot-mounted { background: #34c759; }
  235. .dot-unmounted { background: #ff3b30; }
  236. .dot-unalloc { background: #aeaeb2; }
  237. .mini-bar {
  238. height: 3px;
  239. background: rgba(0,0,0,0.08);
  240. border-radius: 2px;
  241. overflow: hidden;
  242. margin-top: 5px;
  243. width: 64px;
  244. }
  245. .mini-bar-fill { height: 100%; border-radius: 2px; }
  246. /* ── Empty state ── */
  247. .empty-state {
  248. display: flex;
  249. flex-direction: column;
  250. align-items: center;
  251. justify-content: center;
  252. height: 100%;
  253. gap: 14px;
  254. color: #aeaeb2;
  255. text-align: center;
  256. }
  257. .empty-state img { width: 72px; opacity: 0.3; }
  258. .empty-state-text { font-size: 14px; font-weight: 500; }
  259. /* ── Context menu (macOS vibrancy style) ── */
  260. #rightClickMenu {
  261. position: fixed;
  262. z-index: 200;
  263. background: rgba(248,248,250,0.96);
  264. backdrop-filter: blur(20px);
  265. -webkit-backdrop-filter: blur(20px);
  266. border: 1px solid rgba(0,0,0,0.12);
  267. border-radius: 10px;
  268. padding: 4px;
  269. box-shadow: 0 6px 28px rgba(0,0,0,0.16), 0 1px 4px rgba(0,0,0,0.10);
  270. min-width: 162px;
  271. }
  272. #rightClickMenu .ctx-item {
  273. padding: 6px 12px;
  274. border-radius: 6px;
  275. cursor: pointer;
  276. display: flex;
  277. align-items: center;
  278. gap: 8px;
  279. font-size: 13px;
  280. color: #1d1d1f;
  281. }
  282. #rightClickMenu .ctx-item:hover { background: rgba(0,0,0,0.07); }
  283. #rightClickMenu .ctx-item.disabled { color: #aeaeb2; cursor: not-allowed; }
  284. #rightClickMenu .ctx-item.disabled:hover { background: transparent; }
  285. #rightClickMenu .ctx-sep { height: 1px; background: rgba(0,0,0,0.11); margin: 3px 8px; }
  286. /* ── Modal backdrop ── */
  287. .functMenuDimmer {
  288. z-index: 90;
  289. position: fixed;
  290. inset: 0;
  291. background: rgba(0,0,0,0.28);
  292. display: none;
  293. backdrop-filter: blur(3px);
  294. }
  295. /* ── Modal (macOS sheet style) ── */
  296. .funcmenu {
  297. position: fixed;
  298. top: 50%;
  299. left: 50%;
  300. transform: translate(-50%, -50%);
  301. width: 390px;
  302. max-width: 92vw;
  303. max-height: 82vh;
  304. overflow-y: auto;
  305. z-index: 100;
  306. background: #f5f5f7;
  307. border-radius: 14px;
  308. padding: 0;
  309. display: none;
  310. box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  311. }
  312. .funcmenu-title {
  313. padding: 18px 22px 14px;
  314. font-size: 15px;
  315. font-weight: 600;
  316. text-align: center;
  317. color: #1d1d1f;
  318. border-bottom: 1px solid rgba(0,0,0,0.1);
  319. }
  320. .funcmenu-body { padding: 18px 22px; }
  321. .funcmenuBottom {
  322. display: flex;
  323. border-top: 1px solid rgba(0,0,0,0.1);
  324. }
  325. .mac-btn {
  326. flex: 1;
  327. padding: 12px;
  328. text-align: center;
  329. cursor: pointer;
  330. font-size: 14px;
  331. border: none;
  332. background: transparent;
  333. font-family: inherit;
  334. color: #007AFF;
  335. border-right: 1px solid rgba(0,0,0,0.1);
  336. transition: background 0.1s;
  337. }
  338. .mac-btn:last-child { border-right: none; }
  339. .mac-btn.danger { color: #ff3b30; font-weight: 600; }
  340. .mac-btn.primary { font-weight: 600; }
  341. .mac-btn:hover { background: rgba(0,0,0,0.05); }
  342. /* ── Warning banner ── */
  343. .warning-banner {
  344. background: #fff3cd;
  345. border-radius: 8px;
  346. padding: 10px 13px;
  347. font-size: 12px;
  348. margin-bottom: 14px;
  349. color: #664d03;
  350. line-height: 1.5;
  351. }
  352. /* ── Form ── */
  353. .form-field { margin-bottom: 14px; }
  354. .form-label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 7px; color: #1d1d1f; }
  355. .radio-group { display: flex; flex-direction: column; gap: 7px; }
  356. .radio-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
  357. .radio-item input { accent-color: #007AFF; cursor: pointer; }
  358. .info-row {
  359. background: rgba(0,0,0,0.05);
  360. border-radius: 8px;
  361. padding: 11px 14px;
  362. margin-bottom: 14px;
  363. font-size: 13px;
  364. font-weight: 500;
  365. color: #1d1d1f;
  366. }
  367. /* ── Mount list ── */
  368. #mtptlist {
  369. border: 1px solid rgba(0,0,0,0.12);
  370. border-radius: 10px;
  371. max-height: 220px;
  372. overflow-y: auto;
  373. background: #fff;
  374. }
  375. .mountpt {
  376. padding: 9px 14px;
  377. cursor: pointer;
  378. border-bottom: 1px solid rgba(0,0,0,0.06);
  379. font-size: 13px;
  380. transition: background 0.1s;
  381. }
  382. .mountpt:last-child { border-bottom: none; }
  383. .mountpt:hover { background: rgba(0,122,255,0.06); }
  384. .mountpt.selected { background: rgba(0,122,255,0.12); color: #007AFF; }
  385. .fluid-input {
  386. width: 100%;
  387. padding: 6px 10px;
  388. border: 1px solid rgba(0,0,0,0.18);
  389. border-radius: 6px;
  390. font-size: 13px;
  391. font-family: inherit;
  392. margin-top: 6px;
  393. background: #fff;
  394. }
  395. .fluid-input:focus {
  396. outline: none;
  397. border-color: #007AFF;
  398. box-shadow: 0 0 0 2.5px rgba(0,122,255,0.28);
  399. }
  400. /* ── Loader ── */
  401. #loaderUI {
  402. position: fixed;
  403. inset: 0;
  404. background: rgba(255,255,255,0.55);
  405. backdrop-filter: blur(8px);
  406. display: none;
  407. z-index: 300;
  408. align-items: center;
  409. justify-content: center;
  410. flex-direction: column;
  411. gap: 12px;
  412. }
  413. #loaderUI.active { display: flex; }
  414. .loader-spinner {
  415. width: 24px;
  416. height: 24px;
  417. border: 2.5px solid rgba(0,0,0,0.1);
  418. border-top-color: #007AFF;
  419. border-radius: 50%;
  420. animation: spin 0.72s linear infinite;
  421. }
  422. @keyframes spin { to { transform: rotate(360deg); } }
  423. .loader-text { font-size: 13px; color: #6e6e73; }
  424. /* ── Dark theme ── */
  425. body.dark {
  426. background: #000;
  427. color: #f2f2f7;
  428. }
  429. body.dark .sidebar {
  430. background: rgba(28,28,30,0.97);
  431. border-right-color: rgba(255,255,255,0.1);
  432. }
  433. body.dark .sidebar-header { color: #98989d; }
  434. body.dark .sidebar-item:hover { background: rgba(255,255,255,0.07); }
  435. body.dark .sidebar-item.active { background: #0a84ff; }
  436. body.dark .sidebar-item-sub { color: #98989d; }
  437. body.dark .disk-header-card,
  438. body.dark .partition-card {
  439. background: #1c1c1e;
  440. box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 8px rgba(0,0,0,0.3);
  441. }
  442. body.dark .disk-header-name,
  443. body.dark .stat-value { color: #f2f2f7; }
  444. body.dark .disk-header-meta,
  445. body.dark .stat-label,
  446. body.dark .legend-item { color: #98989d; }
  447. body.dark .storage-bar { background: #3a3a3c; }
  448. body.dark .disk-header-stats { border-top-color: rgba(255,255,255,0.08); }
  449. body.dark .partition-card-header {
  450. background: #2c2c2e;
  451. color: #98989d;
  452. border-bottom-color: rgba(255,255,255,0.07);
  453. }
  454. body.dark .partition-table th {
  455. background: #2c2c2e;
  456. color: #98989d;
  457. border-bottom-color: rgba(255,255,255,0.07);
  458. }
  459. body.dark .partition-table td { border-bottom-color: rgba(255,255,255,0.05); }
  460. body.dark .partition-table tbody tr:hover { background: rgba(10,132,255,0.12); }
  461. body.dark .partition-table tbody tr.focusedPart { background: rgba(10,132,255,0.2); }
  462. body.dark .mini-bar { background: rgba(255,255,255,0.12); }
  463. body.dark .empty-state img { opacity: 0.2; }
  464. body.dark .empty-state { color: #636366; }
  465. body.dark #rightClickMenu {
  466. background: rgba(40,40,42,0.97);
  467. border-color: rgba(255,255,255,0.12);
  468. }
  469. body.dark #rightClickMenu .ctx-item { color: #f2f2f7; }
  470. body.dark #rightClickMenu .ctx-item:hover { background: rgba(255,255,255,0.1); }
  471. body.dark #rightClickMenu .ctx-sep { background: rgba(255,255,255,0.1); }
  472. body.dark .funcmenu { background: #2c2c2e; }
  473. body.dark .funcmenu-title {
  474. color: #f2f2f7;
  475. border-bottom-color: rgba(255,255,255,0.1);
  476. }
  477. body.dark .funcmenuBottom { border-top-color: rgba(255,255,255,0.1); }
  478. body.dark .mac-btn { border-right-color: rgba(255,255,255,0.1); color: #0a84ff; }
  479. body.dark .mac-btn.danger { color: #ff453a; }
  480. body.dark .mac-btn.primary { color: #0a84ff; }
  481. body.dark .mac-btn:hover { background: rgba(255,255,255,0.06); }
  482. body.dark .warning-banner { background: #3a2900; color: #ffd60a; }
  483. body.dark .info-row { background: rgba(255,255,255,0.08); color: #f2f2f7; }
  484. body.dark .form-label { color: #f2f2f7; }
  485. body.dark #mtptlist {
  486. background: #1c1c1e;
  487. border-color: rgba(255,255,255,0.12);
  488. }
  489. body.dark .mountpt { border-bottom-color: rgba(255,255,255,0.06); color: #f2f2f7; }
  490. body.dark .mountpt:hover { background: rgba(10,132,255,0.1); }
  491. body.dark .mountpt.selected { background: rgba(10,132,255,0.22); color: #0a84ff; }
  492. body.dark .fluid-input {
  493. background: #3a3a3c;
  494. border-color: rgba(255,255,255,0.18);
  495. color: #f2f2f7;
  496. }
  497. body.dark .fluid-input:focus {
  498. border-color: #0a84ff;
  499. box-shadow: 0 0 0 2.5px rgba(10,132,255,0.35);
  500. }
  501. body.dark #loaderUI { background: rgba(0,0,0,0.6); }
  502. body.dark .loader-text { color: #98989d; }
  503. body.dark .loader-spinner { border-color: rgba(255,255,255,0.1); border-top-color: #0a84ff; }
  504. </style>
  505. </head>
  506. <body>
  507. <!-- ── Main layout ── -->
  508. <div class="main-layout">
  509. <!-- ── Sidebar ── -->
  510. <div class="sidebar">
  511. <div class="sidebar-header" locale="diskmg/sidebar-header">Disks</div>
  512. <div class="sidebar-list" id="sidebarList">
  513. <div class="sidebar-item active">
  514. <img class="sidebar-item-icon" src="../../img/system/drive.svg" alt="">
  515. <div class="sidebar-item-text">
  516. <div class="sidebar-item-name" locale="diskmg/loading">Loading…</div>
  517. <div class="sidebar-item-sub">&nbsp;</div>
  518. </div>
  519. </div>
  520. </div>
  521. </div>
  522. <!-- ── Detail panel ── -->
  523. <div class="detail-panel" id="detailPanel">
  524. <div class="empty-state">
  525. <img src="../../img/system/drive.svg" alt="">
  526. <div class="empty-state-text" locale="diskmg/select-disk">Select a disk to view details</div>
  527. </div>
  528. </div>
  529. </div><!-- /.main-layout -->
  530. <!-- ── Context menu ── -->
  531. <div id="rightClickMenu" style="display:none;">
  532. <div id="formatDisk" class="ctx-item" onclick="toggleFormatInterface(this);">
  533. <i class="erase icon"></i> <span locale="diskmg/erase">Erase…</span>
  534. </div>
  535. <div class="ctx-sep"></div>
  536. <div id="mtbtn" class="ctx-item" onclick="toggleMount(this);">
  537. <i class="plug icon"></i> Mount
  538. </div>
  539. </div>
  540. <!-- ── Format dialog ── -->
  541. <div id="formatOptions" class="funcmenu">
  542. <div class="funcmenu-title" locale="diskmg/erase-title">Erase Partition</div>
  543. <div class="funcmenu-body">
  544. <div class="warning-banner" locale="diskmg/erase-warning">
  545. ⚠&nbsp; This will permanently erase all data on the selected partition.
  546. Back up important files before continuing.
  547. </div>
  548. <div class="info-row" id="selectedDiskDisplay">/dev/sda1</div>
  549. <div class="form-field">
  550. <label class="form-label" locale="diskmg/format-label">Format</label>
  551. <div class="radio-group">
  552. <label class="radio-item"><input id="ext4" type="radio" name="format" checked> EXT4</label>
  553. <label class="radio-item"><input id="ntfs" type="radio" name="format"> NTFS</label>
  554. <label class="radio-item"><input id="vfat" type="radio" name="format"> VFAT</label>
  555. </div>
  556. </div>
  557. </div>
  558. <div class="funcmenuBottom">
  559. <button class="mac-btn" onclick="hideAllFuncMenu();" locale="diskmg/cancel">Cancel</button>
  560. <button class="mac-btn danger" onclick="formatThisDev();" locale="diskmg/erase-btn">Erase</button>
  561. </div>
  562. </div>
  563. <!-- ── Mount dialog ── -->
  564. <div id="mountOptions" class="funcmenu">
  565. <div class="funcmenu-title" locale="diskmg/mount-title">Mount Drive</div>
  566. <div class="funcmenu-body">
  567. <p style="color:#6e6e73;font-size:12px;margin:0 0 12px;" locale="diskmg/mount-desc">Select a mount point for this device.</p>
  568. <div id="mtptlist">
  569. <div class="mountpt userdefine" onclick="selectThis(this);">
  570. <div style="font-weight:600;font-size:12px;" locale="diskmg/custom-mpt">Custom Mount Point</div>
  571. <input id="userDefinedMountPoint" class="fluid-input" type="text" placeholder="diskmg/mpt-placeholder">
  572. </div>
  573. </div>
  574. </div>
  575. <div class="funcmenuBottom">
  576. <button class="mac-btn" onclick="hideAllFuncMenu();" locale="diskmg/cancel">Cancel</button>
  577. <button class="mac-btn primary" onclick="mountThisDev();" locale="diskmg/mount">Mount</button>
  578. </div>
  579. </div>
  580. <!-- ── Loader ── -->
  581. <div id="loaderUI">
  582. <div class="loader-spinner"></div>
  583. <div class="loader-text" locale="diskmg/waiting">Waiting for system response…</div>
  584. </div>
  585. <!-- ── Backdrop ── -->
  586. <div class="functMenuDimmer" onclick="hideAllFuncMenu();"></div>
  587. <script>
  588. var mode = "linux";
  589. var viewMode = "human";
  590. var diskInformation;
  591. var volumeData = null;
  592. var formatPendingDevInfo;
  593. var selectedDiskKey = null;
  594. var appLocale = NewAppLocale();
  595. /* Partition segment colors — macOS palette */
  596. var SEG_COLORS = ["#007AFF","#34c759","#ff9500","#af52de","#ff2d55","#5ac8fa","#ffcc00","#ff6b35"];
  597. appLocale.init("../locale/diskmg.json", function(){
  598. appLocale.translate();
  599. $.get(ao_root + "system/disk/diskmg/platform", function(data){
  600. mode = (data === "windows") ? "windows" : "linux";
  601. initData();
  602. initMountPointList();
  603. });
  604. });
  605. // ── Helpers ──────────────────────────────────────────────────────
  606. function hideAllFuncMenu(){
  607. $(".funcmenu").fadeOut("fast");
  608. $(".functMenuDimmer").fadeOut("fast");
  609. }
  610. function hideRightclickMenu(){ $("#rightClickMenu").hide(); }
  611. function selectThis(el){
  612. $(".mountpt.selected").removeClass("selected");
  613. $(el).addClass("selected");
  614. }
  615. function bytesToSize(bytes){
  616. if (viewMode === "human"){
  617. var sizes = ["Bytes","KB","MB","GB","TB"];
  618. if (bytes == 0) return "0 Byte";
  619. var i = Math.floor(Math.log(bytes) / Math.log(1024));
  620. return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + " " + sizes[i];
  621. }
  622. return bytes + " B";
  623. }
  624. // ── Mount point list ─────────────────────────────────────────────
  625. function initMountPointList(){
  626. $.get(ao_root + "system/disk/diskmg/mpt", function(data){
  627. if (data == null) return;
  628. data.forEach(function(mpt){
  629. $("#mtptlist").prepend(
  630. "<div class='mountpt' onclick='selectThis(this);' ondblclick='mountThisDev(this)'>" + mpt + "</div>"
  631. );
  632. });
  633. });
  634. }
  635. // ── Format ───────────────────────────────────────────────────────
  636. function toggleFormatInterface(btnObject){
  637. if ($(btnObject).hasClass("disabled")) return;
  638. var diskInfo = $(".focusedPart").attr("metadata");
  639. diskInfo = ao_module_utils.attrToObject(diskInfo);
  640. formatPendingDevInfo = diskInfo;
  641. $("#selectedDiskDisplay").text(diskInfo[0] + " (" + bytesToSize(parseInt(diskInfo[5])) + ")");
  642. $(".functMenuDimmer").fadeIn("fast");
  643. $("#formatOptions").fadeIn("fast");
  644. hideRightclickMenu();
  645. }
  646. function formatThisDev(){
  647. var targetFormat = $("input[name='format']:checked").attr("id");
  648. var targetDisk = formatPendingDevInfo;
  649. if (!targetFormat) return;
  650. if (!confirm(appLocale.getString("diskmg/confirm-wipe", "THIS OPERATION WILL WIPE ALL DATA ON /dev/") + targetDisk[0] + appLocale.getString("diskmg/confirm-suffix", ". ARE YOU SURE?"))) return;
  651. $("#formatOptions").fadeOut("fast");
  652. $(".functMenuDimmer").fadeOut("fast");
  653. $("#loaderUI").addClass("active");
  654. $.ajax({
  655. url: ao_root + "system/disk/diskmg/format",
  656. data: { dev: targetDisk[0], format: targetFormat },
  657. method: "POST",
  658. success: function(data){
  659. if (data.error !== undefined) alert(data.error);
  660. initData();
  661. $("#loaderUI").removeClass("active");
  662. }
  663. });
  664. }
  665. // ── Mount / Unmount ──────────────────────────────────────────────
  666. function toggleMount(btnObject){
  667. if ($(btnObject).hasClass("disabled")) return;
  668. var diskInfo = $(".focusedPart").attr("metadata");
  669. diskInfo = ao_module_utils.attrToObject(diskInfo);
  670. hideRightclickMenu();
  671. if (diskInfo[3] === false || diskInfo[3] === "false"){
  672. $(".functMenuDimmer").fadeIn("fast");
  673. $("#mountOptions").fadeIn("fast");
  674. } else {
  675. $("#loaderUI").addClass("active");
  676. $.get(ao_root + "system/disk/diskmg/mount?dev=" + diskInfo[0] +
  677. "&format=" + diskInfo[2] + "&mnt=" + diskInfo[1] + "&umount=true",
  678. function(data){
  679. initData();
  680. $("#loaderUI").removeClass("active");
  681. }
  682. );
  683. }
  684. }
  685. function mountThisDev(object){
  686. if (object != null){
  687. $(".mountpt.selected").removeClass("selected");
  688. $(object).addClass("selected");
  689. }
  690. var selectedMpt = $(".mountpt.selected");
  691. var mountPoint = selectedMpt.text().trim();
  692. if (selectedMpt.hasClass("userdefine")){
  693. mountPoint = $("#userDefinedMountPoint").val();
  694. }
  695. $("#loaderUI").addClass("active");
  696. $("#mountOptions").fadeOut("fast");
  697. $(".functMenuDimmer").fadeOut("fast");
  698. var diskInfo = $(".focusedPart").attr("metadata");
  699. diskInfo = ao_module_utils.attrToObject(diskInfo);
  700. $.get(ao_root + "system/disk/diskmg/mount?dev=" + diskInfo[0] +
  701. "&format=" + diskInfo[2] + "&mnt=" + mountPoint, function(data){
  702. if (data.error != null){
  703. $("#loaderUI").removeClass("active");
  704. alert(data.error);
  705. return;
  706. }
  707. initData();
  708. $("#loaderUI").removeClass("active");
  709. });
  710. }
  711. // ── Data fetch ───────────────────────────────────────────────────
  712. function initData(){
  713. $.when(
  714. $.get(ao_root + "system/disk/diskmg/view"),
  715. $.get(ao_root + "system/disk/diskmg/view?partition=true")
  716. ).done(function(viewResp, partResp){
  717. if (mode === "windows"){
  718. processWindowsData(viewResp[0], partResp[0]);
  719. } else {
  720. processLinuxData(viewResp[0], partResp[0]);
  721. }
  722. });
  723. }
  724. function processWindowsData(viewData, partData){
  725. var volMap = {};
  726. if (!viewData.error){
  727. for (var i = 0; i < viewData.length; i++){
  728. var d = viewData[i];
  729. /* view API returns "C:\" but partition API returns "C:" — normalise */
  730. var volKey = String(d[0]).replace(/\\+$/, '');
  731. volMap[volKey] = { free: d[5], total: d[6] };
  732. }
  733. }
  734. var disks = {};
  735. for (var i = 0; i < partData.length; i++){
  736. var p = partData[i];
  737. var diskID = p[0].replace(/\\+.+\\/, "");
  738. if (disks[diskID] === undefined){
  739. disks[diskID] = {
  740. partitionsTotalSize: p[14],
  741. partitionNames: [p[16]],
  742. partitionID: [p[9]],
  743. partitionVolume: [p[14]],
  744. Type: [p[5]],
  745. Mounted: [p[4] === "True"],
  746. Format: [p[12]]
  747. };
  748. } else {
  749. disks[diskID].partitionsTotalSize = parseInt(disks[diskID].partitionsTotalSize) + parseInt(p[14]);
  750. disks[diskID].partitionVolume.push(p[14]);
  751. disks[diskID].partitionNames.push(p[16]);
  752. disks[diskID].partitionID.push(p[9]);
  753. disks[diskID].Type.push(p[5]);
  754. disks[diskID].Format.push(p[12]);
  755. disks[diskID].Mounted.push(p[4] === "True");
  756. }
  757. }
  758. diskInformation = disks;
  759. volumeData = volMap;
  760. buildSidebar();
  761. }
  762. function processLinuxData(viewData, partData){
  763. var usageMap = {};
  764. if (!viewData.error && viewData[2]){
  765. for (var i = 0; i < viewData[2].length; i++){
  766. var row = viewData[2][i];
  767. usageMap[row[5]] = { usedPct: parseInt((row[4] || "0%").replace("%","")) };
  768. }
  769. }
  770. var disks = {};
  771. var diskInfo = partData[0]["blockdevices"];
  772. for (var i = 0; i < diskInfo.length; i++){
  773. var thisDisk = diskInfo[i];
  774. var diskID = thisDisk["name"];
  775. if (thisDisk["children"] === undefined || thisDisk["children"] === null){
  776. var sz = thisDisk["size"] || 0;
  777. disks[diskID] = {
  778. partitionsTotalSize: sz,
  779. partitionNames: [""],
  780. partitionID: [thisDisk["name"] || "✖"],
  781. partitionVolume: [sz],
  782. Type: [thisDisk["type"]],
  783. Mounted: [thisDisk["mountpoint"] !== null],
  784. Format: ["raw"]
  785. };
  786. continue;
  787. }
  788. for (var j = 0; j < thisDisk["children"].length; j++){
  789. var part = thisDisk["children"][j];
  790. var fmts = partData[1]["blockdevices"][i]["children"][j];
  791. if (disks[diskID] === undefined){
  792. disks[diskID] = {
  793. partitionsTotalSize: part["size"],
  794. partitionNames: [part["mountpoint"]],
  795. partitionID: [part["name"]],
  796. partitionVolume: [part["size"]],
  797. Type: [part["type"]],
  798. Mounted: [part["mountpoint"] != ""],
  799. Format: [fmts["fstype"]]
  800. };
  801. } else {
  802. disks[diskID].partitionsTotalSize = parseInt(disks[diskID].partitionsTotalSize) + parseInt(part["size"]);
  803. disks[diskID].partitionVolume.push(part["size"]);
  804. disks[diskID].partitionNames.push(part["mountpoint"]);
  805. disks[diskID].partitionID.push(part["name"]);
  806. disks[diskID].Type.push(part["type"]);
  807. disks[diskID].Format.push(fmts["fstype"]);
  808. disks[diskID].Mounted.push(part["mountpoint"] !== "");
  809. }
  810. }
  811. }
  812. diskInformation = disks;
  813. volumeData = usageMap;
  814. buildSidebar();
  815. }
  816. // ── Sidebar ──────────────────────────────────────────────────────
  817. function buildSidebar(){
  818. var disks = diskInformation;
  819. var keys = Object.keys(disks).sort();
  820. $("#sidebarList").html("");
  821. for (var i = 0; i < keys.length; i++){
  822. var key = keys[i];
  823. var di = disks[key];
  824. var total = bytesToSize(parseInt(di.partitionsTotalSize));
  825. var typeShort = (di.Type[0] || "disk").split(" ")[0];
  826. var allOn = di.Mounted.every(function(m){ return m === true; });
  827. var allOff = di.Mounted.every(function(m){ return m === false; });
  828. var statusLabel = allOn ? appLocale.getString("diskmg/mounted", "Mounted") : allOff ? appLocale.getString("diskmg/not-mounted-s", "Not mounted") : appLocale.getString("diskmg/partial", "Partial");
  829. (function(k){
  830. var itemHtml =
  831. "<div class='sidebar-item' data-diskkey='" + k + "' onclick='selectDisk(\"" + k + "\")'>" +
  832. "<img class='sidebar-item-icon' src='../../img/system/drive.svg' alt=''>" +
  833. "<div class='sidebar-item-text'>" +
  834. "<div class='sidebar-item-name'>" + k + "</div>" +
  835. "<div class='sidebar-item-sub'>" + total + " &middot; " + statusLabel + "</div>" +
  836. "</div>" +
  837. "</div>";
  838. $("#sidebarList").append(itemHtml);
  839. })(key);
  840. }
  841. /* restore or auto-select first disk */
  842. if (selectedDiskKey && disks[selectedDiskKey]){
  843. selectDisk(selectedDiskKey);
  844. } else if (keys.length > 0){
  845. selectDisk(keys[0]);
  846. }
  847. }
  848. function selectDisk(key){
  849. selectedDiskKey = key;
  850. $(".sidebar-item").removeClass("active");
  851. $(".sidebar-item[data-diskkey='" + key + "']").addClass("active");
  852. renderDiskDetail(key);
  853. }
  854. // ── Detail view ──────────────────────────────────────────────────
  855. function renderDiskDetail(key){
  856. var di = diskInformation[key];
  857. var total = parseInt(di.partitionsTotalSize);
  858. var allOn = di.Mounted.every(function(m){ return m === true; });
  859. var allOff = di.Mounted.every(function(m){ return m === false; });
  860. var mountLabel = allOn ? appLocale.getString("diskmg/mounted", "Mounted") : allOff ? appLocale.getString("diskmg/not-mounted", "Not Mounted") : appLocale.getString("diskmg/partially", "Partially Mounted");
  861. var typeShort = (di.Type[0] || "Disk").split(" ")[0];
  862. /* ── Colored storage bar ── */
  863. var barSegs = "";
  864. var legendHtml = "";
  865. for (var k = 0; k < di.partitionID.length; k++){
  866. var pvol = parseInt(di.partitionVolume[k]);
  867. var pct = (total > 0) ? (pvol / total * 100).toFixed(3) : 0;
  868. var color = (pvol === 0) ? "#e5e5ea" : SEG_COLORS[k % SEG_COLORS.length];
  869. var partLabel = di.partitionID[k] || appLocale.getString("diskmg/unallocated", "Unallocated");
  870. barSegs += "<div class='storage-bar-seg' style='width:" + pct + "%;background:" + color + ";'></div>";
  871. legendHtml += "<div class='legend-item'>" +
  872. "<div class='legend-dot' style='background:" + color + ";'></div>" +
  873. partLabel + " (" + bytesToSize(pvol) + ")" +
  874. "</div>";
  875. }
  876. /* ── Partition table rows ── */
  877. var tableRows = "";
  878. for (var k = 0; k < di.partitionID.length; k++){
  879. var pvol = parseInt(di.partitionVolume[k]);
  880. var pname = di.partitionNames[k];
  881. var pid = di.partitionID[k];
  882. var pfmt = di.Format[k] || "N/A";
  883. var pmnt = di.Mounted[k];
  884. var color = (pvol === 0) ? "#aeaeb2" : SEG_COLORS[k % SEG_COLORS.length];
  885. var dotCls = "dot-mounted";
  886. var statusLabel = appLocale.getString("diskmg/mounted", "Mounted");
  887. var isUnalloc = false;
  888. if (pvol === 0){
  889. dotCls = "dot-unalloc";
  890. statusLabel = appLocale.getString("diskmg/unallocated", "Unallocated");
  891. pname = "—";
  892. pfmt = "—";
  893. isUnalloc = true;
  894. } else if (!pmnt){
  895. dotCls = "dot-unmounted";
  896. statusLabel = appLocale.getString("diskmg/not-mounted", "Not Mounted");
  897. if (!pname || pname === ""){
  898. pname = (mode === "linux" && di.Format[k] === "raw") ? appLocale.getString("diskmg/unallocated", "Unallocated") : "—";
  899. }
  900. } else {
  901. if (!pname || pname === ""){
  902. pname = (mode === "windows") ? appLocale.getString("diskmg/local-disk", "Local Disk") : "—";
  903. }
  904. }
  905. /* usage bar */
  906. var usedPct = 0;
  907. if (!isUnalloc && pmnt){
  908. if (mode === "linux" && volumeData && volumeData[di.partitionNames[k]]){
  909. usedPct = volumeData[di.partitionNames[k]].usedPct || 0;
  910. } else if (mode === "windows" && volumeData && volumeData[pid]){
  911. var vd = volumeData[pid];
  912. if (vd && vd.total > 0) usedPct = Math.round((1 - vd.free / vd.total) * 100);
  913. }
  914. }
  915. var usedDisp = (!isUnalloc && pmnt) ? usedPct + "%" : "—";
  916. var barColor = (usedPct >= 90) ? "#ff3b30" : color;
  917. var miniBar = (!isUnalloc && pmnt)
  918. ? "<div class='mini-bar'><div class='mini-bar-fill' style='width:" + usedPct + "%;background:" + barColor + ";'></div></div>"
  919. : "";
  920. var meta = ao_module_utils.objectToAttr([pid, pname, pfmt, pmnt, di.Type[k], pvol]);
  921. tableRows +=
  922. "<tr class='part-row' metadata='" + meta + "'>" +
  923. "<td><span class='part-color-dot' style='background:" + color + ";'></span>" + pid + "</td>" +
  924. "<td>" + (pname !== "—" ? pname : "<span style='color:#aeaeb2'>—</span>") + "</td>" +
  925. "<td>" + pfmt + "</td>" +
  926. "<td>" + bytesToSize(pvol) + "</td>" +
  927. "<td><span class='status-badge'><span class='status-dot " + dotCls + "'></span>" + statusLabel + "</span></td>" +
  928. "<td>" + usedDisp + miniBar + "</td>" +
  929. "</tr>";
  930. }
  931. var mountColLabel = (mode === "windows") ? appLocale.getString("diskmg/col-name", "Name") : appLocale.getString("diskmg/col-mountpt", "Mount Point");
  932. var html =
  933. "<div class='disk-header-card'>" +
  934. "<img class='disk-header-icon' src='../../img/system/drive.svg' alt='disk'>" +
  935. "<div class='disk-header-info'>" +
  936. "<div class='disk-header-name'>" + key + "</div>" +
  937. "<div class='disk-header-meta'>" + typeShort + " &middot; " + mountLabel + "</div>" +
  938. "<div class='storage-bar'>" + barSegs + "</div>" +
  939. "<div class='storage-bar-legend'>" + legendHtml + "</div>" +
  940. "<div class='disk-header-stats'>" +
  941. "<div><div class='stat-label'>" + appLocale.getString("diskmg/capacity", "Capacity") + "</div><div class='stat-value'>" + bytesToSize(total) + "</div></div>" +
  942. "<div><div class='stat-label'>" + appLocale.getString("diskmg/partitions", "Partitions") + "</div><div class='stat-value'>" + di.partitionID.length + "</div></div>" +
  943. "</div>" +
  944. "</div>" +
  945. "</div>" +
  946. "<div class='partition-card'>" +
  947. "<div class='partition-card-header'>" + appLocale.getString("diskmg/parts-volumes", "Partitions &amp; Volumes") + "</div>" +
  948. "<table class='partition-table'>" +
  949. "<thead><tr>" +
  950. "<th>" + appLocale.getString("diskmg/col-device", "Device") + "</th>" +
  951. "<th>" + mountColLabel + "</th>" +
  952. "<th>" + appLocale.getString("diskmg/format-label-col", "Format") + "</th>" +
  953. "<th>" + appLocale.getString("diskmg/col-size", "Size") + "</th>" +
  954. "<th>" + appLocale.getString("diskmg/col-status", "Status") + "</th>" +
  955. "<th>" + appLocale.getString("diskmg/col-usage", "Usage") + "</th>" +
  956. "</tr></thead>" +
  957. "<tbody>" + tableRows + "</tbody>" +
  958. "</table>" +
  959. "</div>";
  960. $("#detailPanel").html(html);
  961. attachPartitionEvents();
  962. }
  963. // ── Partition row events ─────────────────────────────────────────
  964. function attachPartitionEvents(){
  965. $(".part-row").on("click", function(){
  966. $(".focusedPart").removeClass("focusedPart");
  967. $(this).addClass("focusedPart");
  968. });
  969. $(".part-row").contextmenu(function(e){
  970. if (mode === "windows") return true;
  971. $(".focusedPart").removeClass("focusedPart");
  972. $(this).addClass("focusedPart");
  973. var px = e.clientX;
  974. var py = e.clientY;
  975. var menuH = $("#rightClickMenu").outerHeight() || 80;
  976. var top = py + 4;
  977. if (top + menuH > window.innerHeight) top = py - menuH - 4;
  978. if (typeof ao_module_virtualDesktop !== "undefined" && ao_module_virtualDesktop) top -= 50;
  979. $("#rightClickMenu").css({ left: px + "px", top: top + "px" }).show();
  980. var info = ao_module_utils.attrToObject($(this).attr("metadata"));
  981. var isMounted = (info[3] === true || info[3] === "true");
  982. if (isMounted){
  983. var isSystem = (info[1] === "/" || info[1] === "/boot");
  984. if (isSystem){
  985. $("#mtbtn").addClass("disabled");
  986. $("#formatDisk").addClass("disabled");
  987. } else {
  988. $("#mtbtn").removeClass("disabled");
  989. $("#formatDisk").removeClass("disabled");
  990. }
  991. $("#mtbtn").html('<i class="eject icon"></i> ' + appLocale.getString("diskmg/unmount", "Unmount"));
  992. } else {
  993. $("#mtbtn").html('<i class="plug icon"></i> ' + appLocale.getString("diskmg/mount", "Mount")).removeClass("disabled");
  994. $("#formatDisk").removeClass("disabled");
  995. }
  996. return false;
  997. });
  998. }
  999. $(document).on("click", function(e){
  1000. if (!$(e.target).closest("#rightClickMenu").length) hideRightclickMenu();
  1001. });
  1002. // ── Theme ────────────────────────────────────────────────────────
  1003. function applyTheme(theme){
  1004. document.body.classList.toggle("dark", theme === "dark");
  1005. }
  1006. if (typeof ao_module_getSystemThemeColor === "function"){
  1007. ao_module_getSystemThemeColor(function(c){
  1008. applyTheme(c === "whiteTheme" ? "light" : "dark");
  1009. });
  1010. }
  1011. window.desktopThemeChanged = function(theme){
  1012. applyTheme(theme);
  1013. };
  1014. </script>
  1015. </body>
  1016. </html>