mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
better paint perspective
This commit is contained in:
parent
f7a269383f
commit
2f74eab048
@ -154,3 +154,13 @@ export interface MultipleDatabaseInfo {
|
|||||||
[database: string]: DatabaseInfo;
|
[database: string]: DatabaseInfo;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function switchPerspectiveReferenceDirection(ref: PerspectiveReferenceConfig): PerspectiveReferenceConfig {
|
||||||
|
return {
|
||||||
|
designerId: ref.designerId,
|
||||||
|
sourceId: ref.targetId,
|
||||||
|
targetId: ref.sourceId,
|
||||||
|
isAutoGenerated: ref.isAutoGenerated,
|
||||||
|
columns: ref.columns.map(x => ({ source: x.target, target: x.source })),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -662,7 +662,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const reference of value?.references) {
|
for (const reference of settings?.sortAutoLayoutReferences
|
||||||
|
? settings?.sortAutoLayoutReferences(value?.references)
|
||||||
|
: value?.references) {
|
||||||
graph.addEdge(reference.sourceId, reference.targetId);
|
graph.addEdge(reference.sourceId, reference.targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
let minpos;
|
let minpos;
|
||||||
let columnsY = [];
|
let columnsY = [];
|
||||||
|
|
||||||
const buswi = 10;
|
const BUSWI = 10;
|
||||||
const extwi = 25;
|
const EXTWI = 25;
|
||||||
|
|
||||||
|
$: buswi = settings?.referencePaintSettings?.buswi || BUSWI;
|
||||||
|
$: extwi = settings?.referencePaintSettings?.extwi || EXTWI;
|
||||||
|
|
||||||
export function recomputePosition() {
|
export function recomputePosition() {
|
||||||
const { designerId, sourceId, targetId, columns, joinType } = reference;
|
const { designerId, sourceId, targetId, columns, joinType } = reference;
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
PerspectiveConfig,
|
PerspectiveConfig,
|
||||||
perspectiveNodesHaveStructure,
|
perspectiveNodesHaveStructure,
|
||||||
PerspectiveTreeNode,
|
PerspectiveTreeNode,
|
||||||
|
switchPerspectiveReferenceDirection,
|
||||||
} from 'dbgate-datalib';
|
} from 'dbgate-datalib';
|
||||||
import _, { findIndex } from 'lodash';
|
import _ from 'lodash';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
import runCommand from '../commands/runCommand';
|
import runCommand from '../commands/runCommand';
|
||||||
|
|
||||||
@ -109,14 +110,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function detectAutoArrange(config: PerspectiveConfig, dbInfos) {
|
async function detectAutoArrange(config: PerspectiveConfig, dbInfos, root) {
|
||||||
if (config.nodes.find(x => !x.position) && perspectiveNodesHaveStructure(config, dbInfos, conid, database)) {
|
if (
|
||||||
|
root &&
|
||||||
|
config.nodes.find(x => !x.position) &&
|
||||||
|
perspectiveNodesHaveStructure(config, dbInfos, conid, database) &&
|
||||||
|
config.nodes.every(x => root.findNodeByDesignerId(x.designerId))
|
||||||
|
) {
|
||||||
await tick();
|
await tick();
|
||||||
runCommand('designer.arrange');
|
runCommand('designer.arrange');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: detectAutoArrange(config, dbInfos);
|
$: detectAutoArrange(config, dbInfos, root);
|
||||||
|
|
||||||
|
// $: console.log('DESIGNER ROOT', root);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Designer
|
<Designer
|
||||||
@ -210,6 +218,21 @@
|
|||||||
if (level <= 9) return `icon num-${level}-outline`;
|
if (level <= 9) return `icon num-${level}-outline`;
|
||||||
return 'icon num-9-plus';
|
return 'icon num-9-plus';
|
||||||
},
|
},
|
||||||
|
sortAutoLayoutReferences: references => {
|
||||||
|
// console.log('sortAutoLayoutReferences', root, references.length);
|
||||||
|
return _.sortBy(references, reference => {
|
||||||
|
const node1 = root?.findNodeByDesignerId(reference.sourceId);
|
||||||
|
const node2 = root?.findNodeByDesignerId(reference.targetId);
|
||||||
|
if (!node1 || !node2) return 10000;
|
||||||
|
if (node1.level > node2.level) reference = switchPerspectiveReferenceDirection(reference);
|
||||||
|
const index = _.findIndex(node1.childNodes, x => x.columnName == reference.columns[0].source);
|
||||||
|
return index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
referencePaintSettings: {
|
||||||
|
buswi: 10,
|
||||||
|
extwi: 10,
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
referenceComponent={QueryDesignerReference}
|
referenceComponent={QueryDesignerReference}
|
||||||
value={createDesignerModel(config, dbInfos)}
|
value={createDesignerModel(config, dbInfos)}
|
||||||
|
@ -157,6 +157,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// $: console.log('PERSPECTIVE', config);
|
// $: console.log('PERSPECTIVE', config);
|
||||||
|
// $: console.log('VIEW ROOT', root);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<HorizontalSplitter initialValue={getInitialManagerSize()} bind:size={managerSize}>
|
<HorizontalSplitter initialValue={getInitialManagerSize()} bind:size={managerSize}>
|
||||||
|
Loading…
Reference in New Issue
Block a user