dbgate/packages/datalib/src/GridConfig.ts

43 lines
911 B
TypeScript
Raw Normal View History

2020-03-07 21:39:19 +00:00
import { DisplayColumn } from './GridDisplay';
2020-03-08 17:51:37 +00:00
import { TableInfo } from '@dbgate/types';
2020-03-07 21:39:19 +00:00
2020-03-12 07:02:13 +00:00
export interface GridConfigColumns {
hiddenColumns: string[];
2020-03-07 21:39:19 +00:00
expandedColumns: string[];
2020-03-08 13:58:32 +00:00
addedColumns: string[];
2020-03-07 21:39:19 +00:00
}
2020-03-12 07:02:13 +00:00
export interface GridConfig extends GridConfigColumns {
filters: { [uniqueName: string]: string };
2020-04-27 16:47:09 +00:00
focusedColumn?: string;
2020-04-04 09:06:27 +00:00
sort: {
uniqueName: string;
order: 'ASC' | 'DESC';
}[];
2020-03-12 07:02:13 +00:00
}
2020-03-07 21:39:19 +00:00
export interface GridCache {
2020-03-08 17:51:37 +00:00
tables: { [uniqueName: string]: TableInfo };
2020-04-30 19:47:40 +00:00
loadingTables: { schemaName: string; pureName: string }[];
2020-03-08 17:51:37 +00:00
refreshTime: number;
2020-03-07 21:39:19 +00:00
}
export function createGridConfig(): GridConfig {
return {
hiddenColumns: [],
expandedColumns: [],
2020-03-08 13:58:32 +00:00
addedColumns: [],
2020-03-12 07:02:13 +00:00
filters: {},
2020-04-04 09:06:27 +00:00
sort: [],
focusedColumn: null,
2020-03-07 21:39:19 +00:00
};
}
export function createGridCache(): GridCache {
return {
2020-03-08 17:51:37 +00:00
tables: {},
2020-04-30 19:47:40 +00:00
loadingTables: [],
2020-03-08 17:51:37 +00:00
refreshTime: new Date().getTime(),
2020-03-07 21:39:19 +00:00
};
2020-03-05 10:42:16 +00:00
}