mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 20:46:01 +00:00
perspective refactor WIP
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { DatabaseInfo, ForeignKeyInfo, NamedObjectInfo } from 'dbgate-types';
|
||||
import { DatabaseInfo, ForeignKeyInfo, NamedObjectInfo, TableInfo } from 'dbgate-types';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
|
||||
export interface PerspectiveConfigColumns {
|
||||
expandedColumns: string[];
|
||||
checkedColumns: string[];
|
||||
uncheckedColumns: string[];
|
||||
}
|
||||
// export interface PerspectiveConfigColumns {
|
||||
// expandedColumns: string[];
|
||||
// checkedColumns: string[];
|
||||
// uncheckedColumns: string[];
|
||||
// }
|
||||
|
||||
export interface PerspectiveCustomJoinConfig {
|
||||
joinid: string;
|
||||
@@ -28,32 +29,81 @@ export interface PerspectiveFilterColumnInfo {
|
||||
foreignKey: ForeignKeyInfo;
|
||||
}
|
||||
|
||||
export interface PerspectiveParentFilterConfig {
|
||||
uniqueName: string;
|
||||
}
|
||||
export interface PerspectiveConfig extends PerspectiveConfigColumns {
|
||||
rootObject: { schemaName?: string; pureName: string };
|
||||
filters: { [uniqueName: string]: string };
|
||||
// export interface PerspectiveParentFilterConfig {
|
||||
// uniqueName: string;
|
||||
// }
|
||||
// export interface PerspectiveConfig extends PerspectiveConfigColumns {
|
||||
// rootObject: { schemaName?: string; pureName: string };
|
||||
// filters: { [uniqueName: string]: string };
|
||||
// sort: {
|
||||
// [parentUniqueName: string]: {
|
||||
// uniqueName: string;
|
||||
// order: 'ASC' | 'DESC';
|
||||
// }[];
|
||||
// };
|
||||
// customJoins: PerspectiveCustomJoinConfig[];
|
||||
// parentFilters: PerspectiveParentFilterConfig[];
|
||||
// }
|
||||
|
||||
export interface PerspectiveNodeConfig {
|
||||
designerId: string;
|
||||
schemaName?: string;
|
||||
pureName: string;
|
||||
|
||||
conid?: string;
|
||||
database?: string;
|
||||
|
||||
isParentFilter?: true | undefined;
|
||||
|
||||
expandedNodes: string[];
|
||||
checkedNodes: string[];
|
||||
uncheckedNodes: string[];
|
||||
|
||||
sort: {
|
||||
[parentUniqueName: string]: {
|
||||
uniqueName: string;
|
||||
order: 'ASC' | 'DESC';
|
||||
}[];
|
||||
};
|
||||
customJoins: PerspectiveCustomJoinConfig[];
|
||||
parentFilters: PerspectiveParentFilterConfig[];
|
||||
columnName: string;
|
||||
order: 'ASC' | 'DESC';
|
||||
}[];
|
||||
|
||||
filters: { [uniqueName: string]: string };
|
||||
isAutoGenerated?: true | undefined;
|
||||
}
|
||||
|
||||
export interface PerspectiveReferenceConfig {
|
||||
designerId: string;
|
||||
|
||||
sourceId: string;
|
||||
targetId: string;
|
||||
|
||||
columns: {
|
||||
source: string;
|
||||
target: string;
|
||||
}[];
|
||||
|
||||
isAutoGenerated?: true | undefined;
|
||||
}
|
||||
|
||||
export interface PerspectiveConfig {
|
||||
rootDesignerId: string;
|
||||
nodes: PerspectiveNodeConfig[];
|
||||
references: PerspectiveReferenceConfig[];
|
||||
}
|
||||
|
||||
export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig {
|
||||
return {
|
||||
expandedColumns: [],
|
||||
checkedColumns: [],
|
||||
uncheckedColumns: [],
|
||||
customJoins: [],
|
||||
const rootNode: PerspectiveNodeConfig = {
|
||||
...rootObject,
|
||||
designerId: uuidv1(),
|
||||
|
||||
expandedNodes: [],
|
||||
checkedNodes: [],
|
||||
uncheckedNodes: [],
|
||||
|
||||
sort: [],
|
||||
filters: {},
|
||||
sort: {},
|
||||
rootObject,
|
||||
parentFilters: [],
|
||||
};
|
||||
return {
|
||||
nodes: [rootNode],
|
||||
references: [],
|
||||
rootDesignerId: rootNode.designerId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,8 +124,8 @@ export function extractPerspectiveDatabases(
|
||||
res.push({ conid, database });
|
||||
}
|
||||
|
||||
for (const custom of cfg.customJoins) {
|
||||
add(custom.conid || conid, custom.database || database);
|
||||
for (const node of cfg.nodes) {
|
||||
add(node.conid || conid, node.database || database);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user