discourse/app/assets/javascripts/admin/components/dashboard-table.js.es6
Sam 8a783412b7 UX: improvements to new dashboard
- remove inactive user report and replace with posts
- clean up internals so grouping by week happens on client
- when switching periods old report was not destroyed leading to bugs
- calculate trend based on previous interval ... not previous 30 days
- show percentages for mau/dau
- be more careful about utc date usage
- show uniqu and click through rate on search panel
- publish key of report with report so we only load the correct one
- subscribe earlier in channel in case of concurrency issues
2018-05-11 13:30:32 +10:00

55 lines
1.4 KiB
JavaScript

import { ajax } from "discourse/lib/ajax";
import Report from "admin/models/report";
import AsyncReport from "admin/mixins/async-report";
import computed from "ember-addons/ember-computed-decorators";
import { number } from 'discourse/lib/formatter';
export default Ember.Component.extend(AsyncReport, {
classNames: ["dashboard-table"],
help: null,
helpPage: null,
@computed("report")
values(report) {
if (!report) return;
return Ember.makeArray(report.data)
.map(x => {
return [ x[0], number(x[1]), x[2] ];
});
},
@computed("report")
labels(report) {
if (!report) return;
return Ember.makeArray(report.labels);
},
loadReport(report_json) {
this._setPropertiesFromReport(Report.create(report_json));
},
fetchReport() {
this.set("isLoading", true);
let payload = { data: { async: true } };
if (this.get("startDate")) {
payload.data.start_date = this.get("startDate").format("YYYY-MM-DD[T]HH:mm:ss.SSSZZ");
}
if (this.get("endDate")) {
payload.data.end_date = this.get("endDate").format("YYYY-MM-DD[T]HH:mm:ss.SSSZZ");
}
ajax(this.get("dataSource"), payload)
.then((response) => {
this.set('reportKey', response.report.report_key);
this.loadReport(response.report);
}).finally(() => {
if (!Ember.isEmpty(this.get("report.data"))) {
this.set("isLoading", false);
};
});
}
});