From d93e07061b6398a83855bc025924fcbe7398277f Mon Sep 17 00:00:00 2001 From: Amir Nissim Date: Mon, 28 Jul 2014 14:33:05 +0300 Subject: [PATCH] [#245] Add refresh button to query view page --- rd_ui/app/scripts/controllers/query_source.js | 10 +++++++++- rd_ui/app/scripts/controllers/query_view.js | 18 +++++++----------- rd_ui/app/scripts/services/resources.js | 2 +- rd_ui/app/styles/redash.css | 3 +++ rd_ui/app/views/query.html | 3 ++- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/rd_ui/app/scripts/controllers/query_source.js b/rd_ui/app/scripts/controllers/query_source.js index caf56a0cbd..5b8fb9716b 100644 --- a/rd_ui/app/scripts/controllers/query_source.js +++ b/rd_ui/app/scripts/controllers/query_source.js @@ -32,6 +32,14 @@ $scope.newVisualization = undefined; + // @override + Object.defineProperty($scope, 'showDataset', { + get: function() { + return $scope.queryResult && $scope.queryResult.getStatus() == 'done'; + } + }); + + KeyboardShortcuts.bind(shortcuts); // @override @@ -109,4 +117,4 @@ 'Events', 'growl', '$controller', '$scope', '$location', 'Query', 'Visualization', 'KeyboardShortcuts', QuerySourceCtrl ]); -})(); \ No newline at end of file +})(); diff --git a/rd_ui/app/scripts/controllers/query_view.js b/rd_ui/app/scripts/controllers/query_view.js index b7c23ed9b5..9179053a00 100644 --- a/rd_ui/app/scripts/controllers/query_view.js +++ b/rd_ui/app/scripts/controllers/query_view.js @@ -16,6 +16,10 @@ $scope.query.data_source_id = $scope.query.data_source_id || dataSources[0].id; }); + // in view mode, latest dataset is always visible + // source mode changes this behavior + $scope.showDataset = true; + $scope.lockButton = function(lock) { $scope.queryExecuting = lock; }; @@ -91,16 +95,6 @@ $scope.$parent.pageTitle = $scope.query.name; }); - $scope.$watch('queryResult && queryResult.getError()', function(newError, oldError) { - if (newError == undefined) { - return; - } - - if (oldError == undefined && newError != undefined) { - $scope.lockButton(false); - } - }); - $scope.$watch('queryResult && queryResult.getData()', function(data, oldData) { if (!data) { return; @@ -114,7 +108,7 @@ return; } - if (status == "done") { + if (status == 'done') { if ($scope.query.id && $scope.query.latest_query_data_id != $scope.queryResult.getId() && $scope.query.query_hash == $scope.queryResult.query_result.query_hash) { @@ -126,7 +120,9 @@ $scope.query.latest_query_data_id = $scope.queryResult.getId(); notifications.showNotification("re:dash", $scope.query.name + " updated."); + } + if (status === 'done' || status === 'failed') { $scope.lockButton(false); } }); diff --git a/rd_ui/app/scripts/services/resources.js b/rd_ui/app/scripts/services/resources.js index f6cfaef401..1a7d206483 100644 --- a/rd_ui/app/scripts/services/resources.js +++ b/rd_ui/app/scripts/services/resources.js @@ -221,7 +221,7 @@ if (this.columns == undefined && this.query_result.data) { this.columns = this.query_result.data.columns; } - + return this.columns; } diff --git a/rd_ui/app/styles/redash.css b/rd_ui/app/styles/redash.css index 297b898962..f1864a81cf 100644 --- a/rd_ui/app/styles/redash.css +++ b/rd_ui/app/styles/redash.css @@ -245,6 +245,9 @@ to add those CSS styles here. */ background-color: #FF8080; border-radius: 50%; } +.nav-tabs > li.rd-tab-btn { + float: right; +} /* light version of bootstrap's form-control */ .rd-form-control { diff --git a/rd_ui/app/views/query.html b/rd_ui/app/views/query.html index ead08e14de..6db3737e01 100644 --- a/rd_ui/app/views/query.html +++ b/rd_ui/app/views/query.html @@ -142,7 +142,7 @@

Error running query: {{queryResult.getError()}}
-
+