Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Model Folder #167

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/backend/src/managers/modelsManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ test('getLocalModelsFromDisk should get models in local directory', () => {
file: 'model-id-1-model',
size: 32000,
creation: now,
path: path.resolve(dirent[0].path, dirent[0].name, 'model-id-1-model'),
path: path.resolve(dirent[0].path, dirent[0].name),
},
{
id: 'model-id-2',
file: 'model-id-2-model',
size: 32000,
creation: now,
path: path.resolve(dirent[1].path, dirent[1].name, 'model-id-2-model'),
path: path.resolve(dirent[1].path, dirent[1].name),
},
]);
});
Expand Down Expand Up @@ -165,7 +165,7 @@ test('loadLocalModels should post a message with the message on disk and on cata
file: 'model-id-1-model',
id: 'model-id-1',
size: 32000,
path: path.resolve(dirent[0].path, dirent[0].name, 'model-id-1-model'),
path: path.resolve(dirent[0].path, dirent[0].name),
},
id: 'model-id-1',
},
Expand Down Expand Up @@ -219,7 +219,7 @@ test('deleteLocalModel deletes the model folder', async () => {
file: 'model-id-1-model',
id: 'model-id-1',
size: 32000,
path: path.resolve(dirent[0].path, dirent[0].name, 'model-id-1-model'),
path: path.resolve(dirent[0].path, dirent[0].name),
},
id: 'model-id-1',
state: 'deleting',
Expand Down Expand Up @@ -279,7 +279,7 @@ test('deleteLocalModel fails to delete the model folder', async () => {
file: 'model-id-1-model',
id: 'model-id-1',
size: 32000,
path: path.resolve(dirent[0].path, dirent[0].name, 'model-id-1-model'),
path: path.resolve(dirent[0].path, dirent[0].name),
},
id: 'model-id-1',
state: 'deleting',
Expand All @@ -296,7 +296,7 @@ test('deleteLocalModel fails to delete the model folder', async () => {
file: 'model-id-1-model',
id: 'model-id-1',
size: 32000,
path: path.resolve(dirent[0].path, dirent[0].name, 'model-id-1-model'),
path: path.resolve(dirent[0].path, dirent[0].name),
},
id: 'model-id-1',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/managers/modelsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ModelsManager {
result.set(d.name, {
id: d.name,
file: modelFile,
path: fullPath,
path: path.resolve(d.path, d.name),
size: info.size,
creation: info.mtime,
});
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class StudioApiImpl implements StudioAPI {
return await podmanDesktopApi.env.openExternal(podmanDesktopApi.Uri.parse(url));
}

async openFile(file: string): Promise<boolean> {
return await podmanDesktopApi.env.openExternal(podmanDesktopApi.Uri.file(file));
}

async getPullingStatus(recipeId: string): Promise<RecipeStatus> {
return this.recipeStatusRegistry.getStatus(recipeId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts">
import type { ModelInfo } from "@shared/src/models/IModelInfo";
import { faTrash } from "@fortawesome/free-solid-svg-icons";
import { faFolderOpen } from "@fortawesome/free-solid-svg-icons";
import ListItemButtonIcon from "../../button/ListItemButtonIcon.svelte";
import { studioClient } from "/@/utils/client";
import Modal from "../../Modal.svelte";
import Button from "../../button/Button.svelte";
import Button from "../../button/Button.svelte";
export let object: ModelInfo;

let deleteConfirmVisible: boolean = false;
Expand All @@ -17,8 +18,19 @@ async function goDeleteModel() {
await studioClient.deleteLocalModel(object.id);
deleteConfirmVisible= false;
}

function openModelFolder() {
if (object && object.file) {
studioClient.openFile(object.file.path);
}
}
</script>

<ListItemButtonIcon
icon={faFolderOpen}
onClick={() => openModelFolder()}
title="Open Model Folder"
/>
<ListItemButtonIcon
icon={faTrash}
onClick={() => deleteModel()}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/Models.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const columns: Column<ModelInfo>[] = [
new Column<ModelInfo>('Registry', { width: '2fr', renderer: ModelColumnRegistry }),
new Column<ModelInfo>('Popularity', { width: '1fr', renderer: ModelColumnPopularity }),
new Column<ModelInfo>('License', { width: '2fr', renderer: ModelColumnLicense }),
new Column<ModelInfo>('Actions', { align: 'right', width: '1fr', renderer: ModelColumnActions }),
new Column<ModelInfo>('Actions', { align: 'right', width: '80px', renderer: ModelColumnActions }),
];
const row = new Row<ModelInfo>({});

Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export abstract class StudioAPI {
abstract getPullingStatuses(): Promise<Map<string, RecipeStatus>>;
abstract pullApplication(recipeId: string): Promise<void>;
abstract openURL(url: string): Promise<boolean>;
abstract openFile(file: string): Promise<boolean>;
/**
* Get the information of models saved locally into the user's directory
*/
Expand Down
Loading