-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[18.0][IMP] web_refresher: add auto refresh on interval #3256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Conversation
f179836
to
620e3d7
Compare
1c710d5
to
9dde2b4
Compare
title="Refresh" | ||
tabindex="-1" | ||
> | ||
<i id="manual-refresh-icon" class="fa fa-refresh" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the icons to an <i>
to allow the fa-spin
to be added and removed without spinning the whole button 🤣
id="manual-refresh-btn" | ||
class="btn btn-secondary m-0" | ||
aria-label="Refresh" | ||
t-on-click="onClickRefresh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintain existing flow with the a reset of the new timeout when manually clicked
<button | ||
class="dropdown-item" | ||
t-on-click="onChangeAutoRefreshInterval" | ||
value="1000" | ||
>1s</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure 1s is really appropriate. I could easily be persuaded to remove 1s
<button | ||
class="dropdown-item" | ||
t-on-click="onChangeAutoRefreshInterval" | ||
value="-1" | ||
>Off</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used -1
as the "off" value to avoid null
/undefined
confusions. #javascriptthings
data-bs-toggle="dropdown" | ||
aria-expanded="false" | ||
> | ||
Auto Refresh: Off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default text could be moved out to allow easier i18n
title="Refresh" | ||
tabindex="-1" | ||
> | ||
<i id="manual-refresh-icon" class="fa fa-refresh" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added id
for easy selections
} else { | ||
intervalValue = `${intervalInSeconds}s`; | ||
} | ||
document.getElementById("manual-refresh-icon").classList.add("fa-spin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add fa-spin
to show active auto refresh
} else { | ||
const intervalInSeconds = this.refreshInterval / 1000; | ||
if (intervalInSeconds >= 60) { | ||
intervalValue = `${Math.floor(intervalInSeconds / 60)}min`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
60s or more gets "min" added
let intervalValue = "Off"; | ||
if (!this.refreshInterval || this.refreshInterval <= 0) { | ||
intervalValue = "Off"; | ||
document.getElementById("manual-refresh-icon").classList.remove("fa-spin"); | ||
} else { | ||
const intervalInSeconds = this.refreshInterval / 1000; | ||
if (intervalInSeconds >= 60) { | ||
intervalValue = `${Math.floor(intervalInSeconds / 60)}min`; | ||
} else { | ||
intervalValue = `${intervalInSeconds}s`; | ||
} | ||
document.getElementById("manual-refresh-icon").classList.add("fa-spin"); | ||
} | ||
document.getElementById("auto-refresh-dd").textContent = | ||
`Auto Refresh: ${intervalValue}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing this logic i don't love how it played out. I'm going to refactor
// Check the refreshInterval is greater than 0 and start a timer for the next refresh | ||
if (this.refreshInterval > 0) { | ||
// Always attempt to clear a running timeout in case the refresh was done manually | ||
if (typeof this.runningRefresherId === "number") { | ||
clearTimeout(this.runningRefresherId); | ||
} | ||
this.runningRefresherId = setTimeout(() => { | ||
this.refresh(); | ||
}, this.refreshInterval); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consolidated logic for starting the refresh interval in the current refresh to allow recursive calls
const newIntervalText = | ||
clickedOption.textContent ?? clickedOption.target.textContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the xml button text as the interval on the label
803e87d
to
e746c50
Compare
f922248
to
c1f6881
Compare
c1f6881
to
935ca4d
Compare
This adds a new "auto" refresh option to the UI for allowing an interval refresh. I have also implemented a setting that is stored in localStorage for the auto refresh interval. When the auto refresh is set it puts the value into localStorage to be re-used on each screen by default.
Here is the auto refresh in action with network traffic included:
Screen.Recording.2025-08-21.at.1.36.27.PM.mov
UI of baseline
UI w/hover
UI Clicked dropdown
UI showing animation of manual refresh button to indicate ongoing action