diff --git a/src/lib/common/Breadcrumb.svelte b/src/lib/common/Breadcrumb.svelte index bb59018..438bcc7 100644 --- a/src/lib/common/Breadcrumb.svelte +++ b/src/lib/common/Breadcrumb.svelte @@ -13,7 +13,7 @@
- {$_('View All')} + {$_('View All')}
- +
diff --git a/src/lib/common/ProfileDropdown.svelte b/src/lib/common/ProfileDropdown.svelte index 0ae88a3..3dd7953 100644 --- a/src/lib/common/ProfileDropdown.svelte +++ b/src/lib/common/ProfileDropdown.svelte @@ -1,5 +1,6 @@ diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index c912604..4983f27 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -127,6 +127,7 @@ let loadTextEditor = false; let loadFileEditor = false; let autoScrollLog = false; + let disableAction = false; $: { const editor = lastBotMsg?.rich_content?.editor || ''; @@ -135,6 +136,10 @@ loadEditor = !isSendingMsg && !isThinking && (loadTextEditor || loadFileEditor); } + $: { + disableAction = currentUser?.role !== UserRole.Admin && currentUser?.id !== conversationUser?.id; + } + setContext('chat-window-context', { autoScrollToBottom: autoScrollToBottom }); @@ -914,12 +919,26 @@ {#if !isLoadStateLog} - toggleStateLog()}>View States + toggleStateLog()} + > + View States + {/if} {#if !isOpenUserAddStateModal} - toggleUserAddStateModal()}>Add States + toggleUserAddStateModal()} + > + Add States + {/if} - clearUserAddStates()}>Clear States + clearUserAddStates()} + > + Clear States + @@ -932,6 +951,7 @@
  • {#if !isLite} - + @@ -1055,7 +1075,7 @@
    @@ -1081,7 +1101,7 @@ +{/if} diff --git a/src/routes/page/agent/[agentId]/+page.svelte b/src/routes/page/agent/[agentId]/+page.svelte index d3ad0bc..37d2057 100644 --- a/src/routes/page/agent/[agentId]/+page.svelte +++ b/src/routes/page/agent/[agentId]/+page.svelte @@ -13,10 +13,12 @@ import AgentFunction from './agent-function.svelte'; import AgentLlmConfig from './agent-llm-config.svelte'; import { page } from '$app/stores'; - import { getAgent, saveAgent } from '$lib/services/agent-service.js'; + import { deleteAgent, getAgent, saveAgent } from '$lib/services/agent-service.js'; import { onMount } from 'svelte'; - const params = $page.params; import { _ } from 'svelte-i18n' + import Swal from 'sweetalert2/dist/sweetalert2.js'; + import "sweetalert2/src/sweetalert2.scss"; + import { goto } from '$app/navigation'; /** @type {import('$types').AgentModel} */ @@ -28,13 +30,32 @@ let isLoading = false; let isComplete = false; let isError = false; + const duration = 3000; + const params = $page.params; onMount(async () => { agent = await getAgent(params.agentId); }); - async function handleAgentUpdate() { + function updateCurrentAgent() { + // @ts-ignore + Swal.fire({ + title: 'Are you sure?', + text: "Are you sure you want to update these changes?", + icon: 'warning', + showCancelButton: true, + cancelButtonText: 'No', + confirmButtonText: 'Yes' + // @ts-ignore + }).then(async (result) => { + if (result.value) { + handleAgentUpdate(); + } + }); + } + + function handleAgentUpdate() { fetchJsonContent(); isLoading = true; saveAgent(agent).then(res => { @@ -64,14 +85,37 @@ agent.templates = textContent?.templates?.length > 0 ? textContent.templates : (jsonContent?.templates?.length > 0 ? jsonContent?.templates : []); } + + function deleteCurrentAgent() { + // @ts-ignore + Swal.fire({ + title: 'Are you sure?', + text: "Are you sure you want to delete this agent?", + icon: 'warning', + showCancelButton: true, + cancelButtonText: 'No', + confirmButtonText: 'Yes' + // @ts-ignore + }).then(async (result) => { + if (result.value) { + handleAgentDelete(); + } + }); + } + + function handleAgentDelete() { + deleteAgent(agent?.id).then(res => { + goto(`page/agent`); + }); + } +{#if agent} - {#if agent} @@ -85,10 +129,13 @@ - {/if} - - -
    - -
    + {#if !!agent?.editable} + +
    + + +
    +
    + {/if} +{/if} \ No newline at end of file diff --git a/src/routes/page/agent/card-agent.svelte b/src/routes/page/agent/card-agent.svelte index dde3619..794c7b3 100644 --- a/src/routes/page/agent/card-agent.svelte +++ b/src/routes/page/agent/card-agent.svelte @@ -66,20 +66,20 @@ {format(agent.updated_datetime, 'short-date')}
  • - + {$_('Build')} - +
  • {#if agent.is_public }
  • - + {$_('Train')} - +
  • - + {$_('Test')} - +
  • {/if} diff --git a/src/routes/page/conversation/[conversationId]/+page.svelte b/src/routes/page/conversation/[conversationId]/+page.svelte index 380edb7..036a98e 100644 --- a/src/routes/page/conversation/[conversationId]/+page.svelte +++ b/src/routes/page/conversation/[conversationId]/+page.svelte @@ -41,7 +41,7 @@ - + {#if conversation} @@ -54,9 +54,9 @@
    -{/if}
    +{/if}