QuerySetErrorsWidget.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/array",
  19. "dojo/_base/lang",
  20. "dojo/on",
  21. "dgrid/OnDemandGrid",
  22. "dgrid/Keyboard",
  23. "dgrid/Selection",
  24. "dgrid/selector",
  25. "dgrid/extensions/ColumnResizer",
  26. "dgrid/extensions/DijitRegistry",
  27. "hpcc/GridDetailsWidget",
  28. "hpcc/WsWorkunits",
  29. "hpcc/ESPUtil"
  30. ], function (declare, arrayUtil, lang, on,
  31. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  32. GridDetailsWidget, WsWorkunits, ESPUtil) {
  33. return declare("QuerySetErrorsWidget", [GridDetailsWidget], {
  34. gridTitle: "Errors",
  35. idProperty: "Name",
  36. queryId: null,
  37. querySet: null,
  38. init: function (params) {
  39. if (this.inherited(arguments))
  40. return;
  41. this.refreshGrid();
  42. //disabled buttons for now since we cannot open an error atm
  43. },
  44. createGrid: function (domID) {
  45. var context = this;
  46. var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  47. allowSelectAll: true,
  48. deselectOnRefresh: false,
  49. store: this.store,
  50. columns: {
  51. col1: selector({ width: 27, selectorType: 'checkbox' }),
  52. Cluster: { label: "Cluster", width: 108, sortable: false },
  53. Errors: { label: "Error", width: 108, sortable: false },
  54. State: { label: "State", width: 108, sortable: false },
  55. }
  56. }, domID);
  57. on(document, "." + this.id + "WuidClick:click", function (evt) {
  58. if (context._onRowDblClick) {
  59. var row = retVal.row(evt).data;
  60. context._onRowDblClick(row);
  61. }
  62. });
  63. return retVal;
  64. },
  65. refreshGrid: function (args) {
  66. var errors = [];
  67. if (lang.exists("params.Query.Clusters.ClusterQueryState", this)) {
  68. var context = this;
  69. arrayUtil.forEach(this.params.Query.Clusters.ClusterQueryState, function (item, idx) {
  70. var error = {
  71. Cluster: item.Cluster,
  72. Errors: item.Error,
  73. State: item.State
  74. }
  75. errors.push(error);
  76. });
  77. }
  78. this.store.setData(errors);
  79. this.grid.refresh();
  80. }
  81. });
  82. });