Skip to content

Commit 8961a9f

Browse files
thjaeckleclaude
andcommitted
Add quick-fetch convenience buttons to Historical Thing Updates
Adds "Last 10" / "Last 100" buttons when in By Revision mode and "Last 1h" / "Last 24h" buttons when in By Timestamp mode. Each button sets the from/to range and immediately triggers a fetch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e4a3408 commit 8961a9f

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

ui/modules/things/thingUpdates.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ <h5 data-bs-toggle="collapse" data-bs-target="#collapseThingUpdates">
4646
<input type="radio" class="btn-check" name="historicalRangeMode" id="historicalRangeModeTimestamp">
4747
<label class="btn btn-outline-secondary btn-sm" for="historicalRangeModeTimestamp">By Timestamp</label>
4848
</div>
49+
<span class="ms-2" id="quickFetchRevisionButtons">
50+
<button class="btn btn-outline-primary btn-sm" id="buttonLastNRevisions10"
51+
data-bs-toggle="tooltip" title="Fetch the last 10 revisions">Last 10</button>
52+
<button class="btn btn-outline-primary btn-sm" id="buttonLastNRevisions100"
53+
data-bs-toggle="tooltip" title="Fetch the last 100 revisions">Last 100</button>
54+
</span>
55+
<span class="ms-2" id="quickFetchTimestampButtons" hidden>
56+
<button class="btn btn-outline-primary btn-sm" id="buttonLastTime1h"
57+
data-bs-toggle="tooltip" title="Fetch events from the last hour">Last 1h</button>
58+
<button class="btn btn-outline-primary btn-sm" id="buttonLastTime24h"
59+
data-bs-toggle="tooltip" title="Fetch events from the last 24 hours">Last 24h</button>
60+
</span>
4961
</div>
5062
<div id="historicalRevisionRange">
5163
<div class="input-group input-group-sm mb-1">

ui/modules/things/thingUpdates.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ type DomElements = {
5353
historicalToTimestamp: HTMLInputElement,
5454
buttonFromOldestTimestamp: HTMLButtonElement,
5555
buttonToMostRecentTimestamp: HTMLButtonElement,
56+
quickFetchRevisionButtons: HTMLSpanElement,
57+
buttonLastNRevisions10: HTMLButtonElement,
58+
buttonLastNRevisions100: HTMLButtonElement,
59+
quickFetchTimestampButtons: HTMLSpanElement,
60+
buttonLastTime1h: HTMLButtonElement,
61+
buttonLastTime24h: HTMLButtonElement,
5662
inputHistoricalRqlFilter: HTMLInputElement,
5763
buttonFetchHistorical: HTMLButtonElement,
5864
buttonStopHistorical: HTMLButtonElement,
@@ -82,6 +88,12 @@ let dom: DomElements = {
8288
historicalToTimestamp: null,
8389
buttonFromOldestTimestamp: null,
8490
buttonToMostRecentTimestamp: null,
91+
quickFetchRevisionButtons: null,
92+
buttonLastNRevisions10: null,
93+
buttonLastNRevisions100: null,
94+
quickFetchTimestampButtons: null,
95+
buttonLastTime1h: null,
96+
buttonLastTime24h: null,
8597
inputHistoricalRqlFilter: null,
8698
buttonFetchHistorical: null,
8799
buttonStopHistorical: null,
@@ -153,6 +165,11 @@ export function ready() {
153165
dom.historicalToRevision.value = String(probedMaxRevision);
154166
dom.historicalToRevisionSlider.value = String(probedMaxRevision);
155167
};
168+
dom.buttonLastNRevisions10.onclick = () => quickFetchLastRevisions(10);
169+
dom.buttonLastNRevisions100.onclick = () => quickFetchLastRevisions(100);
170+
dom.buttonLastTime1h.onclick = () => quickFetchLastTime(1);
171+
dom.buttonLastTime24h.onclick = () => quickFetchLastTime(24);
172+
156173
dom.buttonFromOldestTimestamp.onclick = () => {
157174
if (probedOldestTimestamp) {
158175
dom.historicalFromTimestamp.value = probedOldestTimestamp;
@@ -432,6 +449,26 @@ function onRangeModeChange() {
432449
const byRevision = dom.historicalRangeModeRevision.checked;
433450
dom.historicalRevisionRange.hidden = !byRevision;
434451
dom.historicalTimestampRange.hidden = byRevision;
452+
dom.quickFetchRevisionButtons.hidden = !byRevision;
453+
dom.quickFetchTimestampButtons.hidden = byRevision;
454+
}
455+
456+
function quickFetchLastRevisions(count: number) {
457+
const from = Math.max(probedMinRevision, probedMaxRevision - count + 1);
458+
const to = probedMaxRevision;
459+
dom.historicalFromRevision.value = String(from);
460+
dom.historicalFromRevisionSlider.value = String(from);
461+
dom.historicalToRevision.value = String(to);
462+
dom.historicalToRevisionSlider.value = String(to);
463+
onFetchHistorical();
464+
}
465+
466+
function quickFetchLastTime(hours: number) {
467+
const now = new Date();
468+
const from = new Date(now.getTime() - hours * 60 * 60 * 1000);
469+
dom.historicalFromTimestamp.value = Utils.toDatetimeLocalValue(from.toISOString());
470+
dom.historicalToTimestamp.value = Utils.toDatetimeLocalValue(now.toISOString());
471+
onFetchHistorical();
435472
}
436473

437474
function onFetchHistorical() {

0 commit comments

Comments
 (0)