mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 14:06:00 +00:00
query history with search
This commit is contained in:
@@ -14,7 +14,7 @@ function readCore(reader, skip, limit, filter) {
|
||||
if (!line && !line.trim()) return;
|
||||
try {
|
||||
const json = JSON.parse(line);
|
||||
if (filterName(filter, json.sql)) {
|
||||
if (filterName(filter, json.sql, json.database)) {
|
||||
if (!skip || readed >= skip) {
|
||||
res.push(json);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ export function filterName(filter: string, ...names: string[]) {
|
||||
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
||||
const tokens = filter.split(' ').map(x => x.trim());
|
||||
|
||||
return !!_compact(names).find(name => !tokens.find(token => !name.toUpperCase().includes(token.toUpperCase())));
|
||||
// return name.toUpperCase().includes(filter.toUpperCase());
|
||||
const namesCompacted = _compact(names);
|
||||
for (const token of tokens) {
|
||||
const tokenUpper = token.toUpperCase();
|
||||
const found = namesCompacted.find(name => name.toUpperCase().includes(tokenUpper));
|
||||
if (!found) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import socket from '../utility/socket';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
|
||||
let filter = '';
|
||||
let search = '';
|
||||
@@ -50,7 +51,24 @@
|
||||
</SearchBoxWrapper>
|
||||
<WidgetsInnerContainer>
|
||||
{#each historyItems as item}
|
||||
<div class="wrapper" title={item.sql}>
|
||||
<div
|
||||
class="wrapper"
|
||||
title={item.sql}
|
||||
on:click={() => {
|
||||
openNewTab(
|
||||
{
|
||||
title: 'Query #',
|
||||
icon: 'icon sql-file',
|
||||
tabComponent: 'QueryTab',
|
||||
props: {
|
||||
conid: item.conid,
|
||||
database: item.database,
|
||||
},
|
||||
},
|
||||
{ editor: item.sql }
|
||||
);
|
||||
}}
|
||||
>
|
||||
<div class="sql">
|
||||
<FontIcon icon="icon sql-file" />
|
||||
{item.sql}
|
||||
|
||||
Reference in New Issue
Block a user