diskprop.html 9.8 KB

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