fix: funcs, models, prompts, & tools conditional export button

This commit is contained in:
Silentoplayz 2025-04-03 23:33:30 -04:00
parent 1366822f99
commit 41b9ff9e00
4 changed files with 122 additions and 118 deletions

View File

@ -430,6 +430,7 @@
</div>
</button>
{#if $functions.length}
<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"
on:click={async () => {
@ -463,6 +464,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>

View File

@ -93,13 +93,10 @@
const tab = await window.open(`${url}/models/create`, '_blank');
// Define the event handler function
const messageHandler = (event) => {
if (event.origin !== url) return;
if (event.data === 'loaded') {
tab.postMessage(JSON.stringify(model), '*');
// Remove the event listener after handling the message
window.removeEventListener('message', messageHandler);
}
};
@ -477,13 +474,16 @@
</div>
</button>
{#if models.length}
<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"
on:click={async () => {
downloadModels(models);
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Models')}</div>
<div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Export Models')}
</div>
<div class=" self-center">
<svg
@ -500,6 +500,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}

View File

@ -285,17 +285,19 @@
</div>
</button>
{#if prompts.length}
<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"
on:click={async () => {
// promptsImportInputElement.click();
let blob = new Blob([JSON.stringify(prompts)], {
type: 'application/json'
});
saveAs(blob, `prompts-export-${Date.now()}.json`);
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Prompts')}</div>
<div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Export Prompts')}
</div>
<div class=" self-center">
<svg
@ -312,6 +314,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}

View File

@ -71,13 +71,10 @@
const tab = await window.open(`${url}/tools/create`, '_blank');
// Define the event handler function
const messageHandler = (event) => {
if (event.origin !== url) return;
if (event.data === 'loaded') {
tab.postMessage(JSON.stringify(item), '*');
// Remove the event listener after handling the message
window.removeEventListener('message', messageHandler);
}
};
@ -124,8 +121,7 @@
if (res) {
toast.success($i18n.t('Tool deleted successfully'));
init();
await init();
}
};
@ -398,6 +394,7 @@
</div>
</button>
{#if tools.length}
<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"
on:click={async () => {
@ -431,6 +428,7 @@
</svg>
</div>
</button>
{/if}
</div>
</div>
{/if}