mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 19:16:01 +00:00
perspective designer
This commit is contained in:
@@ -66,6 +66,11 @@ export interface PerspectiveNodeConfig {
|
|||||||
|
|
||||||
filters: { [uniqueName: string]: string };
|
filters: { [uniqueName: string]: string };
|
||||||
isAutoGenerated?: true | undefined;
|
isAutoGenerated?: true | undefined;
|
||||||
|
|
||||||
|
position: {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PerspectiveReferenceConfig {
|
export interface PerspectiveReferenceConfig {
|
||||||
|
|||||||
82
packages/web/src/perspectives/PerspectiveDesigner.svelte
Normal file
82
packages/web/src/perspectives/PerspectiveDesigner.svelte
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { MultipleDatabaseInfo, PerspectiveConfig } from 'dbgate-datalib';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
import Designer from '../designer/Designer.svelte';
|
||||||
|
import QueryDesignerReference from '../designer/QueryDesignerReference.svelte';
|
||||||
|
|
||||||
|
export let config: PerspectiveConfig;
|
||||||
|
export let dbInfos: MultipleDatabaseInfo;
|
||||||
|
|
||||||
|
export let conid;
|
||||||
|
export let database;
|
||||||
|
|
||||||
|
export let onChange;
|
||||||
|
|
||||||
|
function createDesignerModel(config: PerspectiveConfig, dbInfos: MultipleDatabaseInfo) {
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
tables: _.compact(
|
||||||
|
config.nodes.map(node => {
|
||||||
|
const table = dbInfos?.[node.conid || conid]?.[node.database || database]?.tables?.find(
|
||||||
|
x => x.pureName == node.pureName && x.schemaName == node.schemaName
|
||||||
|
);
|
||||||
|
if (!table) return null;
|
||||||
|
|
||||||
|
const { designerId } = node;
|
||||||
|
return {
|
||||||
|
...table,
|
||||||
|
left: node?.position?.x || 0,
|
||||||
|
top: node?.position?.y || 0,
|
||||||
|
designerId,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleChange(value) {
|
||||||
|
onChange(oldValue => {
|
||||||
|
const newValue = _.isFunction(value) ? value(createDesignerModel(oldValue, dbInfos)) : value;
|
||||||
|
return {
|
||||||
|
...oldValue,
|
||||||
|
nodes: oldValue.nodes.map(node => {
|
||||||
|
const table = newValue.tables?.find(x => x.designerId == node.designerId);
|
||||||
|
if (table) {
|
||||||
|
return {
|
||||||
|
...node,
|
||||||
|
position: { x: table.left, y: table.top },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Designer
|
||||||
|
{...$$props}
|
||||||
|
settings={{
|
||||||
|
showTableCloseButton: true,
|
||||||
|
allowColumnOperations: true,
|
||||||
|
allowCreateRefByDrag: true,
|
||||||
|
allowTableAlias: true,
|
||||||
|
updateFromDbInfo: false,
|
||||||
|
useDatabaseReferences: false,
|
||||||
|
allowScrollColumns: true,
|
||||||
|
allowAddAllReferences: false,
|
||||||
|
canArrange: false,
|
||||||
|
canExport: false,
|
||||||
|
canSelectColumns: true,
|
||||||
|
canSelectTables: false,
|
||||||
|
allowChangeColor: false,
|
||||||
|
appendTableSystemMenu: false,
|
||||||
|
customizeStyle: false,
|
||||||
|
allowDefineVirtualReferences: false,
|
||||||
|
}}
|
||||||
|
referenceComponent={QueryDesignerReference}
|
||||||
|
value={createDesignerModel(config, dbInfos)}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
@@ -55,6 +55,8 @@
|
|||||||
import SearchInput from '../elements/SearchInput.svelte';
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||||
import { useMultipleDatabaseInfo } from '../utility/useMultipleDatabaseInfo';
|
import { useMultipleDatabaseInfo } from '../utility/useMultipleDatabaseInfo';
|
||||||
|
import VerticalSplitter from '../elements/VerticalSplitter.svelte';
|
||||||
|
import PerspectiveDesigner from './PerspectiveDesigner.svelte';
|
||||||
|
|
||||||
const dbg = debug('dbgate:PerspectiveView');
|
const dbg = debug('dbgate:PerspectiveView');
|
||||||
|
|
||||||
@@ -94,7 +96,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$: dbInfos = useMultipleDatabaseInfo(extractPerspectiveDatabases({ conid, database }, config));
|
let perspectiveDatabases = extractPerspectiveDatabases({ conid, database }, config);
|
||||||
|
$: {
|
||||||
|
const newDatabases = extractPerspectiveDatabases({ conid, database }, config);
|
||||||
|
if (stableStringify(newDatabases) != stableStringify(newDatabases)) {
|
||||||
|
perspectiveDatabases = newDatabases;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$: dbInfos = useMultipleDatabaseInfo(perspectiveDatabases);
|
||||||
$: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId);
|
$: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId);
|
||||||
$: tableInfo = useTableInfo({ conid, database, ...rootObject });
|
$: tableInfo = useTableInfo({ conid, database, ...rootObject });
|
||||||
$: viewInfo = useViewInfo({ conid, database, ...rootObject });
|
$: viewInfo = useViewInfo({ conid, database, ...rootObject });
|
||||||
@@ -138,9 +147,16 @@
|
|||||||
</WidgetColumnBar>
|
</WidgetColumnBar>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<svelte:fragment slot="2">
|
||||||
|
<VerticalSplitter>
|
||||||
|
<svelte:fragment slot="1">
|
||||||
|
<PerspectiveDesigner {config} {conid} {database} onChange={setConfig} dbInfos={$dbInfos} />
|
||||||
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="2">
|
<svelte:fragment slot="2">
|
||||||
<PerspectiveTable {root} {loadedCounts} {config} {setConfig} {conid} {database} />
|
<PerspectiveTable {root} {loadedCounts} {config} {setConfig} {conid} {database} />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
</VerticalSplitter>
|
||||||
|
</svelte:fragment>
|
||||||
</HorizontalSplitter>
|
</HorizontalSplitter>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -107,8 +107,6 @@
|
|||||||
cache.clear();
|
cache.clear();
|
||||||
loadedCounts.set({});
|
loadedCounts.set({});
|
||||||
}
|
}
|
||||||
|
|
||||||
$: console.log('PERSPECTIVE', $modelState.value);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ToolStripContainer>
|
<ToolStripContainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user