QuerySetErrorsWidget.js 3.4 KB

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