diskprop.html 12 KB

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