diff --git a/app/vmui/packages/vmui/src/components/Main/Modal/style.scss b/app/vmui/packages/vmui/src/components/Main/Modal/style.scss index 163574e42..9e85e07d2 100644 --- a/app/vmui/packages/vmui/src/components/Main/Modal/style.scss +++ b/app/vmui/packages/vmui/src/components/Main/Modal/style.scss @@ -1,6 +1,6 @@ @use "src/styles/variables" as *; -$padding-modal: 22px; +$padding-modal: $padding-medium; .vm-modal { position: fixed; @@ -43,9 +43,6 @@ $padding-modal: 22px; } &-content { - display: grid; - grid-template-rows: auto 1fr; - align-items: flex-start; background: $color-background-block; box-shadow: 0 0 24px rgba($color-black, 0.07); border-radius: $border-radius-small; diff --git a/app/vmui/packages/vmui/src/pages/CustomPanel/QueryConfigurator/QueryConfigurator.tsx b/app/vmui/packages/vmui/src/pages/CustomPanel/QueryConfigurator/QueryConfigurator.tsx index 169a2360d..badf930ee 100644 --- a/app/vmui/packages/vmui/src/pages/CustomPanel/QueryConfigurator/QueryConfigurator.tsx +++ b/app/vmui/packages/vmui/src/pages/CustomPanel/QueryConfigurator/QueryConfigurator.tsx @@ -22,6 +22,7 @@ import { arrayEquals } from "../../../utils/array"; import useDeviceDetect from "../../../hooks/useDeviceDetect"; import { QueryStats } from "../../../api/types"; import { usePrettifyQuery } from "./hooks/usePrettifyQuery"; +import QueryHistoryList from "../QueryHistory/QueryHistoryList"; export interface QueryConfiguratorProps { queryErrors: string[]; @@ -51,18 +52,25 @@ const QueryConfigurator: FC = ({ const [stateQuery, setStateQuery] = useState(query || []); const [hideQuery, setHideQuery] = useState([]); + const [awaitStateQuery, setAwaitStateQuery] = useState(false); const prevStateQuery = usePrevious(stateQuery) as (undefined | string[]); const getPrettifiedQuery = usePrettifyQuery(); const updateHistory = () => { queryDispatch({ - type: "SET_QUERY_HISTORY", payload: stateQuery.map((q, i) => { + type: "SET_QUERY_HISTORY", + payload: stateQuery.map((q, i) => { const h = queryHistory[i] || { values: [] }; const queryEqual = q === h.values[h.values.length - 1]; + const newValues = !queryEqual && q ? [...h.values, q] : h.values; + + // limit the history + if (newValues.length > 25) newValues.shift(); + return { index: h.values.length - Number(queryEqual), - values: !queryEqual && q ? [...h.values, q] : h.values + values: newValues }; }) }); @@ -99,6 +107,11 @@ const QueryConfigurator: FC = ({ setStateQuery(prev => prev.map((q, i) => i === index ? value : q)); }; + const handleSelectHistory = (value: string, index: number) => { + handleChangeQuery(value, index); + setAwaitStateQuery(true); + }; + const handleHistoryChange = (step: number, indexQuery: number) => { const { index, values } = queryHistory[indexQuery]; const newIndexHistory = index + step; @@ -149,6 +162,13 @@ const QueryConfigurator: FC = ({ onHideQuery(hideQuery); }, [hideQuery]); + useEffect(() => { + if (awaitStateQuery) { + handleRunQuery(); + setAwaitStateQuery(false); + } + }, [stateQuery, awaitStateQuery]); + return
= ({
+ {stateQuery.length < MAX_QUERY_FIELDS && (
+
+ ))} +
+ + + )} + + ); +}; + +export default QueryHistoryList; diff --git a/app/vmui/packages/vmui/src/pages/CustomPanel/QueryHistory/style.scss b/app/vmui/packages/vmui/src/pages/CustomPanel/QueryHistory/style.scss new file mode 100644 index 000000000..661c1d7f8 --- /dev/null +++ b/app/vmui/packages/vmui/src/pages/CustomPanel/QueryHistory/style.scss @@ -0,0 +1,45 @@ +@use "src/styles/variables" as *; + +.vm-query-history { + max-width: 80vw; + min-width: 40vw; + + &__tabs { + margin: (-$padding-medium) (-$padding-medium) 0; + padding: 0 $padding-medium; + + &_mobile { + margin: (-$padding-global) (-$padding-medium) 0; + } + } + + &-list { + display: grid; + align-items: flex-start; + + &-item { + display: grid; + grid-template-columns: 1fr auto; + gap: $padding-small; + align-items: center; + margin: 0 (-$padding-medium) 0; + padding: $padding-small calc($padding-medium + $padding-small); + border-bottom: $border-divider; + + &:first-child { + border-top: $border-divider; + } + + &__value { + white-space: pre-wrap; + overflow-wrap: anywhere; + font-family: $font-family-monospace; + } + + &__buttons { + display: flex; + gap: $padding-small; + } + } + } +} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 178140cd1..f7c40d13b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -26,6 +26,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components * FEATURE: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): add support for numbers with underscore delimiters such as `1_234_567_890` and `1.234_567_890`. These numbers are easier to read than `1234567890` and `1.234567890`. * FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): add support for server-side copy of existing backups. See [these docs](https://docs.victoriametrics.com/vmbackup.html#server-side-copy-of-the-existing-backup) for details. +* FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): add the option to see the latest 25 queries. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4718). * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add ability to set `member num` label for all the metrics scraped by a particular `vmagent` instance in [a cluster of vmagents](https://docs.victoriametrics.com/vmagent.html#scraping-big-number-of-targets) via `-promscrape.cluster.memberLabel` command-line flag. See [these docs](https://docs.victoriametrics.com/vmagent.html#scraping-big-number-of-targets) and [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4247). * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): do not log `unexpected EOF` when reading incoming metrics, since this error is expected and is handled during metrics' parsing. This reduces the amounts of noisy logs. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4817). * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): retry failed write request on the closed connection immediately, without waiting for backoff. This should improve data delivery speed and reduce amount of error logs emitted by vmagent when using idle connections. See related [issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4139).