Skip to content

Commit

Permalink
fix workspace app
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Aug 21, 2024
1 parent 868018f commit de88aef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 5 additions & 5 deletions hypha/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,15 @@ async def list_files(
"*", UserPermission.admin
), "Permission denied: only admin can access the root folder."
# remove the leading slash
path = path[1:]
full_path = path[1:]
else:
path = safe_join(workspace, path)
full_path = safe_join(workspace, path)
async with self.create_client_async() as s3_client:
# List files in the folder
if not path.endswith("/"):
path += "/"
if not full_path.endswith("/"):
full_path += "/"
items = await list_objects_async(
s3_client, self.workspace_bucket, path, max_length=max_length
s3_client, self.workspace_bucket, full_path, max_length=max_length
)
if len(items) == 0:
raise Exception(f"Directory does not exists: {path}")
Expand Down
17 changes: 11 additions & 6 deletions hypha/templates/ws/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,14 @@ <h2 className="text-2xl font-bold">Clients</h2>
{panel === 'apps' && (
<>
<p className="text-xl text-gray-400 mt-4">Applications installed in workspace: <code>{workspaceName}</code> </p>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mt-6">
<button
<button
className="mt-4 bg-green-600 hover:bg-green-500 text-white font-bold py-2 px-4 rounded-full transition duration-300"
onClick={() => onInstallApp()}
>
Install App
</button>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mt-6">

{apps.map(app => (
<AppCard key={app.id} app={app} />
))}
Expand Down Expand Up @@ -404,16 +405,20 @@ <h2 className="text-2xl font-bold">Clients</h2>
setServices(await ws.listServices(config.workspace));
} else if (activePanel === 'apps') {
try{
const controller = await ws.getService("public/server-apps");
setApps(await controller.listApps());
const controller = await ws.getService("public/server-apps", {case_conversion: "camel"});
const apps = await controller.listApps();
console.log("Apps:", apps);
setApps(apps);
}
catch(e){
alert(`Failed to list apps: ${e.message}`);
}
} else if (activePanel === 'files') {
try{
const s3 = await ws.getService("public/s3-storage", {case_conversion: "camel"});
setFiles(await s3.listFile(""));
const files = await s3.listFiles("")
console.log("Files:", files);
setFiles(files);
}
catch(e){
alert(`Failed to list files: ${e.message}`);
Expand All @@ -437,7 +442,7 @@ <h2 className="text-2xl font-bold">Clients</h2>
const url = prompt("Enter the URL of the app to install", "https://raw.githubusercontent.com/amun-ai/hypha/main/tests/testWebWorkerPlugin.imjoy.html");
try{
if(!url) return;
const controller = await ws.getService("public/server-apps");
const controller = await ws.getService("public/server-apps", {case_conversion: "camel"});
const appInfo = await controller.install(url);
console.log("App installed:", appInfo);
setApps(await controller.listApps());
Expand Down

0 comments on commit de88aef

Please sign in to comment.