From ead1e07e99ad50c3ab0609ed80e40ac91115af4c Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Thu, 28 Jun 2018 11:50:35 +0300 Subject: [PATCH] getredash/redash#2534 Dashboard stops rendering when adding widget with empty query --- client/app/services/query.js | 56 ++++++++++--------- .../app/visualizations/chart/plotly/utils.js | 2 +- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/client/app/services/query.js b/client/app/services/query.js index 13fea386..ef6418e7 100644 --- a/client/app/services/query.js +++ b/client/app/services/query.js @@ -19,32 +19,6 @@ function collectParams(parts) { return parameters; } -class QueryResultError { - constructor(errorMessage) { - this.errorMessage = errorMessage; - } - - getError() { - return this.errorMessage; - } - - static getStatus() { - return 'failed'; - } - - static getData() { - return null; - } - - static getLog() { - return null; - } - - static getChartData() { - return null; - } -} - class Parameter { constructor(parameter) { this.title = parameter.title; @@ -170,6 +144,36 @@ class Parameters { } function QueryResource($resource, $http, $q, $location, currentUser, QueryResult) { + class QueryResultError { + constructor(errorMessage) { + this.errorMessage = errorMessage; + } + + getError() { + return this.errorMessage; + } + + toPromise() { + return $q.reject(this.getError()); + } + + static getStatus() { + return 'failed'; + } + + static getData() { + return null; + } + + static getLog() { + return null; + } + + static getChartData() { + return null; + } + } + const Query = $resource( 'api/queries/:id', { id: '@id' }, diff --git a/client/app/visualizations/chart/plotly/utils.js b/client/app/visualizations/chart/plotly/utils.js index b3290593..c118f49f 100644 --- a/client/app/visualizations/chart/plotly/utils.js +++ b/client/app/visualizations/chart/plotly/utils.js @@ -1,6 +1,6 @@ import { isArray, isNumber, isString, isUndefined, includes, min, max, has, find, -each, values, sortBy, identity, filter, map, extend, reduce, + each, values, sortBy, identity, filter, map, extend, reduce, } from 'lodash'; import moment from 'moment'; import { createFormatter, formatSimpleTemplate } from '@/lib/value-format';