Skip to content

Commit 4930c3c

Browse files
author
Jicheng Lu
committed
refine spinner in conv page
1 parent 3c7bf99 commit 4930c3c

File tree

5 files changed

+278
-248
lines changed

5 files changed

+278
-248
lines changed

src/lib/helpers/http.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function skipLoader(config) {
185185
new RegExp('http(s*)://(.*?)/knowledge/vector/(.*?)/create', 'g'),
186186
new RegExp('http(s*)://(.*?)/knowledge/document/(.*?)/page', 'g'),
187187
new RegExp('http(s*)://(.*?)/users', 'g'),
188-
new RegExp('http(s*)://(.*?)/instruct/chat-completion', 'g'),
188+
new RegExp('http(s*)://(.*?)/instruct/(.*?)', 'g'),
189189
new RegExp('http(s*)://(.*?)/agent/(.*?)/code-scripts', 'g'),
190190
new RegExp('http(s*)://(.*?)/agent/(.*?)/code-script/generate', 'g'),
191191
new RegExp('http(s*)://(.*?)/renew-token', 'g')
@@ -217,10 +217,13 @@ function skipLoader(config) {
217217
new RegExp('http(s*)://(.*?)/user/(.*?)/details', 'g'),
218218
new RegExp('http(s*)://(.*?)/user/me', 'g'),
219219
new RegExp('http(s*)://(.*?)/address/options(.*?)', 'g'),
220+
new RegExp('http(s*)://(.*?)/agents', 'g'),
220221
new RegExp('http(s*)://(.*?)/agent/options', 'g'),
221222
new RegExp('http(s*)://(.*?)/agent/labels', 'g'),
222223
new RegExp('http(s*)://(.*?)/agent/tasks', 'g'),
223224
new RegExp('http(s*)://(.*?)/agent/(.*?)/code-scripts', 'g'),
225+
new RegExp('http(s*)://(.*?)/conversation', 'g'),
226+
new RegExp('http(s*)://(.*?)/conversations/(.*?)/dialogs', 'g'),
224227
new RegExp('http(s*)://(.*?)/conversations', 'g'),
225228
new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'),
226229
new RegExp('http(s*)://(.*?)/conversation/(.*?)/files/(.*?)', 'g'),
@@ -249,7 +252,6 @@ function skipLoader(config) {
249252
}
250253

251254
if (config.method === 'get' && getRegexes.some(regex => regex.test(config.url || ''))) {
252-
console.log('url', config.url);
253255
return true;
254256
}
255257

src/routes/page/agent/code-scripts/+page.svelte

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -174,56 +174,64 @@
174174
175175
<HeadTitle title="{$_('Code Scripts')}" />
176176
<Breadcrumb title="{$_('Agent')}" pagetitle="{$_('Code Scripts')}" />
177-
<LoadingToComplete {isLoading} {isComplete} {isError} />
178-
179-
<Card>
180-
<CardBody class="border-bottom">
181-
<Row class="g-3">
182-
<Col lg="3" class="d-flex flex-column gap-1">
183-
<div class="fw-bold">Agent</div>
184-
<Select
185-
tag={'agent-select'}
186-
placeholder={'Select agent'}
187-
selectedText={'agents'}
188-
searchMode
189-
selectedValues={selectedAgentId ? [selectedAgentId] : []}
190-
options={agentOptions}
191-
on:select={e => changeAgent(e)}
192-
/>
193-
</Col>
177+
178+
179+
<div style="position: relative;">
180+
<LoadingToComplete
181+
spinnerStyles={'position: absolute;'}
182+
{isLoading}
183+
{isComplete}
184+
{isError}
185+
/>
186+
<Card>
187+
<CardBody class="border-bottom">
188+
<Row class="g-3">
189+
<Col lg="3" class="d-flex flex-column gap-1">
190+
<div class="fw-bold">Agent</div>
191+
<Select
192+
tag={'agent-select'}
193+
placeholder={'Select agent'}
194+
selectedText={'agents'}
195+
searchMode
196+
selectedValues={selectedAgentId ? [selectedAgentId] : []}
197+
options={agentOptions}
198+
on:select={e => changeAgent(e)}
199+
/>
200+
</Col>
201+
</Row>
202+
</CardBody>
203+
</Card>
204+
205+
{#if !!selectedAgentId}
206+
<ScriptEditor
207+
title={'Source scripts'}
208+
scriptType={AgentCodeScriptType.Src}
209+
bind:scriptObj={srcScriptObj}
210+
/>
211+
<ScriptEditor
212+
title={'Test scripts'}
213+
scriptType={AgentCodeScriptType.Test}
214+
bind:scriptObj={testScriptObj}
215+
/>
216+
217+
{#if ADMIN_ROLES.includes(user?.role || '')}
218+
<Row>
219+
<div class="hstack gap-2 my-4">
220+
<Button
221+
class="btn btn-soft-primary"
222+
disabled={!selectedAgentId}
223+
on:click={() => saveCodeScripts()}
224+
>
225+
{$_('Save')}
226+
</Button>
227+
<Button
228+
class="btn btn-warning"
229+
disabled={!selectedAgentId}
230+
on:click={() => resetCodeScripts()}>
231+
{$_('Reset')}
232+
</Button>
233+
</div>
194234
</Row>
195-
</CardBody>
196-
</Card>
197-
198-
{#if !!selectedAgentId}
199-
<ScriptEditor
200-
title={'Source scripts'}
201-
scriptType={AgentCodeScriptType.Src}
202-
bind:scriptObj={srcScriptObj}
203-
/>
204-
<ScriptEditor
205-
title={'Test scripts'}
206-
scriptType={AgentCodeScriptType.Test}
207-
bind:scriptObj={testScriptObj}
208-
/>
209-
210-
{#if ADMIN_ROLES.includes(user?.role || '')}
211-
<Row>
212-
<div class="hstack gap-2 my-4">
213-
<Button
214-
class="btn btn-soft-primary"
215-
disabled={!selectedAgentId}
216-
on:click={() => saveCodeScripts()}
217-
>
218-
{$_('Save')}
219-
</Button>
220-
<Button
221-
class="btn btn-warning"
222-
disabled={!selectedAgentId}
223-
on:click={() => resetCodeScripts()}>
224-
{$_('Reset')}
225-
</Button>
226-
</div>
227-
</Row>
228-
{/if}
229-
{/if}
235+
{/if}
236+
{/if}
237+
</div>
Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
<script>
2+
import { onMount } from 'svelte';
3+
import { page } from '$app/stores';
4+
import Swal from 'sweetalert2';
5+
import { _ } from 'svelte-i18n';
26
import { Col, Row, Button } from '@sveltestrap/sveltestrap';
37
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
48
import HeadTitle from '$lib/common/HeadTitle.svelte';
5-
import Dialog from './conv-dialogs.svelte';
9+
import LoadingToComplete from '$lib/common/LoadingToComplete.svelte';
10+
import { getConversation, deleteConversation, getDialogs } from '$lib/services/conversation-service.js';
611
import Overview from './conv-overview.svelte'
712
import States from './conv-states.svelte';
8-
import { getConversation, deleteConversation } from '$lib/services/conversation-service.js';
9-
import { onMount } from 'svelte';
10-
import { page } from '$app/stores';
11-
import Swal from 'sweetalert2'
12-
import { _ } from 'svelte-i18n'
13+
import Dialog from './conv-dialogs.svelte';
1314
1415
const params = $page.params;
16+
const dialogCount = 100;
17+
18+
let isLoading = false;
1519
1620
/** @type {import('$conversationTypes').ConversationModel} */
1721
let conversation;
1822
23+
/** @type {import('$conversationTypes').ChatResponseModel[]} */
24+
let dialogs = [];
25+
26+
1927
onMount(async () => {
28+
isLoading = true;
2029
conversation = await getConversation(params.conversationId, true);
30+
isLoading = false;
31+
dialogs = await getDialogs(conversation.id, dialogCount);
2132
});
2233
2334
function handleConversationDeletion() {
@@ -42,24 +53,30 @@
4253
<HeadTitle title={conversation?.title || 'Not found'} />
4354
<Breadcrumb title="{$_('Conversation')}" pagetitle="{$_('Conversation Detail')}" />
4455

45-
{#if conversation}
46-
<Row>
47-
<Col style="flex: 40%;">
48-
<Overview conversation={conversation} />
49-
<States conversation={conversation} />
50-
</Col>
51-
<Col style="flex: 60%;">
52-
<Dialog conversation={conversation} />
53-
</Col>
54-
</Row>
55-
<Row>
56-
<div class="mb-4">
57-
<Button
58-
class="btn btn-danger btn-hover rounded"
59-
on:click={() => handleConversationDeletion()}
60-
>
61-
<i class="mdi mdi-delete"></i>{$_('Delete Conversation')}
62-
</Button>
63-
</div>
64-
</Row>
65-
{/if}
56+
<div style="position: relative;">
57+
<LoadingToComplete
58+
spinnerStyles={'position: absolute;'}
59+
{isLoading}
60+
/>
61+
{#if conversation}
62+
<Row>
63+
<Col style="flex: 40%;">
64+
<Overview {conversation} />
65+
<States {conversation} />
66+
</Col>
67+
<Col style="flex: 60%;">
68+
<Dialog {conversation} {dialogs} />
69+
</Col>
70+
</Row>
71+
<Row>
72+
<div class="mb-4">
73+
<Button
74+
class="btn btn-danger btn-hover rounded"
75+
on:click={() => handleConversationDeletion()}
76+
>
77+
<i class="mdi mdi-delete"></i>{$_('Delete Conversation')}
78+
</Button>
79+
</div>
80+
</Row>
81+
{/if}
82+
</div>

src/routes/page/conversation/[conversationId]/conv-dialogs.svelte

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { _ } from 'svelte-i18n'
44
import util from "lodash";
55
import { Card, CardBody, CardTitle, Col, Row } from '@sveltestrap/sveltestrap';
6-
import { getDialogs, getConversationFiles, sendNotification } from '$lib/services/conversation-service.js';
6+
import { getConversationFiles, sendNotification } from '$lib/services/conversation-service.js';
77
import { utcToLocal } from '$lib/helpers/datetime';
88
import { IMAGE_DATA_PREFIX, BOT_SENDERS } from '$lib/helpers/constants';
99
import MessageFileGallery from '$lib/common/MessageFileGallery.svelte';
@@ -14,10 +14,6 @@
1414
1515
const maxTextLength = 4096;
1616
const duration = 1500;
17-
const dialogCount = 100;
18-
19-
/** @type {import('$conversationTypes').ChatResponseModel[]} */
20-
let dialogs = [];
2117
2218
/** @type {boolean} */
2319
let isOpenNotificationModal = false;
@@ -29,9 +25,8 @@
2925
/** @type {import('$conversationTypes').ConversationModel} */
3026
export let conversation;
3127
32-
onMount(async () => {
33-
dialogs = await getDialogs(conversation.id, dialogCount);
34-
});
28+
/** @type {import('$conversationTypes').ChatResponseModel[]} */
29+
export let dialogs = [];
3530
3631
/**
3732
* @param {import('$conversationTypes').ChatResponseModel} dialog

0 commit comments

Comments
 (0)