fix: tool edit

This commit is contained in:
Timothy J. Baek 2024-06-10 21:53:51 -07:00
parent 25c0eca414
commit 4601a0246f
3 changed files with 16 additions and 6 deletions

View File

@ -111,7 +111,7 @@ async def create_new_toolkit(form_data: ToolForm, user=Depends(get_admin_user)):
############################ ############################
@router.get("/id/{id}", response_model=Optional[ToolResponse]) @router.get("/id/{id}", response_model=Optional[ToolModel])
async def get_toolkit_by_id(id: str, user=Depends(get_admin_user)): async def get_toolkit_by_id(id: str, user=Depends(get_admin_user)):
toolkit = Tools.get_tool_by_id(id) toolkit = Tools.get_tool_by_id(id)
@ -129,7 +129,7 @@ async def get_toolkit_by_id(id: str, user=Depends(get_admin_user)):
############################ ############################
@router.post("/id/{id}/update", response_model=Optional[ToolResponse]) @router.post("/id/{id}/update", response_model=Optional[ToolModel])
async def update_toolkit_by_id( async def update_toolkit_by_id(
id: str, form_data: ToolForm, user=Depends(get_admin_user) id: str, form_data: ToolForm, user=Depends(get_admin_user)
): ):
@ -143,9 +143,14 @@ async def update_toolkit_by_id(
TOOLS[id] = toolkit_module TOOLS[id] = toolkit_module
specs = get_tools_specs(TOOLS[id]) specs = get_tools_specs(TOOLS[id])
toolkit = Tools.update_tool_by_id(
id, {**form_data.model_dump(), "specs": specs} updated = {
) **form_data.model_dump(),
"specs": specs,
}
print(updated)
toolkit = Tools.update_tool_by_id(id, updated)
if toolkit: if toolkit:
return toolkit return toolkit

View File

@ -60,7 +60,10 @@
]; ];
onMount(() => { onMount(() => {
value = boilerplate; console.log(value);
if (value === '') {
value = boilerplate;
}
// Check if html class has dark mode // Check if html class has dark mode
isDarkMode = document.documentElement.classList.contains('dark'); isDarkMode = document.documentElement.classList.contains('dark');

View File

@ -40,6 +40,8 @@
goto('/workspace/tools'); goto('/workspace/tools');
return null; return null;
}); });
console.log(tool);
} }
}); });
</script> </script>