FilePartsWidget.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/data/ObjectStore",
  22. "dijit/registry",
  23. "dijit/layout/_LayoutWidget",
  24. "dijit/_TemplatedMixin",
  25. "dijit/_WidgetsInTemplateMixin",
  26. "dojo/text!../templates/FilePartsWidget.html",
  27. "dojox/grid/DataGrid"
  28. ],
  29. function (declare, array, Memory, ObjectStore,
  30. registry, _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin,
  31. template) {
  32. return declare("FilePartsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  33. templateString: template,
  34. baseClass: "FilePartsWidget",
  35. filePartsGrid: null,
  36. dataStore: null,
  37. lastSelection: null,
  38. buildRendering: function (args) {
  39. this.inherited(arguments);
  40. },
  41. postCreate: function (args) {
  42. this.inherited(arguments);
  43. this.filePartsGrid = registry.byId(this.id + "FilePartsGrid");
  44. var context = this;
  45. this.filePartsGrid.setStructure([
  46. { name: "Number", field: "Id", width: 4 },
  47. { name: "IP", field: "Ip", width: 15 },
  48. { name: "Size", field: "Partsize", width: 12 },
  49. { name: "Actual Size", field: "ActualSize", width: 12 }
  50. ]);
  51. },
  52. startup: function (args) {
  53. this.inherited(arguments);
  54. },
  55. resize: function (args) {
  56. this.inherited(arguments);
  57. this.filePartsGrid.resize();
  58. },
  59. layout: function (args) {
  60. this.inherited(arguments);
  61. },
  62. // Plugin wrapper ---
  63. init: function (params) {
  64. var memory = new Memory({ data: params.fileParts });
  65. this.store = new ObjectStore({ objectStore: memory });
  66. this.filePartsGrid.setStore(this.store);
  67. this.filePartsGrid.setQuery({
  68. Copy: "1"
  69. });
  70. }
  71. });
  72. });