FIX: better message if request for report is rate limited (#6298)
This commit is contained in:
@@ -43,6 +43,7 @@ export default Ember.Component.extend({
|
||||
isEnabled: true,
|
||||
disabledLabel: "admin.dashboard.disabled",
|
||||
isLoading: false,
|
||||
rateLimitationString: null,
|
||||
dataSourceName: null,
|
||||
report: null,
|
||||
model: null,
|
||||
@@ -303,7 +304,7 @@ export default Ember.Component.extend({
|
||||
_fetchReport() {
|
||||
this._super();
|
||||
|
||||
this.set("isLoading", true);
|
||||
this.setProperties({ isLoading: true, rateLimitationString: null });
|
||||
|
||||
let payload = this._buildPayload(["prev_period"]);
|
||||
|
||||
@@ -315,6 +316,12 @@ export default Ember.Component.extend({
|
||||
console.log("failed loading", this.get("dataSource"));
|
||||
}
|
||||
})
|
||||
.catch(data => {
|
||||
if (data.jqXHR && data.jqXHR.status === 429) {
|
||||
const error = data.jqXHR.responseJSON.errors[0];
|
||||
this.set("rateLimitationString", error);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
||||
this.set("isLoading", false);
|
||||
|
||||
@@ -57,21 +57,28 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<div class="alert alert-info report-alert no-data">
|
||||
{{d-icon "pie-chart"}}
|
||||
{{#if model.reportUrl}}
|
||||
<a href="{{model.reportUrl}}" class="report-url">
|
||||
<span>
|
||||
{{#if model.title}}
|
||||
{{model.title}} —
|
||||
{{/if}}
|
||||
{{i18n "admin.dashboard.reports.no_data"}}
|
||||
</span>
|
||||
</a>
|
||||
{{else}}
|
||||
<span>{{i18n "admin.dashboard.reports.no_data"}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{#if rateLimitationString}}
|
||||
<div class="alert alert-error report-alert rate-limited">
|
||||
{{d-icon "thermometer-three-quarters"}}
|
||||
<span>{{rateLimitationString}}</span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="alert alert-info report-alert no-data">
|
||||
{{d-icon "pie-chart"}}
|
||||
{{#if model.reportUrl}}
|
||||
<a href="{{model.reportUrl}}" class="report-url">
|
||||
<span>
|
||||
{{#if model.title}}
|
||||
{{model.title}} —
|
||||
{{/if}}
|
||||
{{i18n "admin.dashboard.reports.no_data"}}
|
||||
</span>
|
||||
</a>
|
||||
{{else}}
|
||||
<span>{{i18n "admin.dashboard.reports.no_data"}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if showTimeoutError}}
|
||||
|
||||
Reference in New Issue
Block a user