From 7a2a1a16f1eee1d4c3265e9dff058ad774e7e5c1 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Mon, 17 Jan 2022 21:33:05 +0100 Subject: [PATCH] diagram improvements --- .../web/src/appobj/DatabaseAppObject.svelte | 30 +++++++++++++++++++ .../src/appobj/DatabaseObjectAppObject.svelte | 2 +- packages/web/src/designer/Designer.svelte | 26 ++++++++++++++-- packages/web/src/designer/GraphLayout.ts | 3 +- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/packages/web/src/appobj/DatabaseAppObject.svelte b/packages/web/src/appobj/DatabaseAppObject.svelte index 74eb1ca4..13bda44b 100644 --- a/packages/web/src/appobj/DatabaseAppObject.svelte +++ b/packages/web/src/appobj/DatabaseAppObject.svelte @@ -85,6 +85,34 @@ }); }; + const handleShowDiagram = async () => { + const db = await getDatabaseInfo({ + conid: connection._id, + database: name, + }); + openNewTab( + { + title: 'Diagram #', + icon: 'img diagram', + tabComponent: 'DiagramTab', + props: { + conid: connection._id, + database: name, + }, + }, + { + editor: { + tables: db.tables.map(table => ({ + ...table, + designerId: `${table.pureName}-${uuidv1()}`, + })), + references: [], + autoLayout: true, + }, + } + ); + }; + const handleDisconnect = () => { const electron = getElectron(); if (electron) { @@ -138,6 +166,7 @@ { divider: true }, { onClick: handleImport, text: 'Import' }, { onClick: handleExport, text: 'Export' }, + { onClick: handleShowDiagram, text: 'Show diagram' }, { onClick: handleSqlGenerator, text: 'SQL Generator' }, { onClick: handleOpenJsonModel, text: 'Open model as JSON' }, { onClick: handleExportModel, text: 'Export DB model - experimental' }, @@ -157,6 +186,7 @@