mirror of https://git.48k.eu/ogcp
Keep selected clients in the scopes tree
Otherwise, users have to click clients checkboxes every time they switch view. This commit adds one hook to capture when clients checkboxes changes. When they are checked, ogcp (front-end) stores them in browser's local storage. When they are unchecked, ogcp removes them from local storage. Every time users load a page with the scopes tree, ogcp checks local storage to restore selected clients.multi-ogserver
parent
b7e4f47f5c
commit
a9e6340517
|
@ -2,6 +2,23 @@ const Endpoint = '/scopes/status';
|
|||
const Interval = 1000;
|
||||
let updateTimeoutId = null;
|
||||
|
||||
function keepSelectedClients() {
|
||||
const checkboxes = $('input:checkbox[form|="scopesForm"]')
|
||||
|
||||
checkboxes.on('change', function (event) {
|
||||
if (this.checked)
|
||||
localStorage.setItem(this.name, "check");
|
||||
else
|
||||
localStorage.removeItem(this.name);
|
||||
});
|
||||
|
||||
checkboxes.each(function () {
|
||||
if (localStorage.getItem(this.name) == 'check') {
|
||||
this.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function keepScopesTreeState() {
|
||||
const scopes_tree = $('#scopes .collapse')
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
if (document.readyState === 'complete') {
|
||||
updateScopeState();
|
||||
keepScopesTreeState();
|
||||
keepSelectedClients();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue