mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
* locale for title * minimum chart/table while loading * sort users by type * more spacing in the UI * minor refactoring
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
import { ajax } from 'discourse/lib/ajax';
|
|
import computed from 'ember-addons/ember-computed-decorators';
|
|
|
|
export default Ember.Component.extend({
|
|
classNames: ["dashboard-mini-table"],
|
|
|
|
classNameBindings: ["isLoading"],
|
|
|
|
total: null,
|
|
labels: null,
|
|
title: null,
|
|
chartData: null,
|
|
isLoading: false,
|
|
help: null,
|
|
helpPage: null,
|
|
|
|
didInsertElement() {
|
|
this._super();
|
|
|
|
this.fetchReport.apply(this);
|
|
},
|
|
|
|
@computed("dataSourceName")
|
|
dataSource(dataSourceName) {
|
|
return `/admin/reports/${dataSourceName}`;
|
|
},
|
|
|
|
fetchReport() {
|
|
this.set("isLoading", true);
|
|
|
|
ajax(this.get("dataSource"))
|
|
.then((response) => {
|
|
const report = response.report;
|
|
const data = report.data.sort((a, b) => a.x >= b.x);
|
|
|
|
this.setProperties({
|
|
labels: data.map(r => r.x),
|
|
dataset: data.map(r => r.y),
|
|
total: report.total,
|
|
title: report.title,
|
|
chartData: data
|
|
});
|
|
}).finally(() => {
|
|
this.set("isLoading", false);
|
|
});
|
|
}
|
|
});
|