UX: improve new dashboard

- top referred topics
- limit search logs to 8 results
This commit is contained in:
Sam
2018-05-15 15:08:23 +10:00
parent 8d6a9eb511
commit 193b6d5651
12 changed files with 126 additions and 144 deletions
@@ -8,12 +8,31 @@ export default Ember.Component.extend(AsyncReport, {
help: null,
helpPage: null,
loadReport(report_json) {
this._setPropertiesFromReport(Report.create(report_json));
},
fetchReport() {
this.set("isLoading", true);
ajax(this.get("dataSource"))
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");
}
if (this.get("limit")) {
payload.data.limit = this.get("limit");
}
ajax(this.get("dataSource"), payload)
.then((response) => {
this._setPropertiesFromReport(Report.create(response.report));
this.set('reportKey', response.report.report_key);
this.loadReport(response.report);
}).finally(() => {
if (!Ember.isEmpty(this.get("report.data"))) {
this.set("isLoading", false);
@@ -1,8 +0,0 @@
import DashboardTable from "admin/components/dashboard-table";
import AsyncReport from "admin/mixins/async-report";
export default DashboardTable.extend(AsyncReport, {
layoutName: "admin/templates/components/dashboard-table",
classNames: ["dashboard-table", "dashboard-table-trending-search"]
});
@@ -1,59 +0,0 @@
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"],
classNameBindings : ["isDisabled"],
help: null,
helpPage: null,
isDisabled: Ember.computed.not("siteSettings.log_search_queries"),
disabledLabel: "admin.dashboard.reports.disabled",
@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() {
if (this.get("isDisabled")) return;
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);
};
});
}
});