perspective refactor WIP

This commit is contained in:
Jan Prochazka
2022-08-25 13:18:55 +02:00
parent 2a98918857
commit aeceb34d19
7 changed files with 293 additions and 157 deletions

View File

@@ -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;
}