Use session storage for sidebar state

The sidebar state is now maintained per tab/window because users view
different things in different tabs/windows. E.g. users work with a
specific module constantly clicking through the menu while having
other tabs/windows with some important dashboards open.
When the sidebar is closed in one tab/widnow, it should not close
the sidebar in the other tabs/windows.
This commit is contained in:
Eric Lippmann 2019-07-29 10:16:49 +02:00 committed by Johannes Meyer
parent a1a18feb04
commit 62d4e73d5a
1 changed files with 2 additions and 12 deletions

View File

@ -38,22 +38,12 @@
*/
this.storage = Icinga.Storage.BehaviorStorage('navigation');
this.storage.setBackend(window.sessionStorage);
// Restore collapsed sidebar if necessary
if (this.storage.get('sidebar-collapsed')) {
$('#layout').addClass('sidebar-collapsed');
}
// Ensure we'll get notified if the sidebar is toggled in another window
this.storage.onChange('sidebar-collapsed', function (collapsed) {
// Not using toggleClass here to avoid inconsistencies
if (collapsed) {
$('#layout').addClass('sidebar-collapsed');
} else {
$('#layout').removeClass('sidebar-collapsed');
}
$(window).trigger('resize');
}, this);
};
Navigation.prototype = new Icinga.EventListener();