mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 12:06:00 +00:00
WIP
This commit is contained in:
@@ -11,3 +11,4 @@ export * from './MacroDefinition';
|
|||||||
export * from './runMacro';
|
export * from './runMacro';
|
||||||
export * from './FormViewDisplay';
|
export * from './FormViewDisplay';
|
||||||
export * from './TableFormViewDisplay';
|
export * from './TableFormViewDisplay';
|
||||||
|
export * from './CollectionGridDisplay';
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default class ChangeSetGrider extends Grider {
|
|||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.changeSet = changeSetState && changeSetState.value;
|
this.changeSet = changeSetState && changeSetState.value;
|
||||||
this.insertedRows = getChangeSetInsertedRows(this.changeSet, display.baseTable);
|
this.insertedRows = getChangeSetInsertedRows(this.changeSet, display?.baseTable);
|
||||||
this.setChangeSet = value => dispatchChangeSet({ type: 'set', value });
|
this.setChangeSet = value => dispatchChangeSet({ type: 'set', value });
|
||||||
this.rowCacheIndexes = new Set();
|
this.rowCacheIndexes = new Set();
|
||||||
this.rowDataCache = {};
|
this.rowDataCache = {};
|
||||||
@@ -66,7 +66,7 @@ export default class ChangeSetGrider extends Grider {
|
|||||||
if (this.rowCacheIndexes.has(index)) return;
|
if (this.rowCacheIndexes.has(index)) return;
|
||||||
const row = this.getRowSource(index);
|
const row = this.getRowSource(index);
|
||||||
const insertedRowIndex = this.getInsertedRowIndex(index);
|
const insertedRowIndex = this.getInsertedRowIndex(index);
|
||||||
const rowDefinition = this.display.getChangeSetRow(row, insertedRowIndex);
|
const rowDefinition = this.display?.getChangeSetRow(row, insertedRowIndex);
|
||||||
const [matchedField, matchedChangeSetItem] = findExistingChangeSetItem(this.changeSet, rowDefinition);
|
const [matchedField, matchedChangeSetItem] = findExistingChangeSetItem(this.changeSet, rowDefinition);
|
||||||
const rowUpdated = matchedChangeSetItem
|
const rowUpdated = matchedChangeSetItem
|
||||||
? { ...row, ...matchedChangeSetItem.fields }
|
? { ...row, ...matchedChangeSetItem.fields }
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<ManagerInnerContainer width={managerSize}>
|
<ManagerInnerContainer width={managerSize}>
|
||||||
{#each display
|
{#each display
|
||||||
.getColumns(filter)
|
?.getColumns(filter)
|
||||||
.filter(column => filterName(filter, column.columnName)) as column (column.uniqueName)}
|
?.filter(column => filterName(filter, column.columnName)) || [] as column (column.uniqueName)}
|
||||||
<ColumnManagerRow {display} {column} />
|
<ColumnManagerRow {display} {column} />
|
||||||
{/each}
|
{/each}
|
||||||
</ManagerInnerContainer>
|
</ManagerInnerContainer>
|
||||||
|
|||||||
@@ -494,7 +494,7 @@
|
|||||||
// $: visibleRowCountUpperBound = 25;
|
// $: visibleRowCountUpperBound = 25;
|
||||||
|
|
||||||
// $: console.log('grider', grider);
|
// $: console.log('grider', grider);
|
||||||
$: columns = display.allColumns;
|
$: columns = display?.allColumns || [];
|
||||||
|
|
||||||
$: columnSizes = countColumnSizes(grider, columns, containerWidth, display);
|
$: columnSizes = countColumnSizes(grider, columns, containerWidth, display);
|
||||||
|
|
||||||
@@ -551,7 +551,7 @@
|
|||||||
|
|
||||||
// $: console.log('DISPLAY.config', display.config);
|
// $: console.log('DISPLAY.config', display.config);
|
||||||
$: {
|
$: {
|
||||||
if (display.groupColumns && display.baseTable) {
|
if (display?.groupColumns && display?.baseTable) {
|
||||||
onReferenceClick({
|
onReferenceClick({
|
||||||
referenceId: stableStringify(display && display.groupColumns),
|
referenceId: stableStringify(display && display.groupColumns),
|
||||||
schemaName: display.baseTable.schemaName,
|
schemaName: display.baseTable.schemaName,
|
||||||
@@ -1026,7 +1026,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !isDynamicStructure && (!columns || columns.length == 0)}
|
{#if !display || (!isDynamicStructure && (!columns || columns.length == 0))}
|
||||||
<LoadingInfo wrapper message="Waiting for structure" />
|
<LoadingInfo wrapper message="Waiting for structure" />
|
||||||
{:else if errorMessage}
|
{:else if errorMessage}
|
||||||
<ErrorInfo message={errorMessage} />
|
<ErrorInfo message={errorMessage} />
|
||||||
|
|||||||
@@ -99,12 +99,12 @@
|
|||||||
// loadNextDataToken = 0;
|
// loadNextDataToken = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (display.cache.refreshTime > loadedTime) {
|
$: if (display?.cache?.refreshTime > loadedTime) {
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (masterLoadedTime && masterLoadedTime > loadedTime) {
|
if (masterLoadedTime && masterLoadedTime > loadedTime && display) {
|
||||||
display.reload();
|
display.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Grider from './Grider';
|
|||||||
|
|
||||||
export function countColumnSizes(grider: Grider, columns, containerWidth, display: GridDisplay) {
|
export function countColumnSizes(grider: Grider, columns, containerWidth, display: GridDisplay) {
|
||||||
const columnSizes = new SeriesSizes();
|
const columnSizes = new SeriesSizes();
|
||||||
if (!grider || !columns) return columnSizes;
|
if (!grider || !columns || !display) return columnSizes;
|
||||||
|
|
||||||
let canvas = document.createElement('canvas');
|
let canvas = document.createElement('canvas');
|
||||||
let context = canvas.getContext('2d');
|
let context = canvas.getContext('2d');
|
||||||
|
|||||||
@@ -5,19 +5,22 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import App from '../App.svelte';
|
import App from '../App.svelte';
|
||||||
import TableDataGrid from '../datagrid/TableDataGrid.svelte';
|
import DataGrid from '../datagrid/DataGrid.svelte';
|
||||||
import useGridConfig from '../utility/useGridConfig';
|
import useGridConfig from '../utility/useGridConfig';
|
||||||
import {
|
import {
|
||||||
createChangeSet,
|
createChangeSet,
|
||||||
createGridCache,
|
createGridCache,
|
||||||
createGridConfig,
|
createGridConfig,
|
||||||
TableFormViewDisplay,
|
TableFormViewDisplay,
|
||||||
TableGridDisplay,
|
CollectionGridDisplay,
|
||||||
} from 'dbgate-datalib';
|
} from 'dbgate-datalib';
|
||||||
import { findEngineDriver } from 'dbgate-tools';
|
import { findEngineDriver } from 'dbgate-tools';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import createUndoReducer from '../utility/createUndoReducer';
|
import createUndoReducer from '../utility/createUndoReducer';
|
||||||
import invalidateCommands from '../commands/invalidateCommands';
|
import invalidateCommands from '../commands/invalidateCommands';
|
||||||
|
import CollectionDataGridCore from '../datagrid/CollectionDataGridCore.svelte';
|
||||||
|
import { useCollectionInfo, useConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
import { extensions } from '../stores';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -34,9 +37,25 @@
|
|||||||
$changeSetStore;
|
$changeSetStore;
|
||||||
invalidateCommands();
|
invalidateCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: connection = useConnectionInfo({ conid });
|
||||||
|
$: collectionInfo = useCollectionInfo({ conid, database, schemaName, pureName });
|
||||||
|
|
||||||
|
$: display =
|
||||||
|
$collectionInfo && $connection
|
||||||
|
? new CollectionGridDisplay(
|
||||||
|
$collectionInfo,
|
||||||
|
findEngineDriver($connection, $extensions),
|
||||||
|
//@ts-ignore
|
||||||
|
$config,
|
||||||
|
config.update,
|
||||||
|
$cache,
|
||||||
|
cache.update
|
||||||
|
)
|
||||||
|
: null;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<TableDataGrid
|
<DataGrid
|
||||||
{...$$props}
|
{...$$props}
|
||||||
config={$config}
|
config={$config}
|
||||||
setConfig={config.update}
|
setConfig={config.update}
|
||||||
@@ -44,6 +63,8 @@
|
|||||||
setCache={cache.update}
|
setCache={cache.update}
|
||||||
changeSetState={$changeSetStore}
|
changeSetState={$changeSetStore}
|
||||||
focusOnVisible
|
focusOnVisible
|
||||||
|
{display}
|
||||||
{changeSetStore}
|
{changeSetStore}
|
||||||
{dispatchChangeSet}
|
{dispatchChangeSet}
|
||||||
|
gridCoreComponent={CollectionDataGridCore}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -268,6 +268,11 @@ export function useViewInfo(args) {
|
|||||||
return useDbCore(args, 'views');
|
return useDbCore(args, 'views');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {import('dbgate-types').CollectionInfo} */
|
||||||
|
export function useCollectionInfo(args) {
|
||||||
|
return useDbCore(args, 'collections');
|
||||||
|
}
|
||||||
|
|
||||||
export function getSqlObjectInfo(args) {
|
export function getSqlObjectInfo(args) {
|
||||||
return getDbCore(args);
|
return getDbCore(args);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user