mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added toggle between cadence and tiers for the paid mix graph
refs https://github.com/TryGhost/Team/issues/1442
This commit is contained in:
parent
d918be7acf
commit
dfccf030d7
3 changed files with 65 additions and 6 deletions
|
@ -1,4 +1,22 @@
|
||||||
<h4>Paid mix ({{this.mode}})</h4>
|
|
||||||
|
<div class="prototype-paid-mix-dropdown">
|
||||||
|
<PowerSelect
|
||||||
|
@selected={{this.selectedModeOption}}
|
||||||
|
@options={{this.modeOptions}}
|
||||||
|
@searchEnabled={{false}}
|
||||||
|
@onChange={{this.onSwitchMode}}
|
||||||
|
@triggerComponent="gh-power-select/trigger"
|
||||||
|
@triggerClass="gh-contentfilter-menu-trigger"
|
||||||
|
@dropdownClass="gh-contentfilter-menu-dropdown"
|
||||||
|
@matchTriggerWidth={{false}}
|
||||||
|
as |option|
|
||||||
|
>
|
||||||
|
{{#if option.name}}{{option.name}}{{else}}<span class="red">Unknown option</span>{{/if}}
|
||||||
|
</PowerSelect>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4>Paid mix</h4>
|
||||||
|
|
||||||
{{#if this.loading}}
|
{{#if this.loading}}
|
||||||
<div class="prototype-placeholder" style={{html-safe (concat "height: " this.chartHeight "px;")}}/>
|
<div class="prototype-placeholder" style={{html-safe (concat "height: " this.chartHeight "px;")}}/>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
import Component from '@glimmer/component';
|
import Component from '@glimmer/component';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
import {tracked} from '@glimmer/tracking';
|
||||||
|
|
||||||
|
const MODE_OPTIONS = [{
|
||||||
|
name: 'Cadence',
|
||||||
|
value: 'cadence'
|
||||||
|
}, {
|
||||||
|
name: 'Tiers',
|
||||||
|
value: 'tiers'
|
||||||
|
}];
|
||||||
|
|
||||||
export default class ChartPaidMix extends Component {
|
export default class ChartPaidMix extends Component {
|
||||||
@service dashboardStats;
|
@service dashboardStats;
|
||||||
|
@ -24,16 +33,29 @@ export default class ChartPaidMix extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@tracked mode = 'cadence';
|
||||||
|
modeOptions = MODE_OPTIONS;
|
||||||
|
|
||||||
|
get selectedModeOption() {
|
||||||
|
return this.modeOptions.find(option => option.value === this.mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
onSwitchMode(selected) {
|
||||||
|
this.mode = selected.value;
|
||||||
|
|
||||||
|
if (this.loading) {
|
||||||
|
// We don't have the data yet for the newly selected mode
|
||||||
|
this.loadCharts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get loading() {
|
get loading() {
|
||||||
if (this.mode === 'cadence') {
|
if (this.mode === 'cadence') {
|
||||||
return this.dashboardStats.paidMembersByCadence === null;
|
return this.dashboardStats.paidMembersByCadence === null;
|
||||||
}
|
}
|
||||||
return this.dashboardStats.paidMembersByTier === null;
|
return this.dashboardStats.paidMembersByTier === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get mode() {
|
|
||||||
return 'cadence';
|
|
||||||
}
|
|
||||||
|
|
||||||
get chartType() {
|
get chartType() {
|
||||||
return 'pie';
|
return 'pie';
|
||||||
|
@ -51,7 +73,19 @@ export default class ChartPaidMix extends Component {
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new Error('Not yet supported');
|
|
||||||
|
const labels = this.dashboardStats.paidMembersByTier.map(stat => stat.tier.name);
|
||||||
|
const data = this.dashboardStats.paidMembersByTier.map(stat => stat.members);
|
||||||
|
|
||||||
|
return {
|
||||||
|
labels,
|
||||||
|
datasets: [{
|
||||||
|
data,
|
||||||
|
fill: false,
|
||||||
|
backgroundColor: ['#14b8ff'],
|
||||||
|
tension: 0.1
|
||||||
|
}]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get chartOptions() {
|
get chartOptions() {
|
||||||
|
|
|
@ -1093,6 +1093,12 @@ a.gh-dashboard-container {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.prototype-paid-mix-dropdown {
|
||||||
|
position: absolute;
|
||||||
|
right: 15px;
|
||||||
|
top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.prototype-counts {
|
.prototype-counts {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
@ -1125,6 +1131,7 @@ a.gh-dashboard-container {
|
||||||
.prototype-box {
|
.prototype-box {
|
||||||
border: 1px solid #ebeef0;
|
border: 1px solid #ebeef0;
|
||||||
padding: 28px;
|
padding: 28px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prototype-box .number {
|
.prototype-box .number {
|
||||||
|
|
Loading…
Add table
Reference in a new issue