From c77233f07d997f602c26701655772b3e6a1cde07 Mon Sep 17 00:00:00 2001 From: JaxxMoss Date: Fri, 16 May 2025 14:49:01 +0200 Subject: [PATCH] Save panel, when it's enabled in the settings. --- ui/src/components/panels/PanelView.vue | 35 ++++++++++++++++++++++---- ui/src/services/PanelService.js | 31 +++++++++++++++++++++++ ui/src/views/PanelsView.vue | 1 - 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/ui/src/components/panels/PanelView.vue b/ui/src/components/panels/PanelView.vue index 28a1b82..1667e74 100644 --- a/ui/src/components/panels/PanelView.vue +++ b/ui/src/components/panels/PanelView.vue @@ -21,37 +21,48 @@ along with this program. If not, see . @@ -88,7 +113,7 @@ const viewPanelListeners = () => { size-full bg-black; - .panel-preview__content { + .panel-container { @apply relative grid justify-center diff --git a/ui/src/services/PanelService.js b/ui/src/services/PanelService.js index 0f78dab..1637554 100644 --- a/ui/src/services/PanelService.js +++ b/ui/src/services/PanelService.js @@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { useNoticationStore } from '@/stores/notifications' + export const SetPanelStyle = (styleStr) => { const styleEl = document.createElement('style') styleEl.setAttribute('custom_panel_style', true) @@ -118,3 +120,32 @@ export const PanelDialogListeners = (panelEl) => { }) }) } + +const getPanelUrl = () => { + const url = new URL(window.location.href) + return url.pathname +} + +export const SavePanelToLocal = () => { + localStorage.setItem('last_opened_panel', getPanelUrl()) + + const notificationStore = useNoticationStore() + + notificationStore.add({ + message: 'Panel will be opened next launch', + variant: 'success', + time: 1000, + }) +} + +export const CheckLocalPanel = () => { + const localPanel = localStorage.getItem('last_opened_panel') + + if (localPanel) return localPanel == getPanelUrl() + + return false +} + +export const GetLocalPanel = () => { + return localStorage.getItem('last_opened_panel') +} diff --git a/ui/src/views/PanelsView.vue b/ui/src/views/PanelsView.vue index b96e96f..ed3d72c 100644 --- a/ui/src/views/PanelsView.vue +++ b/ui/src/views/PanelsView.vue @@ -45,7 +45,6 @@ import ButtonComp from '@/components/base/ButtonComp.vue' import PanelEdit from '@/components/panels/PanelEdit.vue' import PanelView from '@/components/panels/PanelView.vue' import PanelsOverview from '@/components/panels/PanelsOverview.vue' -import { isLocal } from '@/services/ApiService' import { IconArrowLeft } from '@tabler/icons-vue' import { onMounted, onUpdated, reactive } from 'vue' import { useRoute, useRouter } from 'vue-router'