enh: sync stats
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
import NotificationToast from '$lib/components/NotificationToast.svelte';
|
||||
import AppSidebar from '$lib/components/app/AppSidebar.svelte';
|
||||
import SyncStatsModal from '$lib/components/chat/Settings/SyncStatsModal.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { getUserSettings } from '$lib/apis/users';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -89,6 +90,8 @@
|
||||
let tokenTimer = null;
|
||||
|
||||
let showRefresh = false;
|
||||
let showSyncStatsModal = false;
|
||||
let syncStatsParams = {};
|
||||
|
||||
let heartbeatInterval = null;
|
||||
|
||||
@@ -600,7 +603,24 @@
|
||||
}
|
||||
};
|
||||
|
||||
const windowMessageEventHandler = async (event) => {
|
||||
if (
|
||||
!['https://openwebui.com', 'https://www.openwebui.com', 'http://localhost:9999'].includes(
|
||||
event.origin
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data === 'export:stats' || event.data?.type === 'export:stats') {
|
||||
syncStatsParams = event.data?.searchParams ?? {};
|
||||
showSyncStatsModal = true;
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
window.addEventListener('message', windowMessageEventHandler);
|
||||
|
||||
let touchstartY = 0;
|
||||
|
||||
function isNavOrDescendant(el) {
|
||||
@@ -814,10 +834,20 @@
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
// Notify opener window that the app has loaded
|
||||
if (window.opener ?? false) {
|
||||
window.opener.postMessage('loaded', '*');
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', onResize);
|
||||
};
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
window.removeEventListener('message', windowMessageEventHandler);
|
||||
bc.close();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -855,6 +885,10 @@
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if $config?.features.enable_community_sharing}
|
||||
<SyncStatsModal bind:show={showSyncStatsModal} params={syncStatsParams} />
|
||||
{/if}
|
||||
|
||||
<Toaster
|
||||
theme={$theme.includes('dark')
|
||||
? 'dark'
|
||||
|
||||
Reference in New Issue
Block a user