feat: global filter
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user