Skip to content

A platform for community discussion. Free, open, simple.

Stabalize order of tables in dashboard

Same0695b02d9ef
diff --git a/app/assets/javascripts/admin/mixins/async-report.js.es6 b/app/assets/javascripts/admin/mixins/async-report.js.es6
index 12c5d9543f3..2c22ab15c21 100644
--- a/app/assets/javascripts/admin/mixins/async-report.js.es6
+++ b/app/assets/javascripts/admin/mixins/async-report.js.es6
@@ -17,22 +17,34 @@ export default Ember.Mixin.create({
return dataSourceNames.split(",").map(source => `/admin/reports/${source}`);
},
- @computed("reports.[]", "startDate", "endDate")
- reportsForPeriod(reports, startDate, endDate) {
+ @computed("reports.[]", "startDate", "endDate", "dataSourceNames")
+ reportsForPeriod(reports, startDate, endDate, dataSourceNames) {
// 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)
// to avoid any inconsistencies we filter by period and make sure
// the array contains only unique values
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) {
- return reports;
+ return sort(reports);
}
- return reports.filter(report => {
+
+ return sort(reports.filter(report => {
return report.report_key.includes(startDate.format("YYYYMMDD")) &&
report.report_key.includes(endDate.format("YYYYMMDD"));
- });
+ }));
},
didInsertElement() {
diff --git a/app/assets/javascripts/admin/templates/.dashboard_next.hbs.swl b/app/assets/javascripts/admin/templates/.dashboard_next.hbs.swl
new file mode 100644
index 00000000000..23cc50b1f35
Binary files /dev/null and b/app/assets/javascripts/admin/templates/.dashboard_next.hbs.swl differ
diff --git a/app/assets/javascripts/admin/templates/dashboard_next.hbs b/app/assets/javascripts/admin/templates/dashboard_next.hbs
index 34fe21fafd7..87825182481 100644
--- a/app/assets/javascripts/admin/templates/dashboard_next.hbs
+++ b/app/assets/javascripts/admin/templates/dashboard_next.hbs
@@ -80,7 +80,7 @@
{{/conditional-loading-section}}
</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>
{{#each context.report.data as |data|}}
<td>
@@ -124,9 +124,7 @@
<a rel="noopener" target="_blank" href="https://meta.discourse.org/tags/release-notes" class="btn">
{{i18n "admin.dashboard.whats_new_in_discourse"}}
</a>
-
</div>
-
</div>
</div>