FilePartsWidget.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. define([
  18. "dojo/_base/declare",
  19. "dojo/_base/array",
  20. "dojo/store/Memory",
  21. "dojo/store/Observable",
  22. "dijit/registry",
  23. "dgrid/OnDemandGrid",
  24. "dgrid/Keyboard",
  25. "dgrid/Selection",
  26. "dgrid/selector",
  27. "dgrid/extensions/ColumnResizer",
  28. "dgrid/extensions/DijitRegistry",
  29. "hpcc/_Widget",
  30. "dojo/text!../templates/FilePartsWidget.html"
  31. ],
  32. function (declare, array, Memory, Observable,
  33. registry,
  34. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  35. _Widget,
  36. template) {
  37. return declare("FilePartsWidget", [_Widget], {
  38. templateString: template,
  39. baseClass: "FilePartsWidget",
  40. filePartsGrid: null,
  41. dataStore: null,
  42. lastSelection: null,
  43. buildRendering: function (args) {
  44. this.inherited(arguments);
  45. },
  46. postCreate: function (args) {
  47. this.inherited(arguments);
  48. },
  49. startup: function (args) {
  50. this.inherited(arguments);
  51. var store = new Memory({
  52. idProperty: "Id",
  53. data: []
  54. });
  55. this.filePartsStore = Observable(store);
  56. this.filePartsGrid = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry])({
  57. allowSelectAll: true,
  58. columns: {
  59. Id: { label: "Part", width: 40 },
  60. Ip: { label: "IP" },
  61. Partsize: { label: "Size", width: 120 },
  62. ActualSize: { label: "Actual Size", width: 120 }
  63. },
  64. store: this.filePartsStore
  65. }, this.id + "FilePartsGrid");
  66. this.filePartsGrid.startup();
  67. },
  68. resize: function (args) {
  69. this.inherited(arguments);
  70. this.filePartsGrid.resize();
  71. },
  72. layout: function (args) {
  73. this.inherited(arguments);
  74. },
  75. // Plugin wrapper ---
  76. init: function (params) {
  77. if (this.inherited(arguments))
  78. return;
  79. this.filePartsStore.setData(params.fileParts);
  80. this.filePartsGrid.set("query", {
  81. Copy: "1"
  82. });
  83. }
  84. });
  85. });