2022-03-21 19:58:39 +03:00
|
|
|
import Component from '@glimmer/component';
|
2022-03-23 11:51:53 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-03-21 21:02:57 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
2022-03-21 19:58:39 +03:00
|
|
|
|
2022-03-23 11:51:53 +03:00
|
|
|
const DAYS_OPTIONS = [{
|
|
|
|
name: '7 days',
|
|
|
|
value: 7
|
|
|
|
}, {
|
|
|
|
name: '30 days',
|
|
|
|
value: 30
|
|
|
|
}, {
|
|
|
|
name: '90 days',
|
|
|
|
value: 90
|
|
|
|
}, {
|
|
|
|
name: 'All time',
|
|
|
|
value: 365 // todo: add support for all time (not important for prototype)
|
|
|
|
}];
|
|
|
|
|
2022-03-21 19:58:39 +03:00
|
|
|
export default class DashboardDashboardV5Component extends Component {
|
2022-03-23 11:51:53 +03:00
|
|
|
@service dashboardStats;
|
2022-03-23 13:53:32 +03:00
|
|
|
@service dashboardMocks;
|
2022-03-23 11:51:53 +03:00
|
|
|
|
2022-03-21 21:02:57 +03:00
|
|
|
@tracked mockPaidTiers = true;
|
|
|
|
@tracked mockStripeEnabled = true;
|
|
|
|
@tracked mockNewslettersEnabled = true;
|
|
|
|
@tracked mockMembersEnabled = true;
|
2022-03-23 11:51:53 +03:00
|
|
|
|
|
|
|
@tracked days = 30;
|
|
|
|
|
|
|
|
daysOptions = DAYS_OPTIONS;
|
|
|
|
|
2022-03-24 11:01:30 +03:00
|
|
|
@action
|
|
|
|
onInsert() {
|
|
|
|
this.updateMockedData(14);
|
2022-03-23 18:38:16 +03:00
|
|
|
}
|
|
|
|
|
2022-03-23 11:51:53 +03:00
|
|
|
get selectedDaysOption() {
|
|
|
|
return this.daysOptions.find(d => d.value === this.days);
|
|
|
|
}
|
2022-03-21 21:02:57 +03:00
|
|
|
|
|
|
|
get hasPaidTiers() {
|
|
|
|
return this.mockPaidTiers;
|
|
|
|
}
|
|
|
|
|
|
|
|
get isStripeEnabled() {
|
|
|
|
return this.mockStripeEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
get areNewslettersEnabled() {
|
|
|
|
return this.mockNewslettersEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
get areMembersEnabled() {
|
|
|
|
return this.mockMembersEnabled;
|
|
|
|
}
|
2022-03-23 11:51:53 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
onDaysChange(selected) {
|
|
|
|
this.days = selected.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method generates new data and forces a reload for all the charts
|
|
|
|
* Might be better to move this code to a temporary mocking service
|
|
|
|
*/
|
|
|
|
@action
|
2022-03-23 13:53:32 +03:00
|
|
|
updateMockedData(generateDays) {
|
|
|
|
this.dashboardMocks.updateMockedData({days: generateDays});
|
2022-03-23 11:51:53 +03:00
|
|
|
|
|
|
|
// Force update all data
|
2022-03-23 13:53:32 +03:00
|
|
|
this.dashboardStats.reloadAll(this.days);
|
2022-03-23 11:51:53 +03:00
|
|
|
}
|
2022-03-21 19:58:39 +03:00
|
|
|
}
|