UX: new site setting to define activity metrics displayed on dashboard

This commit is contained in:
Joffrey JAFFEUX 2018-12-26 10:29:07 +01:00 committed by GitHub
parent 2ab02d6642
commit 0402f0f357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 48 deletions

View File

@ -19,16 +19,9 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
logSearchQueriesEnabled: setting("log_search_queries"),
basePath: Discourse.BaseUri,
@computed
activityMetrics() {
return [
"page_view_total_reqs",
"visits",
"time_to_first_response",
"likes",
"flags",
"user_to_user_private_messages_with_replies"
];
@computed("siteSettings.dashboard_general_tab_activity_metrics")
activityMetrics(metrics) {
return (metrics || "").split("|").filter(m => m);
},
@computed

View File

@ -112,17 +112,15 @@
{{#if showFilteringUI}}
<div class="filters">
{{#if showModes}}
<ul class="modes">
<div class="modes">
{{#each displayedModes as |displayedMode|}}
<li class="mode">
{{d-button
action="changeMode"
actionParam=displayedMode.mode
class=displayedMode.cssClass
icon=displayedMode.icon}}
</li>
{{d-button
action="changeMode"
actionParam=displayedMode.mode
class=displayedMode.cssClass
icon=displayedMode.icon}}
{{/each}}
</ul>
</div>
{{/if}}
{{#if showDatesOptions}}

View File

@ -56,36 +56,38 @@
<div class="section-columns">
<div class="section-column">
<div class="admin-report activity-metrics">
<div class="header">
<ul class="breadcrumb">
<li class="item report">
{{#link-to "adminReports" class="report-url"}}
{{i18n "admin.dashboard.activity_metrics"}}
{{/link-to}}
</li>
</ul>
</div>
<div class="report-body">
<div class="counters-list">
<div class="counters-header">
<div class="counters-cell"></div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.today'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.yesterday'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.last_7_days'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.last_30_days'}}</div>
</div>
{{#if activityMetrics.length}}
<div class="admin-report activity-metrics">
<div class="header">
<ul class="breadcrumb">
<li class="item report">
{{#link-to "adminReports" class="report-url"}}
{{i18n "admin.dashboard.activity_metrics"}}
{{/link-to}}
</li>
</ul>
</div>
<div class="report-body">
<div class="counters-list">
<div class="counters-header">
<div class="counters-cell"></div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.today'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.yesterday'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.last_7_days'}}</div>
<div class="counters-cell">{{i18n 'admin.dashboard.reports.last_30_days'}}</div>
</div>
{{#each activityMetrics as |metric|}}
{{admin-report
showHeader=false
filters=activityMetricsFilters
forcedModes="counters"
dataSourceName=metric}}
{{/each}}
{{#each activityMetrics as |metric|}}
{{admin-report
showHeader=false
filters=activityMetricsFilters
forcedModes="counters"
dataSourceName=metric}}
{{/each}}
</div>
</div>
</div>
</div>
{{/if}}
<div class="user-metrics">
{{#conditional-loading-section isLoading=isLoading}}

View File

@ -246,6 +246,8 @@ class Report
def self.report_signups(report)
report.group_filtering = true
report.icon = 'user-plus'
if report.group_id
basic_report_about report, User.real, :count_by_signup_date, report.start_date, report.end_date, report.group_id
add_counts report, User.real, 'users.created_at'

View File

@ -3993,6 +3993,7 @@ en:
tags: "Tags"
search: "Search"
groups: "Groups"
dashboard: "Dashboard"
secret_list:
invalid_input: "Input fields cannot be empty or contain vertical bar character."

View File

@ -1903,6 +1903,8 @@ en:
short_title: "The short title will be used on the user's home screen, launcher, or other places where space may be limited. A maximum of 12 characters is recommended."
dashboard_general_tab_activity_metrics: "Choose reports to be displayed as activity metrics on the general tab."
errors:
invalid_email: "Invalid email address."
invalid_username: "There's no user with that username."

View File

@ -1898,3 +1898,19 @@ tags:
force_lowercase_tags:
default: true
client: true
dashboard:
dashboard_general_tab_activity_metrics:
client: true
type: list
list_type: compact
default: "page_view_total_reqs|visits|time_to_first_response|likes|flags|user_to_user_private_messages_with_replies"
allow_any: false
choices:
- page_view_total_reqs
- visits
- time_to_first_response
- likes
- flags
- user_to_user_private_messages_with_replies
- signups

View File

@ -1,7 +1,10 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Dashboard Next", {
loggedIn: true
loggedIn: true,
settings: {
dashboard_general_tab_activity_metrics: "page_view_total_reqs"
}
});
QUnit.test("Dashboard", async assert => {
@ -26,7 +29,6 @@ QUnit.test("tabs", async assert => {
QUnit.test("general tab", async assert => {
await visit("/admin");
assert.ok(exists(".admin-report.signups"), "signups report");
assert.ok(exists(".admin-report.posts"), "posts report");
assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report");
@ -46,6 +48,10 @@ QUnit.test("general tab", async assert => {
"Houston...",
"displays problems"
);
});
QUnit.test("general tab - activity metrics", async assert => {
await visit("/admin");
assert.equal(
$(".admin-report.page-view-total-reqs .today-count")