mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 18:35:58 +00:00
perspectives: added data provider layer
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
const loadChildNodes = [];
|
||||
const loadChildRows = [];
|
||||
const loadProps = node.getNodeLoadProps(parentRows);
|
||||
const rows = await node.loader(loadProps);
|
||||
const rows = await node.dataProvider.loadData(loadProps);
|
||||
// console.log('ROWS', rows, node.isRoot);
|
||||
|
||||
if (node.isRoot) {
|
||||
@@ -67,7 +67,7 @@
|
||||
await loadLevelData(node, rows);
|
||||
dataRows = rows;
|
||||
|
||||
// console.log('DISPLAY ROWS', rows);
|
||||
console.log('DISPLAY ROWS', rows);
|
||||
// const rows = await node.loadLevelData();
|
||||
// for (const child of node.childNodes) {
|
||||
// const loadProps = [];
|
||||
@@ -97,6 +97,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {});
|
||||
|
||||
$: loadData(root);
|
||||
$: display = root && dataRows ? new PerspectiveDisplay(root, dataRows) : null;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import {
|
||||
getTableChildPerspectiveNodes,
|
||||
PerspectiveDataLoadProps,
|
||||
PerspectiveDataProvider,
|
||||
PerspectiveTableColumnNode,
|
||||
PerspectiveTableNode,
|
||||
} from 'dbgate-datalib';
|
||||
@@ -18,7 +19,7 @@
|
||||
import PerspectiveTable from './PerspectiveTable.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { Select } from 'dbgate-sqltree';
|
||||
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||
|
||||
export let conid;
|
||||
export let database;
|
||||
@@ -28,6 +29,9 @@ import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||
export let config;
|
||||
export let setConfig;
|
||||
|
||||
export let cache;
|
||||
export let setCache;
|
||||
|
||||
let managerSize;
|
||||
|
||||
$: if (managerSize) setLocalStorage('perspectiveManagerWidth', managerSize);
|
||||
@@ -78,6 +82,22 @@ import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||
},
|
||||
})),
|
||||
selectAll: !dataColumns,
|
||||
orderBy: dataColumns
|
||||
? [
|
||||
{
|
||||
exprType: 'column',
|
||||
direction: 'ASC',
|
||||
columnName: dataColumns[0],
|
||||
source: {
|
||||
name: { schemaName, pureName },
|
||||
},
|
||||
},
|
||||
]
|
||||
: null,
|
||||
range: {
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
},
|
||||
};
|
||||
if (bindingColumns?.length == 1) {
|
||||
select.where = {
|
||||
@@ -102,7 +122,8 @@ import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
|
||||
return response.rows;
|
||||
}
|
||||
|
||||
$: root = $tableInfo ? new PerspectiveTableNode($tableInfo, $dbInfo, config, setConfig, loader as any, null) : null;
|
||||
$: dataProvider = new PerspectiveDataProvider(cache, setCache, loader);
|
||||
$: root = $tableInfo ? new PerspectiveTableNode($tableInfo, $dbInfo, config, setConfig, dataProvider, null) : null;
|
||||
</script>
|
||||
|
||||
<HorizontalSplitter initialValue={getInitialManagerSize()} bind:size={managerSize}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import PerspectiveView from '../perspectives/PerspectiveView.svelte';
|
||||
import usePerspectiveConfig from '../utility/usePerspectiveConfig';
|
||||
import usePerspectiveConfig, { usePerspectiveCache } from '../utility/usePerspectiveConfig';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@@ -9,6 +9,16 @@
|
||||
export let pureName;
|
||||
|
||||
const config = usePerspectiveConfig(tabid);
|
||||
const cache = usePerspectiveCache();
|
||||
</script>
|
||||
|
||||
<PerspectiveView {conid} {database} {schemaName} {pureName} config={$config} setConfig={config.update} />
|
||||
<PerspectiveView
|
||||
{conid}
|
||||
{database}
|
||||
{schemaName}
|
||||
{pureName}
|
||||
config={$config}
|
||||
setConfig={config.update}
|
||||
{cache}
|
||||
setCache={cache.update}
|
||||
/>
|
||||
|
||||
@@ -19,7 +19,14 @@ function doLoadPerspectiveConfigFunc(tabid) {
|
||||
|
||||
export default function usePerspectiveConfig(tabid) {
|
||||
const config = writable(doLoadPerspectiveConfigFunc(tabid));
|
||||
const unsubscribe = config.subscribe(value => localStorage.setItem(`tabdata_perspective_${tabid}`, JSON.stringify(value)));
|
||||
const unsubscribe = config.subscribe(value =>
|
||||
localStorage.setItem(`tabdata_perspective_${tabid}`, JSON.stringify(value))
|
||||
);
|
||||
onDestroy(unsubscribe);
|
||||
return config;
|
||||
}
|
||||
|
||||
export function usePerspectiveCache() {
|
||||
const cache = writable({});
|
||||
return cache;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user