save perspective to file

This commit is contained in:
Jan Prochazka
2022-08-06 17:43:49 +02:00
parent cc019281d4
commit 563a35560b
7 changed files with 101 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
import { DatabaseInfo, ForeignKeyInfo } from 'dbgate-types';
import { DatabaseInfo, ForeignKeyInfo, NamedObjectInfo } from 'dbgate-types';
export interface PerspectiveConfigColumns {
expandedColumns: string[];
@@ -28,6 +28,7 @@ export interface PerspectiveFilterColumnInfo {
foreignKey: ForeignKeyInfo;
}
export interface PerspectiveConfig extends PerspectiveConfigColumns {
rootObject: { schemaName?: string; pureName: string };
filters: { [uniqueName: string]: string };
filterInfos: { [uniqueName: string]: PerspectiveFilterColumnInfo };
sort: {
@@ -39,7 +40,7 @@ export interface PerspectiveConfig extends PerspectiveConfigColumns {
customJoins: PerspectiveCustomJoinConfig[];
}
export function createPerspectiveConfig(): PerspectiveConfig {
export function createPerspectiveConfig(rootObject: { schemaName?: string; pureName: string }): PerspectiveConfig {
return {
expandedColumns: [],
checkedColumns: [],
@@ -48,6 +49,7 @@ export function createPerspectiveConfig(): PerspectiveConfig {
filters: {},
filterInfos: {},
sort: {},
rootObject,
};
}

View File

@@ -12,7 +12,7 @@ test('test flat view', () => {
const root = new PerspectiveTableNode(
artistTable,
{ conid: { db: chinookDbInfo } },
createPerspectiveConfig(),
createPerspectiveConfig({ pureName: 'Artist' }),
null,
null,
{ conid: 'conid', database: 'db' },
@@ -38,7 +38,7 @@ test('test one level nesting', () => {
const root = new PerspectiveTableNode(
artistTable,
{ conid: { db: chinookDbInfo } },
{ ...createPerspectiveConfig(), checkedColumns: ['Artist.Album'] },
{ ...createPerspectiveConfig({ pureName: 'Artist' }), checkedColumns: ['Artist.Album'] },
null,
null,
{ conid: 'conid', database: 'db' },
@@ -88,7 +88,7 @@ test('test two level nesting', () => {
const root = new PerspectiveTableNode(
artistTable,
{ conid: { db: chinookDbInfo } },
{ ...createPerspectiveConfig(), checkedColumns: ['Artist.Album', 'Artist.Album.Track'] },
{ ...createPerspectiveConfig({ pureName: 'Artist' }), checkedColumns: ['Artist.Album', 'Artist.Album.Track'] },
null,
null,
{ conid: 'conid', database: 'db' },