From f01035f915d409d458abbfd2fc2a4a03308dabf6 Mon Sep 17 00:00:00 2001 From: ktx-vaidehi <134508096+ktx-vaidehi@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:53:31 +0530 Subject: [PATCH] feat: auto complete for promql legend, variables, filters, drilldown variables (#3153) **1. **Add Variables:**** ![image](https://github.com/openobserve/openobserve/assets/134508096/30c4e7d4-09ad-4f3f-8551-0a548429d05d) **2. **PromQL Legend:**** ![image](https://github.com/openobserve/openobserve/assets/134508096/a5bd0ca0-fecb-48a3-b158-dd34e92cfa88) **3. **Filter Options:**** ![image](https://github.com/openobserve/openobserve/assets/134508096/e2b115ee-0d31-46f6-a03e-5aff1b4f2098) **4. **DrillDown PopUp:**** ![image](https://github.com/openobserve/openobserve/assets/134508096/5f5a1727-4cca-4d2e-8400-8769c1e5eefe) ![image](https://github.com/openobserve/openobserve/assets/134508096/598cec27-66a9-4c76-b9cb-365bcd788c85) --------- Co-authored-by: ktx-abhay Co-authored-by: Kirtan Thakkar --- .../dashboards/PanelSchemaRenderer.vue | 12 +- .../dashboards/VariablesValueSelector.vue | 6 +- .../addPanel/CommonAutoComplete.vue | 145 ++++++++++++++++++ .../dashboards/addPanel/ConfigPanel.vue | 53 +++++-- .../addPanel/DashboardMapQueryBuilder.vue | 38 +++-- .../addPanel/DashboardQueryBuilder.vue | 43 ++++-- .../addPanel/DashboardSankeyChartBuilder.vue | 38 +++-- .../dashboards/addPanel/DrilldownPopUp.vue | 120 ++++++++++++--- .../addPanel/DrilldownUserGuide.vue | 4 +- .../settings/AddSettingVariable.vue | 34 ++-- .../dashboards/settings/VariableSettings.vue | 1 + .../composables/useSearchInputUsingRegex.ts | 45 ++++++ .../Dashboards/RenderDashboardCharts.vue | 6 +- .../views/Dashboards/addPanel/AddPanel.vue | 4 +- 14 files changed, 447 insertions(+), 102 deletions(-) create mode 100644 web/src/components/dashboards/addPanel/CommonAutoComplete.vue create mode 100644 web/src/composables/useSearchInputUsingRegex.ts diff --git a/web/src/components/dashboards/PanelSchemaRenderer.vue b/web/src/components/dashboards/PanelSchemaRenderer.vue index 07219bff47..1f2d45d912 100644 --- a/web/src/components/dashboards/PanelSchemaRenderer.vue +++ b/web/src/components/dashboards/PanelSchemaRenderer.vue @@ -590,7 +590,7 @@ export default defineComponent({ variablesData.value.values.forEach((variable: any) => { if (variable.type != "dynamic_filters") { - drilldownVariables["var-" + variable.name] = variable.value; + drilldownVariables[variable.name] = variable.value; } }); @@ -653,11 +653,11 @@ export default defineComponent({ pos > -1 ? window.location.origin + window.location.pathname.slice(0, pos) + - "/web/" + "/web" : window.location.origin; // always, go to view dashboard page - currentUrl += "dashboards/view?"; + currentUrl += "/dashboards/view?"; // if pass all variables in url currentUrl += drilldownData.data.passAllVariables @@ -670,7 +670,8 @@ export default defineComponent({ drilldownData.data.variables.forEach((variable: any) => { if (variable?.name?.trim() && variable?.value?.trim()) { url.searchParams.set( - replacePlaceholders(variable.name, drilldownVariables), + "var-" + + replacePlaceholders(variable.name, drilldownVariables), replacePlaceholders(variable.value, drilldownVariables) ); } @@ -693,7 +694,8 @@ export default defineComponent({ drilldownData.data.variables.forEach((variable: any) => { if (variable?.name?.trim() && variable?.value?.trim()) { oldParams[ - replacePlaceholders(variable.name, drilldownVariables) + "var-" + + replacePlaceholders(variable.name, drilldownVariables) ] = replacePlaceholders(variable.value, drilldownVariables); } }); diff --git a/web/src/components/dashboards/VariablesValueSelector.vue b/web/src/components/dashboards/VariablesValueSelector.vue index 850265cbaf..cc18d60f96 100644 --- a/web/src/components/dashboards/VariablesValueSelector.vue +++ b/web/src/components/dashboards/VariablesValueSelector.vue @@ -298,6 +298,9 @@ export default defineComponent({ const changeInitialVariableValues = async ( newInitialVariableValues: any ) => { + // reject all promises + rejectAllPromises(); + // NOTE: need to re-initialize variables data resetVariablesData(); @@ -307,9 +310,6 @@ export default defineComponent({ // make list of variables using variables config list initializeVariablesData(); - // reject all promises - rejectAllPromises(); - // load all variables loadAllVariablesData(); }; diff --git a/web/src/components/dashboards/addPanel/CommonAutoComplete.vue b/web/src/components/dashboards/addPanel/CommonAutoComplete.vue new file mode 100644 index 0000000000..e46c9d7171 --- /dev/null +++ b/web/src/components/dashboards/addPanel/CommonAutoComplete.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/web/src/components/dashboards/addPanel/ConfigPanel.vue b/web/src/components/dashboards/addPanel/ConfigPanel.vue index 8e1de88974..149d705a7d 100644 --- a/web/src/components/dashboards/addPanel/ConfigPanel.vue +++ b/web/src/components/dashboards/addPanel/ConfigPanel.vue @@ -497,23 +497,29 @@ along with this program. If not, see . - - +
@@ -735,10 +741,12 @@ import useDashboardPanelData from "@/composables/useDashboardPanel"; import { computed, defineComponent, onBeforeMount } from "vue"; import { useI18n } from "vue-i18n"; import Drilldown from "./Drilldown.vue"; +import CommonAutoComplete from "@/components/dashboards/addPanel/CommonAutoComplete.vue"; export default defineComponent({ - components: { Drilldown }, - setup() { + components: { Drilldown, CommonAutoComplete }, + props: ["dashboardPanelData"], + setup(props) { const { dashboardPanelData, promqlMode } = useDashboardPanelData(); const { t } = useI18n(); @@ -913,7 +921,30 @@ export default defineComponent({ field[value] = key; } }; - + + const selectPromQlNameOption = (option: any) => { + const inputValue = + dashboardPanelData.data.queries[ + dashboardPanelData.layout.currentQueryIndex + ].config.promql_legend; + + const openingBraceIndex = inputValue.lastIndexOf("{"); + const newValue = + inputValue.slice(0, openingBraceIndex + 1) + option + "}"; + return newValue; + }; + + const dashboardSelectfieldPromQlList = computed(() => + props.dashboardPanelData.meta.stream.selectedStreamFields.map( + (it: any) => { + return { + label: it.name, + value: it.name, + }; + } + ) + ); + return { t, dashboardPanelData, @@ -927,6 +958,8 @@ export default defineComponent({ setUnit, handleBlur, legendWidthValue, + dashboardSelectfieldPromQlList, + selectPromQlNameOption, }; }, }); diff --git a/web/src/components/dashboards/addPanel/DashboardMapQueryBuilder.vue b/web/src/components/dashboards/addPanel/DashboardMapQueryBuilder.vue index 11475fac66..b4765d46c3 100644 --- a/web/src/components/dashboards/addPanel/DashboardMapQueryBuilder.vue +++ b/web/src/components/dashboards/addPanel/DashboardMapQueryBuilder.vue @@ -500,9 +500,9 @@ along with this program. If not, see . @show="(e) => loadFilterItem(filteredItem.column)" :data-test="`dashboard-filter-item-${filteredItem.column}-menu`" > -
-
-
+
+
+
. name="condition" class="q-pa-none" > -
+
. style="width: 100%" :rules="[(val) => !!val || 'Required']" /> - + :items="dashboardVariablesFilterItems" + searchRegex="(?:^|[^$])\$?(\w+)" + :rules="[(val: any) => val?.length > 0 || 'Required']" + >
+ (props.dashboardData?.variables?.list ?? []).map((it: any) => ({ + label: it.name, + value: "'" + "$" + it.name + "'", + })) + ); + return { t, dashboardPanelData, @@ -937,6 +944,7 @@ export default defineComponent({ promqlMode, weightLabel, onFieldDragStart, + dashboardVariablesFilterItems, options: [ "=", "<>", diff --git a/web/src/components/dashboards/addPanel/DashboardQueryBuilder.vue b/web/src/components/dashboards/addPanel/DashboardQueryBuilder.vue index 64cbe8741a..c597962fb3 100644 --- a/web/src/components/dashboards/addPanel/DashboardQueryBuilder.vue +++ b/web/src/components/dashboards/addPanel/DashboardQueryBuilder.vue @@ -702,9 +702,9 @@ along with this program. If not, see . @show="(e) => loadFilterItem(filteredItem.column)" :data-test="`dashboard-filter-item-${filteredItem.column}-menu`" > -
-
-
+
+
+
. name="condition" class="q-pa-none" > -
+
. style="width: 100%" :rules="[(val) => !!val || 'Required']" /> - + :items="dashboardVariablesFilterItems" + searchRegex="(?:^|[^$])\$?(\w+)" + :rules="[(val: any) => val?.length > 0 || 'Required']" + >
.
- - + +