diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 55586e9..8edd9e5 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -321,6 +321,7 @@ "ExtractPublicPropTypes": true, "WritableComputedRef": true, "injectLocal": true, + "storeRouteMapping": true, "provideLocal": true } } diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 7d89347..f254fea 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -115,6 +115,7 @@ declare global { const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] + const storeRouteMapping: typeof import('./src/utils/storeRouteMapping')['default'] const storeToRefs: typeof import('pinia')['storeToRefs'] const suite: typeof import('vitest')['suite'] const syncRef: typeof import('@vueuse/core')['syncRef'] diff --git a/src/App.vue b/src/App.vue index 6c9c8fd..dd4ce29 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,11 @@ import { useSettings } from '@stores/useSettings' import ModalBox from '@components/ModalBox.vue' import { updateAuthKey } from '@/api' +import useStoreMapping from '@/utils/storeRouteMapping' +const routesToExclude = ['home', 'settings'] +const route = useRoute() +const { storeMapping } = useStoreMapping() const settings = useSettings() const { getStatus } = settings const { isReadyAndAuth } = storeToRefs(settings) @@ -23,6 +27,17 @@ const authenticate = async () => { //resetAllStores() } } + +const currentComponentLoading = computed(() => { + const routeName = route.name?.toString() + let store + if (routeName !== undefined && !routesToExclude.includes(routeName)) { + store = storeMapping[routeName] + const { currentState } = storeToRefs(store) + return store && currentState.value.loading + } + return false +}) @@ -50,7 +65,7 @@ const authenticate = async () => { enterActiveClass="animate__animated animate__fadeIn animate__fastest" leaveActiveClass="animate__animated animate__fadeOut animate__fastest"> - + diff --git a/src/components/ModalBox.vue b/src/components/ModalBox.vue index ba272fb..bc7e24d 100644 --- a/src/components/ModalBox.vue +++ b/src/components/ModalBox.vue @@ -25,6 +25,7 @@ const closeModal = () => { defineExpose({ toggleModal, isOpen, + closeModal, }) diff --git a/src/components/SidePanel.vue b/src/components/SidePanel.vue index de3fd80..41cfd21 100644 --- a/src/components/SidePanel.vue +++ b/src/components/SidePanel.vue @@ -1,6 +1,7 @@ - + + leave-to="translate-x-full"> {{ title }} - + Close panel diff --git a/src/directives/vLock.ts b/src/directives/vLock.ts new file mode 100644 index 0000000..43801a3 --- /dev/null +++ b/src/directives/vLock.ts @@ -0,0 +1,19 @@ +import type { Directive } from 'vue' + +export const vLock: Directive = { + mounted(el, binding) { + if (binding.value) { + el.style.pointerEvents = 'none' + } else { + el.style.pointerEvents = 'initial' + } + }, + updated(el, binding) { + if (binding.value) { + el.style.pointerEvents = 'none' + } else { + el.style.pointerEvents = 'initial' + } + }, +} +export default vLock diff --git a/src/main.ts b/src/main.ts index df5ce9d..4ef9eb7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue' import { createPinia } from 'pinia' import { defineRule } from 'vee-validate' import AllRules from '@vee-validate/rules' +import vLock from '@/directives/vLock' Object.keys(AllRules).forEach(rule => { defineRule(rule, AllRules[rule]) @@ -23,8 +24,8 @@ pinia.use(({ store }) => { const state = cloneDeep(store.$state) store.$reset = () => store.$patch(state) }) - app.use(pinia) app.use(router) +app.directive('lock', vLock) app.mount('#app') diff --git a/src/stores/useMemory.ts b/src/stores/useMemory.ts index 736a3c6..080c314 100644 --- a/src/stores/useMemory.ts +++ b/src/stores/useMemory.ts @@ -29,7 +29,9 @@ export const useMemory = defineStore('memory', () => { const { sendNotificationFromJSON } = useNotifications() const wipeAllCollections = async () => { + currentState.loading = true const result = await MemoryService.wipeAllCollections() + currentState.loading = false if (result.status == 'success' && currentState.data) { remove(currentState.data, v => v.name != 'procedural') fetchCollections() @@ -43,7 +45,9 @@ export const useMemory = defineStore('memory', () => { } const wipeCollection = async (collection: string) => { + currentState.loading = true const result = await MemoryService.wipeCollection(collection) + currentState.loading = false if (result.status == 'success' && currentState.data) { remove(currentState.data, v => v.name == collection) fetchCollections() diff --git a/src/stores/usePlugins.ts b/src/stores/usePlugins.ts index d860bf6..db37ec9 100644 --- a/src/stores/usePlugins.ts +++ b/src/stores/usePlugins.ts @@ -39,6 +39,7 @@ export const usePlugins = defineStore('plugins', () => { const getSettings = async (id: Plugin['id']) => (await PluginService.getSinglePluginSettings(id))?.value const togglePlugin = async (id: Plugin['id'], name: Plugin['name'], active: boolean) => { + currentState.loading = true const res = await PluginService.togglePlugin(id) if (res.status == 'success') { showNotification({ @@ -46,7 +47,9 @@ export const usePlugins = defineStore('plugins', () => { type: 'info', }) } else sendNotificationFromJSON(res) + fetchSettings() fetchPlugins() + currentState.loading = false return res.status != 'error' } @@ -69,9 +72,10 @@ export const usePlugins = defineStore('plugins', () => { const installPlugin = async (file: File) => { currentState.loading = true const res = await PluginService.sendFile(file) + await fetchSettings() + await fetchPlugins() currentState.loading = false sendNotificationFromJSON(res) - fetchPlugins() } const searchPlugin = async (query: string) => { @@ -86,6 +90,8 @@ export const usePlugins = defineStore('plugins', () => { currentState.loading = true const res = await PluginService.installFromRegistry(url) if (res.status == 'error') sendNotificationFromJSON(res) + fetchSettings() + fetchPlugins() currentState.loading = false return res.data } diff --git a/src/utils/storeRouteMapping.ts b/src/utils/storeRouteMapping.ts new file mode 100644 index 0000000..ecf9524 --- /dev/null +++ b/src/utils/storeRouteMapping.ts @@ -0,0 +1,20 @@ +import { useEmbedderConfig } from '@/stores/useEmbedderConfig' +import { useLLMConfig } from '@/stores/useLLMConfig' +import { useMemory } from '@/stores/useMemory' +import { usePlugins } from '@/stores/usePlugins' + +export default function useStoreMapping() { + const storeEmbedder = useEmbedderConfig() + const storeLLM = useLLMConfig() + const storePlugins = usePlugins() + const storeMemory = useMemory() + + const storeMapping: Record = { + embedders: storeEmbedder, + providers: storeLLM, + memory: storeMemory, + plugins: storePlugins, + } + + return { storeMapping } +} diff --git a/src/views/MemoryView.vue b/src/views/MemoryView.vue index 260f7a5..79d130a 100644 --- a/src/views/MemoryView.vue +++ b/src/views/MemoryView.vue @@ -39,6 +39,7 @@ const wipeMemory = async () => { if (selectCollection.value) { const selected = selectCollection.value.selected?.value if (!selected) return + if (boxWipe.value?.isOpen) boxWipe.value?.closeModal() if (selected === 'all') await wipeAllCollections() else await wipeCollection(selected) if (boxWipe.value?.isOpen) boxWipe.value?.toggleModal() @@ -210,10 +211,51 @@ const dateFilter = ref(''), + + + + + Wipe + + + + + + + Wipe collection + + Are you sure you want to wipe + + {{ selectCollection?.selected.label.toLowerCase() }} + + the collections? + + + Are you sure you want to wipe the + + {{ selectCollection?.selected.label.toLowerCase() }} + + collection? + + + No + Yes + + + + + :error="memoryState.error" + :text="`Doing some magic...`" /> - - - - - Wipe - - - - - - - Wipe collection - - Are you sure you want to wipe - - {{ selectCollection?.selected.label.toLowerCase() }} - - the collections? - - - Are you sure you want to wipe the - - {{ selectCollection?.selected.label.toLowerCase() }} - - collection? - - - No - Yes - - - - diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue index 7db9e76..be493ed 100644 --- a/src/views/SettingsView.vue +++ b/src/views/SettingsView.vue @@ -1,6 +1,9 @@
+ Are you sure you want to wipe + + {{ selectCollection?.selected.label.toLowerCase() }} + + the collections? +
+ Are you sure you want to wipe the + + {{ selectCollection?.selected.label.toLowerCase() }} + + collection? +
- Are you sure you want to wipe - - {{ selectCollection?.selected.label.toLowerCase() }} - - the collections? -
- Are you sure you want to wipe the - - {{ selectCollection?.selected.label.toLowerCase() }} - - collection? -
diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue index 7db9e76..be493ed 100644 --- a/src/views/SettingsView.vue +++ b/src/views/SettingsView.vue @@ -1,6 +1,9 @@