From 2c91d17805eb1ab083c2f288c59a70ba1e28cefa Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Tue, 23 Jan 2024 14:27:14 +0100 Subject: [PATCH] frontend: display size and creation age of models --- packages/backend/src/studio-api-impl.ts | 7 ++++--- packages/frontend/package.json | 4 ++++ .../src/lib/progress/TasksProgress.svelte | 2 +- .../table/model/ModelColumnCreation.svelte | 11 ++++++++++ .../src/lib/table/model/ModelColumnHW.svelte | 2 +- .../lib/table/model/ModelColumnLicense.svelte | 2 +- .../lib/table/model/ModelColumnName.svelte | 2 +- .../table/model/ModelColumnPopularity.svelte | 2 +- .../table/model/ModelColumnRegistry.svelte | 2 +- .../lib/table/model/ModelColumnSize.svelte | 11 ++++++++++ .../frontend/src/pages/ModelPlayground.svelte | 6 +++--- packages/frontend/src/pages/Models.svelte | 14 ++++++++----- packages/frontend/src/utils/dimensions.ts | 9 +++++++++ packages/shared/src/models/IModelInfo.ts | 2 +- yarn.lock | 20 +++++++++++++++++++ 15 files changed, 78 insertions(+), 18 deletions(-) create mode 100644 packages/frontend/src/lib/table/model/ModelColumnCreation.svelte create mode 100644 packages/frontend/src/lib/table/model/ModelColumnSize.svelte create mode 100644 packages/frontend/src/utils/dimensions.ts diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index 4aacdbdba..122a6a361 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -30,7 +30,7 @@ import type { CatalogManager } from './managers/catalogManager'; import type { Catalog } from '@shared/src/models/ICatalog'; import type { PlaygroundState } from '@shared/src/models/IPlaygroundState'; import type { ModelsManager } from './managers/modelsManager'; -import { LocalModelInfo } from '@shared/src/models/ILocalModelInfo'; +import type { LocalModelInfo } from '@shared/src/models/ILocalModelInfo'; export class StudioApiImpl implements StudioAPI { constructor( @@ -40,7 +40,7 @@ export class StudioApiImpl implements StudioAPI { private playgroundManager: PlayGroundManager, private catalogManager: CatalogManager, private modelsManager: ModelsManager, - ) { } + ) {} async ping(): Promise { return 'pong'; @@ -87,7 +87,8 @@ export class StudioApiImpl implements StudioAPI { localMap.set(l.id, l); } const localIds = local.map(l => l.id); - return this.catalogManager.getModels() + return this.catalogManager + .getModels() .filter(m => localIds.includes(m.id)) .map(m => ({ ...m, file: localMap.get(m.id) })); } diff --git a/packages/frontend/package.json b/packages/frontend/package.json index e3b105746..2ca9ed9bc 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -27,8 +27,12 @@ "@testing-library/svelte": "^4.0.5", "@testing-library/user-event": "^14.5.1", "@tsconfig/svelte": "^5.0.2", + "@types/humanize-duration": "^3.27.4", "@typescript-eslint/eslint-plugin": "6.15.0", + "filesize": "^10.1.0", + "humanize-duration": "^3.31.0", "jsdom": "^23.2.0", + "moment": "^2.30.1", "postcss": "^8.4.33", "postcss-load-config": "^5.0.2", "svelte": "4.2.8", diff --git a/packages/frontend/src/lib/progress/TasksProgress.svelte b/packages/frontend/src/lib/progress/TasksProgress.svelte index 4fb6cc636..c4aa2b2db 100644 --- a/packages/frontend/src/lib/progress/TasksProgress.svelte +++ b/packages/frontend/src/lib/progress/TasksProgress.svelte @@ -1,5 +1,5 @@ diff --git a/packages/frontend/src/lib/table/model/ModelColumnCreation.svelte b/packages/frontend/src/lib/table/model/ModelColumnCreation.svelte new file mode 100644 index 000000000..12ffbc59a --- /dev/null +++ b/packages/frontend/src/lib/table/model/ModelColumnCreation.svelte @@ -0,0 +1,11 @@ + + +
+ {#if (object.file?.creation)} + {humanizeAge(object.file.creation.getTime()/1000)} + {/if} +
diff --git a/packages/frontend/src/lib/table/model/ModelColumnHW.svelte b/packages/frontend/src/lib/table/model/ModelColumnHW.svelte index a9d1a35ae..56033b778 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnHW.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnHW.svelte @@ -1,5 +1,5 @@ diff --git a/packages/frontend/src/lib/table/model/ModelColumnLicense.svelte b/packages/frontend/src/lib/table/model/ModelColumnLicense.svelte index ff8e02093..f326aa3b2 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnLicense.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnLicense.svelte @@ -1,5 +1,5 @@ diff --git a/packages/frontend/src/lib/table/model/ModelColumnName.svelte b/packages/frontend/src/lib/table/model/ModelColumnName.svelte index 0822bb7e2..1fbd6c011 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnName.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnName.svelte @@ -1,5 +1,5 @@ diff --git a/packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte b/packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte index fb48caf85..0786bd415 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte @@ -1,5 +1,5 @@ diff --git a/packages/frontend/src/lib/table/model/ModelColumnSize.svelte b/packages/frontend/src/lib/table/model/ModelColumnSize.svelte new file mode 100644 index 000000000..1453ae595 --- /dev/null +++ b/packages/frontend/src/lib/table/model/ModelColumnSize.svelte @@ -0,0 +1,11 @@ + + +
+ {#if (object.file?.size)} + {filesize(object.file.size)} + {/if} +
diff --git a/packages/frontend/src/pages/ModelPlayground.svelte b/packages/frontend/src/pages/ModelPlayground.svelte index 6331e74aa..7394256b9 100644 --- a/packages/frontend/src/pages/ModelPlayground.svelte +++ b/packages/frontend/src/pages/ModelPlayground.svelte @@ -1,11 +1,11 @@