mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
getredash/redash#2601 Show real status when loading cached query result
This commit is contained in:
@@ -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…
|
||||
<rd-timer timestamp="queryResult.getUpdatedAt()"></rd-timer>
|
||||
</div>
|
||||
<div class="alert alert-info m-t-15" ng-show="queryResult.getStatus() == 'waiting'">
|
||||
Query in queue…
|
||||
<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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user