mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 20:23:59 +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;
|
if (!line && !line.trim()) return;
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(line);
|
const json = JSON.parse(line);
|
||||||
if (filterName(filter, json.sql)) {
|
if (filterName(filter, json.sql, json.database)) {
|
||||||
if (!skip || readed >= skip) {
|
if (!skip || readed >= skip) {
|
||||||
res.push(json);
|
res.push(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ export function filterName(filter: string, ...names: string[]) {
|
|||||||
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
||||||
const tokens = filter.split(' ').map(x => x.trim());
|
const tokens = filter.split(' ').map(x => x.trim());
|
||||||
|
|
||||||
return !!_compact(names).find(name => !tokens.find(token => !name.toUpperCase().includes(token.toUpperCase())));
|
const namesCompacted = _compact(names);
|
||||||
// return name.toUpperCase().includes(filter.toUpperCase());
|
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 { onMount } from 'svelte';
|
||||||
import socket from '../utility/socket';
|
import socket from '../utility/socket';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
|
||||||
let filter = '';
|
let filter = '';
|
||||||
let search = '';
|
let search = '';
|
||||||
@@ -50,7 +51,24 @@
|
|||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
{#each historyItems as item}
|
{#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">
|
<div class="sql">
|
||||||
<FontIcon icon="icon sql-file" />
|
<FontIcon icon="icon sql-file" />
|
||||||
{item.sql}
|
{item.sql}
|
||||||
|
|||||||
Reference in New Issue
Block a user