Skip to content

Commit 8ab4211

Browse files
committed
last 24h
1 parent 1fd4927 commit 8ab4211

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

services/static-webserver/client/source/class/osparc/desktop/credits/CreditsSummary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ qx.Class.define("osparc.desktop.credits.CreditsSummary", {
4646
WIDTH: 350,
4747
TIME_RANGES: [{
4848
key: 1,
49-
label: "Today"
49+
label: "Last 24h"
5050
}, {
5151
key: 7,
5252
label: "Last week"

services/static-webserver/client/source/class/osparc/desktop/credits/DateFilters.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)