mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
159f56b0d2
refs https://github.com/TryGhost/Team/issues/1442 All the data from the charts now come from the dashboard stats service
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class ChartEngagement extends Component {
|
|
@service dashboardStats;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.loadCharts();
|
|
}
|
|
|
|
loadCharts() {
|
|
this.dashboardStats.loadLastSeen(this.status);
|
|
this.dashboardStats.loadMembersCounts();
|
|
}
|
|
|
|
get status() {
|
|
// todo: this should come from a dropdown
|
|
// + reload stats after changing this value
|
|
return 'total';
|
|
}
|
|
|
|
get loading() {
|
|
return this.dashboardStats.memberCounts === null
|
|
|| !this.dashboardStats.memberCounts[this.status]
|
|
|| this.dashboardStats.membersLastSeen30d === null
|
|
|| this.dashboardStats.membersLastSeen7d === null;
|
|
}
|
|
|
|
get data30Days() {
|
|
if (this.loading) {
|
|
return '- %';
|
|
}
|
|
const total = this.dashboardStats.memberCounts[this.status];
|
|
const part = this.dashboardStats.membersLastSeen30d;
|
|
|
|
if (total <= 0) {
|
|
return '- %';
|
|
}
|
|
|
|
const percentage = Math.round(part / total * 100);
|
|
return `${percentage}%`;
|
|
}
|
|
|
|
get data7Days() {
|
|
if (this.loading) {
|
|
return '- %';
|
|
}
|
|
const total = this.dashboardStats.memberCounts[this.status];
|
|
const part = this.dashboardStats.membersLastSeen7d;
|
|
|
|
if (total <= 0) {
|
|
return '- %';
|
|
}
|
|
|
|
const percentage = Math.round(part / total * 100);
|
|
return `${percentage}%`;
|
|
}
|
|
}
|