diff --git a/common/constants/explorer.ts b/common/constants/explorer.ts index f572a9a0c..f09d53412 100644 --- a/common/constants/explorer.ts +++ b/common/constants/explorer.ts @@ -269,3 +269,13 @@ export enum ConfigChartOptionsEnum { export const CUSTOM_LABEL = 'customLabel'; export const BREAKDOWNS = 'breakdowns'; + +// Metrics constants +export const UNITS_OF_MEASURE = [ + 'seconds (s)', + 'hours (h)', + 'celsius (C)', + 'farenheit (F)', + 'meters (m)', + 'kilometers (k)', +] diff --git a/public/components/common/search/search.tsx b/public/components/common/search/search.tsx index ed9f85381..a714dfa94 100644 --- a/public/components/common/search/search.tsx +++ b/public/components/common/search/search.tsx @@ -83,6 +83,8 @@ export const Search = (props: any) => { setIsLiveTailPopoverOpen, liveTailName, searchError = null, + curVisId, + spanValue, } = props; const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX); @@ -215,6 +217,8 @@ export const Search = (props: any) => { showSavePanelOptionsList && searchBarConfigs[selectedSubTabId]?.showSavePanelOptionsList } + curVisId={curVisId} + spanValue={spanValue} /> diff --git a/public/components/event_analytics/explorer/explorer.tsx b/public/components/event_analytics/explorer/explorer.tsx index c4002c1ef..d63dee0c3 100644 --- a/public/components/event_analytics/explorer/explorer.tsx +++ b/public/components/event_analytics/explorer/explorer.tsx @@ -156,6 +156,7 @@ export const Explorer = ({ const [isValidDataConfigOptionSelected, setIsValidDataConfigOptionSelected] = useState( false ); + const [spanValue, setSpanValue] = useState(false); const queryRef = useRef(); const appBasedRef = useRef(''); appBasedRef.current = appBaseQuery; @@ -1279,6 +1280,12 @@ export const Explorer = ({ [tempQuery] ); + useEffect(() => { + const statsTokens = queryManager.queryParser().parse(tempQuery).getStats(); + const updatedDataConfig = getUpdatedDataConfig(statsTokens); + setSpanValue(!isEqual(typeof updatedDataConfig.span, 'undefined')); + }, [tempQuery, query, selectedContentTabId]); + return ( { const [options, setOptions] = useState([]); + const [checked, setChecked] = useState(false); + const [measure, setMeasure] = useState([]); + const [label, setLabel] = useState([]); const getCustomPabnelList = async (savedObjects: SavedObjects) => { const optionRes = await savedObjects @@ -50,6 +65,18 @@ export const SavePanel = ({ getCustomPabnelList(savedObjects); }, []); + const onToggleChange = (e: { target: { checked: React.SetStateAction } }) => { + setChecked(e.target.checked); + }; + + const onMeasureChange = (selectedMeasures: React.SetStateAction) => { + setMeasure(selectedMeasures); + }; + + const onLabelChange = (selectedLabels: React.SetStateAction) => { + setLabel(selectedLabels); + }; + return ( <> {showOptionList && ( @@ -90,6 +117,60 @@ export const SavePanel = ({ data-test-subj="eventExplorer__querySaveName" /> + {showOptionList && (isEqual(curVisId, 'line')) && spanValue && ( + <> + + + + {checked && ( + <> + + +

{'Units of Measure'}

+
+ + { + return { + label: i, + }; + })} + isClearable={false} + data-test-subj="eventExplorer__metricMeasureSaveComboBox" + /> + + + +

{'Labels'}

+
+ + { + return { + label: i, + }; + })} + isClearable={true} + data-test-subj="eventExplorer__metricLabelSaveComboBox" + /> + + + )} + + )} ); };