Ghost/ghost/admin/app/components/dashboard/dashboard-v5.js
Simon Backx 01b411de85 Added paid mix chart implementation for dashboard 5.0
refs https://github.com/TryGhost/Team/issues/1443

- Includes support for 'all' data in member count charts
- Fixed reloading of MRR data when switching between days
- Loading data now always returns a 'promise' instead of just dropping it
- Tiers and cadence paid mix chart added
- Defaults to mocked data = off (required to prevent loading paid mix tiers on page load)
- Note that there is still some discussion about the correctness of the tiers paid mix data, refs Slack https://ghost.slack.com/archives/C02G9E68C/p1648717224956659
2022-03-31 16:22:49 +02:00

66 lines
1.3 KiB
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
const DAYS_OPTIONS = [{
name: '7 days',
value: 7
}, {
name: '30 days',
value: 30
}, {
name: '90 days',
value: 90
}, {
name: 'All time',
value: 'all'
}];
export default class DashboardDashboardV5Component extends Component {
@service dashboardStats;
daysOptions = DAYS_OPTIONS;
get days() {
return this.dashboardStats.chartDays;
}
set days(days) {
this.dashboardStats.chartDays = days;
}
@action
onInsert() {
this.dashboardStats.loadSiteStatus();
}
get selectedDaysOption() {
return this.daysOptions.find(d => d.value === this.days);
}
get isLoading() {
return this.dashboardStats.siteStatus === null;
}
get hasPaidTiers() {
return this.dashboardStats.siteStatus?.hasPaidTiers;
}
get isStripeEnabled() {
return this.dashboardStats.siteStatus?.stripeEnabled;
}
get areNewslettersEnabled() {
return this.dashboardStats.siteStatus?.newslettersEnabled;
}
get areMembersEnabled() {
return this.dashboardStats.siteStatus?.membersEnabled;
}
@action
onDaysChange(selected) {
this.days = selected.value;
}
}