From c29a6aa271250ab152430058e0bfebbd39cb7a1a Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 29 Jan 2024 10:48:54 +0100 Subject: [PATCH 1/4] feat: open model folder --- .../backend/src/managers/modelsManager.spec.ts | 12 ++++++------ packages/backend/src/managers/modelsManager.ts | 2 +- .../src/lib/table/model/ModelColumnActions.svelte | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/managers/modelsManager.spec.ts b/packages/backend/src/managers/modelsManager.spec.ts index 83f301309..facb3c3e5 100644 --- a/packages/backend/src/managers/modelsManager.spec.ts +++ b/packages/backend/src/managers/modelsManager.spec.ts @@ -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), }, ]); }); @@ -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', }, @@ -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', @@ -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', @@ -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', }, diff --git a/packages/backend/src/managers/modelsManager.ts b/packages/backend/src/managers/modelsManager.ts index 0c6e6224e..855edef90 100644 --- a/packages/backend/src/managers/modelsManager.ts +++ b/packages/backend/src/managers/modelsManager.ts @@ -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, }); diff --git a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte index 6c596c721..94fb1d472 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte @@ -1,10 +1,11 @@ + openModelFolder()} + title="Open Model Folder" +/> deleteModel()} From 450c6a58e46d20b8ef49c0a900bc12e9120e03d4 Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 29 Jan 2024 11:43:44 +0100 Subject: [PATCH 2/4] Update packages/frontend/src/lib/table/model/ModelColumnActions.svelte Co-authored-by: Florent BENOIT --- packages/frontend/src/lib/table/model/ModelColumnActions.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte index 94fb1d472..bdd11e407 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte @@ -20,7 +20,6 @@ async function goDeleteModel() { } function openModelFolder() { - console.log(object.file); if (object && object.file) { studioClient.openURL('file://'+object.file.path); } From b5076adc06c3433afba6a6572a178967b2fc5f06 Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 29 Jan 2024 14:02:24 +0100 Subject: [PATCH 3/4] add openFile method --- packages/backend/src/studio-api-impl.ts | 4 ++++ .../frontend/src/lib/table/model/ModelColumnActions.svelte | 2 +- packages/shared/src/StudioAPI.ts | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index e24a49d77..d1521db75 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -47,6 +47,10 @@ export class StudioApiImpl implements StudioAPI { return await podmanDesktopApi.env.openExternal(podmanDesktopApi.Uri.parse(url)); } + async openFile(file: string): Promise { + return await podmanDesktopApi.env.openExternal(podmanDesktopApi.Uri.file(file)); + } + async getPullingStatus(recipeId: string): Promise { return this.recipeStatusRegistry.getStatus(recipeId); } diff --git a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte index bdd11e407..74fc37869 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte @@ -21,7 +21,7 @@ async function goDeleteModel() { function openModelFolder() { if (object && object.file) { - studioClient.openURL('file://'+object.file.path); + studioClient.openFile(object.file.path); } } diff --git a/packages/shared/src/StudioAPI.ts b/packages/shared/src/StudioAPI.ts index 98928932b..7e406b63a 100644 --- a/packages/shared/src/StudioAPI.ts +++ b/packages/shared/src/StudioAPI.ts @@ -11,6 +11,7 @@ export abstract class StudioAPI { abstract getPullingStatuses(): Promise>; abstract pullApplication(recipeId: string): Promise; abstract openURL(url: string): Promise; + abstract openFile(file: string): Promise; /** * Get the information of models saved locally into the user's directory */ From 87353db31cbcbe784e9bdbc65f92a9020a818c82 Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 29 Jan 2024 14:08:51 +0100 Subject: [PATCH 4/4] fix actions column width --- packages/frontend/src/pages/Models.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/Models.svelte b/packages/frontend/src/pages/Models.svelte index 964d97476..783d47695 100644 --- a/packages/frontend/src/pages/Models.svelte +++ b/packages/frontend/src/pages/Models.svelte @@ -26,7 +26,7 @@ const columns: Column[] = [ new Column('Registry', { width: '2fr', renderer: ModelColumnRegistry }), new Column('Popularity', { width: '1fr', renderer: ModelColumnPopularity }), new Column('License', { width: '2fr', renderer: ModelColumnLicense }), - new Column('Actions', { align: 'right', width: '1fr', renderer: ModelColumnActions }), + new Column('Actions', { align: 'right', width: '80px', renderer: ModelColumnActions }), ]; const row = new Row({});