From 08038785777345277bb7b78ecd44851cb130935b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Tue, 10 Mar 2026 09:27:04 +0000 Subject: [PATCH] feat: collection color image management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gašper Grom --- .../U1773131945__collectionsImageColor.sql | 2 + .../V1773131945__collectionsImageColor.sql | 2 + .../components/lf-collection-add.vue | 87 +++++++++++++++---- .../collections/models/collection.model.ts | 6 ++ scripts/cli | 2 +- .../src/collections/index.ts | 8 +- 6 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 backend/src/database/migrations/U1773131945__collectionsImageColor.sql create mode 100644 backend/src/database/migrations/V1773131945__collectionsImageColor.sql diff --git a/backend/src/database/migrations/U1773131945__collectionsImageColor.sql b/backend/src/database/migrations/U1773131945__collectionsImageColor.sql new file mode 100644 index 0000000000..4ed94be514 --- /dev/null +++ b/backend/src/database/migrations/U1773131945__collectionsImageColor.sql @@ -0,0 +1,2 @@ +ALTER TABLE collections DROP COLUMN IF EXISTS "imageUrl"; +ALTER TABLE collections DROP COLUMN IF EXISTS "color"; diff --git a/backend/src/database/migrations/V1773131945__collectionsImageColor.sql b/backend/src/database/migrations/V1773131945__collectionsImageColor.sql new file mode 100644 index 0000000000..11a05baba8 --- /dev/null +++ b/backend/src/database/migrations/V1773131945__collectionsImageColor.sql @@ -0,0 +1,2 @@ +ALTER TABLE collections ADD COLUMN IF NOT EXISTS "imageUrl" VARCHAR(1024); +ALTER TABLE collections ADD COLUMN IF NOT EXISTS "color" VARCHAR(30); diff --git a/frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue b/frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue index 685018b808..4424d844ab 100644 --- a/frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue +++ b/frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue @@ -56,23 +56,69 @@ - -
- - - - -
+ +
+
+ Appearance +
+ + +
+ + + + Recommended image size: 800×240px + +
+ + +
+ + + + Recommended image size: 400×400px + +
+ + +
+ +
+ + +
+ Leave blank to use the default color #009AFF +
+
+
@@ -204,6 +250,8 @@ const form = reactive({ type: '', categoryId: null, logoUrl: '', + imageUrl: '', + color: '', projects: [], starred: false, }); @@ -214,6 +262,7 @@ const rules = { maxLength, }, description: { required: (value: string) => value.trim().length }, + imageUrl: { url }, logoUrl: { url }, projects: { required: (value: any) => value.length > 0 }, }; @@ -239,6 +288,8 @@ const fillForm = (record?: CollectionModel) => { form.type = record.category?.categoryGroupType; form.categoryId = record.categoryId || null; form.logoUrl = record.logoUrl || ''; + form.imageUrl = record.imageUrl || ''; + form.color = record.color || ''; } formSnapshot(); @@ -263,6 +314,8 @@ const onSubmit = () => { name: form.name, description: form.description, logoUrl: form.logoUrl || undefined, + imageUrl: form.imageUrl || undefined, + color: form.color || undefined, projects: form.projects.map((project: any) => ({ id: project.id, starred: project?.starred || false, diff --git a/frontend/src/modules/admin/modules/collections/models/collection.model.ts b/frontend/src/modules/admin/modules/collections/models/collection.model.ts index 50a0f7b832..cee9b61151 100644 --- a/frontend/src/modules/admin/modules/collections/models/collection.model.ts +++ b/frontend/src/modules/admin/modules/collections/models/collection.model.ts @@ -8,6 +8,8 @@ export interface CollectionModel { slug: string; categoryId?: string; logoUrl?: string; + imageUrl?: string; + color?: string; ssoUserId?: string; projects: InsightsProjectModel[]; category: Category & {categoryGroupType: string, categoryGroupName: string}; @@ -19,6 +21,8 @@ export interface CollectionRequest { description: string; categoryId: string | null; logoUrl?: string; + imageUrl?: string; + color?: string; slug: string; starred: boolean; projects: { @@ -32,6 +36,8 @@ export interface CollectionFormModel { type: string | null; categoryId: string | null; logoUrl: string; + imageUrl: string; + color: string; projects: InsightsProjectModel[]; starred: boolean; } diff --git a/scripts/cli b/scripts/cli index 63547ea3f3..8ee3d6182d 100755 --- a/scripts/cli +++ b/scripts/cli @@ -1058,7 +1058,7 @@ while test $# -gt 0; do exit ;; clean-start-fe-dev) - IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "discord-ws" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker") + IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "discord-ws" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker" "cache-worker" "categorization-worker" "cron-service" "data-sink-worker" "git-integration" "integration-run-worker" "integration-stream-worker" "nango-webhook-api" "nango-worker" "script-executor-worker" "search-sync-api" "search-sync-worker" "security-best-practices-worker" "snowflake-connectors-worker") CLEAN_START=1 DEV=1 start diff --git a/services/libs/data-access-layer/src/collections/index.ts b/services/libs/data-access-layer/src/collections/index.ts index 7a5ca91b47..d53649bfac 100644 --- a/services/libs/data-access-layer/src/collections/index.ts +++ b/services/libs/data-access-layer/src/collections/index.ts @@ -15,7 +15,9 @@ import { QueryOptions } from '../utils' export interface ICreateCollection { categoryId: string + color?: string | null description?: string + imageUrl?: string | null name: string slug?: string starred: boolean @@ -80,9 +82,11 @@ export interface ICollectionInsightProject { export enum CollectionField { CATEGORY_ID = 'categoryId', + COLOR = 'color', CREATED_AT = 'createdAt', DESCRIPTION = 'description', ID = 'id', + IMAGE_URL = 'imageUrl', IS_PRIVATE = 'isPrivate', LOGO_URL = 'logoUrl', NAME = 'name', @@ -136,8 +140,8 @@ export async function createCollection( ): Promise { return qx.selectOne( ` - INSERT INTO collections (name, description, slug, "categoryId", starred, "logoUrl") - VALUES ($(name), $(description), $(slug), $(categoryId), $(starred), $(logoUrl)) + INSERT INTO collections (name, description, slug, "categoryId", starred, "logoUrl", "imageUrl", color) + VALUES ($(name), $(description), $(slug), $(categoryId), $(starred), $(logoUrl), $(imageUrl), $(color)) RETURNING * `, collection,