mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 03:16:01 +00:00
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import _ from 'lodash';
|
|
import { GridDisplay, ChangeCacheFunc, ChangeConfigFunc } from './GridDisplay';
|
|
import { EngineDriver, ViewInfo, ColumnInfo } from 'dbgate-types';
|
|
import { GridConfig, GridCache } from './GridConfig';
|
|
|
|
export class ViewGridDisplay extends GridDisplay {
|
|
constructor(
|
|
public view: ViewInfo,
|
|
driver: EngineDriver,
|
|
config: GridConfig,
|
|
setConfig: ChangeConfigFunc,
|
|
cache: GridCache,
|
|
setCache: ChangeCacheFunc,
|
|
serverVersion
|
|
) {
|
|
super(config, setConfig, cache, setCache, driver, serverVersion);
|
|
this.columns = this.getDisplayColumns(view);
|
|
this.filterable = true;
|
|
this.sortable = true;
|
|
this.editable = false;
|
|
this.supportsReload = true;
|
|
}
|
|
|
|
getDisplayColumns(view: ViewInfo) {
|
|
return (
|
|
view?.columns
|
|
?.map(col => this.getDisplayColumn(view, col))
|
|
?.map(col => ({
|
|
...col,
|
|
isChecked: this.isColumnChecked(col),
|
|
})) || []
|
|
);
|
|
}
|
|
|
|
getDisplayColumn(view: ViewInfo, col: ColumnInfo) {
|
|
const uniquePath = [col.columnName];
|
|
const uniqueName = uniquePath.join('.');
|
|
return {
|
|
...col,
|
|
pureName: view.pureName,
|
|
schemaName: view.schemaName,
|
|
headerText: col.columnName,
|
|
uniqueName,
|
|
uniquePath,
|
|
};
|
|
}
|
|
|
|
createSelect(options = {}) {
|
|
const select = this.createSelectBase(this.view, this.view.columns, options);
|
|
return select;
|
|
}
|
|
}
|