123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- /*##############################################################################
- # Copyright (C) 2011 HPCC Systems.
- #
- # All rights reserved. This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as
- # published by the Free Software Foundation, either version 3 of the
- # License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- ############################################################################## */
- define([
- "dojo/_base/declare",
- "dojo/_base/array",
- "dijit/registry",
- "dijit/layout/_LayoutWidget",
- "dijit/_TemplatedMixin",
- "dijit/_WidgetsInTemplateMixin",
- "dojox/data/AndOrReadStore",
- "hpcc/ESPWorkunit",
- "dojo/text!../templates/InfoGridWidget.html",
- "dijit/layout/BorderContainer",
- "dijit/layout/ContentPane",
- "dijit/form/CheckBox",
- "dojox/grid/DataGrid"
- ],
- function (declare, array,
- registry, _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin,
- AndOrReadStore,
- ESPWorkunit,
- template) {
- return declare("InfoGridWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
- templateString: template,
- baseClass: "InfoGridWidget",
- borderContainer: null,
- infoGrid: null,
- errorsCheck: null,
- warningsCheck: null,
- infoCheck: null,
- dataStore: null,
- lastSelection: null,
- buildRendering: function (args) {
- this.inherited(arguments);
- },
- test: function (value, rowIdx, cell) {
- switch (value) {
- case "Error":
- cell.customClasses.push("ErrorCell");
- break;
- case "Warning":
- cell.customClasses.push("WarningCell");
- break;
- }
- return value;
- },
- postCreate: function (args) {
- this.inherited(arguments);
- this.borderContainer = registry.byId(this.id + "BorderContainer");
- this.infoGrid = registry.byId(this.id + "InfoGrid");
- this.errorsCheck = registry.byId(this.id + "Errors");
- this.warningsCheck = registry.byId(this.id + "Warnings");
- this.infoCheck = registry.byId(this.id + "Info");
- var context = this;
- this.infoGrid.setStructure([
- { name: "Severity", field: "Severity", width: 8, formatter: context.test },
- { name: "Source", field: "Source", width: 8 },
- { name: "Code", field: "Code", width: 4 },
- { name: "Message", field: "Message", width: "40" },
- { name: "Col", field: "Column", width: 3 },
- { name: "Line", field: "LineNo", width: 3 },
- { name: "FileName", field: "FileName", width: "40" }
- ]);
-
- this.infoGrid.on("RowClick", function (evt) {
- var idx = evt.rowIndex;
- var item = this.getItem(idx);
- var line = parseInt(this.store.getValue(item, "LineNo"), 10);
- var col = parseInt(this.store.getValue(item, "Column"), 10);
- context.onErrorClick(line, col);
- }, true);
- },
- startup: function (args) {
- this.inherited(arguments);
- },
- resize: function (args) {
- this.inherited(arguments);
- this.borderContainer.resize();
- },
- layout: function (args) {
- this.inherited(arguments);
- },
- onErrorClick: function(line, col) {
- },
- _onErrors: function (args) {
- this.refreshFilter();
- },
- _onWarnings: function (args) {
- this.refreshFilter();
- },
- _onInfo: function (args) {
- this.refreshFilter();
- },
- // Plugin wrapper ---
- _onStyleRow: function (row) {
- var item = this.infoGrid.getItem(row.index);
- if (item) {
- var severity = this.store.getValue(item, "Severity", null);
- if (severity == "Error") {
- row.customStyles += "background-color: red;";
- } else if (severity == "Warning") {
- row.customStyles += "background-color: yellow;";
- }
- }
- this.infoGrid.focus.styleRow(row);
- this.infoGrid.edit.styleRow(row);
- },
- init: function (params) {
- if (this.initalized)
- return;
- this.initalized = true;
- if (params.onErrorClick) {
- this.onErrorClick = params.onErrorClick;
- }
-
- this.wu = new ESPWorkunit({
- Wuid: params.Wuid
- });
- var context = this;
- this.wu.monitor(function () {
- context.wu.getInfo({
- onGetWUExceptions: function (exceptions) {
- context.loadExceptions(exceptions);
- }
- });
- });
- },
- refreshFilter: function (graphName) {
- var filter = "";
- if (this.errorsCheck.get("checked")) {
- filter = "Severity: 'Error'";
- }
- if (this.warningsCheck.get("checked")) {
- if (filter.length) {
- filter += " OR ";
- }
- filter += "Severity: 'Warning'";
- }
- if (this.infoCheck.get("checked")) {
- if (filter.length) {
- filter += " OR ";
- }
- filter += "Severity: 'Info'";
- }
- this.infoGrid.setQuery({
- complexQuery: filter
- });
- },
- getSelected: function () {
- return this.infoGrid.selection.getSelected();
- },
- setSelected: function (selItems) {
- for (var i = 0; i < this.infoGrid.rowCount; ++i) {
- var row = this.infoGrid.getItem(i);
- this.infoGrid.selection.setSelected(i, (row.SubGraphId && array.indexOf(selItems, row.SubGraphId) != -1));
- }
- },
- loadExceptions: function (exceptions) {
- var data = {
- 'items': exceptions
- };
- this.store = new AndOrReadStore({
- data: data
- });
- this.infoGrid.setStore(this.store);
- this.refreshFilter();
- }
- });
- });
|