Ghost/ghost/admin/app/controllers/stats.js
Peter Zimon dd183cf25e
Stats page refinements (#20924)
[ANAL-43](https://linear.app/tryghost/issue/ANAL-50/update-colors-of-barlist)

- Copy is too technical, doesn't follow conventions on Stats page
- Range filter dropdown has to be updated with more meaningful values
- KPI charts need a granularity dropdown to display meaninful charts
depending on the context
- Typography details should be updated
- "Posts/pages" dropdown needs to be added to Content section. This is a
Ghost specific filter that brings high value to customers
- "Campaigns" dropdown needs to be added to Sources section to support
ad tracking and filtering in the future
- BarList colors should be updated to be less purple all over the place
2024-09-05 17:49:20 +02:00

44 lines
1.3 KiB
JavaScript

import Controller from '@ember/controller';
import {AUDIENCE_TYPES, RANGE_OPTIONS} from 'ghost-admin/utils/stats';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
export default class StatsController extends Controller {
rangeOptions = RANGE_OPTIONS;
audienceOptions = AUDIENCE_TYPES;
/**
* @type {number|'all'}
* Date range to load for member count and MRR related charts
*/
@tracked chartRange = 30 + 1;
/**
* @type {array}
* Filter by audience
*/
@tracked audience = [];
@tracked excludedAudiences = '';
@action
onRangeChange(selected) {
this.chartRange = selected.value;
}
@action
onAudienceChange(newExcludedAudiences) {
if (newExcludedAudiences !== null) {
this.excludedAudiences = newExcludedAudiences;
this.audience = this.audienceOptions
.filter(a => !this.excludedAudiences.includes(a.value))
.map(a => a.value);
// this.audience = this.audienceOptions.filter(a => !this.excludedAudiences.includes(a.value));
} else {
this.excludedAudiences = '';
this.audience = this.audienceOptions.map(a => a.value);
}
}
get selectedRangeOption() {
return this.rangeOptions.find(d => d.value === this.chartRange);
}
}