Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ qx.Class.define("osparc.desktop.credits.CreditsSummary", {
WIDTH: 350,
TIME_RANGES: [{
key: 1,
label: "Today"
label: "Last 24h"
}, {
key: 7,
label: "Last week"
Expand Down Expand Up @@ -116,8 +116,8 @@ qx.Class.define("osparc.desktop.credits.CreditsSummary", {
const trItem = new qx.ui.form.ListItem(tr.label, null, tr.key);
control.add(trItem);
});
// default one week
const found = control.getSelectables().find(trItem => trItem.getModel() === 7);
// default last 24h
const found = control.getSelectables().find(trItem => trItem.getModel() === 1);
if (found) {
control.setSelection([found]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,30 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
members: {
_buildLayout() {
this._removeAll();
const defaultFrom = new Date()
defaultFrom.setMonth(defaultFrom.getMonth() - 1)
// Range defaults to previous month

const defaultFrom = new Date();
// Range defaults
// from last 24h...
defaultFrom.setDate(defaultFrom.getDate() - 1);
// .. to now
const defaultTo = new Date();

this.__from = this.__addDateInput("From", defaultFrom);
this.__until = this.__addDateInput("Until");
this.__until = this.__addDateInput("Until", defaultTo);

const lastDayBtn = new qx.ui.form.Button("Last 24h").set({
allowStretchY: false,
alignY: "bottom"
});
lastDayBtn.addListener("execute", () => {
const today = new Date();
const last24h = new Date(today);
last24h.setDate(today.getDate() - 1);
this.__from.setValue(last24h);
this.__until.setValue(today);
});
this._add(lastDayBtn);

const lastWeekBtn = new qx.ui.form.Button("Last week").set({
allowStretchY: false,
alignY: "bottom"
Expand All @@ -38,6 +57,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
this.__until.setValue(today);
});
this._add(lastWeekBtn);

const lastMonthBtn = new qx.ui.form.Button("Last month").set({
allowStretchY: false,
alignY: "bottom"
Expand All @@ -50,6 +70,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
this.__until.setValue(today);
});
this._add(lastMonthBtn);

const lastYearBtn = new qx.ui.form.Button("Last year").set({
allowStretchY: false,
alignY: "bottom"
Expand Down
Loading