diff --git a/templates/index.html b/templates/index.html index e022008..bd72d5d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1964,6 +1964,37 @@ function updateContainerSelectionUI() { // Обновляем заголовок updateLogTitle(); + + // Если есть сохраненный контейнер, убеждаемся что его чекбокс отмечен + const savedContainerId = getSelectedContainerFromStorage(); + if (savedContainerId && state.selectedContainers.includes(savedContainerId)) { + const checkbox = document.querySelector(`.container-checkbox[data-container-id="${savedContainerId}"]`); + if (checkbox) { + checkbox.checked = true; + const containerItem = checkbox.closest('.container-item'); + if (containerItem) { + containerItem.classList.add('selected'); + } + } + } +} + +// Функция для сохранения выбранного контейнера в localStorage +function saveSelectedContainer(containerId) { + if (containerId) { + localStorage.setItem('lb_selected_container', containerId); + console.log('Saved selected container to localStorage:', containerId); + } else { + localStorage.removeItem('lb_selected_container'); + console.log('Removed selected container from localStorage'); + } +} + +// Функция для восстановления выбранного контейнера из localStorage +function getSelectedContainerFromStorage() { + const containerId = localStorage.getItem('lb_selected_container'); + console.log('Retrieved selected container from localStorage:', containerId); + return containerId; } async function updateMultiViewMode() { @@ -1982,8 +2013,14 @@ async function updateMultiViewMode() { if (selectedService) { console.log('Switching to single view for:', selectedService.name); console.log('updateMultiViewMode: About to call switchToSingle - VERSION 2'); - await switchToSingle(selectedService); - console.log('updateMultiViewMode: switchToSingle call completed - VERSION 2'); + + // Сохраняем выбранный контейнер в localStorage + saveSelectedContainer(selectedService.id); + + // Обновляем страницу для полного сброса состояния + console.log('Refreshing page to switch to single view'); + window.location.reload(); + return; // Прерываем выполнение, так как страница перезагрузится } } else { // Когда снимаем все галочки, переключаемся в single view @@ -3313,6 +3350,24 @@ window.addEventListener('keydown', async (e)=>{ await fetchProjects(); await fetchServices(); + // Проверяем, есть ли сохраненный контейнер в localStorage + const savedContainerId = getSelectedContainerFromStorage(); + if (savedContainerId) { + console.log('Found saved container, switching to it:', savedContainerId); + const savedService = state.services.find(s => s.id === savedContainerId); + if (savedService) { + // Добавляем контейнер в выбранные + state.selectedContainers = [savedContainerId]; + // Переключаемся на сохраненный контейнер + await switchToSingle(savedService); + // Очищаем сохраненный контейнер из localStorage + saveSelectedContainer(null); + } else { + console.log('Saved container not found in services, clearing localStorage'); + saveSelectedContainer(null); + } + } + // Инициализируем видимость счетчиков updateCounterVisibility();