Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
90c3d68f
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "52fd701f2ee2420a0efb90bba97a51292e3da4dc"
Commit
90c3d68f
authored
Jul 11, 2024
by
Timothy J. Baek
Browse files
enh: input type event call
parent
97098edf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+20
-2
src/lib/components/common/ConfirmDialog.svelte
src/lib/components/common/ConfirmDialog.svelte
+16
-1
No files found.
src/lib/components/chat/Chat.svelte
View file @
90c3d68f
...
@@ -78,6 +78,8 @@
...
@@ -78,6 +78,8 @@
let showEventConfirmation = false;
let showEventConfirmation = false;
let eventConfirmationTitle = '';
let eventConfirmationTitle = '';
let eventConfirmationMessage = '';
let eventConfirmationMessage = '';
let eventConfirmationInput = false;
let eventConfirmationInputPlaceholder = '';
let eventCallback = null;
let eventCallback = null;
let showModelSelector = true;
let showModelSelector = true;
...
@@ -161,10 +163,21 @@
...
@@ -161,10 +163,21 @@
message.content += data.content;
message.content += data.content;
} else if (type === 'confirmation') {
} else if (type === 'confirmation') {
eventCallback = cb;
eventCallback = cb;
eventConfirmationInput = false;
showEventConfirmation = true;
eventConfirmationTitle = data.title;
eventConfirmationMessage = data.message;
} else if (type === 'input') {
eventCallback = cb;
eventConfirmationInput = true;
showEventConfirmation = true;
showEventConfirmation = true;
eventConfirmationTitle = data.title;
eventConfirmationTitle = data.title;
eventConfirmationMessage = data.message;
eventConfirmationMessage = data.message;
eventConfirmationInputPlaceholder = data.placeholder;
} else {
} else {
console.log('Unknown message type', data);
console.log('Unknown message type', data);
}
}
...
@@ -1411,8 +1424,14 @@
...
@@ -1411,8 +1424,14 @@
bind:show={showEventConfirmation}
bind:show={showEventConfirmation}
title={eventConfirmationTitle}
title={eventConfirmationTitle}
message={eventConfirmationMessage}
message={eventConfirmationMessage}
input={eventConfirmationInput}
inputPlaceholder={eventConfirmationInputPlaceholder}
on:confirm={(e) => {
on:confirm={(e) => {
eventCallback(true);
if (e.detail) {
eventCallback(e.detail);
} else {
eventCallback(true);
}
}}
}}
on:cancel={() => {
on:cancel={() => {
eventCallback(false);
eventCallback(false);
...
@@ -1545,7 +1564,6 @@
...
@@ -1545,7 +1564,6 @@
<ChatControls
<ChatControls
models={selectedModelIds.reduce((a, e, i, arr) => {
models={selectedModelIds.reduce((a, e, i, arr) => {
const model = $models.find((m) => m.id === e);
const model = $models.find((m) => m.id === e);
if (model) {
if (model) {
return [...a, model];
return [...a, model];
}
}
...
...
src/lib/components/common/ConfirmDialog.svelte
View file @
90c3d68f
...
@@ -13,9 +13,14 @@
...
@@ -13,9 +13,14 @@
export let cancelLabel = $i18n.t('Cancel');
export let cancelLabel = $i18n.t('Cancel');
export let confirmLabel = $i18n.t('Confirm');
export let confirmLabel = $i18n.t('Confirm');
export let input = false;
export let inputPlaceholder = '';
export let show = false;
export let show = false;
let modalElement = null;
let modalElement = null;
let mounted = false;
let mounted = false;
let inputValue = '';
const handleKeyDown = (event: KeyboardEvent) => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
if (event.key === 'Escape') {
...
@@ -73,6 +78,16 @@
...
@@ -73,6 +78,16 @@
{:else}
{:else}
{$i18n.t('This action cannot be undone. Do you wish to continue?')}
{$i18n.t('This action cannot be undone. Do you wish to continue?')}
{/if}
{/if}
{#if input}
<textarea
bind:value={inputValue}
placeholder={inputPlaceholder ? inputPlaceholder : $i18n.t('Enter your message')}
class="w-full mt-2 rounded-lg px-4 py-2 text-sm dark:text-gray-300 dark:bg-gray-900 outline-none resize-none"
rows="3"
required
/>
{/if}
</div>
</div>
</slot>
</slot>
...
@@ -91,7 +106,7 @@
...
@@ -91,7 +106,7 @@
class="bg-gray-900 hover:bg-gray-850 text-gray-100 dark:bg-gray-100 dark:hover:bg-white dark:text-gray-800 font-medium w-full py-2.5 rounded-lg transition"
class="bg-gray-900 hover:bg-gray-850 text-gray-100 dark:bg-gray-100 dark:hover:bg-white dark:text-gray-800 font-medium w-full py-2.5 rounded-lg transition"
on:click={() => {
on:click={() => {
show = false;
show = false;
dispatch('confirm');
dispatch('confirm'
, inputValue
);
}}
}}
type="button"
type="button"
>
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment