From 5ee5ced8c0f8cd0c5f5c9e173b2eac8960ca0dac Mon Sep 17 00:00:00 2001 From: haex Date: Sun, 26 Oct 2025 00:19:15 +0200 Subject: [PATCH] desktopicons now with foreign key to extensions --- ...kyrie.sql => 0000_secret_ender_wiggin.sql} | 7 +- .../migrations/meta/0000_snapshot.json | 35 +++++++-- .../database/migrations/meta/_journal.json | 4 +- src-tauri/database/schemas/haex.ts | 17 ++++- src-tauri/database/tableNames.json | 3 +- src-tauri/database/vault.db | Bin 118784 -> 118784 bytes src/components/haex/desktop/index.vue | 51 ++++++++++--- src/components/haex/extension/launcher.vue | 72 ++++++++++++++++-- .../haex/extension/marketplace-card.vue | 2 +- src/stores/desktop/index.ts | 32 ++++++-- 10 files changed, 184 insertions(+), 39 deletions(-) rename src-tauri/database/migrations/{0000_bumpy_valkyrie.sql => 0000_secret_ender_wiggin.sql} (78%) diff --git a/src-tauri/database/migrations/0000_bumpy_valkyrie.sql b/src-tauri/database/migrations/0000_secret_ender_wiggin.sql similarity index 78% rename from src-tauri/database/migrations/0000_bumpy_valkyrie.sql rename to src-tauri/database/migrations/0000_secret_ender_wiggin.sql index 05d2675..1762a40 100644 --- a/src-tauri/database/migrations/0000_bumpy_valkyrie.sql +++ b/src-tauri/database/migrations/0000_secret_ender_wiggin.sql @@ -28,11 +28,14 @@ CREATE TABLE `haex_desktop_items` ( `id` text PRIMARY KEY NOT NULL, `workspace_id` text NOT NULL, `item_type` text NOT NULL, - `reference_id` text NOT NULL, + `extension_id` text, + `system_window_id` text, `position_x` integer DEFAULT 0 NOT NULL, `position_y` integer DEFAULT 0 NOT NULL, `haex_timestamp` text, - FOREIGN KEY (`workspace_id`) REFERENCES `haex_workspaces`(`id`) ON UPDATE no action ON DELETE cascade + FOREIGN KEY (`workspace_id`) REFERENCES `haex_workspaces`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`extension_id`) REFERENCES `haex_extensions`(`id`) ON UPDATE no action ON DELETE cascade, + CONSTRAINT "item_reference" CHECK(("haex_desktop_items"."item_type" = 'extension' AND "haex_desktop_items"."extension_id" IS NOT NULL AND "haex_desktop_items"."system_window_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'system' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'file' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'folder' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL)) ); --> statement-breakpoint CREATE TABLE `haex_extension_permissions` ( diff --git a/src-tauri/database/migrations/meta/0000_snapshot.json b/src-tauri/database/migrations/meta/0000_snapshot.json index 92cc2f2..8c74bd2 100644 --- a/src-tauri/database/migrations/meta/0000_snapshot.json +++ b/src-tauri/database/migrations/meta/0000_snapshot.json @@ -1,7 +1,7 @@ { "version": "6", "dialect": "sqlite", - "id": "21ca1268-1057-48c1-8647-29bd7cb67d49", + "id": "bcdd9ad3-a87a-4a43-9eba-673f94b10287", "prevId": "00000000-0000-0000-0000-000000000000", "tables": { "haex_crdt_configs": { @@ -179,11 +179,18 @@ "notNull": true, "autoincrement": false }, - "reference_id": { - "name": "reference_id", + "extension_id": { + "name": "extension_id", "type": "text", "primaryKey": false, - "notNull": true, + "notNull": false, + "autoincrement": false + }, + "system_window_id": { + "name": "system_window_id", + "type": "text", + "primaryKey": false, + "notNull": false, "autoincrement": false }, "position_x": { @@ -224,11 +231,29 @@ ], "onDelete": "cascade", "onUpdate": "no action" + }, + "haex_desktop_items_extension_id_haex_extensions_id_fk": { + "name": "haex_desktop_items_extension_id_haex_extensions_id_fk", + "tableFrom": "haex_desktop_items", + "tableTo": "haex_extensions", + "columnsFrom": [ + "extension_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "checkConstraints": { + "item_reference": { + "name": "item_reference", + "value": "(\"haex_desktop_items\".\"item_type\" = 'extension' AND \"haex_desktop_items\".\"extension_id\" IS NOT NULL AND \"haex_desktop_items\".\"system_window_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'system' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'file' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'folder' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL)" + } + } }, "haex_extension_permissions": { "name": "haex_extension_permissions", diff --git a/src-tauri/database/migrations/meta/_journal.json b/src-tauri/database/migrations/meta/_journal.json index 82997d5..0942352 100644 --- a/src-tauri/database/migrations/meta/_journal.json +++ b/src-tauri/database/migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "6", - "when": 1761216357702, - "tag": "0000_bumpy_valkyrie", + "when": 1761430560028, + "tag": "0000_secret_ender_wiggin", "breakpoints": true } ] diff --git a/src-tauri/database/schemas/haex.ts b/src-tauri/database/schemas/haex.ts index 8f86a22..e9cd665 100644 --- a/src-tauri/database/schemas/haex.ts +++ b/src-tauri/database/schemas/haex.ts @@ -1,5 +1,6 @@ import { sql } from 'drizzle-orm' import { + check, integer, sqliteTable, text, @@ -158,9 +159,13 @@ export const haexDesktopItems = sqliteTable( itemType: text(tableNames.haex.desktop_items.columns.itemType, { enum: ['system', 'extension', 'file', 'folder'], }).notNull(), - referenceId: text( - tableNames.haex.desktop_items.columns.referenceId, - ).notNull(), // systemId für system windows, extensionId für extensions, filePath für files/folders + // Für Extensions (wenn itemType = 'extension') + extensionId: text(tableNames.haex.desktop_items.columns.extensionId) + .references((): AnySQLiteColumn => haexExtensions.id, { + onDelete: 'cascade', + }), + // Für System Windows (wenn itemType = 'system') + systemWindowId: text(tableNames.haex.desktop_items.columns.systemWindowId), positionX: integer(tableNames.haex.desktop_items.columns.positionX) .notNull() .default(0), @@ -170,6 +175,12 @@ export const haexDesktopItems = sqliteTable( }, tableNames.haex.desktop_items.columns, ), + (table) => [ + check( + 'item_reference', + sql`(${table.itemType} = 'extension' AND ${table.extensionId} IS NOT NULL AND ${table.systemWindowId} IS NULL) OR (${table.itemType} = 'system' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL) OR (${table.itemType} = 'file' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL) OR (${table.itemType} = 'folder' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL)`, + ), + ], ) export type InsertHaexDesktopItems = typeof haexDesktopItems.$inferInsert export type SelectHaexDesktopItems = typeof haexDesktopItems.$inferSelect diff --git a/src-tauri/database/tableNames.json b/src-tauri/database/tableNames.json index ae8e4b4..7600483 100644 --- a/src-tauri/database/tableNames.json +++ b/src-tauri/database/tableNames.json @@ -80,7 +80,8 @@ "id": "id", "workspaceId": "workspace_id", "itemType": "item_type", - "referenceId": "reference_id", + "extensionId": "extension_id", + "systemWindowId": "system_window_id", "positionX": "position_x", "positionY": "position_y", diff --git a/src-tauri/database/vault.db b/src-tauri/database/vault.db index 4227ac351f6ce52ac1746d8b80f06480010ff867..ec908f2c7ee625225d480da1acbe637ab55066f2 100644 GIT binary patch delta 1808 zcmZozz}~QceL}vxIR9_HBfQ*vj673#6uJI$-(nNy+Qod4bsy78hNnzflLZCBxBuJ2 z*vhy$i*+S4XQv7`ySSkt zQSb}(@xh}B-3uU%U_F`&{y_>vISyh3rpxLPzQJw_Vb`I1i6ocRE2yVs=A>dej85*V z#~q((`8g@6MKpGq2sjl$f=rW3)0u}&Jlt^dLPpumcexZM?vlK%$-0&KQqHe_N0=D?MK z+S51gXH=X1dJm)U=9R2jqj?Ws!7!Tlu$NYYEbjr+x+^5_ZNJ;asH&=RlYyT#kb!?U z?>XK|oI*HtY1}?Tm*QrKh{?V7$&KGu@|w z(VkIi`oZl$qG2ba=k)gtjGBxR)Ae>SHcg(*XvHWw`5L1!qv&QXCOt+@F<=Jc0A;et emdtCm@884d$h`R?+grxTySQ8z87M4rZ~y?TuTlsA delta 597 zcmb8sKWGzS9LDkY$tCwMce#|LwrZ3VROlj?-d&Pw!4i;&Ac%u>l((0=T!I+L;9L?q z*K&mybm0 zdZ8v$P&Skqd6axBW#nCcPaGtA+%VDPY`l(rA)j$Cm`E?NwK`^TjP2C%6jSWB4+Gio zzK`?3B-?LbD;(-rMZX#AaZ>k8QkW_fuo~p}hf3S^+_rnmac?wg0Y!$jJct2=mu#nn zOZ|~NipP$tkJGza)uNV7P0OUVQ}WCrr6s*aJ;!kjx;*C=ZBKV8t?AVEmL1DA<}A}F z*+#i+lx?$QIuv))Tf=H6|0EBj`_M;M%c?jaD!)fGL3@ReYRcVFNRN&_usbXX{NY^n0;Mj@J&z z^?GG|yxoMvS~sBv-x9h1;tNOf;Lhex6IJLE?Ln%m94gP0jQmyJmgCYZ>6|z%z8AXv zi8K}1H5bpLl&pt0(n&&y7(McL - -
- - -
- + +
+ +
+
{ const handleWindowDragEnd = async () => { console.log('[Desktop] handleWindowDragEnd') + + // Check if window should snap to left or right + const draggingWindowId = windowManager.draggingWindowId + + if (draggingWindowId) { + if (showLeftSnapZone.value) { + // Snap to left half + windowManager.updateWindowPosition(draggingWindowId, 0, 0) + windowManager.updateWindowSize( + draggingWindowId, + viewportWidth.value / 2, + viewportHeight.value, + ) + } else if (showRightSnapZone.value) { + // Snap to right half + windowManager.updateWindowPosition( + draggingWindowId, + viewportWidth.value / 2, + 0, + ) + windowManager.updateWindowSize( + draggingWindowId, + viewportWidth.value / 2, + viewportHeight.value, + ) + } + } + isWindowDragging.value = false windowManager.draggingWindowId = null // Clear from store allowSwipe.value = true // Re-enable Swiper after drag diff --git a/src/components/haex/extension/launcher.vue b/src/components/haex/extension/launcher.vue index 1aea498..823e65d 100644 --- a/src/components/haex/extension/launcher.vue +++ b/src/components/haex/extension/launcher.vue @@ -55,9 +55,23 @@ + + +