diff --git a/assets/js/components/CountWidget.js b/assets/js/components/CountWidget.js
index fe91b78..834ac8b 100644
--- a/assets/js/components/CountWidget.js
+++ b/assets/js/components/CountWidget.js
@@ -41,6 +41,7 @@ class CountWidget extends Component {
}
renderPercentage() {
+ // wait for request to finish
if( ! this.state.previousCount ) {
return '';
}
@@ -58,7 +59,6 @@ class CountWidget extends Component {
{loadingOverlay}
{this.props.title}
{numbers.formatWithComma(this.state.count)} {this.renderPercentage()}
- last {this.props.period} days
)
}
diff --git a/assets/js/components/DatePicker.js b/assets/js/components/DatePicker.js
index 2c43dd4..92e44cd 100644
--- a/assets/js/components/DatePicker.js
+++ b/assets/js/components/DatePicker.js
@@ -2,7 +2,7 @@
import { h, render, Component } from 'preact';
-var availablePeriods = [
+const availablePeriods = [
{
id: 7,
label: 'Last 7 days'
diff --git a/assets/js/pages/dashboard.js b/assets/js/pages/dashboard.js
index c61d637..a3bc97d 100644
--- a/assets/js/pages/dashboard.js
+++ b/assets/js/pages/dashboard.js
@@ -29,8 +29,15 @@ class Dashboard extends Component {
super(props)
this.state = {
- period: 7
+ period: parseInt(window.location.hash.substring(2)) || 7
}
+
+ this.onPeriodChoose = this.onPeriodChoose.bind(this)
+ }
+
+ onPeriodChoose(p) {
+ this.setState({ period: p })
+ window.history.replaceState(this.state, null, `#!${p}`)
}
render() {
@@ -40,7 +47,7 @@ class Dashboard extends Component {
- { this.setState({ period: p })}} />
+