dbgate/packages/datalib/src/GridConfig.ts

58 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-03-07 21:39:19 +00:00
import { DisplayColumn } from './GridDisplay';
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-05-10 06:58:56 +00:00
export interface GridReferenceDefinition {
schemaName: string;
pureName: string;
columns: {
baseName: string;
refName: string;
}[];
}
2020-06-21 18:04:00 +00:00
export type GroupFunc = 'GROUP' | 'MAX' | 'MIN' | 'SUM' | 'AVG' | 'COUNT' | 'COUNT DISTINCT' | 'NULL';
2020-06-21 08:36:43 +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-05-10 16:52:14 +00:00
columnWidths: { [uniqueName: string]: number };
2020-04-04 09:06:27 +00:00
sort: {
uniqueName: string;
order: 'ASC' | 'DESC';
}[];
2020-06-21 08:36:43 +00:00
grouping: { [uniqueName: string]: GroupFunc };
2020-10-10 14:15:43 +00:00
childConfig?: GridConfig;
reference?: GridReferenceDefinition;
isFormView?: boolean;
formViewKey?: { [uniqueName: string]: string };
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
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-05-10 16:52:14 +00:00
columnWidths: {},
2020-04-04 09:06:27 +00:00
sort: [],
focusedColumn: null,
2020-06-21 08:36:43 +00:00
grouping: {},
2020-03-07 21:39:19 +00:00
};
}
export function createGridCache(): GridCache {
return {
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
}