This commit is contained in:
Timothy Jaeryang Baek 2024-11-15 03:02:08 -08:00
parent a0f1164af7
commit 147bd0717d
2 changed files with 10 additions and 5 deletions

View File

@ -116,7 +116,7 @@ async def delete_model_by_id(id: str, user=Depends(get_verified_user)):
detail=ERROR_MESSAGES.NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND,
) )
if model.user_id != user.id: if model.user_id != user.id and user.role != "admin":
raise HTTPException( raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.UNAUTHORIZED, detail=ERROR_MESSAGES.UNAUTHORIZED,

View File

@ -28,6 +28,7 @@
import GarbageBin from '../icons/GarbageBin.svelte'; import GarbageBin from '../icons/GarbageBin.svelte';
import Search from '../icons/Search.svelte'; import Search from '../icons/Search.svelte';
import Plus from '../icons/Plus.svelte'; import Plus from '../icons/Plus.svelte';
import { get } from 'svelte/store';
let shiftKey = false; let shiftKey = false;
@ -51,13 +52,17 @@
let searchValue = ''; let searchValue = '';
const deleteModelHandler = async (model) => { const deleteModelHandler = async (model) => {
const res = await deleteModelById(localStorage.token, model.id); const res = await deleteModelById(localStorage.token, model.id).catch((e) => {
toast.error(e);
return null;
});
if (res) { if (res) {
toast.success($i18n.t(`Deleted {{name}}`, { name: model.id })); toast.success($i18n.t(`Deleted {{name}}`, { name: model.id }));
} }
await _models.set(await getModels(localStorage.token)); await _models.set(await getModels(localStorage.token));
models = $_models; models = await getWorkspaceModels(localStorage.token);
}; };
const cloneModelHandler = async (model) => { const cloneModelHandler = async (model) => {
@ -123,7 +128,7 @@
} }
await _models.set(await getModels(localStorage.token)); await _models.set(await getModels(localStorage.token));
models = $_models; models = await getWorkspaceModels(localStorage.token);
}; };
const downloadModels = async (models) => { const downloadModels = async (models) => {
@ -431,7 +436,7 @@
} }
await _models.set(await getModels(localStorage.token)); await _models.set(await getModels(localStorage.token));
models = $_models; models = await getWorkspaceModels(localStorage.token);
}; };
reader.readAsText(importFiles[0]); reader.readAsText(importFiles[0]);