mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add custom date range filter for admin dashboard reports (#23702)
* FEATURE: add custom date range filter for admin dashboard reports * Improvements per David's review
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { computed } from "@ember/object";
|
||||
import { action, computed } from "@ember/object";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import AdminDashboard from "admin/models/admin-dashboard";
|
||||
import I18n from "I18n";
|
||||
@@ -9,6 +9,7 @@ import getURL from "discourse-common/lib/get-url";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
import { setting } from "discourse/lib/computed";
|
||||
import { inject as service } from "@ember/service";
|
||||
import CustomDateRangeModal from "../components/modal/custom-date-range";
|
||||
|
||||
function staticReport(reportType) {
|
||||
return computed("reports.[]", function () {
|
||||
@@ -19,6 +20,7 @@ function staticReport(reportType) {
|
||||
export default class AdminDashboardGeneralController extends Controller.extend(
|
||||
PeriodComputationMixin
|
||||
) {
|
||||
@service modal;
|
||||
@service router;
|
||||
@service siteSettings;
|
||||
@controller("exception") exceptionController;
|
||||
@@ -154,4 +156,20 @@ export default class AdminDashboardGeneralController extends Controller.extend(
|
||||
_reportsForPeriodURL(period) {
|
||||
return getURL(`/admin?period=${period}`);
|
||||
}
|
||||
|
||||
@action
|
||||
setCustomDateRange(startDate, endDate) {
|
||||
this.setProperties({ startDate, endDate });
|
||||
}
|
||||
|
||||
@action
|
||||
openCustomDateRangeModal() {
|
||||
this.modal.show(CustomDateRangeModal, {
|
||||
model: {
|
||||
startDate: this.startDate,
|
||||
endDate: this.endDate,
|
||||
setCustomDateRange: this.setCustomDateRange,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { computed } from "@ember/object";
|
||||
import { action, computed } from "@ember/object";
|
||||
import Controller from "@ember/controller";
|
||||
import PeriodComputationMixin from "admin/mixins/period-computation";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import { inject as service } from "@ember/service";
|
||||
import CustomDateRangeModal from "../components/modal/custom-date-range";
|
||||
|
||||
export default class AdminDashboardModerationController extends Controller.extend(
|
||||
PeriodComputationMixin
|
||||
) {
|
||||
@service modal;
|
||||
|
||||
@discourseComputed
|
||||
flagsStatusOptions() {
|
||||
return {
|
||||
@@ -48,4 +52,20 @@ export default class AdminDashboardModerationController extends Controller.exten
|
||||
_reportsForPeriodURL(period) {
|
||||
return getURL(`/admin/dashboard/moderation?period=${period}`);
|
||||
}
|
||||
|
||||
@action
|
||||
setCustomDateRange(startDate, endDate) {
|
||||
this.setProperties({ startDate, endDate });
|
||||
}
|
||||
|
||||
@action
|
||||
openCustomDateRangeModal() {
|
||||
this.modal.show(CustomDateRangeModal, {
|
||||
model: {
|
||||
startDate: this.startDate,
|
||||
endDate: this.endDate,
|
||||
setCustomDateRange: this.setCustomDateRange,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user