Skip to content

Commit

Permalink
feat: open model folder
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jan 29, 2024
1 parent a431851 commit 2a8682c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
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
15 changes: 14 additions & 1 deletion packages/frontend/src/lib/table/model/ModelColumnActions.svelte
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,20 @@ async function goDeleteModel() {
await studioClient.deleteLocalModel(object.id);
deleteConfirmVisible= false;
}
function openModelFolder() {
console.log(object.file);
if (object && object.file) {
studioClient.openURL('file://'+object.file.path);
}
}
</script>

<ListItemButtonIcon
icon={faFolderOpen}
onClick={() => openModelFolder()}
title="Open Model Folder"
/>
<ListItemButtonIcon
icon={faTrash}
onClick={() => deleteModel()}
Expand Down

0 comments on commit 2a8682c

Please sign in to comment.