quota.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <html>
  2. <head>
  3. <title>Disk Quota</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../../script/semantic/semantic.min.css">
  7. <link rel="stylesheet" href="../disk/quota/script/Chart.min.css">
  8. <script type="text/javascript" src="../../../script/jquery.min.js"></script>
  9. <script type="text/javascript" src="../../../script/semantic/semantic.min.js"></script>
  10. <script src="../disk/quota/script/Chart.min.js"></script>
  11. <style>
  12. </style>
  13. </head>
  14. <body>
  15. <div class="ui container">
  16. <p>System Storage Space Quota</p>
  17. <h1 class="ui header">
  18. <span id="usedSpace">Loading</span>
  19. <div class="sub header">Total used of <span id="remaining">N/A</span></div>
  20. </h1>
  21. <div class="ui divider"></div>
  22. <p id="loadWarning"><i class="ui loading spinner icon"></i> File Category Graph might take some time to load...</p>
  23. <div id="canvas-holder">
  24. <canvas id="chart-area"></canvas>
  25. </div>
  26. <br>
  27. <div class="ui divider"></div>
  28. </div>
  29. <script>
  30. var c = document.getElementById("chart-area");
  31. var ctx = c.getContext("2d");
  32. var accurateUsedSpace = 0;
  33. initQuotaInfo();
  34. initFileTypeDistribution();
  35. function initQuotaInfo(){
  36. //This will initalize the accumulative update quota information (Not accuratem, just estimation)
  37. $.get("../../../system/disk/quota/quotaInfo",function(data){
  38. if (data.error !== undefined){
  39. }else{
  40. var used = ao_module_utils.formatBytes(data.Used);
  41. var total = "Unlimited";
  42. if (data.Total > 0){
  43. total = ao_module_utils.formatBytes(data.Total);
  44. }else if (data.Total == 0){
  45. total = "Read Only";
  46. }
  47. $("#usedSpace").html(used + ` <i style="color: #dedede;" class="tiny info circle icon" title="Cumulative Estimation"></i>`);
  48. $("#remaining").text(total);
  49. }
  50. });
  51. }
  52. function initFileTypeDistribution(){
  53. var dynamicColors = function() {
  54. var r = Math.floor(Math.random() * 180 + 75);
  55. var g = Math.floor(Math.random() * 180 + 75);
  56. var b = Math.floor(Math.random() * 180 + 75);
  57. return "rgb(" + r + "," + g + "," + b + ")";
  58. };
  59. $.get("../../../system/disk/quota/quotaDist",function(list){
  60. accurateUsedSpace = 0;
  61. if (list == null){
  62. return;
  63. }
  64. //Create the corret data structure for the pie chart
  65. data = {};
  66. var dataset = [];
  67. var labels = [];
  68. var colors = [];
  69. var stopping = list.length;
  70. for (var i = 0; i < stopping; i++){
  71. labels.push(list[i].Mime);
  72. dataset.push(list[i].Size);
  73. accurateUsedSpace += list[i].Size;
  74. colors.push(dynamicColors());
  75. }
  76. //Update the actual used spaces
  77. var actualSpaceUsed = ao_module_utils.formatBytes(accurateUsedSpace);
  78. $("#usedSpace").text(actualSpaceUsed);
  79. data["datasets"] = [{
  80. data: dataset,
  81. backgroundColor: colors
  82. }];
  83. data["labels"] = labels;
  84. var fileDistChart = new Chart(ctx, {
  85. type: 'doughnut',
  86. data: data,
  87. options: {
  88. responsive: true,
  89. tooltips: {
  90. callbacks: {
  91. label: function(tooltipItem, data){
  92. var partitionsize = (data.datasets[0].data[tooltipItem.index]);
  93. var labeltext = data.labels[tooltipItem.index];
  94. var label = labeltext + ": " +ao_module_utils.formatBytes(partitionsize, 2);
  95. return label;
  96. }
  97. },
  98. },
  99. legend: {
  100. position: 'right',
  101. labels: {
  102. boxWidth: 20,
  103. padding: 20
  104. }
  105. }
  106. }
  107. });
  108. $("#loadWarning").hide();
  109. });
  110. }
  111. </script>
  112. </body>
  113. </html>