diskprop.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. Disk Hierarchy:
  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"></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: 50%; background-color: #52bdf2;">
  142. <div class="progress"></div>
  143. </div>
  144. <div id="userUsedSpace" class="overlap bar" style="min-width: 5px; width: 30%; 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.Avilable));
  185. $("#usableSpaceInHumanReadableFormat").text(bytesToSize(data.Avilable));
  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));
  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 (data.Total != undefined){
  204. $("#userUsedSpace").css("width", (folderdata.Filesize / data.Total) * 100 + "%");
  205. }else{
  206. //Error when reading disk size. Just make it full width
  207. $("#userUsedSpace").css("width", "100%");
  208. }
  209. });
  210. });
  211. }
  212. }
  213. function bytesToSize(bytes) {
  214. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
  215. if (bytes == 0) return '0 Byte';
  216. var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
  217. return (bytes / Math.pow(1024, i) * 100 / 100).toFixed(1) + ' ' + sizes[i];
  218. }
  219. function getDiskProp(vpath, callback){
  220. $.ajax({
  221. url: "../../system/disk/space/resolve",
  222. data: {path: vpath},
  223. method: "POST",
  224. success: function(data){
  225. diskInfo = data;
  226. callback(data);
  227. }
  228. })
  229. }
  230. function getFileProp(vpath, callback){
  231. $.ajax({
  232. url: "../../system/file_system/getProperties",
  233. data: {path: vpath},
  234. method: "POST",
  235. success: function(data){
  236. callback(data);
  237. fileInfo = data;
  238. //Initialize system theme
  239. loadPreference("file_explorer/theme",function(data){
  240. if (data.error === undefined){
  241. if (data == "darkTheme"){
  242. toggleDarkTheme();
  243. }else{
  244. //White theme. Do nothing
  245. }
  246. }
  247. });
  248. }
  249. })
  250. }
  251. function loadPreference(key, callback){
  252. $.get("../../system/file_system/preference?key=" + key,function(data){
  253. callback(data);
  254. });
  255. }
  256. function toggleDarkTheme(){
  257. $("body").css({
  258. "background-color":"#242330",
  259. "color":"white",
  260. });
  261. $("#filePropertiesWindow td,.header,p,div").css({
  262. "color":"white",
  263. });
  264. }
  265. </script>
  266. </body>
  267. </html>