2018-05-16 02:12:03 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2018-05-03 21:41:41 +08:00
|
|
|
import Report from "admin/models/report";
|
|
|
|
import AsyncReport from "admin/mixins/async-report";
|
2018-04-16 16:42:06 +08:00
|
|
|
|
2018-05-03 21:41:41 +08:00
|
|
|
export default Ember.Component.extend(AsyncReport, {
|
2018-04-26 20:49:41 +08:00
|
|
|
classNames: ["dashboard-table", "dashboard-inline-table", "fixed"],
|
2018-04-16 16:42:06 +08:00
|
|
|
help: null,
|
|
|
|
helpPage: null,
|
2018-04-17 17:01:06 +08:00
|
|
|
|
2018-05-15 13:08:23 +08:00
|
|
|
loadReport(report_json) {
|
2018-05-16 02:12:03 +08:00
|
|
|
return Report.create(report_json);
|
2018-05-15 13:08:23 +08:00
|
|
|
},
|
|
|
|
|
2018-05-03 21:41:41 +08:00
|
|
|
fetchReport() {
|
2018-05-16 02:12:03 +08:00
|
|
|
this._super();
|
2018-04-16 16:42:06 +08:00
|
|
|
|
2018-05-16 14:05:03 +08:00
|
|
|
let payload = { data: { cache: true, facets: ["total", "prev30Days"] } };
|
2018-05-15 13:08:23 +08:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.get("limit")) {
|
|
|
|
payload.data.limit = this.get("limit");
|
|
|
|
}
|
|
|
|
|
2018-05-16 02:12:03 +08:00
|
|
|
return Ember.RSVP.Promise.all(this.get("dataSources").map(dataSource => {
|
|
|
|
return ajax(dataSource, payload)
|
|
|
|
.then(response => {
|
2018-05-16 22:45:21 +08:00
|
|
|
this.get("reports").pushObject(this.loadReport(response.report));
|
2018-05-16 02:12:03 +08:00
|
|
|
});
|
|
|
|
}));
|
2018-04-16 16:42:06 +08:00
|
|
|
}
|
|
|
|
});
|