DiskUsageWidget.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/lang",
  19. "dojo/i18n",
  20. "dojo/i18n!./nls/hpcc",
  21. "dojo/on",
  22. "dgrid/OnDemandGrid",
  23. "dgrid/Keyboard",
  24. "dgrid/Selection",
  25. "dgrid/selector",
  26. "dgrid/extensions/ColumnResizer",
  27. "dgrid/extensions/DijitRegistry",
  28. "hpcc/WsDfu",
  29. "hpcc/ESPUtil",
  30. "hpcc/FilterDropDownWidget",
  31. "dojo/text!../templates/DiskUsageWidget.html"
  32. ], function (declare, lang, i18n, nlsHPCC, on,
  33. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  34. WsDfu, ESPUtil, FilterDropDownWidget,
  35. template) {
  36. return declare("DiskUsageWidget", [_Widget, ESPUtil.FormHelper], {
  37. templateString: template,
  38. baseClass: "DiskUsageWidget",
  39. i18n: nlsHPCC,
  40. resize: function (args) {
  41. this.inherited(arguments);
  42. this.widget.BorderContainer.resize();
  43. },
  44. getTitle: function () {
  45. return this.i18n.title_DiskUsage;
  46. },
  47. // Hitched actions ---
  48. _onRefresh: function (event) {
  49. this.refreshGrid();
  50. },
  51. // Implementation ---
  52. init: function (params) {
  53. if (this.inherited(arguments))
  54. return;
  55. this.initDiskUsageGrid();
  56. this.widget.Filter.refreshState();
  57. var context = this;
  58. this.widget.Filter.on("clear", function (evt) {
  59. context.refreshGrid();
  60. });
  61. this.widget.Filter.on("apply", function (evt) {
  62. context.refreshGrid();
  63. });
  64. },
  65. initDiskUsageGrid: function () {
  66. var store = new WsDfu.CreateDiskUsageStore();
  67. this.diskUsageGrid = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  68. allowSelectAll: true,
  69. deselectOnRefresh: false,
  70. store: store,
  71. query: this.getFilter(),
  72. columns: {
  73. Name: { label: this.i18n.Grouping, width: 90, sortable: true },
  74. NumOfFiles: { label: this.i18n.FileCounts, width: 90, sortable: true },
  75. TotalSize: { label: this.i18n.TotalSize, width: 90, sortable: true },
  76. LargestFile: { label: this.i18n.LargestFile, sortable: true },
  77. LargestSize: { label: this.i18n.LargestSize, width: 90, sortable: true },
  78. SmallestFile: { label: this.i18n.SmallestFile, sortable: true },
  79. SmallestSize: { label: this.i18n.SmallestSize, width: 90, sortable: true },
  80. NumOfFilesUnknown: { label: this.i18n.FilesWithUnknownSize, width: 90, sortable: true }
  81. }
  82. }, this.id + "DiskUsageGrid");
  83. },
  84. getFilter: function () {
  85. var retVal = this.widget.Filter.toObject();
  86. lang.mixin(retVal, {
  87. StartDate: this.getISOString("FromDate", "FromTime"),
  88. EndDate: this.getISOString("ToDate", "ToTime")
  89. });
  90. return retVal;
  91. },
  92. refreshGrid: function (clearSelection) {
  93. this.diskUsageGrid.set("query", this.getFilter());
  94. if (clearSelection) {
  95. this.diskUsageGrid.clearSelection();
  96. }
  97. }
  98. });
  99. });