mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
perspective fixes
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
TableInfo,
|
||||
ViewInfo,
|
||||
} from 'dbgate-types';
|
||||
import { equalFullName } from 'dbgate-tools';
|
||||
import {
|
||||
ChangePerspectiveConfigFunc,
|
||||
createPerspectiveNodeConfig,
|
||||
@@ -141,7 +142,7 @@ export abstract class PerspectiveTreeNode {
|
||||
return this.isCheckedColumn;
|
||||
}
|
||||
get isCheckedNode() {
|
||||
return !!this.config.nodes?.find(x => x.designerId == this.designerId)?.isNodeChecked;
|
||||
return !!this.designerId && !!this.config.nodes?.find(x => x.designerId == this.designerId)?.isNodeChecked;
|
||||
}
|
||||
get isSecondaryChecked() {
|
||||
return false;
|
||||
@@ -1017,9 +1018,14 @@ function findDesignerIdForNode<T extends PerspectiveTreeNode>(
|
||||
_isEqual(
|
||||
refColumns.map(x => x.target),
|
||||
x.columns.map(x => x.target)
|
||||
) &&
|
||||
equalFullName(
|
||||
config.nodes.find(n => n.designerId == x.targetId),
|
||||
node.namedObject
|
||||
)
|
||||
);
|
||||
if (ref1 && !parentNode.hasDesignerIdInIncestors(ref1.targetId)) {
|
||||
// console.log('FOUND1', node.title, ref1.targetId, refColumns);
|
||||
return nodeCreateFunc(ref1.targetId);
|
||||
}
|
||||
|
||||
@@ -1033,9 +1039,14 @@ function findDesignerIdForNode<T extends PerspectiveTreeNode>(
|
||||
_isEqual(
|
||||
refColumns.map(x => x.source),
|
||||
x.columns.map(x => x.target)
|
||||
) &&
|
||||
equalFullName(
|
||||
config.nodes.find(n => n.designerId == x.sourceId),
|
||||
node.namedObject
|
||||
)
|
||||
);
|
||||
if (ref2 && !parentNode.hasDesignerIdInIncestors(ref2.sourceId)) {
|
||||
// console.log('FOUND2', node.title, ref2.sourceId, refColumns);
|
||||
return nodeCreateFunc(ref2.sourceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,16 +42,13 @@ function getPerspectiveDefaultColumns(
|
||||
return [[columns[0]], null];
|
||||
}
|
||||
|
||||
export function shouldProcessPerspectiveDefaultColunns(
|
||||
export function perspectiveNodesHaveStructure(
|
||||
config: PerspectiveConfig,
|
||||
dbInfos: MultipleDatabaseInfo,
|
||||
conid: string,
|
||||
database: string
|
||||
) {
|
||||
const nodesNotProcessed = config.nodes.filter(x => !x.defaultColumnsProcessed);
|
||||
if (nodesNotProcessed.length == 0) return false;
|
||||
|
||||
for (const node of nodesNotProcessed) {
|
||||
for (const node of config.nodes) {
|
||||
const db = dbInfos?.[node.conid || conid]?.[node.database || database];
|
||||
if (!db) return false;
|
||||
|
||||
@@ -64,6 +61,18 @@ export function shouldProcessPerspectiveDefaultColunns(
|
||||
return true;
|
||||
}
|
||||
|
||||
export function shouldProcessPerspectiveDefaultColunns(
|
||||
config: PerspectiveConfig,
|
||||
dbInfos: MultipleDatabaseInfo,
|
||||
conid: string,
|
||||
database: string
|
||||
) {
|
||||
const nodesNotProcessed = config.nodes.filter(x => !x.defaultColumnsProcessed);
|
||||
if (nodesNotProcessed.length == 0) return false;
|
||||
|
||||
return perspectiveNodesHaveStructure(config, dbInfos, conid, database);
|
||||
}
|
||||
|
||||
function processPerspectiveDefaultColunnsStep(
|
||||
config: PerspectiveConfig,
|
||||
dbInfos: MultipleDatabaseInfo,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import _cloneDeep from 'lodash/cloneDeep';
|
||||
import _isString from 'lodash/isString';
|
||||
import { ColumnInfo, ColumnReference, DatabaseInfo, DatabaseInfoObjects, SqlDialect, TableInfo } from 'dbgate-types';
|
||||
import {
|
||||
ColumnInfo,
|
||||
ColumnReference,
|
||||
DatabaseInfo,
|
||||
DatabaseInfoObjects,
|
||||
NamedObjectInfo,
|
||||
SqlDialect,
|
||||
TableInfo,
|
||||
} from 'dbgate-types';
|
||||
|
||||
export function fullNameFromString(name) {
|
||||
const m = name.match(/\[([^\]]+)\]\.\[([^\]]+)\]/);
|
||||
@@ -39,6 +47,11 @@ export function equalStringLike(s1, s2) {
|
||||
return (s1 || '').toLowerCase().trim() == (s2 || '').toLowerCase().trim();
|
||||
}
|
||||
|
||||
export function equalFullName(name1: NamedObjectInfo, name2: NamedObjectInfo) {
|
||||
if (!name1 || !name2) return name1 == name2;
|
||||
return name1.pureName == name2.pureName && name1.schemaName == name2.schemaName;
|
||||
}
|
||||
|
||||
export function findObjectLike(
|
||||
{ pureName, schemaName },
|
||||
dbinfo: DatabaseInfo,
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { createPerspectiveNodeConfig, MultipleDatabaseInfo, PerspectiveConfig } from 'dbgate-datalib';
|
||||
import {
|
||||
createPerspectiveNodeConfig,
|
||||
MultipleDatabaseInfo,
|
||||
PerspectiveConfig,
|
||||
perspectiveNodesHaveStructure,
|
||||
} from 'dbgate-datalib';
|
||||
import _ from 'lodash';
|
||||
import { tick } from 'svelte';
|
||||
import runCommand from '../commands/runCommand';
|
||||
@@ -102,7 +107,7 @@
|
||||
}
|
||||
|
||||
async function detectAutoArrange(config: PerspectiveConfig, dbInfos) {
|
||||
if (config.nodes.find(x => !x.position)) {
|
||||
if (config.nodes.find(x => !x.position) && perspectiveNodesHaveStructure(config, dbInfos, conid, database)) {
|
||||
await tick();
|
||||
runCommand('designer.arrange');
|
||||
}
|
||||
|
||||
@@ -154,21 +154,9 @@
|
||||
if (shouldProcessPerspectiveDefaultColunns(config, $dbInfos, conid, database)) {
|
||||
setConfig(cfg => processPerspectiveDefaultColunns(cfg, $dbInfos, conid, database));
|
||||
}
|
||||
// tick().then(() => {
|
||||
// const newConfig = processPerspectiveDefaultColunns(config, $dbInfos, conid, database);
|
||||
// if (newConfig) {
|
||||
// if (
|
||||
// newConfig.nodes.filter(x => x.defaultColumnsProcessed).length >
|
||||
// config.nodes.filter(x => x.defaultColumnsProcessed).length
|
||||
// ) {
|
||||
// console.log('CONFIG CHANGED');
|
||||
// setConfig(() => newConfig);
|
||||
// } else {
|
||||
// console.warn('No new default columns', newConfig);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
// $: console.log('PERSPECTIVE', config);
|
||||
</script>
|
||||
|
||||
<HorizontalSplitter initialValue={getInitialManagerSize()} bind:size={managerSize}>
|
||||
|
||||
Reference in New Issue
Block a user