QuerySetErrorsWidget.js 3.5 KB

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