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
b986c2ae
Commit
b986c2ae
authored
Mar 03, 2024
by
Carlos Daniel Vilaseca
Browse files
rf: dom queries in layout and pages
parent
50acdb09
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
32 deletions
+32
-32
src/routes/(app)/+layout.svelte
src/routes/(app)/+layout.svelte
+3
-2
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+6
-4
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+6
-4
src/routes/(app)/documents/+page.svelte
src/routes/(app)/documents/+page.svelte
+3
-4
src/routes/(app)/modelfiles/+page.svelte
src/routes/(app)/modelfiles/+page.svelte
+3
-4
src/routes/(app)/playground/+page.svelte
src/routes/(app)/playground/+page.svelte
+7
-9
src/routes/(app)/prompts/+page.svelte
src/routes/(app)/prompts/+page.svelte
+4
-5
No files found.
src/routes/(app)/+layout.svelte
View file @
b986c2ae
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
let ollamaVersion = '';
let ollamaVersion = '';
let loaded = false;
let loaded = false;
let showShortcutsButton:HTMLButtonElement
let DB = null;
let DB = null;
let localDBChats = [];
let localDBChats = [];
...
@@ -184,7 +184,7 @@
...
@@ -184,7 +184,7 @@
if (isCtrlPressed && event.key === '/') {
if (isCtrlPressed && event.key === '/') {
event.preventDefault();
event.preventDefault();
console.log('showShortcuts');
console.log('showShortcuts');
document.getElementById('
show
-s
hortcuts
-b
utton
')?
.click();
show
S
hortcuts
B
utton.click();
}
}
});
});
...
@@ -203,6 +203,7 @@
...
@@ -203,6 +203,7 @@
<div class=" hidden lg:flex fixed bottom-0 right-0 px-3 py-3 z-10">
<div class=" hidden lg:flex fixed bottom-0 right-0 px-3 py-3 z-10">
<button
<button
id="show-shortcuts-button"
id="show-shortcuts-button"
bind:this={showShortcutsButton}
class="text-gray-600 dark:text-gray-300 bg-gray-300/20 w-6 h-6 flex items-center justify-center text-xs rounded-full"
class="text-gray-600 dark:text-gray-300 bg-gray-300/20 w-6 h-6 flex items-center justify-center text-xs rounded-full"
on:click={() => {
on:click={() => {
showShortcuts = !showShortcuts;
showShortcuts = !showShortcuts;
...
...
src/routes/(app)/+page.svelte
View file @
b986c2ae
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
let
stopResponseFlag
=
false
;
let
stopResponseFlag
=
false
;
let
autoScroll
=
true
;
let
autoScroll
=
true
;
let
processing
=
''
;
let
processing
=
''
;
let
messagesContainerElement
:
HTMLDivElement
;
let
currentRequestId
=
null
;
let
currentRequestId
=
null
;
let
selectedModels
=
[
''
];
let
selectedModels
=
[
''
];
...
@@ -140,8 +140,7 @@
...
@@ -140,8 +140,7 @@
};
};
const
scrollToBottom
=
()
=>
{
const
scrollToBottom
=
()
=>
{
const
element
=
document
.
getElementById
(
'messages-container'
);
messagesContainerElement
.
scrollTop
=
messagesContainerElement
.
scrollHeight
;
element
.
scrollTop
=
element
.
scrollHeight
;
};
};
//////////////////////////
//////////////////////////
...
@@ -821,8 +820,11 @@
...
@@ -821,8 +820,11 @@
<
div
<
div
class
=
" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
class
=
" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
id
=
"messages-container"
id
=
"messages-container"
bind
:
this
={
messagesContainerElement
}
on
:
scroll
={(
e
)
=>
{
on
:
scroll
={(
e
)
=>
{
autoScroll
=
e
.
target
.
scrollHeight
-
e
.
target
.
scrollTop
<=
e
.
target
.
clientHeight
+
50
;
autoScroll
=
messagesContainerElement
.
scrollHeight
-
messagesContainerElement
.
scrollTop
<=
messagesContainerElement
.
clientHeight
+
50
;
}}
}}
>
>
<
div
<
div
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
b986c2ae
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
let
stopResponseFlag
=
false
;
let
stopResponseFlag
=
false
;
let
autoScroll
=
true
;
let
autoScroll
=
true
;
let
processing
=
''
;
let
processing
=
''
;
let
messagesContainerElement
:
HTMLDivElement
;
let
currentRequestId
=
null
;
let
currentRequestId
=
null
;
//
let
chatId
=
$
page
.
params
.
id
;
//
let
chatId
=
$
page
.
params
.
id
;
...
@@ -160,8 +160,7 @@
...
@@ -160,8 +160,7 @@
};
};
const
scrollToBottom
=
()
=>
{
const
scrollToBottom
=
()
=>
{
const
element
=
document
.
getElementById
(
'messages-container'
);
messagesContainerElement
.
scrollTop
=
messagesContainerElement
.
scrollHeight
;
element
.
scrollTop
=
element
.
scrollHeight
;
};
};
//////////////////////////
//////////////////////////
...
@@ -852,8 +851,11 @@
...
@@ -852,8 +851,11 @@
<
div
<
div
class
=
" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
class
=
" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
id
=
"messages-container"
id
=
"messages-container"
bind
:
this
={
messagesContainerElement
}
on
:
scroll
={(
e
)
=>
{
on
:
scroll
={(
e
)
=>
{
autoScroll
=
e
.
target
.
scrollHeight
-
e
.
target
.
scrollTop
<=
e
.
target
.
clientHeight
+
50
;
autoScroll
=
messagesContainerElement
.
scrollHeight
-
messagesContainerElement
.
scrollTop
<=
messagesContainerElement
.
clientHeight
+
50
;
}}
}}
>
>
<
div
<
div
...
...
src/routes/(app)/documents/+page.svelte
View file @
b986c2ae
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
let inputFiles = '';
let inputFiles = '';
let query = '';
let query = '';
let documentsImportInputElement: HTMLInputElement;
let tags = [];
let tags = [];
let showSettingsModal = false;
let showSettingsModal = false;
...
@@ -524,6 +524,7 @@
...
@@ -524,6 +524,7 @@
<div class="flex space-x-2">
<div class="flex space-x-2">
<input
<input
id="documents-import-input"
id="documents-import-input"
bind:this={documentsImportInputElement}
bind:files={importFiles}
bind:files={importFiles}
type="file"
type="file"
accept=".json"
accept=".json"
...
@@ -558,9 +559,7 @@
...
@@ -558,9 +559,7 @@
<button
<button
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
on:click={async () => {
on:click={documentsImportInputElement.click}
document.getElementById('documents-import-input')?.click();
}}
>
>
<div class=" self-center mr-2 font-medium">Import Documents Mapping</div>
<div class=" self-center mr-2 font-medium">Import Documents Mapping</div>
...
...
src/routes/(app)/modelfiles/+page.svelte
View file @
b986c2ae
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
let localModelfiles = [];
let localModelfiles = [];
let importFiles;
let importFiles;
let modelfilesImportInputElement: HTMLInputElement;
const deleteModelHandler = async (tagName) => {
const deleteModelHandler = async (tagName) => {
let success = null;
let success = null;
...
@@ -235,6 +235,7 @@
...
@@ -235,6 +235,7 @@
<div class="flex space-x-1">
<div class="flex space-x-1">
<input
<input
id="modelfiles-import-input"
id="modelfiles-import-input"
bind:this={modelfilesImportInputElement}
bind:files={importFiles}
bind:files={importFiles}
type="file"
type="file"
accept=".json"
accept=".json"
...
@@ -262,9 +263,7 @@
...
@@ -262,9 +263,7 @@
<button
<button
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
on:click={async () => {
on:click={modelfilesImportInputElement.click}
document.getElementById('modelfiles-import-input')?.click();
}}
>
>
<div class=" self-center mr-2 font-medium">Import Modelfiles</div>
<div class=" self-center mr-2 font-medium">Import Modelfiles</div>
...
...
src/routes/(app)/playground/+page.svelte
View file @
b986c2ae
<script>
<script
lang="ts"
>
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { onMount, tick } from 'svelte';
import { onMount, tick } from 'svelte';
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
let mode = 'chat';
let mode = 'chat';
let loaded = false;
let loaded = false;
let text = '';
let text = '';
let selectedModelId = '';
let selectedModelId = '';
...
@@ -30,6 +29,9 @@
...
@@ -30,6 +29,9 @@
let currentRequestId;
let currentRequestId;
let stopResponseFlag = false;
let stopResponseFlag = false;
let messagesContainerElement: HTMLDivElement;
let textCompletionAreaElement: HTMLTextAreaElement;
let system = '';
let system = '';
let messages = [
let messages = [
{
{
...
@@ -39,13 +41,7 @@
...
@@ -39,13 +41,7 @@
];
];
const scrollToBottom = () => {
const scrollToBottom = () => {
let element;
const element = mode === 'chat' ? messagesContainerElement : textCompletionAreaElement;
if (mode === 'chat') {
element = document.getElementById('messages-container');
} else {
element = document.getElementById('text-completion-textarea');
}
if (element) {
if (element) {
element.scrollTop = element?.scrollHeight;
element.scrollTop = element?.scrollHeight;
...
@@ -417,12 +413,14 @@
...
@@ -417,12 +413,14 @@
<div
<div
class=" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
class=" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"
id="messages-container"
id="messages-container"
bind:this={messagesContainerElement}
>
>
<div class=" h-full w-full flex flex-col">
<div class=" h-full w-full flex flex-col">
<div class="flex-1 p-1">
<div class="flex-1 p-1">
{#if mode === 'complete'}
{#if mode === 'complete'}
<textarea
<textarea
id="text-completion-textarea"
id="text-completion-textarea"
bind:this={textCompletionAreaElement}
class="w-full h-full p-3 bg-transparent outline outline-1 outline-gray-200 dark:outline-gray-800 resize-none rounded-lg text-sm"
class="w-full h-full p-3 bg-transparent outline outline-1 outline-gray-200 dark:outline-gray-800 resize-none rounded-lg text-sm"
bind:value={text}
bind:value={text}
placeholder="You're a helpful assistant."
placeholder="You're a helpful assistant."
...
...
src/routes/(app)/prompts/+page.svelte
View file @
b986c2ae
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
let importFiles = '';
let importFiles = '';
let query = '';
let query = '';
let promptsImportInputElement: HTMLInputElement;
const sharePrompt = async (prompt) => {
const sharePrompt = async (prompt) => {
toast.success('Redirecting you to OpenWebUI Community');
toast.success('Redirecting you to OpenWebUI Community');
...
@@ -208,6 +208,7 @@
...
@@ -208,6 +208,7 @@
<div class="flex space-x-2">
<div class="flex space-x-2">
<input
<input
id="prompts-import-input"
id="prompts-import-input"
bind:this={promptsImportInputElement}
bind:files={importFiles}
bind:files={importFiles}
type="file"
type="file"
accept=".json"
accept=".json"
...
@@ -241,9 +242,7 @@
...
@@ -241,9 +242,7 @@
<button
<button
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
on:click={async () => {
on:click={promptsImportInputElement.click}
document.getElementById('prompts-import-input')?.click();
}}
>
>
<div class=" self-center mr-2 font-medium">Import Prompts</div>
<div class=" self-center mr-2 font-medium">Import Prompts</div>
...
@@ -266,7 +265,7 @@
...
@@ -266,7 +265,7 @@
<button
<button
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
on:click={async () => {
on:click={async () => {
//
document.getElementById('modelfiles-i
mport
-i
nput
')?
.click();
//
promptsI
mport
I
nput
Element
.click();
let blob = new Blob([JSON.stringify($prompts)], {
let blob = new Blob([JSON.stringify($prompts)], {
type: 'application/json'
type: 'application/json'
});
});
...
...
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