@@ -37,6 +37,7 @@ const TABLET_SERVER_PROCESS_VIEW = 'tserversView';
3737var STATUS_REQUEST = null ;
3838const RUNNING_COMPACTIONS_BY_TABLE = 'runningCompactionsByTable' ;
3939const RUNNING_COMPACTIONS_BY_GROUP = 'runningCompactionsByGroup' ;
40+ const AUTO_REFRESH_KEY = 'auto-refresh' ;
4041const MESSAGE_CATEGORIES = 'messageCategories' ;
4142const MESSAGES = 'messages' ;
4243
@@ -55,25 +56,17 @@ if ($.fn && $.fn.dataTable) {
5556 * and creates listeners for auto refresh
5657 */
5758function 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 */
9083TIMER = 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
0 commit comments