mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
search columns WIP
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
export let onDropOnGroup = undefined;
|
||||
export let groupContextMenu = null;
|
||||
export let collapsedGroupNames;
|
||||
export let filter = undefined;
|
||||
|
||||
$: isExpanded = !$collapsedGroupNames.includes(group);
|
||||
|
||||
@@ -86,6 +87,8 @@
|
||||
on:objectClick
|
||||
{disableContextMenu}
|
||||
{passProps}
|
||||
isExpandedBySearch={filter && item.isChildMatched}
|
||||
{filter}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
export let expandIconFunc = undefined;
|
||||
export let checkedObjectsStore = null;
|
||||
export let disableContextMenu = false;
|
||||
export let passProps;
|
||||
export let passProps = {};
|
||||
export let getIsExpanded = null;
|
||||
export let setIsExpanded = null;
|
||||
export let sortGroups = false;
|
||||
@@ -27,7 +27,7 @@
|
||||
export let emptyGroupNames = [];
|
||||
|
||||
export let collapsedGroupNames = writable([]);
|
||||
export let onChangeFilteredList;
|
||||
export let onChangeFilteredList = undefined;
|
||||
|
||||
$: matcher = module.createMatcher && module.createMatcher(filter, passProps?.searchSettings);
|
||||
$: childMatcher = module.createChildMatcher && module.createChildMatcher(filter, passProps?.searchSettings);
|
||||
@@ -53,9 +53,10 @@
|
||||
$: listGrouped = groupFunc
|
||||
? _.compact(
|
||||
(list || []).map(data => {
|
||||
const isMatched = matcher && !matcher(data) ? false : true;
|
||||
const isMatched = !matcher || matcher(data);
|
||||
const isChildMatched = !childMatcher || childMatcher(data);
|
||||
const group = groupFunc(data);
|
||||
return { group, data, isMatched };
|
||||
return { group, data, isMatched, isChildMatched };
|
||||
})
|
||||
)
|
||||
: null;
|
||||
@@ -110,7 +111,7 @@
|
||||
{checkedObjectsStore}
|
||||
{disableContextMenu}
|
||||
{filter}
|
||||
isExpandedBySearch={childrenMatched.includes(data)}
|
||||
isExpandedBySearch={filter && childrenMatched.includes(data)}
|
||||
{passProps}
|
||||
{getIsExpanded}
|
||||
{setIsExpanded}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = ({ columnName }) => columnName;
|
||||
|
||||
export const createMatcher =
|
||||
(filter, cfg = DEFAULT_SEARCH_SETTINGS) =>
|
||||
data => {
|
||||
const filterArgs = [];
|
||||
if (cfg.columnName) filterArgs.push(data.columnName);
|
||||
if (cfg.columnComment) filterArgs.push(data.columnComment);
|
||||
if (cfg.columnDataType) filterArgs.push(data.dataType);
|
||||
|
||||
const res = filterName(filter, ...filterArgs);
|
||||
return res;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -9,6 +21,8 @@
|
||||
import { renameDatabaseObjectDialog, alterDatabaseDialog } from '../utility/alterDatabaseTools';
|
||||
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { DEFAULT_SEARCH_SETTINGS } from '../stores';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
|
||||
export let data;
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
export const extractKey = props => props.name;
|
||||
|
||||
export const createMatcher = filter => props => {
|
||||
const { name, displayName, server } = props;
|
||||
return filterName(filter, name, displayName, server);
|
||||
};
|
||||
|
||||
export function disconnectDatabaseConnection(conid, database, showConfirmation = true) {
|
||||
const closeCondition = x =>
|
||||
x.props?.conid == conid &&
|
||||
@@ -465,7 +470,13 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { showSnackbarError, showSnackbarSuccess } from '../utility/snackbar';
|
||||
import { extractDbNameFromComposite, extractPackageName, findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
||||
import {
|
||||
extractDbNameFromComposite,
|
||||
extractPackageName,
|
||||
filterName,
|
||||
findEngineDriver,
|
||||
getConnectionLabel,
|
||||
} from 'dbgate-tools';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import { getDatabaseInfo, useUsedApps } from '../utility/metadataLoaders';
|
||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||
|
||||
@@ -25,6 +25,25 @@
|
||||
const res = filterName(filter, ...filterArgs);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const createChildMatcher =
|
||||
(filter, cfg = DEFAULT_SEARCH_SETTINGS) =>
|
||||
({ columns, objectTypeField, createSql }) => {
|
||||
const filterArgs = [];
|
||||
if (objectTypeField == 'tables') {
|
||||
for (const column of columns || []) {
|
||||
if (cfg.columnName) filterArgs.push(column.columnName);
|
||||
if (cfg.columnComment) filterArgs.push(column.columnComment);
|
||||
if (cfg.columnDataType) filterArgs.push(column.dataType);
|
||||
}
|
||||
} else {
|
||||
if (cfg.sqlObjectText) filterArgs.push(createSql);
|
||||
}
|
||||
|
||||
const res = filterName(filter, ...filterArgs);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const createTitle = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
|
||||
|
||||
export const databaseObjectIcons = {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import * as columnAppObject from './ColumnAppObject.svelte';
|
||||
|
||||
export let data;
|
||||
export let filter;
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
@@ -14,4 +15,5 @@
|
||||
foreignKey: findForeignKeyForColumn(data, col),
|
||||
}))}
|
||||
module={columnAppObject}
|
||||
{filter}
|
||||
/>
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
|
||||
$: databases = useDatabaseList({ conid: isExpandedOnlyBySearch ? null : data._id });
|
||||
$: dbList = isExpandedOnlyBySearch ? getLocalStorage(`database_list_${data._id}`) || [] : $databases || [];
|
||||
|
||||
// .filter(x => filterName(filter, x.name, data.displayName, data.server))
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
list={_.sortBy(
|
||||
dbList.filter(x => filterName(filter, x.name, data.displayName, data.server)),
|
||||
x => x.sortOrder ?? x.name
|
||||
).map(db => ({ ...db, connection: data }))}
|
||||
list={_.sortBy(dbList, x => x.sortOrder ?? x.name).map(db => ({ ...db, connection: data }))}
|
||||
module={databaseAppObject}
|
||||
{passProps}
|
||||
{filter}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user