view data tab

This commit is contained in:
Jan Prochazka 2021-03-18 10:28:41 +01:00
parent 24f4e1d898
commit b7663e2e06
7 changed files with 78 additions and 12 deletions

View File

@ -143,10 +143,10 @@ export default class ChangeSetGrider extends Grider {
this.dispatchChangeSet({ type: 'redo' });
}
get canUndo() {
return this.changeSetState.canUndo;
return this.changeSetState?.canUndo;
}
get canRedo() {
return this.changeSetState.canRedo;
return this.changeSetState?.canRedo;
}
get containsChanges() {
return changeSetContainsChanges(this.changeSet);

View File

@ -9,7 +9,7 @@
export let gridCoreComponent;
export let isDetailView = false;
export let showReferences = true;
export let showReferences = false;
let managerSize;
</script>
@ -21,7 +21,13 @@
<ColumnManager {...$$props} {managerSize} />
</WidgetColumnBarItem>
<WidgetColumnBarItem title="References" name="references" height="30%" collapsed={isDetailView}>
<WidgetColumnBarItem
title="References"
name="references"
height="30%"
collapsed={isDetailView}
skip={!showReferences}
>
<ReferenceManager {...$$props} {managerSize} />
</WidgetColumnBarItem>
</WidgetColumnBar>

View File

@ -112,6 +112,7 @@
{...$$props}
gridCoreComponent={SqlDataGridCore}
{display}
showReferences
onReferenceSourceChanged={reference ? handleReferenceSourceChanged : null}
onReferenceClick={value => {
if (value && value.referenceId && reference && reference.referenceId == value.referenceId) {

View File

@ -0,0 +1,54 @@
<script lang="ts" context="module">
export const matchingProps = ['conid', 'database', 'schemaName', 'pureName'];
export const allowAddToFavorites = props => true;
</script>
<script lang="ts">
import { createGridCache, ViewGridDisplay } from 'dbgate-datalib';
import { findEngineDriver } from 'dbgate-tools';
import { writable } from 'svelte/store';
import DataGrid from '../datagrid/DataGrid.svelte';
import SqlDataGridCore from '../datagrid/SqlDataGridCore.svelte';
import { extensions } from '../stores';
import { useConnectionInfo, useViewInfo } from '../utility/metadataLoaders';
import useGridConfig from '../utility/useGridConfig';
export let tabid;
export let conid;
export let database;
export let schemaName;
export let pureName;
$: connection = useConnectionInfo({ conid });
$: viewInfo = useViewInfo({ conid, database, schemaName, pureName });
const config = useGridConfig(tabid);
const cache = writable(createGridCache());
$: display =
$viewInfo && $connection
? new ViewGridDisplay(
$viewInfo,
findEngineDriver($connection, $extensions),
//@ts-ignore
$config,
config.update,
$cache,
cache.update
)
: null;
</script>
{#if display}
<DataGrid
{...$$props}
{display}
config={$config}
setConfig={config.update}
cache={$cache}
setCache={cache.update}
focusOnVisible
gridCoreComponent={SqlDataGridCore}
/>
{/if}

View File

@ -1,5 +1,5 @@
import * as TableDataTab from './TableDataTab.svelte';
// import ViewDataTab from './ViewDataTab';
import * as ViewDataTab from './ViewDataTab.svelte';
// import TableStructureTab from './TableStructureTab';
import * as QueryTab from './QueryTab.svelte';
import * as ShellTab from './ShellTab.svelte';
@ -16,7 +16,7 @@ import * as MarkdownEditorTab from './MarkdownEditorTab.svelte';
export default {
TableDataTab,
// ViewDataTab,
ViewDataTab,
// TableStructureTab,
QueryTab,
// InfoPageTab,

View File

@ -6,6 +6,7 @@ import { cacheClean } from './cache';
import socket from './socket';
import getAsArray from './getAsArray';
import { DatabaseInfo } from 'dbgate-types';
import { derived } from 'svelte/store';
const databaseInfoLoader = ({ conid, database }) => ({
url: 'database-connections/structure',
@ -247,11 +248,14 @@ export async function getDbCore(args, objectTypeField = undefined) {
}
export function useDbCore(args, objectTypeField = undefined) {
const db = useDatabaseInfo(args);
const dbStore = useDatabaseInfo(args);
if (!dbStore) return null;
return derived(dbStore, db => {
if (!db) return null;
return db[objectTypeField || args.objectTypeField].find(
x => x.pureName == args.pureName && x.schemaName == args.schemaName
);
});
}
/** @returns {Promise<import('dbgate-types').TableInfo>} */

View File

@ -27,11 +27,12 @@
{
collapsed,
height,
skip,
},
dynamicProps
);
$: updateWidgetItemDefinition(widgetItemIndex, { collapsed: !visible, height });
$: updateWidgetItemDefinition(widgetItemIndex, { collapsed: !visible, height, skip });
$: setInitialSize(height, $widgetColumnBarHeight);