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
e756c415
Commit
e756c415
authored
Dec 26, 2023
by
Timothy J. Baek
Browse files
feat: chat storage migration overlay
parent
a696698a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
13 deletions
+62
-13
src/routes/(app)/+layout.svelte
src/routes/(app)/+layout.svelte
+62
-13
No files found.
src/routes/(app)/+layout.svelte
View file @
e756c415
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
let ollamaVersion = '';
let ollamaVersion = '';
let loaded = false;
let loaded = false;
let DB = null;
let localDBChats = [];
const getModels = async () => {
const getModels = async () => {
let models = [];
let models = [];
models.push(
models.push(
...
@@ -69,16 +72,13 @@
...
@@ -69,16 +72,13 @@
if ($user === undefined) {
if ($user === undefined) {
await goto('/auth');
await goto('/auth');
} else if (['user', 'admin'].includes($user.role)) {
} else if (['user', 'admin'].includes($user.role)) {
const
DB = await openDB('Chats', 1);
DB = await openDB('Chats', 1);
if (DB) {
if (DB) {
le
t chats = await DB.getAllFromIndex('chats', 'timestamp');
cons
t chats = await DB.getAllFromIndex('chats', 'timestamp');
c
hats = chats.map((item, idx) => chats[chats.length - 1 - idx]);
localDBC
hats = chats.map((item, idx) => chats[chats.length - 1 - idx]);
if (chats.length > 0) {
console.log('localdb', localDBChats);
let blob = new Blob([JSON.stringify(chats)], { type: 'application/json' });
saveAs(blob, `chat-export-${Date.now()}.json`);
}
}
}
console.log(DB);
console.log(DB);
...
@@ -103,9 +103,9 @@
...
@@ -103,9 +103,9 @@
{#if loaded}
{#if loaded}
<div class="app relative">
<div class="app relative">
{#if !['user', 'admin'].includes($user.role)}
{#if !['user', 'admin'].includes($user.role)}
<div class="
absolute
w-full h-full flex z-50">
<div class="
fixed
w-full h-full flex z-50">
<div
<div
class="absolute rounded-xl w-full h-full backdrop-blur bg-gray-900/
6
0 flex justify-center"
class="absolute rounded-xl w-full h-full backdrop-blur
bg-gray-100/20 dark:
bg-gray-900/
5
0 flex justify-center"
>
>
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="max-w-md">
<div class="max-w-md">
...
@@ -121,7 +121,7 @@
...
@@ -121,7 +121,7 @@
<div class=" mt-6 mx-auto relative group w-fit">
<div class=" mt-6 mx-auto relative group w-fit">
<button
<button
class="relative z-20 flex px-5 py-2 rounded-full bg-
gray-100
hover:bg-gray-
2
00 transition font-medium text-sm"
class="relative z-20 flex px-5 py-2 rounded-full bg-
white
hover:bg-gray-
1
00 transition font-medium text-sm"
on:click={async () => {
on:click={async () => {
location.href = '/';
location.href = '/';
}}
}}
...
@@ -142,9 +142,9 @@
...
@@ -142,9 +142,9 @@
</div>
</div>
</div>
</div>
{:else if checkVersion(REQUIRED_OLLAMA_VERSION, ollamaVersion ?? '0')}
{:else if checkVersion(REQUIRED_OLLAMA_VERSION, ollamaVersion ?? '0')}
<div class="
absolute
w-full h-full flex z-50">
<div class="
fixed
w-full h-full flex z-50">
<div
<div
class="absolute rounded-xl w-full h-full backdrop-blur bg-gray-900/
6
0 flex justify-center"
class="absolute rounded-xl w-full h-full backdrop-blur
bg-gray-100/20 dark:
bg-gray-900/
5
0 flex justify-center"
>
>
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="max-w-md">
<div class="max-w-md">
...
@@ -164,7 +164,7 @@
...
@@ -164,7 +164,7 @@
<div class=" mt-6 mx-auto relative group w-fit">
<div class=" mt-6 mx-auto relative group w-fit">
<button
<button
class="relative z-20 flex px-5 py-2 rounded-full bg-
gray-100
hover:bg-gray-
2
00 transition font-medium text-sm"
class="relative z-20 flex px-5 py-2 rounded-full bg-
white
hover:bg-gray-
1
00 transition font-medium text-sm"
on:click={async () => {
on:click={async () => {
await setOllamaVersion();
await setOllamaVersion();
}}
}}
...
@@ -183,6 +183,55 @@
...
@@ -183,6 +183,55 @@
</div>
</div>
</div>
</div>
</div>
</div>
{:else if localDBChats.length > 0}
<div class="fixed w-full h-full flex z-50">
<div
class="absolute rounded-xl w-full h-full backdrop-blur bg-gray-100/20 dark:bg-gray-900/50 flex justify-center"
>
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="max-w-md">
<div class="text-center dark:text-white text-2xl font-medium z-50">
Important Update<br /> Action Required for Chat Log Storage
</div>
<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full">
Saving chat logs directly to your browser's storage is no longer supported. Please
take a moment to download and delete your chat logs by clicking the button below.
Don't worry, you can easily re-import your chat logs to the backend through <span
class="font-semibold text-white">Settings > Chats > Import Chats</span
>. This ensures that your valuable conversations are securely saved to your backend
database. Thank you!
</div>
<div class=" mt-6 mx-auto relative group w-fit">
<button
class="relative z-20 flex px-5 py-2 rounded-full bg-white hover:bg-gray-100 transition font-medium text-sm"
on:click={async () => {
let blob = new Blob([JSON.stringify(localDBChats)], {
type: 'application/json'
});
saveAs(blob, `chat-export-${Date.now()}.json`);
const tx = DB.transaction('chats', 'readwrite');
await Promise.all([tx.store.clear(), tx.done]);
localDBChats = [];
}}
>
Download & Delete
</button>
<button
class="text-xs text-center w-full mt-2 text-gray-400 underline"
on:click={async () => {
localDBChats = [];
}}>Close</button
>
</div>
</div>
</div>
</div>
</div>
{/if}
{/if}
<div
<div
...
...
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