Skip to content

Commit

Permalink
re-add today view to date presets (1d)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Dec 4, 2018
1 parent 8f436ee commit e2fb3aa
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions assets/src/js/components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ window.setInterval(() => {
now = new Date();
}, 60000 );

// today, yesterday, this week, last 7 days, last 30 days
const availablePeriods = {
'1d': {
label: '1d',
start: function() {
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
},
end: function() {
return this.start();
},
},
'1w': {
label: '1w',
start: function() {
Expand Down Expand Up @@ -116,7 +124,12 @@ class DatePicker extends Component {
end.setHours(23, 59, 59);

let diff = Math.round((end - start) / 1000 / 60 / 60 / 24)
let groupBy = diff >= 31 ? 'month' : 'day';
let groupBy = 'day';
if(diff >= 31) {
groupBy = 'month';
} else if( diff < 2) {
groupBy = 'hour';
}

this.setState({
period: period || '',
Expand Down

0 comments on commit e2fb3aa

Please sign in to comment.