This commit is contained in:
sebseb7
2025-12-23 06:59:23 +01:00
parent 1b56e2cc42
commit eec45ee379
5 changed files with 105 additions and 40 deletions

View File

@@ -28,9 +28,19 @@ class Dashboard extends Component {
const { range, offset } = this.state;
const nowMs = Date.now();
const durationSec = (range === 'week' ? 7 * 24 * 3600 : (range === 'month' ? 30 * 24 * 3600 : 24 * 3600));
const endMs = nowMs - (offset * durationSec * 1000);
const startMs = endMs - (durationSec * 1000);
let startMs, endMs;
if (range === 'today') {
const d = new Date(nowMs);
d.setHours(0, 0, 0, 0);
const midnightMs = d.getTime();
startMs = midnightMs - (offset * 24 * 3600 * 1000);
endMs = startMs + (24 * 3600 * 1000);
} else {
const durationSec = (range === 'week' ? 7 * 24 * 3600 : (range === 'month' ? 30 * 24 * 3600 : 24 * 3600));
endMs = nowMs - (offset * durationSec * 1000);
startMs = endMs - (durationSec * 1000);
}
const dateOpts = { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' };
const dateRangeLabel = `${new Date(startMs).toLocaleString([], dateOpts)} - ${new Date(endMs).toLocaleString([], dateOpts)}`;
@@ -71,6 +81,12 @@ class Dashboard extends Component {
>
{t('dashboard.hours24')}
</Button>
<Button
onClick={() => this.setRange('today')}
color={range === 'today' ? 'primary' : 'inherit'}
>
1 Tag
</Button>
<Button
onClick={() => this.setRange('week')}
color={range === 'week' ? 'primary' : 'inherit'}