diskprop.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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(data.error);
  176. $("#hierarchy").text("Unknown");
  177. $("#usedSpaceInBytes").text("Not Available");
  178. $("#usableSpaceInBytes").text("Not Available");
  179. $("#totalSpaceInBytes").text("Not Available");
  180. }else{
  181. $("#usedSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Used));
  182. $("#usedSpaceInHumanReadableFormat").text(bytesToSize(data.Used));
  183. $("#usableSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Avilable));
  184. $("#usableSpaceInHumanReadableFormat").text(bytesToSize(data.Avilable));
  185. $("#totalSpaceInBytes").text(new Intl.NumberFormat('en-US').format(data.Total));
  186. $("#totalSpaceInHumanReadableFormat").text(bytesToSize(data.Total));
  187. $("#phydisk").text(data.PhysicalDevice + "/");
  188. var s = data.MountingHierarchy;
  189. s = s[0].toUpperCase() + s.slice(1);
  190. $("#hierarchy").text(applocale.getString("hierarchy/" + s, s));
  191. $("#totalUsedSpace").css("width", (data.Used / data.Total) * 100 + "%");
  192. }
  193. getFileProp(files[0], function(folderdata){
  194. //User Used Space
  195. $("#usedVirtualSpaceInByte").text(new Intl.NumberFormat('en-US').format(folderdata.Filesize));
  196. $("#usedVirtualSpaceInHumanReadableFormat").text(bytesToSize(folderdata.Filesize));
  197. if (data.Total != undefined){
  198. $("#userUsedSpace").css("width", (folderdata.Filesize / data.Total) * 100 + "%");
  199. }else{
  200. //Error when reading disk size. Just make it full width
  201. $("#userUsedSpace").css("width", "100%");
  202. }
  203. });
  204. });
  205. }
  206. }
  207. function bytesToSize(bytes) {
  208. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
  209. if (bytes == 0) return '0 Byte';
  210. var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
  211. return (bytes / Math.pow(1024, i) * 100 / 100).toFixed(1) + ' ' + sizes[i];
  212. }
  213. function getDiskProp(vpath, callback){
  214. $.ajax({
  215. url: "../../system/disk/space/resolve",
  216. data: {path: vpath},
  217. method: "POST",
  218. success: function(data){
  219. diskInfo = data;
  220. callback(data);
  221. }
  222. })
  223. }
  224. function getFileProp(vpath, callback){
  225. $.ajax({
  226. url: "../../system/file_system/getProperties",
  227. data: {path: vpath},
  228. method: "POST",
  229. success: function(data){
  230. callback(data);
  231. fileInfo = data;
  232. //Initialize system theme
  233. loadPreference("file_explorer/theme",function(data){
  234. if (data.error === undefined){
  235. if (data == "darkTheme"){
  236. toggleDarkTheme();
  237. }else{
  238. //White theme. Do nothing
  239. }
  240. }
  241. });
  242. }
  243. })
  244. }
  245. function loadPreference(key, callback){
  246. $.get("../../system/file_system/preference?key=" + key,function(data){
  247. callback(data);
  248. });
  249. }
  250. function toggleDarkTheme(){
  251. $("body").css({
  252. "background-color":"#242330",
  253. "color":"white",
  254. });
  255. $("#filePropertiesWindow td,.header,p,div").css({
  256. "color":"white",
  257. });
  258. }
  259. </script>
  260. </body>
  261. </html>