mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 12:43:58 +00:00
SYNC: show diagram table counts WIP
This commit is contained in:
committed by
Diflow
parent
f2570c97f3
commit
6467db4a21
@@ -1,6 +1,7 @@
|
|||||||
import { DatabaseInfo, TableInfo } from 'dbgate-types';
|
import { DatabaseInfo, TableInfo } from 'dbgate-types';
|
||||||
import { extendDatabaseInfo } from './structureTools';
|
import { extendDatabaseInfo } from './structureTools';
|
||||||
import _sortBy from 'lodash/sortBy';
|
import _sortBy from 'lodash/sortBy';
|
||||||
|
import { filterName } from './filterName';
|
||||||
|
|
||||||
function tableWeight(table: TableInfo, maxRowcount?: number) {
|
function tableWeight(table: TableInfo, maxRowcount?: number) {
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
@@ -18,9 +19,23 @@ function tableWeight(table: TableInfo, maxRowcount?: number) {
|
|||||||
if (maxRowcount) return weight;
|
if (maxRowcount) return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function chooseTopTables(tables: TableInfo[], count: number) {
|
export function chooseTopTables(tables: TableInfo[], count: number, tableFilter: string, omitTablesFilter: string) {
|
||||||
|
const filteredTables = tables.filter(table => {
|
||||||
|
if (tableFilter) {
|
||||||
|
if (!filterName(tableFilter, table?.pureName)) return false;
|
||||||
|
}
|
||||||
|
if (omitTablesFilter) {
|
||||||
|
if (filterName(omitTablesFilter, table?.pureName)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!(count > 0)) {
|
||||||
|
return filteredTables;
|
||||||
|
}
|
||||||
|
|
||||||
const dbinfo: DatabaseInfo = {
|
const dbinfo: DatabaseInfo = {
|
||||||
tables,
|
tables: filteredTables,
|
||||||
} as DatabaseInfo;
|
} as DatabaseInfo;
|
||||||
|
|
||||||
const extended = extendDatabaseInfo(dbinfo);
|
const extended = extendDatabaseInfo(dbinfo);
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
export let menu;
|
export let menu;
|
||||||
export let settings;
|
export let settings;
|
||||||
export let referenceComponent;
|
export let referenceComponent;
|
||||||
|
export let onReportCounts = undefined;
|
||||||
|
|
||||||
export const activator = createActivator('Designer', true);
|
export const activator = createActivator('Designer', true);
|
||||||
|
|
||||||
@@ -81,8 +82,13 @@
|
|||||||
$: dbInfoExtended = $dbInfo ? extendDatabaseInfoFromApps($dbInfo, $apps) : null;
|
$: dbInfoExtended = $dbInfo ? extendDatabaseInfoFromApps($dbInfo, $apps) : null;
|
||||||
|
|
||||||
$: tables =
|
$: tables =
|
||||||
(value?.style?.topTables > 0 && value?.tables
|
(value?.tables
|
||||||
? chooseTopTables(value?.tables, value?.style?.topTables)
|
? chooseTopTables(
|
||||||
|
value?.tables,
|
||||||
|
value?.style?.topTables,
|
||||||
|
value?.style?.tableFilter,
|
||||||
|
value?.style?.omitTablesFilter
|
||||||
|
)
|
||||||
: value?.tables) || ([] as any[]);
|
: value?.tables) || ([] as any[]);
|
||||||
$: references = (value?.references || [])?.filter(
|
$: references = (value?.references || [])?.filter(
|
||||||
ref => tables.find(x => x.designerId == ref.sourceId) && tables.find(x => x.designerId == ref.targetId)
|
ref => tables.find(x => x.designerId == ref.sourceId) && tables.find(x => x.designerId == ref.targetId)
|
||||||
@@ -164,7 +170,7 @@
|
|||||||
if (settings?.useDatabaseReferences) {
|
if (settings?.useDatabaseReferences) {
|
||||||
references = [];
|
references = [];
|
||||||
for (const table of newTables) {
|
for (const table of newTables) {
|
||||||
for (const fk of table.foreignKeys) {
|
for (const fk of table.foreignKeys || []) {
|
||||||
const dst = newTables.find(x => x.pureName == fk.refTableName && x.schemaName == fk.refSchemaName);
|
const dst = newTables.find(x => x.pureName == fk.refTableName && x.schemaName == fk.refSchemaName);
|
||||||
if (!dst) continue;
|
if (!dst) continue;
|
||||||
references.push({
|
references.push({
|
||||||
@@ -922,6 +928,28 @@
|
|||||||
}
|
}
|
||||||
oldZoomKoefRef.set(value?.style?.zoomKoef);
|
oldZoomKoefRef.set(value?.style?.zoomKoef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $: console.log('DESIGNER VALUE', value);
|
||||||
|
|
||||||
|
// $: console.log('TABLES ARRAY', tables);
|
||||||
|
|
||||||
|
// $: {
|
||||||
|
// if (value?.tables?.find(x => !x)) {
|
||||||
|
// console.log('**** INCORRECT DESIGNER VALUE**** ', value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $: {
|
||||||
|
// if (value?.tables?.length < 100) {
|
||||||
|
// console.log('**** SMALL TABLES**** ', value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $: if (onReportCounts) {
|
||||||
|
// onReportCounts({
|
||||||
|
// all: value?.tables?.length ?? 0,
|
||||||
|
// filtered: tables?.length ?? 0,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
|
|
||||||
|
let tableCounts = {};
|
||||||
|
|
||||||
export const activator = createActivator('DiagramTab', true);
|
export const activator = createActivator('DiagramTab', true);
|
||||||
|
|
||||||
$: setEditorData($modelState.value);
|
$: setEditorData($modelState.value);
|
||||||
@@ -129,6 +131,9 @@
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
menu={createMenu}
|
menu={createMenu}
|
||||||
columnFilter={$styleStore.columnFilter}
|
columnFilter={$styleStore.columnFilter}
|
||||||
|
onReportCounts={counts => {
|
||||||
|
tableCounts = counts;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="2">
|
<svelte:fragment slot="2">
|
||||||
@@ -142,7 +147,7 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<WidgetsInnerContainer skipDefineWidth>
|
<WidgetsInnerContainer skipDefineWidth>
|
||||||
<DiagramSettings values={styleStore} />
|
<DiagramSettings values={styleStore} {tableCounts} />
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
</WidgetColumnBarItem>
|
</WidgetColumnBarItem>
|
||||||
</WidgetColumnBar>
|
</WidgetColumnBar>
|
||||||
|
|||||||
Reference in New Issue
Block a user