Skip to content

Commit 81bc40c

Browse files
Converted auto-refresh to a switch (#6355)
Co-authored-by: Dom G. <domgarguilo@apache.org>
1 parent 9fe0950 commit 81bc40c

3 files changed

Lines changed: 18 additions & 29 deletions

File tree

server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/css/screen.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,6 @@ pre.logevent {
421421
left: unset;
422422
}
423423

424-
.active {
425-
color: #fff;
426-
text-decoration: none;
427-
background-color: #337ab7;
428-
outline: 0;
429-
}
430-
431-
432424
.btn-white-font {
433425
color: #fff;
434426
background-color: #0dcaf0;

server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const TABLET_SERVER_PROCESS_VIEW = 'tserversView';
3737
var STATUS_REQUEST = null;
3838
const RUNNING_COMPACTIONS_BY_TABLE = 'runningCompactionsByTable';
3939
const RUNNING_COMPACTIONS_BY_GROUP = 'runningCompactionsByGroup';
40+
const AUTO_REFRESH_KEY = 'auto-refresh';
4041
const MESSAGE_CATEGORIES = 'messageCategories';
4142
const MESSAGES = 'messages';
4243

@@ -55,25 +56,17 @@ if ($.fn && $.fn.dataTable) {
5556
* and creates listeners for auto refresh
5657
*/
5758
function setupAutoRefresh() {
58-
// Sets auto refresh to true or false
59-
if (!sessionStorage.autoRefresh) {
60-
sessionStorage.autoRefresh = 'false';
61-
}
62-
// Need this to set the initial value for the autorefresh on page load
63-
if (sessionStorage.autoRefresh === 'false') {
64-
$('.auto-refresh').parent().removeClass('active');
59+
60+
var autoRefreshSwitch = $('#autoRefreshSwitch');
61+
var savedValue = localStorage.getItem(AUTO_REFRESH_KEY);
62+
if (savedValue === null || savedValue === 'false') {
63+
autoRefreshSwitch.prop('checked', false);
6564
} else {
66-
$('.auto-refresh').parent().addClass('active');
65+
autoRefreshSwitch.prop('checked', true);
6766
}
6867
// Initializes the auto refresh on click listener
69-
$('.auto-refresh').on("click", function () {
70-
if ($(this).parent().attr('class') === 'active') {
71-
$(this).parent().removeClass('active');
72-
sessionStorage.autoRefresh = 'false';
73-
} else {
74-
$(this).parent().addClass('active');
75-
sessionStorage.autoRefresh = 'true';
76-
}
68+
$('#autoRefreshSwitch').on("change", function () {
69+
localStorage.setItem(AUTO_REFRESH_KEY, $(this).is(':checked'));
7770
});
7871
}
7972

@@ -88,12 +81,9 @@ function refresh() {
8881
* Global timer that checks for auto refresh status every 5 seconds
8982
*/
9083
TIMER = setInterval(function () {
91-
if (sessionStorage.autoRefresh === 'true') {
92-
$('.auto-refresh').parent().addClass('active');
84+
if (localStorage.getItem(AUTO_REFRESH_KEY) === 'true') {
9385
refresh();
9486
refreshNavBar();
95-
} else {
96-
$('.auto-refresh').parent().removeClass('active');
9787
}
9888
}, 5000);
9989

server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/navbar.ftl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@
7878
<span style="font-size: 1.2em;" class="bi bi-three-dots-vertical"></span>
7979
</a>
8080
<ul class="dropdown-menu dropdown-menu-end">
81-
<li><a class="dropdown-item auto-refresh" style="cursor:pointer">Auto-Refresh</a></li>
81+
<li>
82+
<div class="dropdown-item d-flex justify-content-between align-items-center">
83+
<label class="mb-0" for="autoRefreshSwitch">Auto-Refresh</label>
84+
<div class="form-check form-switch mb-0 ms-3">
85+
<input id="autoRefreshSwitch" class="form-check-input mt-0" type="checkbox" role="switch">
86+
</div>
87+
</div>
88+
</li>
8289
<li><a class="dropdown-item" data-bs-toggle="modal" href="#aboutModal">About</a></li>
8390
</ul>
8491
</li>

0 commit comments

Comments
 (0)