getredash/redash#2601 Show real status when loading cached query result

This commit is contained in:
Levko Kravets
2018-06-25 13:29:25 +03:00
parent 35bb558f44
commit 10ff9ec86e
2 changed files with 28 additions and 5 deletions

View File

@@ -216,14 +216,18 @@
<button type="button" class="btn btn-warning btn-xs pull-right" ng-disabled="cancelling" ng-click="cancelExecution()">Cancel
</button>
</div>
<div class="alert alert-info m-t-15" ng-show="queryResult.getStatus() == 'loading-result'">
Loading results&hellip;
<rd-timer timestamp="queryResult.getUpdatedAt()"></rd-timer>
</div>
<div class="alert alert-info m-t-15" ng-show="queryResult.getStatus() == 'waiting'">
Query in queue&hellip;
<rd-timer timestamp="queryResult.getUpdatedAt()"></rd-timer>
<button type="button" class="btn btn-warning btn-xs pull-right" ng-disabled="cancelling" ng-click="cancelExecution()">Cancel
</button>
</div>
<div class="alert alert-danger m-t-15" ng-show="queryResult.getError()">Error running query:
<strong>{{queryResult.getError()}}</strong>
<div class="alert alert-danger m-t-15" ng-show="queryResult.getError()">
Error running query: <strong>{{queryResult.getError()}}</strong>
</div>
</div>
<!-- End of Query Execution Status -->
@@ -318,4 +322,4 @@
</div>
</div>
</main>
</div>
</div>

View File

@@ -73,6 +73,9 @@ function QueryResultService($resource, $timeout, $q) {
this.updatedAt = moment();
// exteded status flags
this.isLoadingResult = false;
if (props) {
this.update(props);
}
@@ -148,6 +151,9 @@ function QueryResultService($resource, $timeout, $q) {
}
getStatus() {
if (this.isLoadingResult) {
return 'loading-result';
}
return this.status || statuses[this.job.status];
}
@@ -335,7 +341,6 @@ function QueryResultService($resource, $timeout, $q) {
return this.columnNames;
}
getColumnCleanNames() {
return this.getColumnNames().map(col => getColumnCleanName(col));
}
@@ -414,18 +419,32 @@ function QueryResultService($resource, $timeout, $q) {
static getById(id) {
const queryResult = new QueryResult();
queryResult.isLoadingResult = true;
QueryResultResource.get({ id }, (response) => {
// Success handler
queryResult.isLoadingResult = false;
queryResult.update(response);
}, (response) => {
// Error handler
queryResult.isLoadingResult = false;
queryResult.update({
job: {
error: response.data.message,
status: 4,
},
});
});
return queryResult;
}
loadResult(tryCount) {
this.isLoadingResult = true;
QueryResultResource.get(
{ id: this.job.query_result_id },
(response) => {
this.update(response);
this.isLoadingResult = false;
},
(error) => {
if (tryCount === undefined) {
@@ -440,6 +459,7 @@ function QueryResultService($resource, $timeout, $q) {
status: 4,
},
});
this.isLoadingResult = false;
} else {
$timeout(() => {
this.loadResult(tryCount + 1);
@@ -508,7 +528,6 @@ function QueryResultService($resource, $timeout, $q) {
}
}
return QueryResult;
}