diskprop.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title locale="title/title">File Properties</title>
  5. <meta name="mobile-web-app-capable" content="yes">
  6. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  7. <meta charset="UTF-8">
  8. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  9. <script src="../../script/jquery.min.js"></script>
  10. <script src="../../script/semantic/semantic.min.js"></script>
  11. <script type="text/javascript" src="../../script/ao_module.js"></script>
  12. <script type="text/javascript" src="../../script/applocale.js"></script>
  13. <link rel="stylesheet" href="../../script/ao.css">
  14. <style>
  15. .hidden{
  16. display:none;
  17. }
  18. .disabled{
  19. opacity: 0.5;
  20. pointer-events: none;
  21. }
  22. .colorblock{
  23. width: 20px;
  24. height: 20px;
  25. display: inline-block;
  26. vertical-align: bottom;
  27. margin-right: 12px;
  28. }
  29. .blue.colorblock{
  30. background-color: #52bdf2;
  31. }
  32. .grey.colorblock{
  33. background-color: #b9b9b9;
  34. }
  35. .yellow.colorblock{
  36. background-color: #e5e75c;
  37. }
  38. .ui.table tr td{
  39. border-top: 0px solid transparent !important;
  40. }
  41. .overlap.bar{
  42. position: absolute !important;
  43. top:0px;
  44. left: 0px;
  45. }
  46. .smallerFont{
  47. font-size: 98%;
  48. }
  49. /* Theme overwrite */
  50. body{
  51. background-color: var(--body_background);
  52. color: var(--text_color);
  53. }
  54. input{
  55. background-color: var(--body_background_secondary) !important;
  56. color: var(--text_color_secondary) !important;
  57. border: 1px solid var(--body_background_active) !important;
  58. }
  59. button{
  60. background-color: var(--body_background_active) !important;
  61. color: var(--text_color) !important;
  62. }
  63. button:hover{
  64. opacity: 0.8;
  65. }
  66. td,.header,p,div,span{
  67. color: var(--text_color) !important;
  68. }
  69. </style>
  70. </head>
  71. <body class="whiteTheme">
  72. <br>
  73. <div class="ui container">
  74. <h3 class="ui header">
  75. <span locale="title/title">Virtual Disk Properties</span>
  76. <div class="sub header" locale="title/desc">Show information about vroot mount points</div>
  77. </h3>
  78. <div class="ui divider"></div>
  79. <div class="ui container">
  80. <div class="ui grid">
  81. <div class="three wide right aligned column" style="text-align: center; padding: 0px;">
  82. <img class="ui image" style="position: absolute; top: 0px; left: calc(50% - 25px); max-width: 50px; pointer-events: none;" src="../../img/system/drive-virtual.svg">
  83. </div>
  84. <div class="thirteen wide column" style="padding: 0px; padding-top: 0.8em; padding-left: 1em;">
  85. <div class="ui fluid small input">
  86. <input id="vrootName" type="text" placeholder="" readonly="true">
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <br>
  92. <div class="ui divider" style="margin-top: 8px; margin-bottom: 8px;"></div>
  93. <table class="ui very basic collapsing compact unstackable table" style="vertical-align: middle;">
  94. <tbody>
  95. <tr>
  96. <td locale="diskinfo/physical">
  97. Physical Disk:
  98. </td>
  99. <td id="phydisk">
  100. </td>
  101. </tr>
  102. <tr>
  103. <td locale="diskinfo/hierarchy">
  104. Hierarchy (Format):
  105. </td>
  106. <td id="hierarchy">
  107. </td>
  108. </tr>
  109. </table>
  110. <div class="ui divider" style="margin-top: 8px; margin-bottom: 8px;"></div>
  111. <table class="ui very basic collapsing compact unstackable table" style="vertical-align: middle; font-size:90%;">
  112. <tbody>
  113. <tr>
  114. <td>
  115. <div class="blue colorblock"></div><span locale="spaceinfo/totalUsed">Total Used Space:</span>
  116. </td>
  117. <td>
  118. <span id="usedSpaceInBytes" class="smallerFont"></span> <span locale="unit/bytes">Bytes</span>
  119. </td>
  120. <td>
  121. <span id="usedSpaceInHumanReadableFormat" class="smallerFont"></span>
  122. </td>
  123. </tr>
  124. <tr>
  125. <td>
  126. <div class="yellow colorblock"></div><span locale="spaceinfo/userUsed">User Used Space:</span>
  127. </td>
  128. <td>
  129. <span id="usedVirtualSpaceInByte" class="smallerFont"><i class="ui spinner loading icon"></i></span> <span locale="unit/bytes">Bytes</span>
  130. </td>
  131. <td>
  132. <span id="usedVirtualSpaceInHumanReadableFormat" class="smallerFont"></span>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>
  137. <div class="grey colorblock"></div><span locale="spaceinfo/Usable">Usable Space:</span>
  138. </td>
  139. <td>
  140. <span id="usableSpaceInBytes" class="smallerFont"></span> <span locale="unit/bytes">Bytes</span>
  141. </td>
  142. <td>
  143. <span id="usableSpaceInHumanReadableFormat" class="smallerFont"></span>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td>
  148. <div class="transparent colorblock"></div><span locale="spaceinfo/Capacity">Capacity:</span>
  149. </td>
  150. <td>
  151. <span id="totalSpaceInBytes" class="smallerFont"></span> <span locale="unit/bytes">Bytes</span>
  152. </td>
  153. <td>
  154. <span id="totalSpaceInHumanReadableFormat" class="smallerFont"></span>
  155. </td>
  156. </tr>
  157. </table>
  158. <div class="ui small progress">
  159. <div class="overlap bar" style="width: 100%; background-color: #b9b9b9;">
  160. <div class="progress"></div>
  161. </div>
  162. <div id="totalUsedSpace" class="overlap bar" style="min-width: 5px; width: 100%; background-color: #52bdf2;">
  163. <div class="progress"></div>
  164. </div>
  165. <div id="userUsedSpace" class="overlap bar" style="min-width: 5px; width: 100%; background-color: #e5e75c;">
  166. <div class="progress"></div>
  167. </div>
  168. </div>
  169. <div class="ui divider" style="margin-top: 8px; margin-bottom: 8px;"></div>
  170. <br>
  171. <button class="ui right floated button" onclick="ao_module_close();" locale="button/close">Close</button>
  172. <br>
  173. </div>
  174. <br><br>
  175. <script>
  176. //Initiate the view model
  177. var files = ao_module_loadInputFiles();
  178. var fileProperties = [];
  179. var fileInfo = {};
  180. var diskInfo = {};
  181. try{
  182. applocale.init("../locale/disk_properties.json", function(){
  183. applocale.translate();
  184. init();
  185. });
  186. }catch(ex){
  187. init();
  188. }
  189. //Initialize system theme
  190. loadPreference("file_explorer/theme",function(data){
  191. if (data.error === undefined){
  192. if (data == "darkTheme"){
  193. $("body").addClass("darkTheme");
  194. }else{
  195. $("body").addClass("whiteTheme");
  196. }
  197. }
  198. });
  199. function init(){
  200. //There are something to load. Load the vroot properties
  201. if (window.location.hash.length > 0 && typeof(files) != null){
  202. var rootName = files[0].split("/")[0];
  203. var NALocaleString = applocale.getString("error/na", "[Not Available]");
  204. $("#vrootName").val(rootName + "/");
  205. getDiskProp(files[0], function(data){
  206. if (data.error !== undefined){
  207. $("#phydisk").text("Unknown");
  208. $("#hierarchy").text("Unknown");
  209. $("#usedSpaceInBytes").text(NALocaleString);
  210. $("#usableSpaceInBytes").text(NALocaleString);
  211. $("#totalSpaceInBytes").text(NALocaleString);
  212. console.log(data.error);
  213. }else{
  214. if (data.Used == 0){
  215. //Network drive
  216. $("#usedSpaceInBytes").text(NALocaleString);
  217. $("#usedSpaceInHumanReadableFormat").text("");
  218. }else{
  219. $("#usedSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Used));
  220. $("#usedSpaceInHumanReadableFormat").text(bytesToSize(data.Used));
  221. }
  222. $("#usableSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Available));
  223. $("#usableSpaceInHumanReadableFormat").text(bytesToSize(data.Available));
  224. $("#totalSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Total));
  225. $("#totalSpaceInHumanReadableFormat").text(bytesToSize(data.Total));
  226. $("#phydisk").text(data.PhysicalDevice + "/");
  227. var s = data.MountingHierarchy;
  228. s = s[0].toUpperCase() + s.slice(1);
  229. $("#hierarchy").text(applocale.getString("hierarchy/" + s, s) + ` (${data.FileSystemType.toUpperCase()})`);
  230. $("#totalUsedSpace").css("width", (data.Used / data.Total) * 100 + "%");
  231. }
  232. getFileProp(files[0], function(folderdata){
  233. //User Used Space
  234. if (folderdata.Filesize >= 0){
  235. $("#usedVirtualSpaceInByte").text(new Intl.NumberFormat('en-US').format(folderdata.Filesize));
  236. $("#usedVirtualSpaceInHumanReadableFormat").text(bytesToSize(folderdata.Filesize));
  237. }else{
  238. $("#usedVirtualSpaceInByte").text(NALocaleString);
  239. $("#usedVirtualSpaceInHumanReadableFormat").text("");
  240. }
  241. if (diskInfo.Used == 0 && folderdata.Filesize >= 0){
  242. //Network or special drive. Use user space as usedSpace
  243. $("#usedSpaceInBytes").text(new Intl.NumberFormat('en-US').format(folderdata.Filesize));
  244. $("#usedSpaceInHumanReadableFormat").text(bytesToSize(folderdata.Filesize));
  245. }else if (diskInfo.Used == 0){
  246. $("#usedSpaceInBytes").text(NALocaleString);
  247. $("#usedSpaceInHumanReadableFormat").text("");
  248. }
  249. if (data.Total != undefined && data.Total > 0){
  250. $("#userUsedSpace").css("width", (folderdata.Filesize / data.Total) * 100 + "%");
  251. }else{
  252. //Error when reading disk size. Just make it full width
  253. $("#userUsedSpace").css("width", "100%");
  254. }
  255. });
  256. });
  257. }
  258. }
  259. function bytesToSize(bytes) {
  260. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
  261. if (bytes == 0) return '0 Byte';
  262. var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
  263. return (bytes / Math.pow(1024, i) * 100 / 100).toFixed(1) + ' ' + sizes[i];
  264. }
  265. function getDiskProp(vpath, callback){
  266. $.ajax({
  267. url: "../../system/disk/space/resolve",
  268. data: {path: vpath},
  269. method: "POST",
  270. success: function(data){
  271. diskInfo = data;
  272. callback(data);
  273. }
  274. })
  275. }
  276. function getFileProp(vpath, callback){
  277. $.ajax({
  278. url: "../../system/file_system/getProperties",
  279. data: {path: vpath},
  280. method: "POST",
  281. success: function(data){
  282. callback(data);
  283. fileInfo = data;
  284. }
  285. })
  286. }
  287. function loadPreference(key, callback){
  288. $.get("../../system/file_system/preference?key=" + key,function(data){
  289. callback(data);
  290. });
  291. }
  292. </script>
  293. </body>
  294. </html>