Commit 0fdb346a authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

feat: webui notification

parent b7ff3af4
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// General // General
let API_BASE_URL = OLLAMA_API_BASE_URL; let API_BASE_URL = OLLAMA_API_BASE_URL;
let theme = 'dark'; let theme = 'dark';
let notificationEnabled = false;
let system = ''; let system = '';
// Advanced // Advanced
...@@ -49,7 +50,6 @@ ...@@ -49,7 +50,6 @@
let pullProgress = null; let pullProgress = null;
// Addons // Addons
let responseNotification = false;
let titleAutoGenerate = true; let titleAutoGenerate = true;
let speechAutoSend = false; let speechAutoSend = false;
...@@ -110,12 +110,12 @@ ...@@ -110,12 +110,12 @@
saveSettings({ titleAutoGenerate: titleAutoGenerate }); saveSettings({ titleAutoGenerate: titleAutoGenerate });
}; };
const toggleResponseNotification = async () => { const toggleNotification = async () => {
const permission = await Notification.requestPermission(); const permission = await Notification.requestPermission();
if (permission === 'granted') { if (permission === 'granted') {
responseNotification = !responseNotification; notificationEnabled = !notificationEnabled;
saveSettings({ responseNotification: responseNotification }); saveSettings({ notificationEnabled: notificationEnabled });
} else { } else {
toast.error( toast.error(
'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.' 'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
...@@ -168,6 +168,13 @@ ...@@ -168,6 +168,13 @@
if (data.status) { if (data.status) {
if (!data.digest) { if (!data.digest) {
toast.success(data.status); toast.success(data.status);
if (data.status === 'success') {
const notification = new Notification(`Ollama`, {
body: `Model '${modelTag}' has been successfully downloaded.`,
icon: '/favicon.png'
});
}
} else { } else {
digest = data.digest; digest = data.digest;
if (data.completed) { if (data.completed) {
...@@ -524,8 +531,10 @@ ...@@ -524,8 +531,10 @@
{#if selectedTab === 'general'} {#if selectedTab === 'general'}
<div class="flex flex-col space-y-3"> <div class="flex flex-col space-y-3">
<div> <div>
<div class=" py-1 flex w-full justify-between"> <div class=" mb-1 text-sm font-medium">WebUI Settings</div>
<div class=" self-center text-sm font-medium">Theme</div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">Theme</div>
<button <button
class="p-1 px-3 text-xs flex rounded transition" class="p-1 px-3 text-xs flex rounded transition"
...@@ -563,6 +572,26 @@ ...@@ -563,6 +572,26 @@
{/if} {/if}
</button> </button>
</div> </div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">Notification</div>
<button
class="p-1 px-3 text-xs flex rounded transition"
on:click={() => {
toggleNotification();
}}
type="button"
>
{#if notificationEnabled === true}
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
</div> </div>
<hr class=" dark:border-gray-700" /> <hr class=" dark:border-gray-700" />
...@@ -819,26 +848,6 @@ ...@@ -819,26 +848,6 @@
<div> <div>
<div class=" mb-1 text-sm font-medium">WebUI Add-ons</div> <div class=" mb-1 text-sm font-medium">WebUI Add-ons</div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">Response Notification</div>
<button
class="p-1 px-3 text-xs flex rounded transition"
on:click={() => {
toggleResponseNotification();
}}
type="button"
>
{#if responseNotification === true}
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
<div> <div>
<div class=" py-0.5 flex w-full justify-between"> <div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">Title Auto Generation</div> <div class=" self-center text-xs font-medium">Title Auto Generation</div>
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
}; };
messages = messages; messages = messages;
if ($settings.responseNotification && !document.hasFocus()) { if ($settings.notificationEnabled && !document.hasFocus()) {
const notification = new Notification( const notification = new Notification(
selectedModelfile selectedModelfile
? `${ ? `${
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
}; };
messages = messages; messages = messages;
if ($settings.responseNotification && !document.hasFocus()) { if ($settings.notificationEnabled && !document.hasFocus()) {
const notification = new Notification( const notification = new Notification(
selectedModelfile selectedModelfile
? `${ ? `${
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment