@@ -21,11 +21,28 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
2121 members : {
2222 _buildLayout ( ) {
2323 this . _removeAll ( ) ;
24- const defaultFrom = new Date ( )
25- defaultFrom . setMonth ( defaultFrom . getMonth ( ) - 1 )
26- // Range defaults to previous month
24+
25+ const defaultFrom = new Date ( ) ;
26+ // Range defaults to last 24h
27+ defaultFrom . defaultFrom ( today . getDate ( ) - 1 ) ;
28+ const defaultTo = new Date ( ) ;
29+
2730 this . __from = this . __addDateInput ( "From" , defaultFrom ) ;
28- this . __until = this . __addDateInput ( "Until" ) ;
31+ this . __until = this . __addDateInput ( "Until" , defaultTo ) ;
32+
33+ const lastDayBtn = new qx . ui . form . Button ( "Last 24h" ) . set ( {
34+ allowStretchY : false ,
35+ alignY : "bottom"
36+ } ) ;
37+ lastDayBtn . addListener ( "execute" , ( ) => {
38+ const today = new Date ( ) ;
39+ const last24h = new Date ( today ) ;
40+ last24h . setDate ( today . getDate ( ) - 1 ) ;
41+ this . __from . setValue ( last24h ) ;
42+ this . __until . setValue ( today ) ;
43+ } ) ;
44+ this . _add ( lastDayBtn ) ;
45+
2946 const lastWeekBtn = new qx . ui . form . Button ( "Last week" ) . set ( {
3047 allowStretchY : false ,
3148 alignY : "bottom"
@@ -38,6 +55,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
3855 this . __until . setValue ( today ) ;
3956 } ) ;
4057 this . _add ( lastWeekBtn ) ;
58+
4159 const lastMonthBtn = new qx . ui . form . Button ( "Last month" ) . set ( {
4260 allowStretchY : false ,
4361 alignY : "bottom"
@@ -50,6 +68,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
5068 this . __until . setValue ( today ) ;
5169 } ) ;
5270 this . _add ( lastMonthBtn ) ;
71+
5372 const lastYearBtn = new qx . ui . form . Button ( "Last year" ) . set ( {
5473 allowStretchY : false ,
5574 alignY : "bottom"
0 commit comments