1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-members-chart.hbs
Kevin Ansfield cbc085fb14 Fixed members chart
no issue

- "stale data" logic was incorrect so we were always returning `undefined` from `membersStats.fetch()`
- improved behaviour of the chart when stats are not available or are loading
2020-05-27 16:12:13 +01:00

64 lines
3.1 KiB
Handlebars

<div class="flex justify-between mb6 items-stretch gh-members-chart-wrapper"
{{did-insert (perform this.fetchStatsTask)}}
>
{{!-- Chart title/filter graph --}}
<div class="flex-auto bg-white br3 shadow-1 bg-grouped-table mr6 gh-members-chart-box">
<div class="flex justify-between items-center gh-members-chart-header">
<h2 class="f-small ttu midgrey fw5 mb0">Total members</h2>
<div class="view-actions">
<div class="gh-contentfilter gh-contentfilter-menu gh-contentfilter-type">
<PowerSelect
@selected={{this.selectedRange}}
@options={{this.availableRanges}}
@searchEnabled={{false}}
@onChange={{action "changeDateRange"}}
@triggerComponent="gh-power-select/trigger"
@triggerClass="gh-contentfilter-menu-trigger"
@dropdownClass="gh-contentfilter-menu-dropdown gh-members-chart-dropdown"
@matchTriggerWidth={{false}}
data-test-type-select="true"
as |range|
>
{{range.name}}
</PowerSelect>
</div>
</div>
</div>
<div class="gh-members-chart-container">
{{#if (not this.stats)}}
<GhLoadingSpinner />
{{else}}
<EmberChart
@type="LineWithLine"
@options={{this.chartOptions}}
@data={{this.chartData}}
@height={{300}} />
{{/if}}
</div>
<div class="flex justify-between pa4 pt0 pb2 nt1">
<span class="f8 midlightgrey">{{this.startDateLabel}}</span>
<span class="f8 midlightgrey">Today</span>
</div>
</div>
{{!-- Summary --}}
<div class="flex flex-column justify-between gh-members-chart-summary bg-white br3 shadow-1 bg-grouped-table">
<div class="flex-auto flex flex-column justify-center items-start pa4 bb b--whitegrey">
<h3 class="f-small ttu midgrey fw5">Total Members</h3>
<div class="gh-members-chart-summary-data">{{if (not this.stats) "-" (format-number this.stats.total)}}</div>
</div>
<div class="flex-auto flex flex-column justify-center items-start pa4 bb b--whitegrey">
{{#if (eq this.range "all-time")}}
<h3 class="f-small ttu midgrey fw5">All time signups</h3>
{{else}}
<h3 class="f-small ttu midgrey fw5">Signed up in the last {{this.range}} days</h3>
{{/if}}
<div class="gh-members-chart-summary-data">{{if (not this.stats) "-" (format-number this.stats.total_in_range)}}</div>
</div>
<div class="flex-auto flex flex-column justify-center items-start pa4">
<h3 class="f-small ttu midgrey fw5">Signed up today</h3>
<div class="gh-members-chart-summary-data">{{if (not this.stats) "-" (format-number this.stats.new_today)}}</div>
</div>
</div>
</div>