feat: global filter

This commit is contained in:
Timothy J. Baek
2024-06-27 13:04:12 -07:00
parent c8c85ba7fc
commit edbd07f893
8 changed files with 212 additions and 29 deletions
+24 -1
View File
@@ -14,7 +14,8 @@
exportFunctions,
getFunctionById,
getFunctions,
toggleFunctionById
toggleFunctionById,
toggleGlobalById
} from '$lib/apis/functions';
import ArrowDownTray from '../icons/ArrowDownTray.svelte';
@@ -113,6 +114,22 @@
models.set(await getModels(localStorage.token));
}
};
const toggleGlobalHandler = async (func) => {
const res = await toggleGlobalById(localStorage.token, func.id).catch((error) => {
toast.error(error);
});
if (res) {
if (func.is_global) {
toast.success($i18n.t('Filter is now globally enabled'));
} else {
toast.success($i18n.t('Filter is now globally disabled'));
}
functions.set(await getFunctions(localStorage.token));
}
};
</script>
<svelte:head>
@@ -259,6 +276,7 @@
</Tooltip>
<FunctionMenu
{func}
editHandler={() => {
goto(`/workspace/functions/edit?id=${encodeURIComponent(func.id)}`);
}}
@@ -275,6 +293,11 @@
selectedFunction = func;
showDeleteConfirm = true;
}}
toggleGlobalHandler={() => {
if (func.type === 'filter') {
toggleGlobalHandler(func);
}
}}
onClose={() => {}}
>
<button