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