Stabalize order of tables in dashboard
This commit is contained in:
parent
f21a47eadd
commit
e0695b02d9
|
@ -17,22 +17,34 @@ export default Ember.Mixin.create({
|
||||||
return dataSourceNames.split(",").map(source => `/admin/reports/${source}`);
|
return dataSourceNames.split(",").map(source => `/admin/reports/${source}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("reports.[]", "startDate", "endDate")
|
@computed("reports.[]", "startDate", "endDate", "dataSourceNames")
|
||||||
reportsForPeriod(reports, startDate, endDate) {
|
reportsForPeriod(reports, startDate, endDate, dataSourceNames) {
|
||||||
// on a slow network fetchReport could be called multiple times between
|
// on a slow network fetchReport could be called multiple times between
|
||||||
// T and T+x, and all the ajax responses would occur after T+(x+y)
|
// T and T+x, and all the ajax responses would occur after T+(x+y)
|
||||||
// to avoid any inconsistencies we filter by period and make sure
|
// to avoid any inconsistencies we filter by period and make sure
|
||||||
// the array contains only unique values
|
// the array contains only unique values
|
||||||
reports = reports.uniqBy("report_key");
|
reports = reports.uniqBy("report_key");
|
||||||
|
|
||||||
|
|
||||||
|
const sort = (r) => {
|
||||||
|
if (r.length > 1) {
|
||||||
|
return dataSourceNames
|
||||||
|
.split(",")
|
||||||
|
.map(name => r.findBy("type", name));
|
||||||
|
} else {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (!startDate || !endDate) {
|
if (!startDate || !endDate) {
|
||||||
return reports;
|
return sort(reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reports.filter(report => {
|
|
||||||
|
return sort(reports.filter(report => {
|
||||||
return report.report_key.includes(startDate.format("YYYYMMDD")) &&
|
return report.report_key.includes(startDate.format("YYYYMMDD")) &&
|
||||||
report.report_key.includes(endDate.format("YYYYMMDD"));
|
report.report_key.includes(endDate.format("YYYYMMDD"));
|
||||||
});
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
|
Binary file not shown.
|
@ -80,7 +80,7 @@
|
||||||
{{/conditional-loading-section}}
|
{{/conditional-loading-section}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#dashboard-inline-table dataSourceNames="users_by_trust_level,users_by_type" lastRefreshedAt=lastRefreshedAt as |context|}}
|
{{#dashboard-inline-table dataSourceNames="users_by_type,users_by_trust_level" lastRefreshedAt=lastRefreshedAt as |context|}}
|
||||||
<tr>
|
<tr>
|
||||||
{{#each context.report.data as |data|}}
|
{{#each context.report.data as |data|}}
|
||||||
<td>
|
<td>
|
||||||
|
@ -124,9 +124,7 @@
|
||||||
<a rel="noopener" target="_blank" href="https://meta.discourse.org/tags/release-notes" class="btn">
|
<a rel="noopener" target="_blank" href="https://meta.discourse.org/tags/release-notes" class="btn">
|
||||||
{{i18n "admin.dashboard.whats_new_in_discourse"}}
|
{{i18n "admin.dashboard.whats_new_in_discourse"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue