mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-05 00:27:25 +00:00
Add 'today' and 'yesterday' to date range picker
This commit is contained in:
parent
b4c2cdef7d
commit
26319ac59b
@ -224,9 +224,18 @@ class DateRange {
|
||||
else if (type == 'ytd')
|
||||
return DateRange.ytd();
|
||||
else if (type == 'last30days')
|
||||
return DateRange.lastXdays(30);
|
||||
return DateRange.lastXdays(29);
|
||||
else if (type == 'last7days')
|
||||
return DateRange.lastXdays(7)
|
||||
return DateRange.lastXdays(6)
|
||||
else if (type == 'today') {
|
||||
var d = new Date();
|
||||
return [ d, d ];
|
||||
}
|
||||
else if (type == 'yesterday') {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() - (1 * 24 * 60 * 60 * 1000));
|
||||
return [ d, d ];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@ -911,7 +920,8 @@ class TimeseriesData {
|
||||
max_width = (max_width === undefined) ? 75 : max_width;
|
||||
var first_date = this.dates[0];
|
||||
var last_date = this.dates[this.dates.length-1];
|
||||
var bins = (last_date.getTime() - first_date.getTime()) / (1000 * 60 * this.binsize);
|
||||
var bins = (last_date.getTime() - first_date.getTime()) / (1000 * 60 * this.binsize) + 1;
|
||||
if (bins == 1) return max_width;
|
||||
return Math.min(max_width, Math.max(1, (xscale(last_date) - xscale(first_date))/bins - barspacing));
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ Vue.component('date-range-picker', {
|
||||
range: range,
|
||||
range_type: range_type,
|
||||
options: [
|
||||
{ value:'today', text:'Today' },
|
||||
{ value:'yesterday', text:'Yesterday' },
|
||||
{ value:'last7days', text:'Last 7 days' },
|
||||
{ value:'last30days', text:'Last 30 days' },
|
||||
{ value:'wtd', text:'Week-to-date' },
|
||||
@ -153,16 +155,20 @@ Vue.component('date-range-picker', {
|
||||
|
||||
range_type_change: function(evt) {
|
||||
// ui select callback
|
||||
if (this.range_type == 'last7days')
|
||||
this.range = DateRange.lastXdays_as_ymd(7);
|
||||
else if (this.range_type == 'last30days')
|
||||
this.range = DateRange.lastXdays_as_ymd(30);
|
||||
else if (this.range_type == 'wtd')
|
||||
this.range = DateRange.wtd_as_ymd();
|
||||
else if (this.range_type == 'mtd')
|
||||
this.range = DateRange.mtd_as_ymd();
|
||||
else if (this.range_type == 'ytd')
|
||||
this.range = DateRange.ytd_as_ymd();
|
||||
var range = DateRange.rangeFromType(this.range_type);
|
||||
if (range) {
|
||||
this.range = range.map(d => DateFormatter.ymd(d));
|
||||
}
|
||||
// if (this.range_type == 'last7days')
|
||||
// this.range = DateRange.lastXdays_as_ymd(7);
|
||||
// else if (this.range_type == 'last30days')
|
||||
// this.range = DateRange.lastXdays_as_ymd(30);
|
||||
// else if (this.range_type == 'wtd')
|
||||
// this.range = DateRange.wtd_as_ymd();
|
||||
// else if (this.range_type == 'mtd')
|
||||
// this.range = DateRange.mtd_as_ymd();
|
||||
// else if (this.range_type == 'ytd')
|
||||
// this.range = DateRange.ytd_as_ymd();
|
||||
},
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user