mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 05:16:00 +00:00
jsl grid display
This commit is contained in:
@@ -58,13 +58,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInfo_meta: 'get',
|
getInfo_meta: 'get',
|
||||||
getInfo(jslid) {
|
getInfo({ jslid }) {
|
||||||
const file = path.join(jsldir(), `${jslid}.jsonl.info`);
|
const file = path.join(jsldir(), `${jslid}.jsonl.info`);
|
||||||
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
||||||
},
|
},
|
||||||
|
|
||||||
getRows_meta: 'get',
|
getRows_meta: 'get',
|
||||||
async getRows(jslid, offset, limit) {
|
async getRows({ jslid, offset, limit }) {
|
||||||
await this.ensureReader(jslid, offset);
|
await this.ensureReader(jslid, offset);
|
||||||
const res = [];
|
const res = [];
|
||||||
for (let i = 0; i < limit; i += 1) {
|
for (let i = 0; i < limit; i += 1) {
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ const io = require('socket.io');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const useController = require('./utility/useController');
|
const useController = require('./utility/useController');
|
||||||
|
const socket = require('./utility/socket');
|
||||||
|
|
||||||
const connections = require('./controllers/connections');
|
const connections = require('./controllers/connections');
|
||||||
const serverConnections = require('./controllers/serverConnections');
|
const serverConnections = require('./controllers/serverConnections');
|
||||||
const databaseConnections = require('./controllers/databaseConnections');
|
const databaseConnections = require('./controllers/databaseConnections');
|
||||||
const tables = require('./controllers/tables');
|
const tables = require('./controllers/tables');
|
||||||
const sessions = require('./controllers/sessions');
|
const sessions = require('./controllers/sessions');
|
||||||
const socket = require('./utility/socket');
|
const jsldata = require('./controllers/jsldata');
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
console.log('process.argv', process.argv);
|
console.log('process.argv', process.argv);
|
||||||
@@ -29,6 +31,7 @@ function start() {
|
|||||||
useController(app, '/database-connections', databaseConnections);
|
useController(app, '/database-connections', databaseConnections);
|
||||||
useController(app, '/tables', tables);
|
useController(app, '/tables', tables);
|
||||||
useController(app, '/sessions', sessions);
|
useController(app, '/sessions', sessions);
|
||||||
|
useController(app, '/jsldata', jsldata);
|
||||||
|
|
||||||
if (fs.existsSync('/home/dbgate-docker/build')) {
|
if (fs.existsSync('/home/dbgate-docker/build')) {
|
||||||
// server static files inside docker container
|
// server static files inside docker container
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ import { Select, Expression } from '@dbgate/sqltree';
|
|||||||
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
||||||
|
|
||||||
export interface DisplayColumn {
|
export interface DisplayColumn {
|
||||||
schemaName: string;
|
schemaName?: string;
|
||||||
pureName: string;
|
pureName?: string;
|
||||||
columnName: string;
|
columnName: string;
|
||||||
headerText: string;
|
headerText: string;
|
||||||
uniqueName: string;
|
uniqueName: string;
|
||||||
uniquePath: string[];
|
uniquePath: string[];
|
||||||
notNull: boolean;
|
notNull: boolean;
|
||||||
autoIncrement: boolean;
|
autoIncrement?: boolean;
|
||||||
isPrimaryKey: boolean;
|
isPrimaryKey?: boolean;
|
||||||
foreignKey: ForeignKeyInfo;
|
foreignKey?: ForeignKeyInfo;
|
||||||
isChecked?: boolean;
|
isChecked?: boolean;
|
||||||
hintColumnName?: string;
|
hintColumnName?: string;
|
||||||
commonType?: DbType;
|
commonType?: DbType;
|
||||||
@@ -47,9 +47,11 @@ export abstract class GridDisplay {
|
|||||||
public cache: GridCache,
|
public cache: GridCache,
|
||||||
protected setCache: ChangeCacheFunc,
|
protected setCache: ChangeCacheFunc,
|
||||||
protected getTableInfo: ({ schemaName, pureName }) => Promise<TableInfo>,
|
protected getTableInfo: ({ schemaName, pureName }) => Promise<TableInfo>,
|
||||||
public driver: EngineDriver
|
public driver?: EngineDriver
|
||||||
) {}
|
) {}
|
||||||
abstract getPageQuery(offset: number, count: number): string;
|
getPageQuery(offset: number, count: number): string {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
columns: DisplayColumn[];
|
columns: DisplayColumn[];
|
||||||
baseTable?: TableInfo;
|
baseTable?: TableInfo;
|
||||||
changeSetKeyFields: string[] = null;
|
changeSetKeyFields: string[] = null;
|
||||||
@@ -65,7 +67,7 @@ export abstract class GridDisplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get engine() {
|
get engine() {
|
||||||
return this.driver.engine;
|
return this.driver?.engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
|
|||||||
24
packages/datalib/src/JslGridDisplay.ts
Normal file
24
packages/datalib/src/JslGridDisplay.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { GridDisplay, ChangeCacheFunc } from './GridDisplay';
|
||||||
|
import { QueryResultColumn } from '@dbgate/types';
|
||||||
|
import { GridConfig, GridCache } from './GridConfig';
|
||||||
|
|
||||||
|
export class JslGridDisplay extends GridDisplay {
|
||||||
|
constructor(
|
||||||
|
jslid,
|
||||||
|
columns: QueryResultColumn[],
|
||||||
|
config: GridConfig,
|
||||||
|
setConfig: (config: GridConfig) => void,
|
||||||
|
cache: GridCache,
|
||||||
|
setCache: ChangeCacheFunc
|
||||||
|
) {
|
||||||
|
super(config, setConfig, cache, setCache, null, null);
|
||||||
|
this.columns = columns.map((col) => ({
|
||||||
|
columnName: col.columnName,
|
||||||
|
headerText: col.columnName,
|
||||||
|
uniqueName: col.columnName,
|
||||||
|
uniquePath: [col.columnName],
|
||||||
|
notNull: col.notNull,
|
||||||
|
autoIncrement: col.autoIncrement,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from "./GridDisplay";
|
export * from "./GridDisplay";
|
||||||
export * from "./GridConfig";
|
export * from "./GridConfig";
|
||||||
export * from "./TableGridDisplay";
|
export * from "./TableGridDisplay";
|
||||||
|
export * from "./JslGridDisplay";
|
||||||
export * from "./ChangeSet";
|
export * from "./ChangeSet";
|
||||||
export * from "./filterName";
|
export * from "./filterName";
|
||||||
|
|||||||
@@ -14,7 +14,12 @@ const dialect = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function extractColumns(columns) {
|
function extractColumns(columns) {
|
||||||
return _.sortBy(_.values(columns), 'index')
|
return _.sortBy(_.values(columns), 'index').map((col) => ({
|
||||||
|
...col,
|
||||||
|
columnName: col.name,
|
||||||
|
notNull: !col.nullable,
|
||||||
|
autoIncrement: !!col.identity,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@dbgate/types').EngineDriver} */
|
/** @type {import('@dbgate/types').EngineDriver} */
|
||||||
|
|||||||
4
packages/types/query.d.ts
vendored
4
packages/types/query.d.ts
vendored
@@ -4,7 +4,9 @@ export interface RangeDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryResultColumn {
|
export interface QueryResultColumn {
|
||||||
name: string;
|
columnName: string;
|
||||||
|
notNull: boolean;
|
||||||
|
autoIncrement?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryResult {
|
export interface QueryResult {
|
||||||
|
|||||||
@@ -108,6 +108,47 @@ const FocusField = styled.input`
|
|||||||
top: -1000px;
|
top: -1000px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
/** @param props {import('./types').DataGridProps} */
|
||||||
|
async function loadDataPage(props, offset, limit) {
|
||||||
|
const { display, conid, database, jslid } = props;
|
||||||
|
|
||||||
|
console.log('LOAD PAGE', jslid);
|
||||||
|
|
||||||
|
if (jslid) {
|
||||||
|
const response = await axios.request({
|
||||||
|
url: 'jsldata/get-rows',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
jslid,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sql = display.getPageQuery(offset, limit);
|
||||||
|
|
||||||
|
const response = await axios.request({
|
||||||
|
url: 'database-connections/query-data',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
},
|
||||||
|
data: { sql },
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dataPageAvailable(props) {
|
||||||
|
const { display, conid, database, jslid } = props;
|
||||||
|
if (jslid) return true;
|
||||||
|
const sql = display.getPageQuery(0, 1);
|
||||||
|
return !!sql;
|
||||||
|
}
|
||||||
|
|
||||||
/** @param props {import('./types').DataGridProps} */
|
/** @param props {import('./types').DataGridProps} */
|
||||||
export default function DataGridCore(props) {
|
export default function DataGridCore(props) {
|
||||||
const { conid, database, display, changeSetState, dispatchChangeSet, tabVisible } = props;
|
const { conid, database, display, changeSetState, dispatchChangeSet, tabVisible } = props;
|
||||||
@@ -146,8 +187,8 @@ export default function DataGridCore(props) {
|
|||||||
// const [inplaceEditorShouldSave, setInplaceEditorShouldSave] = React.useState(false);
|
// const [inplaceEditorShouldSave, setInplaceEditorShouldSave] = React.useState(false);
|
||||||
// const [inplaceEditorChangedOnCreate, setInplaceEditorChangedOnCreate] = React.useState(false);
|
// const [inplaceEditorChangedOnCreate, setInplaceEditorChangedOnCreate] = React.useState(false);
|
||||||
|
|
||||||
const changeSet = changeSetState.value;
|
const changeSet = changeSetState && changeSetState.value;
|
||||||
const setChangeSet = React.useCallback(value => dispatchChangeSet({ type: 'set', value }), [dispatchChangeSet]);
|
const setChangeSet = React.useCallback((value) => dispatchChangeSet({ type: 'set', value }), [dispatchChangeSet]);
|
||||||
|
|
||||||
const changeSetRef = React.useRef(changeSet);
|
const changeSetRef = React.useRef(changeSet);
|
||||||
|
|
||||||
@@ -155,8 +196,8 @@ export default function DataGridCore(props) {
|
|||||||
|
|
||||||
const autofillMarkerCell = React.useMemo(
|
const autofillMarkerCell = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1
|
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map((x) => x[0])).length == 1
|
||||||
? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))]
|
? [_.max(selectedCells.map((x) => x[0])), _.max(selectedCells.map((x) => x[1]))]
|
||||||
: null,
|
: null,
|
||||||
[selectedCells]
|
[selectedCells]
|
||||||
);
|
);
|
||||||
@@ -170,17 +211,7 @@ export default function DataGridCore(props) {
|
|||||||
const loadStart = new Date().getTime();
|
const loadStart = new Date().getTime();
|
||||||
loadedTimeRef.current = loadStart;
|
loadedTimeRef.current = loadStart;
|
||||||
|
|
||||||
const sql = display.getPageQuery(loadedRows.length, 100);
|
const nextRows = await loadDataPage(props, loadedRows.length, 100);
|
||||||
|
|
||||||
const response = await axios.request({
|
|
||||||
url: 'database-connections/query-data',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
conid,
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
data: { sql },
|
|
||||||
});
|
|
||||||
if (loadedTimeRef.current !== loadStart) {
|
if (loadedTimeRef.current !== loadStart) {
|
||||||
// new load was dispatched
|
// new load was dispatched
|
||||||
return;
|
return;
|
||||||
@@ -189,7 +220,6 @@ export default function DataGridCore(props) {
|
|||||||
// console.log('Error loading data from server', nextRows);
|
// console.log('Error loading data from server', nextRows);
|
||||||
// nextRows = [];
|
// nextRows = [];
|
||||||
// }
|
// }
|
||||||
const { rows: nextRows } = response.data;
|
|
||||||
// console.log('nextRows', nextRows);
|
// console.log('nextRows', nextRows);
|
||||||
const loadedInfo = {
|
const loadedInfo = {
|
||||||
loadedRows: [...loadedRows, ...nextRows],
|
loadedRows: [...loadedRows, ...nextRows],
|
||||||
@@ -288,9 +318,10 @@ export default function DataGridCore(props) {
|
|||||||
firstVisibleRowScrollIndex + visibleRowCountUpperBound >= loadedRows.length &&
|
firstVisibleRowScrollIndex + visibleRowCountUpperBound >= loadedRows.length &&
|
||||||
insertedRows.length == 0
|
insertedRows.length == 0
|
||||||
) {
|
) {
|
||||||
const sql = display.getPageQuery(0, 1);
|
if (dataPageAvailable(props)) {
|
||||||
// try to get SQL, if success, load page. If not, callbacks to load missing metadata are dispatched
|
// If not, callbacks to load missing metadata are dispatched
|
||||||
if (sql) loadNextData();
|
loadNextData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (display.cache.refreshTime > loadedTime) {
|
if (display.cache.refreshTime > loadedTime) {
|
||||||
reload();
|
reload();
|
||||||
@@ -327,7 +358,7 @@ export default function DataGridCore(props) {
|
|||||||
|
|
||||||
const realColumnUniqueNames = React.useMemo(
|
const realColumnUniqueNames = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
_.range(columnSizes.realCount).map(realIndex => (columns[columnSizes.realToModel(realIndex)] || {}).uniqueName),
|
_.range(columnSizes.realCount).map((realIndex) => (columns[columnSizes.realToModel(realIndex)] || {}).uniqueName),
|
||||||
[columnSizes, columns]
|
[columnSizes, columns]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -335,15 +366,15 @@ export default function DataGridCore(props) {
|
|||||||
const insertedRows = getChangeSetInsertedRows(changeSet, display.baseTable);
|
const insertedRows = getChangeSetInsertedRows(changeSet, display.baseTable);
|
||||||
const rowCountNewIncluded = loadedRows.length + insertedRows.length;
|
const rowCountNewIncluded = loadedRows.length + insertedRows.length;
|
||||||
|
|
||||||
const handleRowScroll = value => {
|
const handleRowScroll = (value) => {
|
||||||
setFirstVisibleRowScrollIndex(value);
|
setFirstVisibleRowScrollIndex(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleColumnScroll = value => {
|
const handleColumnScroll = (value) => {
|
||||||
setFirstVisibleColumnScrollIndex(value);
|
setFirstVisibleColumnScrollIndex(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContextMenu = event => {
|
const handleContextMenu = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
showMenu(
|
showMenu(
|
||||||
event.pageX,
|
event.pageX,
|
||||||
@@ -407,7 +438,7 @@ export default function DataGridCore(props) {
|
|||||||
const pasteRows = pastedText
|
const pasteRows = pastedText
|
||||||
.replace(/\r/g, '')
|
.replace(/\r/g, '')
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(row => row.split('\t'));
|
.map((row) => row.split('\t'));
|
||||||
let chs = changeSet;
|
let chs = changeSet;
|
||||||
let allRows = loadedAndInsertedRows;
|
let allRows = loadedAndInsertedRows;
|
||||||
|
|
||||||
@@ -439,8 +470,8 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
if (selectedCells.length > 1) {
|
if (selectedCells.length > 1) {
|
||||||
const regularSelected = selectedCells.filter(isRegularCell);
|
const regularSelected = selectedCells.filter(isRegularCell);
|
||||||
const startRow = _.min(regularSelected.map(x => x[0]));
|
const startRow = _.min(regularSelected.map((x) => x[0]));
|
||||||
const startCol = _.min(regularSelected.map(x => x[1]));
|
const startCol = _.min(regularSelected.map((x) => x[1]));
|
||||||
for (const cell of regularSelected) {
|
for (const cell of regularSelected) {
|
||||||
const [rowIndex, colIndex] = cell;
|
const [rowIndex, colIndex] = cell;
|
||||||
const selectionRow = rowIndex - startRow;
|
const selectionRow = rowIndex - startRow;
|
||||||
@@ -464,16 +495,16 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyToClipboard() {
|
function copyToClipboard() {
|
||||||
const rowIndexes = _.uniq(selectedCells.map(x => x[0])).sort();
|
const rowIndexes = _.uniq(selectedCells.map((x) => x[0])).sort();
|
||||||
const lines = rowIndexes.map(rowIndex => {
|
const lines = rowIndexes.map((rowIndex) => {
|
||||||
const colIndexes = selectedCells
|
const colIndexes = selectedCells
|
||||||
.filter(x => x[0] == rowIndex)
|
.filter((x) => x[0] == rowIndex)
|
||||||
.map(x => x[1])
|
.map((x) => x[1])
|
||||||
.sort();
|
.sort();
|
||||||
const rowData = loadedAndInsertedRows[rowIndex];
|
const rowData = loadedAndInsertedRows[rowIndex];
|
||||||
const line = colIndexes
|
const line = colIndexes
|
||||||
.map(col => realColumnUniqueNames[col])
|
.map((col) => realColumnUniqueNames[col])
|
||||||
.map(col => (rowData[col] == null ? '' : rowData[col]))
|
.map((col) => (rowData[col] == null ? '' : rowData[col]))
|
||||||
.join('\t');
|
.join('\t');
|
||||||
return line;
|
return line;
|
||||||
});
|
});
|
||||||
@@ -485,7 +516,7 @@ export default function DataGridCore(props) {
|
|||||||
if (autofillDragStartCell) {
|
if (autofillDragStartCell) {
|
||||||
const cell = cellFromEvent(event);
|
const cell = cellFromEvent(event);
|
||||||
if (isRegularCell(cell) && (cell[0] == autofillDragStartCell[0] || cell[1] == autofillDragStartCell[1])) {
|
if (isRegularCell(cell) && (cell[0] == autofillDragStartCell[0] || cell[1] == autofillDragStartCell[1])) {
|
||||||
const autoFillStart = [selectedCells[0][0], _.min(selectedCells.map(x => x[1]))];
|
const autoFillStart = [selectedCells[0][0], _.min(selectedCells.map((x) => x[1]))];
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
setAutofillSelectedCells(getCellRange(autoFillStart, cell));
|
setAutofillSelectedCells(getCellRange(autoFillStart, cell));
|
||||||
}
|
}
|
||||||
@@ -506,9 +537,9 @@ export default function DataGridCore(props) {
|
|||||||
if (autofillDragStartCell) {
|
if (autofillDragStartCell) {
|
||||||
const currentRowNumber = currentCell[0];
|
const currentRowNumber = currentCell[0];
|
||||||
if (_.isNumber(currentRowNumber)) {
|
if (_.isNumber(currentRowNumber)) {
|
||||||
const rowIndexes = _.uniq((autofillSelectedCells || []).map(x => x[0])).filter(x => x != currentRowNumber);
|
const rowIndexes = _.uniq((autofillSelectedCells || []).map((x) => x[0])).filter((x) => x != currentRowNumber);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const colNames = selectedCells.map(cell => realColumnUniqueNames[cell[1]]);
|
const colNames = selectedCells.map((cell) => realColumnUniqueNames[cell[1]]);
|
||||||
const changeObject = _.pick(loadedAndInsertedRows[currentRowNumber], colNames);
|
const changeObject = _.pick(loadedAndInsertedRows[currentRowNumber], colNames);
|
||||||
setChangeSet(
|
setChangeSet(
|
||||||
batchUpdateChangeSet(
|
batchUpdateChangeSet(
|
||||||
@@ -539,7 +570,7 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedRowDefinitions() {
|
function getSelectedRowDefinitions() {
|
||||||
return getRowDefinitions(_.uniq((selectedCells || []).map(x => x[0])));
|
return getRowDefinitions(_.uniq((selectedCells || []).map((x) => x[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
function revertRowChanges() {
|
function revertRowChanges() {
|
||||||
@@ -874,7 +905,7 @@ export default function DataGridCore(props) {
|
|||||||
<TableHead>
|
<TableHead>
|
||||||
<TableHeaderRow ref={headerRowRef}>
|
<TableHeaderRow ref={headerRowRef}>
|
||||||
<TableHeaderCell data-row="header" data-col="header" />
|
<TableHeaderCell data-row="header" data-col="header" />
|
||||||
{visibleRealColumns.map(col => (
|
{visibleRealColumns.map((col) => (
|
||||||
<TableHeaderCell
|
<TableHeaderCell
|
||||||
data-row="header"
|
data-row="header"
|
||||||
data-col={col.colIndex}
|
data-col={col.colIndex}
|
||||||
@@ -883,7 +914,7 @@ export default function DataGridCore(props) {
|
|||||||
>
|
>
|
||||||
<ColumnHeaderControl
|
<ColumnHeaderControl
|
||||||
column={col}
|
column={col}
|
||||||
setSort={order => display.setSort(col.uniqueName, order)}
|
setSort={(order) => display.setSort(col.uniqueName, order)}
|
||||||
order={display.getSortOrder(col.uniqueName)}
|
order={display.getSortOrder(col.uniqueName)}
|
||||||
/>
|
/>
|
||||||
</TableHeaderCell>
|
</TableHeaderCell>
|
||||||
@@ -901,7 +932,7 @@ export default function DataGridCore(props) {
|
|||||||
</InlineButton>
|
</InlineButton>
|
||||||
)}
|
)}
|
||||||
</TableHeaderCell>
|
</TableHeaderCell>
|
||||||
{visibleRealColumns.map(col => (
|
{visibleRealColumns.map((col) => (
|
||||||
<TableFilterCell
|
<TableFilterCell
|
||||||
key={col.uniqueName}
|
key={col.uniqueName}
|
||||||
style={{ width: col.widthPx, minWidth: col.widthPx, maxWidth: col.widthPx }}
|
style={{ width: col.widthPx, minWidth: col.widthPx, maxWidth: col.widthPx }}
|
||||||
@@ -911,7 +942,7 @@ export default function DataGridCore(props) {
|
|||||||
<DataFilterControl
|
<DataFilterControl
|
||||||
filterType={getFilterType(col.commonType ? col.commonType.typeCode : null)}
|
filterType={getFilterType(col.commonType ? col.commonType.typeCode : null)}
|
||||||
filter={display.getFilter(col.uniqueName)}
|
filter={display.getFilter(col.uniqueName)}
|
||||||
setFilter={value => display.setFilter(col.uniqueName, value)}
|
setFilter={(value) => display.setFilter(col.uniqueName, value)}
|
||||||
/>
|
/>
|
||||||
</TableFilterCell>
|
</TableFilterCell>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { GridDisplay, ChangeSet } from '@dbgate/datalib';
|
import { GridDisplay, ChangeSet } from '@dbgate/datalib';
|
||||||
|
|
||||||
export interface DataGridProps {
|
export interface DataGridProps {
|
||||||
conid?: number;
|
conid?: string;
|
||||||
database?: string;
|
database?: string;
|
||||||
display: GridDisplay;
|
display: GridDisplay;
|
||||||
tabVisible?: boolean;
|
tabVisible?: boolean;
|
||||||
changeSetState?: { value: ChangeSet };
|
changeSetState?: { value: ChangeSet };
|
||||||
dispatchChangeSet?: Function;
|
dispatchChangeSet?: Function;
|
||||||
toolbarPortalRef?: any;
|
toolbarPortalRef?: any;
|
||||||
|
jslid?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import DataGrid from '../datagrid/DataGrid';
|
import DataGrid from '../datagrid/DataGrid';
|
||||||
|
import { JslGridDisplay, createGridConfig, createGridCache } from '@dbgate/datalib';
|
||||||
|
import useFetch from '../utility/useFetch';
|
||||||
|
|
||||||
export default function JslDataGrid({ jslid }) {
|
export default function JslDataGrid({ jslid }) {
|
||||||
return <div>{jslid}</div>;
|
const columns = useFetch({
|
||||||
// const display=React.useMemo(()=>)
|
params: { jslid },
|
||||||
// return <DataGrid />;
|
url: 'jsldata/get-info',
|
||||||
|
defaultValue: [],
|
||||||
|
});
|
||||||
|
const [config, setConfig] = React.useState(createGridConfig());
|
||||||
|
const [cache, setCache] = React.useState(createGridCache());
|
||||||
|
const display = React.useMemo(() => new JslGridDisplay(jslid, columns, config, setConfig, cache, setCache), [
|
||||||
|
jslid,
|
||||||
|
columns,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return <DataGrid display={display} jslid={jslid} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ const EditorContainer = styled.div`
|
|||||||
position: relative;
|
position: relative;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const MessagesContainer = styled.div``;
|
const MessagesContainer = styled.div`
|
||||||
|
height: 200px;
|
||||||
|
`;
|
||||||
|
|
||||||
export default function QueryTab({ tabid, conid, database, tabVisible, toolbarPortalRef }) {
|
export default function QueryTab({ tabid, conid, database, tabVisible, toolbarPortalRef }) {
|
||||||
const localStorageKey = `sql_${tabid}`;
|
const localStorageKey = `sql_${tabid}`;
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ const TabNameWrapper = styled.span`
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TabContainer = styled.div``;
|
const TabContainer = styled.div`
|
||||||
|
position: relative;
|
||||||
|
flex-grow: 1;
|
||||||
|
`;
|
||||||
|
|
||||||
const TabsContainer = styled.div`
|
const TabsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -31,6 +34,11 @@ const TabsContainer = styled.div`
|
|||||||
background-color: ${theme.tabsPanel.background};
|
background-color: ${theme.tabsPanel.background};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const MainContainer = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
`;
|
||||||
|
|
||||||
export function TabPage({ label = undefined, children }) {
|
export function TabPage({ label = undefined, children }) {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
@@ -39,7 +47,7 @@ export function TabControl({ children }) {
|
|||||||
const [value, setValue] = React.useState(0);
|
const [value, setValue] = React.useState(0);
|
||||||
const childrenArray = (_.isArray(children) ? _.flatten(children) : [children]).filter((x) => x);
|
const childrenArray = (_.isArray(children) ? _.flatten(children) : [children]).filter((x) => x);
|
||||||
return (
|
return (
|
||||||
<div>
|
<MainContainer>
|
||||||
<TabsContainer>
|
<TabsContainer>
|
||||||
{childrenArray
|
{childrenArray
|
||||||
.filter((x) => x.props)
|
.filter((x) => x.props)
|
||||||
@@ -51,6 +59,6 @@ export function TabControl({ children }) {
|
|||||||
))}
|
))}
|
||||||
</TabsContainer>
|
</TabsContainer>
|
||||||
{<TabContainer key={value}>{childrenArray[value] && childrenArray[value].props.children}</TabContainer>}
|
{<TabContainer key={value}>{childrenArray[value] && childrenArray[value].props.children}</TabContainer>}
|
||||||
</div>
|
</MainContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user