feat(elasticsearch): add visual search profiler
This commit is contained in:
1 parent
5d1061d490
commit
3ee0640fc2
22 files changed
+1093
-11
No files matched your search
@@ -14,6 +14,7 @@ import {
|
||||
Columns3Cog,
|
||||
Copy,
|
||||
EyeOff,
|
||||
Gauge,
|
||||
Loader2,
|
||||
Search,
|
||||
TableProperties,
|
||||
@@ -100,6 +101,7 @@ const MongoBucketBrowser = defineAsyncComponent(() => import("@/components/docum
|
||||
const VectorBrowser = defineAsyncComponent(() => import("@/components/vector/VectorBrowser.vue"));
|
||||
const HBaseBrowser = defineAsyncComponent(() => import("@/components/hbase/HBaseBrowser.vue"));
|
||||
const ElasticsearchJsonResponsePanel = defineAsyncComponent(() => import("@/components/common/ElasticsearchJsonResponsePanel.vue"));
|
||||
const ElasticsearchProfilePanel = defineAsyncComponent(() => import("@/components/common/ElasticsearchProfilePanel.vue"));
|
||||
const MqAdminConsole = defineAsyncComponent(() => import("@/components/mq/MqAdminConsole.vue"));
|
||||
const MqttAdminConsole = defineAsyncComponent(() => import("@/components/mqtt/MqttAdminConsole.vue"));
|
||||
const NacosAdminConsole = defineAsyncComponent(() => import("@/components/nacos/NacosAdminConsole.vue"));
|
||||
@@ -150,6 +152,7 @@ import type { CodeMirrorSqlDialectName } from "@/lib/editor/codemirrorSqlDialect
|
||||
import { codeMirrorSqlDialect, codeMirrorSqlDialectForConnection, effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
||||
import { chartableColumnIndexes } from "@/lib/dataGrid/chartData";
|
||||
import { elasticsearchJsonResponseForResult } from "@/lib/elasticsearch/elasticsearchJsonResponse";
|
||||
import { elasticsearchProfileBodyForResult, parseElasticsearchProfile } from "@/lib/elasticsearch/elasticsearchProfile";
|
||||
import * as api from "@/lib/backend/api";
|
||||
import { applyMongoGridChangesToDocument, applyMongoGridChangesToDocumentBaseline, buildMongoUpdateDocument, formatMongoShellLiteral, serializeMongoDocumentId, type MongoInputValue } from "@/lib/mongo/mongoDocumentValues";
|
||||
import type { DataGridSortMode } from "@/lib/dataGrid/dataGridSort";
|
||||
@@ -469,6 +472,13 @@ const activeElasticsearchRawBody = computed(() => {
|
||||
if (activeEffectiveDatabaseType.value !== "elasticsearch" && activeEffectiveDatabaseType.value !== "easysearch") return undefined;
|
||||
return props.activeTab.result?.elasticsearch_raw_body;
|
||||
});
|
||||
/** ES `_search?profile=true` body extracted from the active result, when present. */
|
||||
const activeElasticsearchProfileBody = computed(() => elasticsearchProfileBodyForResult(activeEffectiveDatabaseType.value, props.activeTab.result));
|
||||
/** Only surfaces the "Profile" entry when the response actually carries a profile section. */
|
||||
const canShowProfile = computed(() => {
|
||||
const body = activeElasticsearchProfileBody.value;
|
||||
return body !== null && parseElasticsearchProfile(body) !== null;
|
||||
});
|
||||
/** Toggle between the _source table and the raw JSON panel for Elasticsearch REST results. */
|
||||
const showElasticsearchRawJson = ref(false);
|
||||
watch(
|
||||
@@ -1675,10 +1685,12 @@ defineExpose({
|
||||
class="ml-auto"
|
||||
:active-view="activeOutputView"
|
||||
:can-show-explain="canShowExplainOutput"
|
||||
:can-show-profile="canShowProfile"
|
||||
:can-export-archive="canExportResultArchive"
|
||||
:archive-exporting="resultArchiveExporting"
|
||||
:compact="standaloneResultToolbarCompact"
|
||||
@select-explain="emit('update:activeOutputView', activeTab.id, 'explain')"
|
||||
@select-profile="emit('update:activeOutputView', activeTab.id, 'profile')"
|
||||
@export-archive="exportResultArchive"
|
||||
/>
|
||||
</div>
|
||||
@@ -1695,6 +1707,8 @@ defineExpose({
|
||||
:table-error="activeTab.explainTableError"
|
||||
/>
|
||||
|
||||
<ElasticsearchProfilePanel v-else-if="activeOutputView === 'profile' && canShowProfile" class="flex-1 min-h-0" :body="activeElasticsearchProfileBody ?? ''" />
|
||||
|
||||
<QueryChart v-else-if="activeOutputView === 'chart' && activeTab.result && !activeElasticsearchJsonResponse" class="flex-1 min-h-0" :result="activeTab.result" />
|
||||
|
||||
<div v-else-if="activeOutputView === 'summary'" class="flex flex-1 min-h-0 flex-col bg-background">
|
||||
@@ -1885,16 +1899,31 @@ defineExpose({
|
||||
{{ showElasticsearchRawJson ? t("tabs.tableData") : t("redis.jsonView") }}
|
||||
</button>
|
||||
</template>
|
||||
<template v-else-if="canShowProfile">
|
||||
<div class="mx-1 h-4 w-px bg-border" />
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-5 shrink-0 items-center gap-1 rounded-sm border border-transparent px-2 text-xs leading-none transition-colors"
|
||||
:class="activeOutputView === 'profile' ? 'bg-secondary text-secondary-foreground' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-pressed="activeOutputView === 'profile'"
|
||||
@click="emit('update:activeOutputView', activeTab.id, activeOutputView === 'profile' ? 'result' : 'profile')"
|
||||
>
|
||||
<Gauge class="h-3.5 w-3.5" />
|
||||
{{ t("profile.title") }}
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
||||
<template #result-toolbar-actions="{ compact }">
|
||||
<DataGridColumnLayoutPopover :grid="dataGridRef" :compact="compact" />
|
||||
<QueryResultToolbarActions
|
||||
:active-view="activeOutputView"
|
||||
:can-show-explain="canShowExplainOutput"
|
||||
:can-show-profile="canShowProfile"
|
||||
:can-export-archive="canExportResultArchive"
|
||||
:archive-exporting="resultArchiveExporting"
|
||||
:compact="compact"
|
||||
@select-explain="emit('update:activeOutputView', activeTab.id, 'explain')"
|
||||
@select-profile="emit('update:activeOutputView', activeTab.id, 'profile')"
|
||||
@export-archive="exportResultArchive"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { GitBranch, Loader2, Upload } from "@lucide/vue";
|
||||
import { GitBranch, Gauge, Loader2, Upload } from "@lucide/vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import LightTooltip from "@/components/ui/LightTooltip.vue";
|
||||
|
||||
type OutputView = "result" | "summary" | "explain" | "chart" | "messages";
|
||||
type OutputView = "result" | "summary" | "explain" | "chart" | "messages" | "profile";
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
activeView: OutputView;
|
||||
canShowExplain: boolean;
|
||||
canShowProfile: boolean;
|
||||
canExportArchive: boolean;
|
||||
archiveExporting: boolean;
|
||||
compact?: boolean;
|
||||
@@ -19,6 +20,7 @@ withDefaults(
|
||||
|
||||
const emit = defineEmits<{
|
||||
selectExplain: [];
|
||||
selectProfile: [];
|
||||
exportArchive: [];
|
||||
}>();
|
||||
|
||||
@@ -44,6 +46,22 @@ const { t } = useI18n();
|
||||
</Button>
|
||||
</LightTooltip>
|
||||
|
||||
<LightTooltip v-if="canShowProfile" :text="t('profile.title')" :disabled="!compact" side="bottom" :delay="0" :close-delay="0" nowrap>
|
||||
<Button
|
||||
size="sm"
|
||||
:variant="activeView === 'profile' ? 'secondary' : 'ghost'"
|
||||
class="h-5 shrink-0 text-xs leading-none"
|
||||
:class="compact ? 'w-6 gap-0 px-0' : 'gap-1 px-2'"
|
||||
:title="t('profile.title')"
|
||||
:aria-label="t('profile.title')"
|
||||
:aria-pressed="activeView === 'profile'"
|
||||
@click="emit('selectProfile')"
|
||||
>
|
||||
<Gauge class="block h-3.5 w-3.5 self-center" />
|
||||
<span v-if="!compact" class="inline-flex h-4 items-center leading-none">{{ t("profile.title") }}</span>
|
||||
</Button>
|
||||
</LightTooltip>
|
||||
|
||||
<LightTooltip v-if="canExportArchive" :text="t('tabs.exportResultArchive')" :disabled="!compact" side="bottom" :delay="0" :close-delay="0" nowrap>
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useI18n } from "vue-i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import LightTooltip from "@/components/ui/LightTooltip.vue";
|
||||
|
||||
type OutputView = "result" | "summary" | "explain" | "chart" | "messages";
|
||||
type PrimaryResultView = Exclude<OutputView, "explain">;
|
||||
type OutputView = "result" | "summary" | "explain" | "chart" | "messages" | "profile";
|
||||
type PrimaryResultView = Exclude<OutputView, "explain" | "profile">;
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
|
||||
@@ -44,7 +44,7 @@ export interface ContentAreaSurfaceProps {
|
||||
activeTab: QueryTab;
|
||||
activeConnection?: ConnectionConfig;
|
||||
executableSql: string;
|
||||
activeOutputView: "result" | "summary" | "explain" | "chart" | "messages";
|
||||
activeOutputView: "result" | "summary" | "explain" | "chart" | "messages" | "profile";
|
||||
formatSqlRequest: { id: number; tabId: string } | null;
|
||||
compressSqlRequest: { id: number; tabId: string } | null;
|
||||
selectedSql: string;
|
||||
@@ -61,7 +61,7 @@ export interface ContentAreaSurfaceProps {
|
||||
* global active tab after an await (see redevelopment guide §6.1).
|
||||
*/
|
||||
export interface ContentAreaSurfaceEmits {
|
||||
"update:activeOutputView": [tabId: string, value: "result" | "summary" | "explain" | "chart" | "messages"];
|
||||
"update:activeOutputView": [tabId: string, value: "result" | "summary" | "explain" | "chart" | "messages" | "profile"];
|
||||
fixWithAi: [tabId: string, errorMessage: string];
|
||||
sendSelectionToAi: [tabId: string, sql: string];
|
||||
previewChangesAvailable: [tabId: string, value: boolean];
|
||||
|
||||
Reference in new issue
Block a user