Skip to content

Commit

Permalink
[#245] Add refresh button to query view page
Browse files Browse the repository at this point in the history
  • Loading branch information
amirnissim committed Aug 3, 2014
1 parent cb59973 commit d93e070
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
10 changes: 9 additions & 1 deletion rd_ui/app/scripts/controllers/query_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -109,4 +117,4 @@
'Events', 'growl', '$controller', '$scope', '$location', 'Query',
'Visualization', 'KeyboardShortcuts', QuerySourceCtrl
]);
})();
})();
18 changes: 7 additions & 11 deletions rd_ui/app/scripts/controllers/query_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
}
});
Expand Down
2 changes: 1 addition & 1 deletion rd_ui/app/scripts/services/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
if (this.columns == undefined && this.query_result.data) {
this.columns = this.query_result.data.columns;
}

return this.columns;
}

Expand Down
3 changes: 3 additions & 0 deletions rd_ui/app/styles/redash.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion rd_ui/app/views/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h2>
<div class="alert alert-danger" ng-show="queryResult.getError()">Error running query: <strong>{{queryResult.getError()}}</strong></div>

<!-- tabs and data -->
<div ng-show="queryResult.getStatus() == 'done'">
<div ng-show="showDataset">
<div class="row">
<div class="col-lg-12">
<ul class="nav nav-tabs">
Expand All @@ -152,6 +152,7 @@ <h2>
<span class="remove" ng-click="deleteVisualization($event, vis)" ng-show="canEdit"> &times;</span>
</rd-tab>
<rd-tab tab-id="add" name="&plus; New" removeable="true" ng-show="canEdit"></rd-tab>
<li ng-if="!sourceMode" class="rd-tab-btn"><button class="btn btn-sm btn-default" ng-click="executeQuery()" ng-disabled="queryExecuting" title="Refresh Dataset"><span class="glyphicon glyphicon-refresh"></span></button></li>
</ul>
</div>
</div>
Expand Down

0 comments on commit d93e070

Please sign in to comment.