@swiss-ai-hub/web 0.290.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +479 -0
- package/app.config.ts +1 -0
- package/app.vue +52 -0
- package/assets/css/main.css +4 -0
- package/assets/images/logo.png +0 -0
- package/components/Agent/Avatar.vue +40 -0
- package/components/Agent/Card.vue +139 -0
- package/components/Agent/Configuration.vue +20 -0
- package/components/Agent/CreateModal.vue +287 -0
- package/components/Agent/EmptyCard.vue +35 -0
- package/components/Agent/List.vue +85 -0
- package/components/Agent/TemplateCard.vue +58 -0
- package/components/AppLoader.vue +55 -0
- package/components/Chat/Message.vue +90 -0
- package/components/Chat/SourceNodes.vue +120 -0
- package/components/Chat/Thread.vue +134 -0
- package/components/Costs/Table.vue +56 -0
- package/components/Dashboard/Component/BarChart.vue +46 -0
- package/components/Dashboard/Component/LineChart.vue +138 -0
- package/components/Dashboard/Component/Number.vue +31 -0
- package/components/Dashboard/Grid.vue +214 -0
- package/components/Dashboard/Item.vue +75 -0
- package/components/Dashboard/Trend.vue +34 -0
- package/components/Display/List/DisplayList.vue +93 -0
- package/components/Evaluation/Dataset/Card.vue +70 -0
- package/components/Evaluation/Dataset/Create.vue +81 -0
- package/components/Evaluation/Dataset/Edit.vue +132 -0
- package/components/Event/Display/AddMemoryToChatHistoryEvent.vue +60 -0
- package/components/Event/Display/AgentInTheLoopRequestEvent.vue +56 -0
- package/components/Event/Display/AgentInTheLoopResponseEvent.vue +17 -0
- package/components/Event/Display/Base.vue +125 -0
- package/components/Event/Display/BaseRetrieveMemoryEvent.vue +101 -0
- package/components/Event/Display/BaseStoreMemoryEvent.vue +182 -0
- package/components/Event/Display/ChunkEvent.vue +40 -0
- package/components/Event/Display/EmbeddingEvent.vue +25 -0
- package/components/Event/Display/ExceptionEvent.vue +21 -0
- package/components/Event/Display/GuardAcceptEvent.vue +25 -0
- package/components/Event/Display/GuardEvent.vue +17 -0
- package/components/Event/Display/GuardRejectionEvent.vue +25 -0
- package/components/Event/Display/HumanInTheLoopRequestEvent.vue +53 -0
- package/components/Event/Display/HumanInTheLoopResponseEvent.vue +40 -0
- package/components/Event/Display/LLMCostEvent.vue +25 -0
- package/components/Event/Display/LLMEvent.vue +92 -0
- package/components/Event/Display/LimitChatHistoryEvent.vue +60 -0
- package/components/Event/Display/RAGFailureStopEvent.vue +28 -0
- package/components/Event/Display/RAGStartEvent.vue +77 -0
- package/components/Event/Display/RAGSuccessStopEvent.vue +16 -0
- package/components/Event/Display/RawDataContent.vue +69 -0
- package/components/Event/Display/RerankerEvent.vue +39 -0
- package/components/Event/Display/RetrieverEvent.vue +22 -0
- package/components/Event/Display/RouterEvent.vue +54 -0
- package/components/Event/Display/StandaloneQuestionCondenserEvent.vue +38 -0
- package/components/Event/Display/StopEvent.vue +16 -0
- package/components/Event/Display/ThoughtEvent.vue +20 -0
- package/components/Event/Display/ToolEvent.vue +38 -0
- package/components/Event/Display/UnknownEvent.vue +17 -0
- package/components/Event/Display/UserMessageEvent.vue +35 -0
- package/components/Event/List/EventList.vue +249 -0
- package/components/Event/Statistics.vue +49 -0
- package/components/Event/Timeseries.vue +224 -0
- package/components/FormKit/AgentSelector.vue +307 -0
- package/components/FormKit/ChipsInput.vue +62 -0
- package/components/FormKit/DynamicConfiguration.vue +155 -0
- package/components/FormKit/IconSelector.vue +72 -0
- package/components/FormKit/KnowledgeDatabaseSelector.vue +92 -0
- package/components/FormKit/LocaleInput.vue +150 -0
- package/components/FormKit/ModelSelect.vue +110 -0
- package/components/FormKit/Repeater.vue +93 -0
- package/components/FormKit/VectorStoreInput.vue +247 -0
- package/components/Knowledge/Document/List.vue +140 -0
- package/components/Knowledge/Document/Overview.vue +28 -0
- package/components/Knowledge/Document/UploadModal.vue +298 -0
- package/components/Knowledge/Document/WithNodes.vue +105 -0
- package/components/Knowledge/Namespace/Card.vue +108 -0
- package/components/Knowledge/Namespace/CreateModal.vue +203 -0
- package/components/Knowledge/Namespace/EditModal.vue +134 -0
- package/components/Knowledge/Namespace/EmptyCard.vue +35 -0
- package/components/Knowledge/Node/Content.vue +71 -0
- package/components/Markdown/Renderer.vue +87 -0
- package/components/Memory/DetailPage.vue +48 -0
- package/components/Memory/Edit.vue +241 -0
- package/components/Memory/Graph.vue +318 -0
- package/components/Memory/List.vue +155 -0
- package/components/Memory/MemoryManagementPage.vue +178 -0
- package/components/Memory/OpenWebUIContent.vue +96 -0
- package/components/Memory/PageLayout.vue +72 -0
- package/components/Models/ModelDetailsPanel.vue +250 -0
- package/components/Models/NamespaceCard.vue +79 -0
- package/components/Navigation/Left.vue +85 -0
- package/components/Navigation/Top.vue +31 -0
- package/components/Notification/Item.vue +88 -0
- package/components/Notification/NotificationsOverlay.vue +164 -0
- package/components/Process/Card.vue +119 -0
- package/components/Process/Configuration.vue +20 -0
- package/components/Process/CreateModal.vue +276 -0
- package/components/Process/EmptyCard.vue +35 -0
- package/components/Process/Form.vue +153 -0
- package/components/Process/Starts.vue +44 -0
- package/components/Process/Walkthrough/List.vue +162 -0
- package/components/Role/AccessRulesEditor.vue +132 -0
- package/components/Role/Card.vue +68 -0
- package/components/Role/Create.vue +55 -0
- package/components/Role/Edit.vue +82 -0
- package/components/Role/UsageLimitsEditor.vue +225 -0
- package/components/Service/Selection.vue +148 -0
- package/components/Structural/Column.vue +74 -0
- package/components/Structural/Screen.vue +10 -0
- package/components/Structural/Substructure.vue +5 -0
- package/components/Tenant/Switcher.vue +102 -0
- package/components/Thread/Details.vue +135 -0
- package/components/Thread/Hierarchy.vue +136 -0
- package/components/Thread/Info.vue +41 -0
- package/components/Thread/List.vue +136 -0
- package/components/User/Bar.vue +74 -0
- package/components/User/List.vue +86 -0
- package/components/User/RoleChips.vue +83 -0
- package/components/User/Settings.vue +79 -0
- package/components/Workflow/Modal.vue +39 -0
- package/components/Workflow/NodeCard.vue +41 -0
- package/components/Workflow/StartNode.vue +24 -0
- package/components/Workflow/StepNode.vue +27 -0
- package/components/Workflow/StopNode.vue +24 -0
- package/components/Workflow/Visualization.vue +265 -0
- package/components/mdc/MarkdownFigure.vue +9 -0
- package/components/mdc/MarkdownTable.vue +9 -0
- package/components/mdc/ResolveImageComponent.vue +58 -0
- package/composables/agent/useAgentClass.ts +27 -0
- package/composables/agent/useAgentClassInstances.ts +27 -0
- package/composables/agent/useAgentClasses.ts +27 -0
- package/composables/agent/useAgentIconFromThread.ts +8 -0
- package/composables/agent/useAgentInstance.ts +28 -0
- package/composables/agent/useAgentInstanceThreads.ts +76 -0
- package/composables/agent/useAgentInstances.ts +25 -0
- package/composables/agent/useAgentNavigation.ts +35 -0
- package/composables/agent/useCreateAgentInstance.ts +33 -0
- package/composables/agent/useDeleteAgentInstance.ts +31 -0
- package/composables/agent/useUpdateAgentInstance.ts +40 -0
- package/composables/auth/useAuth.ts +54 -0
- package/composables/auth/useAuthProviders.ts +14 -0
- package/composables/chat/useChatCompletions.ts +30 -0
- package/composables/dashboard/useAgentNameFromDashboardWidget.ts +27 -0
- package/composables/dashboard/useDashboardComponent.ts +27 -0
- package/composables/dashboard/useSaveDashboard.ts +21 -0
- package/composables/document/useCreateNamespace.ts +26 -0
- package/composables/document/useDatabases.ts +23 -0
- package/composables/document/useDocument.ts +29 -0
- package/composables/document/useDocumentUrl.ts +20 -0
- package/composables/document/useDocuments.ts +107 -0
- package/composables/document/useNodes.ts +29 -0
- package/composables/document/useSummaryNodes.ts +32 -0
- package/composables/document/useUpdateNamespace.ts +22 -0
- package/composables/evaluation/useCreateDataset.ts +19 -0
- package/composables/evaluation/useDataset.ts +26 -0
- package/composables/evaluation/useDatasets.ts +25 -0
- package/composables/evaluation/useUpdateDataset.ts +23 -0
- package/composables/event/useBasicEventStatistics.ts +83 -0
- package/composables/event/useEventColor.ts +25 -0
- package/composables/event/useEventComponent.ts +87 -0
- package/composables/event/useEventTimeseries.ts +39 -0
- package/composables/event/useEventTimeseriesStats.ts +26 -0
- package/composables/file/useFileUpload.ts +91 -0
- package/composables/file/useSupportedFileTypes.ts +22 -0
- package/composables/form/useCreateInstanceForm.ts +251 -0
- package/composables/form/useFormKitTransform.ts +753 -0
- package/composables/memory/useMemoryCRUD.ts +88 -0
- package/composables/memory/useMemoryFactory.ts +319 -0
- package/composables/memory/useMemorySearchFilter.ts +74 -0
- package/composables/models/useModelsList.ts +24 -0
- package/composables/models/useSingleModel.ts +30 -0
- package/composables/notification/useNotificationPoller.ts +58 -0
- package/composables/notification/useNotifications.ts +57 -0
- package/composables/notification/useUpdateMultipleNotifications.ts +17 -0
- package/composables/notification/useUpdateNotification.ts +17 -0
- package/composables/process/useCreateProcessInstance.ts +32 -0
- package/composables/process/useDeleteProcessInstance.ts +31 -0
- package/composables/process/useProcessClasses.ts +27 -0
- package/composables/process/useProcessInstance.ts +28 -0
- package/composables/process/useProcessInstances.ts +27 -0
- package/composables/process/useProcessWalkthroughs.ts +73 -0
- package/composables/process/useSendProcessStartForm.ts +43 -0
- package/composables/process/useUpdateProcessInstance.ts +40 -0
- package/composables/role/useCreateRole.ts +19 -0
- package/composables/role/useDeleteRole.ts +21 -0
- package/composables/role/useRole.ts +30 -0
- package/composables/role/useRoles.ts +25 -0
- package/composables/role/useUpdateRole.ts +22 -0
- package/composables/suite/useApps.ts +31 -0
- package/composables/suite/useSuite.ts +26 -0
- package/composables/tenant/useActiveTenant.ts +27 -0
- package/composables/tenant/useSysadminNavigation.ts +19 -0
- package/composables/tenant/useTenant.ts +38 -0
- package/composables/tenant/useTenantMemberships.ts +15 -0
- package/composables/tenant/useTenantPath.ts +20 -0
- package/composables/tenant/useTenantPolling.ts +30 -0
- package/composables/tenant/useTenantReady.ts +12 -0
- package/composables/theme/useDarkMode.ts +5 -0
- package/composables/thread/useThread.ts +27 -0
- package/composables/thread/useThreadEvents.ts +91 -0
- package/composables/thread/useThreadUtils.ts +49 -0
- package/composables/thread/useThreads.ts +64 -0
- package/composables/thread/useThreadsInfinite.ts +56 -0
- package/composables/translation/useTranslate.ts +20 -0
- package/composables/useRouteReady.ts +21 -0
- package/composables/useTimeAgo.ts +40 -0
- package/composables/user/useAssignRoleToUser.ts +22 -0
- package/composables/user/useMyUser.ts +25 -0
- package/composables/user/useRevokeRoleFromUser.ts +21 -0
- package/composables/user/useUser.ts +30 -0
- package/composables/user/useUsers.ts +63 -0
- package/composables/utils/useJsonTree.ts +138 -0
- package/formkit.config.ts +44 -0
- package/i18n/locales/de.yaml +815 -0
- package/i18n/locales/en.yaml +804 -0
- package/i18n/locales/fr.yaml +812 -0
- package/i18n/locales/it.yaml +808 -0
- package/layouts/anonymous.vue +8 -0
- package/layouts/default.vue +116 -0
- package/middleware/auth.global.ts +62 -0
- package/nuxt.config.ts +145 -0
- package/package.json +114 -0
- package/pages/[tenant]/index.vue +31 -0
- package/pages/[tenant]/notifications/index.vue +235 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/chat.vue +67 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/configuration.vue +122 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/memories/[memory_id].vue +3 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/memories.vue +20 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/overview.vue +72 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/threads.vue +52 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id]/workflow.vue +19 -0
- package/pages/[tenant]/service/agents/[agent_class]-[agent_id].vue +63 -0
- package/pages/[tenant]/service/agents/templates.vue +102 -0
- package/pages/[tenant]/service/agents.vue +185 -0
- package/pages/[tenant]/service/datasets/[dataset_id].vue +81 -0
- package/pages/[tenant]/service/datasets.vue +53 -0
- package/pages/[tenant]/service/health/index.vue +3 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/nodes.vue +20 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/overview.vue +40 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id]/summary.vue +88 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace]/[document_id].vue +48 -0
- package/pages/[tenant]/service/knowledge/[db]/[namespace].vue +144 -0
- package/pages/[tenant]/service/knowledge.vue +126 -0
- package/pages/[tenant]/service/models/[model_name].vue +84 -0
- package/pages/[tenant]/service/models.vue +61 -0
- package/pages/[tenant]/service/my-account.vue +117 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/memories.vue +66 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/sources.vue +100 -0
- package/pages/[tenant]/service/openai/[thread_id]/[display_id]/tracing.vue +49 -0
- package/pages/[tenant]/service/openai.vue +101 -0
- package/pages/[tenant]/service/organization-memories/graph.vue +97 -0
- package/pages/[tenant]/service/organization-memories/list/[memory_id].vue +3 -0
- package/pages/[tenant]/service/organization-memories/list.vue +150 -0
- package/pages/[tenant]/service/organization-memories.vue +3 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/[process_walkthrough_id].vue +7 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/configuration.vue +106 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/overview.vue +67 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/start.vue +26 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/walkthroughs/[process_walkthrough_id]/overview.vue +14 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id]/walkthroughs.vue +54 -0
- package/pages/[tenant]/service/processes/[process_class]-[process_id].vue +60 -0
- package/pages/[tenant]/service/processes.vue +129 -0
- package/pages/[tenant]/service/roles/[role_id].vue +54 -0
- package/pages/[tenant]/service/roles.vue +84 -0
- package/pages/[tenant]/service/threads/[thread_id]/chat.vue +51 -0
- package/pages/[tenant]/service/threads/[thread_id]/display/[display_id].vue +21 -0
- package/pages/[tenant]/service/threads/[thread_id]/display.vue +29 -0
- package/pages/[tenant]/service/threads/[thread_id]/hierarchy.vue +14 -0
- package/pages/[tenant]/service/threads/[thread_id]/memories/[memory_id].vue +3 -0
- package/pages/[tenant]/service/threads/[thread_id]/memories.vue +19 -0
- package/pages/[tenant]/service/threads/[thread_id]/overview.vue +100 -0
- package/pages/[tenant]/service/threads/[thread_id].vue +54 -0
- package/pages/[tenant]/service/threads.vue +52 -0
- package/pages/[tenant]/service/user-memories/graph.vue +97 -0
- package/pages/[tenant]/service/user-memories/list/[memory_id].vue +3 -0
- package/pages/[tenant]/service/user-memories/list.vue +150 -0
- package/pages/[tenant]/service/user-memories.vue +3 -0
- package/pages/[tenant]/service/users/[user_id].vue +117 -0
- package/pages/[tenant]/service/users.vue +88 -0
- package/pages/auth/callback.vue +52 -0
- package/pages/auth/login.vue +80 -0
- package/pages/auth/renew.vue +24 -0
- package/pages/index.vue +59 -0
- package/pages/select-tenant.vue +76 -0
- package/plugins/0.runtime-config.client.ts +55 -0
- package/plugins/apexcharts.client.ts +5 -0
- package/plugins/api-client.client.ts +38 -0
- package/plugins/dark-mode.client.ts +12 -0
- package/plugins/keycloak-client.ts +41 -0
- package/plugins/oidc-client.ts +78 -0
- package/sdk/client/client/client.gen.ts +237 -0
- package/sdk/client/client/index.ts +24 -0
- package/sdk/client/client/types.gen.ts +213 -0
- package/sdk/client/client/utils.gen.ts +407 -0
- package/sdk/client/client.gen.ts +25 -0
- package/sdk/client/core/auth.gen.ts +42 -0
- package/sdk/client/core/bodySerializer.gen.ts +96 -0
- package/sdk/client/core/params.gen.ts +181 -0
- package/sdk/client/core/pathSerializer.gen.ts +180 -0
- package/sdk/client/core/queryKeySerializer.gen.ts +136 -0
- package/sdk/client/core/serverSentEvents.gen.ts +265 -0
- package/sdk/client/core/types.gen.ts +118 -0
- package/sdk/client/core/utils.gen.ts +143 -0
- package/sdk/client/index.ts +1013 -0
- package/sdk/client/schemas.gen.ts +35395 -0
- package/sdk/client/sdk.gen.ts +3438 -0
- package/sdk/client/transformers.gen.ts +143 -0
- package/sdk/client/types.gen.ts +27567 -0
- package/tailwind.config.mjs +27 -0
- package/themes/aihub-theme.ts +125 -0
- package/types/DashboardWidget.ts +13 -0
- package/types/EventChartInput.ts +7 -0
- package/types/NavItem.ts +6 -0
- package/types/TimeseriesInput.ts +7 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createProcessInstance, type CreateProcessInstanceRequest } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useCreateProcessInstance = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
mutateAsync: createProcessInstanceMutation,
|
|
8
|
+
isPending: isCreating,
|
|
9
|
+
error: createError,
|
|
10
|
+
} = useMutation({
|
|
11
|
+
mutation: async ({ processClass, request, tenantId }: { processClass: string, request: CreateProcessInstanceRequest, tenantId: string }) => {
|
|
12
|
+
const result = await createProcessInstance({
|
|
13
|
+
composable: '$fetch',
|
|
14
|
+
path: {
|
|
15
|
+
tenant_id: tenantId,
|
|
16
|
+
process_class: processClass,
|
|
17
|
+
},
|
|
18
|
+
body: request,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-instances'] })
|
|
22
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-class-instances', processClass] })
|
|
23
|
+
return result
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
createProcessInstance: createProcessInstanceMutation,
|
|
29
|
+
isCreating,
|
|
30
|
+
createError,
|
|
31
|
+
}
|
|
32
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { deleteProcessInstance } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useDeleteProcessInstance = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
mutateAsync: deleteProcessInstanceMutation,
|
|
8
|
+
isPending: isDeleting,
|
|
9
|
+
error: deleteError,
|
|
10
|
+
} = useMutation({
|
|
11
|
+
mutation: async ({ processClass, processId, tenantId }: { processClass: string, processId: string, tenantId: string }) => {
|
|
12
|
+
await deleteProcessInstance({
|
|
13
|
+
composable: '$fetch',
|
|
14
|
+
path: {
|
|
15
|
+
tenant_id: tenantId,
|
|
16
|
+
process_class: processClass,
|
|
17
|
+
process_id: processId,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-instances'] })
|
|
22
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-class-instances', processClass] })
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
deleteProcessInstance: deleteProcessInstanceMutation,
|
|
28
|
+
isDeleting,
|
|
29
|
+
deleteError,
|
|
30
|
+
}
|
|
31
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ProcessClassDtoReadable, getProcessClasses } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export type ProcessClassDto = ProcessClassDtoReadable
|
|
5
|
+
|
|
6
|
+
export const useProcessClasses = defineQuery((options?: { online?: boolean }) => {
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const { data: processClasses, isPending: processClassesAreLoading } = useQuery<ProcessClassDto[]>({
|
|
10
|
+
key: () => ['tenant', tenantId.value, 'process-classes', options?.online],
|
|
11
|
+
staleTime: minutesToMilliseconds(5),
|
|
12
|
+
enabled: useTenantReady(),
|
|
13
|
+
query: async () => {
|
|
14
|
+
return await getProcessClasses({
|
|
15
|
+
composable: '$fetch',
|
|
16
|
+
path: { tenant_id: tenantId.value! },
|
|
17
|
+
query: {
|
|
18
|
+
online: options?.online,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
return {
|
|
24
|
+
processClasses,
|
|
25
|
+
processClassesAreLoading,
|
|
26
|
+
}
|
|
27
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FullProcessInstanceDtoReadable, getProcessInstance } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export const useProcessInstance = defineQuery(() => {
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const { data: processInstance, isPending: processInstanceIsLoading } = useQuery<FullProcessInstanceDtoReadable>({
|
|
10
|
+
key: () => ['tenant', tenantId.value, 'process-instances', route.params.process_class as string, route.params.process_id as string],
|
|
11
|
+
staleTime: minutesToMilliseconds(5),
|
|
12
|
+
enabled: useTenantReady('process_id', 'process_class'),
|
|
13
|
+
query: async () => {
|
|
14
|
+
return await getProcessInstance({
|
|
15
|
+
composable: '$fetch',
|
|
16
|
+
path: {
|
|
17
|
+
tenant_id: tenantId.value!,
|
|
18
|
+
process_id: route.params.process_id as string,
|
|
19
|
+
process_class: route.params.process_class as string,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
return {
|
|
25
|
+
processInstance,
|
|
26
|
+
processInstanceIsLoading,
|
|
27
|
+
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type FullProcessInstanceDtoReadable, getAllProcessInstances } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export type FullProcessInstanceDto = FullProcessInstanceDtoReadable
|
|
5
|
+
|
|
6
|
+
export const useProcessInstances = defineQuery((options?: { online?: boolean }) => {
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const { data: processInstances, isPending: processInstancesAreLoading } = useQuery<FullProcessInstanceDto[]>({
|
|
10
|
+
key: () => ['tenant', tenantId.value, 'process-instances', options?.online],
|
|
11
|
+
staleTime: minutesToMilliseconds(5),
|
|
12
|
+
enabled: useTenantReady(),
|
|
13
|
+
query: async () => {
|
|
14
|
+
return await getAllProcessInstances({
|
|
15
|
+
composable: '$fetch',
|
|
16
|
+
path: { tenant_id: tenantId.value! },
|
|
17
|
+
query: {
|
|
18
|
+
online: options?.online,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
return {
|
|
24
|
+
processInstances,
|
|
25
|
+
processInstancesAreLoading,
|
|
26
|
+
}
|
|
27
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getProcessWalkthroughs, type ProcessWalkthroughDto } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useProcessWalkthroughs = defineQuery(() => {
|
|
4
|
+
const route = useRoute()
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
const currentPage = ref(1)
|
|
8
|
+
const pageSize = ref(10)
|
|
9
|
+
|
|
10
|
+
const processClass = computed(() => route.params.process_class as string)
|
|
11
|
+
const processId = computed(() => route.params.process_id as string)
|
|
12
|
+
|
|
13
|
+
const walkthroughsQuery = useQuery({
|
|
14
|
+
key: () => ['tenant', tenantId.value, 'process-walkthroughs', processClass.value, processId.value, { page: currentPage.value, size: pageSize.value }],
|
|
15
|
+
enabled: useTenantReady('process_class', 'process_id'),
|
|
16
|
+
query: async () => {
|
|
17
|
+
const pageToFetch = Math.max(1, currentPage.value)
|
|
18
|
+
|
|
19
|
+
return await getProcessWalkthroughs({
|
|
20
|
+
composable: '$fetch',
|
|
21
|
+
path: {
|
|
22
|
+
tenant_id: tenantId.value!,
|
|
23
|
+
process_class: processClass.value,
|
|
24
|
+
process_id: processId.value,
|
|
25
|
+
},
|
|
26
|
+
query: {
|
|
27
|
+
page: pageToFetch,
|
|
28
|
+
page_size: pageSize.value,
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
placeholderData: previousData => previousData,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const setPageSize = (newSize: number) => {
|
|
36
|
+
if (newSize > 0) {
|
|
37
|
+
pageSize.value = newSize
|
|
38
|
+
currentPage.value = 1
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const setPage = (newPage: number) => {
|
|
43
|
+
if (newPage > 0) {
|
|
44
|
+
currentPage.value = newPage
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const paginationMeta = computed(() => {
|
|
49
|
+
const data = walkthroughsQuery.state.value?.data
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
total: data?.total ?? 0,
|
|
53
|
+
currentPage: data?.page ?? currentPage.value,
|
|
54
|
+
pageSize: data?.page_size ?? pageSize.value,
|
|
55
|
+
totalPages: data?.total_pages ?? 0,
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const walkthroughs = computed(() => (walkthroughsQuery.state.value?.data)?.walkthroughs ?? [] as ProcessWalkthroughDto[])
|
|
60
|
+
|
|
61
|
+
const isLoading = computed(() => walkthroughsQuery.asyncStatus.value === 'loading')
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
walkthroughs,
|
|
65
|
+
isLoading,
|
|
66
|
+
pagination: paginationMeta,
|
|
67
|
+
currentPage,
|
|
68
|
+
pageSize,
|
|
69
|
+
setPage,
|
|
70
|
+
setPageSize,
|
|
71
|
+
refetch: walkthroughsQuery.refetch,
|
|
72
|
+
}
|
|
73
|
+
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { sendProcessStartForm } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useSendProcessStartForm = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: sendProcessStartFormMutation } = useMutation({
|
|
7
|
+
mutation: async ({
|
|
8
|
+
processClass,
|
|
9
|
+
processId,
|
|
10
|
+
tenantId,
|
|
11
|
+
submissionRoute,
|
|
12
|
+
submissionMethod,
|
|
13
|
+
data,
|
|
14
|
+
}: {
|
|
15
|
+
processClass: string
|
|
16
|
+
processId: string
|
|
17
|
+
tenantId: string
|
|
18
|
+
submissionRoute: string
|
|
19
|
+
submissionMethod: string
|
|
20
|
+
data: Record<string, unknown>
|
|
21
|
+
}) => {
|
|
22
|
+
console.log('sending', data)
|
|
23
|
+
await sendProcessStartForm({
|
|
24
|
+
composable: '$fetch',
|
|
25
|
+
path: {
|
|
26
|
+
tenant_id: tenantId,
|
|
27
|
+
process_class: processClass,
|
|
28
|
+
process_id: processId,
|
|
29
|
+
},
|
|
30
|
+
query: {
|
|
31
|
+
submission_route: submissionRoute,
|
|
32
|
+
submission_method: submissionMethod,
|
|
33
|
+
},
|
|
34
|
+
body: JSON.parse(JSON.stringify(data)),
|
|
35
|
+
})
|
|
36
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-instances'] })
|
|
37
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-walkthroughs'] })
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
return {
|
|
41
|
+
sendProcessStartForm: sendProcessStartFormMutation,
|
|
42
|
+
}
|
|
43
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { updateProcessInstance } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useUpdateProcessInstance = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: updateProcessInstanceMutation, isPending: isUpdating } = useMutation({
|
|
7
|
+
mutation: async ({
|
|
8
|
+
processClass,
|
|
9
|
+
processId,
|
|
10
|
+
tenantId,
|
|
11
|
+
configuration,
|
|
12
|
+
}: {
|
|
13
|
+
processClass: string
|
|
14
|
+
processId: string
|
|
15
|
+
tenantId: string
|
|
16
|
+
configuration: Record<string, unknown>
|
|
17
|
+
}) => {
|
|
18
|
+
const result = await updateProcessInstance({
|
|
19
|
+
composable: '$fetch',
|
|
20
|
+
path: {
|
|
21
|
+
tenant_id: tenantId,
|
|
22
|
+
process_class: processClass,
|
|
23
|
+
process_id: processId,
|
|
24
|
+
},
|
|
25
|
+
body: {
|
|
26
|
+
configuration,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-instances', processClass, processId] })
|
|
30
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-instances'] })
|
|
31
|
+
queryCache.invalidateQueries({ key: ['tenant', tenantId, 'process-class-instances', processClass] })
|
|
32
|
+
return result
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
updateProcessInstance: updateProcessInstanceMutation,
|
|
38
|
+
isUpdating,
|
|
39
|
+
}
|
|
40
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRole, type CreateRoleRequest } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useCreateRole = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: createRoleMutation } = useMutation({
|
|
7
|
+
mutation: async ({ createdRole, tenantId }: { createdRole: CreateRoleRequest, tenantId: string }) => {
|
|
8
|
+
await createRole({
|
|
9
|
+
composable: '$fetch',
|
|
10
|
+
path: { tenant_id: tenantId },
|
|
11
|
+
body: createdRole,
|
|
12
|
+
})
|
|
13
|
+
queryCache.invalidateQueries()
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
return {
|
|
17
|
+
createRole: createRoleMutation,
|
|
18
|
+
}
|
|
19
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { deleteRole } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useDeleteRole = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: removeRole } = useMutation({
|
|
7
|
+
mutation: async ({ roleId, tenantId }: { roleId: string, tenantId: string }) => {
|
|
8
|
+
await deleteRole({
|
|
9
|
+
composable: '$fetch',
|
|
10
|
+
path: {
|
|
11
|
+
tenant_id: tenantId,
|
|
12
|
+
role_id: roleId,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
queryCache.invalidateQueries()
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
return {
|
|
19
|
+
deleteRole: removeRole,
|
|
20
|
+
}
|
|
21
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getRole, type RoleResponse } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export default defineQuery(() => {
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
const { tenantId } = useTenant()
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
data: role,
|
|
11
|
+
isPending: roleIsLoading,
|
|
12
|
+
} = useQuery<RoleResponse>({
|
|
13
|
+
key: () => ['tenant', tenantId.value, 'roles', route.params.role_id as string],
|
|
14
|
+
staleTime: minutesToMilliseconds(5),
|
|
15
|
+
enabled: useTenantReady('role_id'),
|
|
16
|
+
query: async () => {
|
|
17
|
+
return await getRole({
|
|
18
|
+
composable: '$fetch',
|
|
19
|
+
path: {
|
|
20
|
+
tenant_id: tenantId.value!,
|
|
21
|
+
role_id: route.params.role_id as string,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
return {
|
|
27
|
+
role,
|
|
28
|
+
roleIsLoading,
|
|
29
|
+
}
|
|
30
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getRoles, type RoleResponse } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export default defineQuery(() => {
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
data: roles,
|
|
9
|
+
isPending: rolesAreLoading,
|
|
10
|
+
} = useQuery<RoleResponse[]>({
|
|
11
|
+
key: () => ['tenant', tenantId.value, 'roles'],
|
|
12
|
+
staleTime: minutesToMilliseconds(5),
|
|
13
|
+
enabled: useTenantReady(),
|
|
14
|
+
query: async () => {
|
|
15
|
+
return await getRoles({
|
|
16
|
+
composable: '$fetch',
|
|
17
|
+
path: { tenant_id: tenantId.value! },
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
return {
|
|
22
|
+
roles,
|
|
23
|
+
rolesAreLoading,
|
|
24
|
+
}
|
|
25
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { updateRole, type UpdateRoleRequest } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
export const useUpdateRole = defineMutation(() => {
|
|
4
|
+
const queryCache = useQueryCache()
|
|
5
|
+
|
|
6
|
+
const { mutateAsync: updateRoleMutation } = useMutation({
|
|
7
|
+
mutation: async ({ roleId, updatedRole, tenantId }: { roleId: string, updatedRole: UpdateRoleRequest, tenantId: string }) => {
|
|
8
|
+
await updateRole({
|
|
9
|
+
composable: '$fetch',
|
|
10
|
+
path: {
|
|
11
|
+
tenant_id: tenantId,
|
|
12
|
+
role_id: roleId,
|
|
13
|
+
},
|
|
14
|
+
body: updatedRole,
|
|
15
|
+
})
|
|
16
|
+
queryCache.invalidateQueries()
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
return {
|
|
20
|
+
updateRole: updateRoleMutation,
|
|
21
|
+
}
|
|
22
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ServiceDto } from '@core/sdk/client'
|
|
2
|
+
import type { MenuItem } from 'primevue/menuitem'
|
|
3
|
+
|
|
4
|
+
export const useApps = () => {
|
|
5
|
+
const { suite, suiteIsLoading } = useSuite()
|
|
6
|
+
const router = useRouter()
|
|
7
|
+
const tenantPath = useTenantPath()
|
|
8
|
+
|
|
9
|
+
const apps = computed<MenuItem>(() => {
|
|
10
|
+
const suiteApps = suite.value?.services.map((service: ServiceDto) => ({
|
|
11
|
+
label: service.name,
|
|
12
|
+
description: service.description,
|
|
13
|
+
icon: service.icon,
|
|
14
|
+
path: service.path,
|
|
15
|
+
isAdmin: service.user_is_admin ?? false,
|
|
16
|
+
} satisfies MenuItem
|
|
17
|
+
)) ?? []
|
|
18
|
+
return [
|
|
19
|
+
{ icon: 'material-symbols:home', label: 'Home', path: '/' },
|
|
20
|
+
...suiteApps,
|
|
21
|
+
].filter((app: MenuItem) => {
|
|
22
|
+
const resolved = app.path === '/' ? tenantPath('/') : tenantPath(app.path)
|
|
23
|
+
return router.resolve(resolved).matched.length > 0
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
apps,
|
|
29
|
+
appsLoading: suiteIsLoading,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getSuite, type SuiteDto } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export const useSuite = defineQuery(() => {
|
|
5
|
+
const { tenantId } = useTenant()
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
data: suite,
|
|
9
|
+
isPending: suiteIsLoading,
|
|
10
|
+
} = useQuery<SuiteDto>({
|
|
11
|
+
key: () => ['tenant', tenantId.value, 'suite'],
|
|
12
|
+
staleTime: minutesToMilliseconds(5),
|
|
13
|
+
enabled: useTenantReady(),
|
|
14
|
+
query: async () => {
|
|
15
|
+
return await getSuite({
|
|
16
|
+
composable: '$fetch',
|
|
17
|
+
path: { tenant_id: tenantId.value! },
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
suite,
|
|
24
|
+
suiteIsLoading,
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getMyActiveTenant, setMyActiveTenant } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export const useActiveTenantQuery = defineQuery(() => {
|
|
5
|
+
const { data: activeTenant, isPending: activeTenantIsLoading } = useQuery({
|
|
6
|
+
key: () => ['active-tenant'],
|
|
7
|
+
staleTime: minutesToMilliseconds(1),
|
|
8
|
+
query: async () => await getMyActiveTenant({ composable: '$fetch' }),
|
|
9
|
+
})
|
|
10
|
+
return { activeTenant, activeTenantIsLoading }
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const useSetActiveTenant = defineMutation(() => {
|
|
14
|
+
const queryCache = useQueryCache()
|
|
15
|
+
const { mutateAsync: setActiveTenantMutation } = useMutation({
|
|
16
|
+
mutation: async ({ tenantId }: { tenantId: string }) => {
|
|
17
|
+
const result = await setMyActiveTenant({
|
|
18
|
+
composable: '$fetch',
|
|
19
|
+
body: { tenant_id: tenantId },
|
|
20
|
+
})
|
|
21
|
+
queryCache.invalidateQueries({ key: ['active-tenant'] })
|
|
22
|
+
queryCache.invalidateQueries({ key: ['my-tenants'] })
|
|
23
|
+
return result
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
return { setActiveTenant: setActiveTenantMutation }
|
|
27
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The sysadmin plane (tenant administration) is a separately-licensed app on
|
|
2
|
+
// its own origin (sysadmin.${DOMAIN}, or localhost:3334 in dev) — it is NOT a
|
|
3
|
+
// route inside @swiss-ai-hub/web. Anything in this app that lets a sysadmin
|
|
4
|
+
// "manage tenants" must therefore jump cross-origin, not navigateTo() a local
|
|
5
|
+
// route (that route no longer exists here and would 404). This composable is
|
|
6
|
+
// the single place that contract lives.
|
|
7
|
+
export function useSysadminNavigation() {
|
|
8
|
+
const config = useRuntimeConfig()
|
|
9
|
+
const { locale } = useI18n()
|
|
10
|
+
|
|
11
|
+
const sysadminUrl = computed(() => (config.public.sysadmin as { url?: string } | undefined)?.url ?? '')
|
|
12
|
+
|
|
13
|
+
function enterSysadmin(): void {
|
|
14
|
+
if (!sysadminUrl.value || !import.meta.client) return
|
|
15
|
+
globalThis.location.href = `${sysadminUrl.value}/${locale.value}/tenants`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return { sysadminUrl, enterSysadmin }
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { setMyActiveTenant } from '@core/sdk/client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Single source of truth for tenant context.
|
|
5
|
+
*
|
|
6
|
+
* - **Read**: ``tenantId`` is a reactive computed derived from the route. Tenant-scoped
|
|
7
|
+
* routes carry the id as ``route.params.tenant`` (``/[tenant]/...``); sysadmin admin
|
|
8
|
+
* routes carry it as ``route.params.tenant_id`` (``/sysadmin/tenants/[tenant_id]/...``).
|
|
9
|
+
* Both shapes resolve to the same tenant context so composables and components that
|
|
10
|
+
* depend on ``useTenant()`` work transparently in either place.
|
|
11
|
+
* - **Write**: ``setTenant(id)`` navigates to the same route with the new ``tenant``
|
|
12
|
+
* param. Only valid on tenant-scoped routes — calling it from a sysadmin route would
|
|
13
|
+
* break the URL shape.
|
|
14
|
+
*/
|
|
15
|
+
export function useTenant() {
|
|
16
|
+
const route = useRoute()
|
|
17
|
+
const router = useRouter()
|
|
18
|
+
const queryCache = useQueryCache()
|
|
19
|
+
|
|
20
|
+
const tenantId = computed(
|
|
21
|
+
() => (route.params.tenant as string | undefined) ?? (route.params.tenant_id as string | undefined),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
async function setTenant(id: string) {
|
|
25
|
+
if (id === tenantId.value) return
|
|
26
|
+
|
|
27
|
+
await setMyActiveTenant({ composable: '$fetch', body: { tenant_id: id } })
|
|
28
|
+
await queryCache.invalidateQueries()
|
|
29
|
+
|
|
30
|
+
router.replace({
|
|
31
|
+
name: route.name!,
|
|
32
|
+
params: { ...route.params, tenant: id },
|
|
33
|
+
query: route.query,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { tenantId, setTenant }
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getMyTenants, type MyTenantsResponse } from '@core/sdk/client'
|
|
2
|
+
import { minutesToMilliseconds } from 'date-fns'
|
|
3
|
+
|
|
4
|
+
export const useTenantMemberships = defineQuery(() => {
|
|
5
|
+
const { data, isPending: tenantsAreLoading } = useQuery<MyTenantsResponse>({
|
|
6
|
+
key: () => ['my-tenants'],
|
|
7
|
+
staleTime: minutesToMilliseconds(5),
|
|
8
|
+
query: async () => await getMyTenants({ composable: '$fetch' }),
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const tenants = computed(() => data.value?.tenants)
|
|
12
|
+
const isSysAdmin = computed(() => data.value?.is_sys_admin ?? false)
|
|
13
|
+
|
|
14
|
+
return { tenants, tenantsAreLoading, isSysAdmin }
|
|
15
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps ``useLocalePath()`` to auto-inject the current tenant ID from the route.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* const tenantPath = useTenantPath()
|
|
7
|
+
* router.push(tenantPath('/service/agents'))
|
|
8
|
+
* // → /{locale}/{tenantId}/service/agents
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export function useTenantPath() {
|
|
12
|
+
const localePath = useLocalePath()
|
|
13
|
+
const { tenantId } = useTenant()
|
|
14
|
+
|
|
15
|
+
return (path: string) => {
|
|
16
|
+
const id = tenantId.value
|
|
17
|
+
if (!id) return localePath(path)
|
|
18
|
+
return localePath(`/${id}${path}`)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getMyActiveTenant } from '@core/sdk/client'
|
|
2
|
+
import { useIntervalFn } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Polls the backend active tenant every 30 seconds and detects mismatches
|
|
6
|
+
* with the current URL tenant. Used exclusively on the OpenWebUI page where
|
|
7
|
+
* the iframe relies on the backend's active tenant.
|
|
8
|
+
*/
|
|
9
|
+
export function useTenantPolling() {
|
|
10
|
+
const { tenantId } = useTenant()
|
|
11
|
+
const mismatchDetected = ref(false)
|
|
12
|
+
const backendTenantId = ref<string | undefined>()
|
|
13
|
+
const backendTenantName = ref<string | undefined>()
|
|
14
|
+
|
|
15
|
+
async function poll() {
|
|
16
|
+
try {
|
|
17
|
+
const activeTenant = await getMyActiveTenant({ composable: '$fetch' })
|
|
18
|
+
backendTenantId.value = activeTenant?.id
|
|
19
|
+
backendTenantName.value = activeTenant?.name
|
|
20
|
+
mismatchDetected.value = !!(tenantId.value && activeTenant?.id && tenantId.value !== activeTenant.id)
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Ignore polling errors
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
useIntervalFn(poll, 30_000, { immediateCallback: true })
|
|
28
|
+
|
|
29
|
+
return { mismatchDetected, backendTenantId, backendTenantName }
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a computed boolean that is ``true`` when the tenant is available
|
|
3
|
+
* and (optionally) when the given route params have resolved.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the repeated ``computed(() => !!tenantId.value)`` and
|
|
6
|
+
* ``computed(() => isRouteReady.value && !!tenantId.value)`` pattern.
|
|
7
|
+
*/
|
|
8
|
+
export function useTenantReady(...routeParams: string[]) {
|
|
9
|
+
const { tenantId } = useTenant()
|
|
10
|
+
const isRouteReady = routeParams.length ? useRouteReady(...routeParams) : ref(true)
|
|
11
|
+
return computed(() => isRouteReady.value && !!tenantId.value)
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createSharedComposable, useDark } from '@vueuse/core'
|
|
2
|
+
|
|
3
|
+
// Shared across all callers so DOM / localStorage / prefers-color-scheme
|
|
4
|
+
// listeners are installed exactly once and toggles propagate synchronously.
|
|
5
|
+
export const useDarkMode = createSharedComposable(() => useDark({ storageKey: 'dark' }))
|