[#245] Add refresh button to query view page

This commit is contained in:
Amir Nissim
2014-07-28 14:33:05 +03:00
parent cb59973b9a
commit d93e07061b
5 changed files with 22 additions and 14 deletions

View File

@@ -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
]);
})();
})();

View File

@@ -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);
}
});

View File

@@ -221,7 +221,7 @@
if (this.columns == undefined && this.query_result.data) {
this.columns = this.query_result.data.columns;
}
return this.columns;
}

View File

@@ -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 {

View File

@@ -142,7 +142,7 @@
<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">
@@ -152,6 +152,7 @@
<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>