diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
commit | 84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch) | |
tree | f550fa965f507077e20dbb6d61a8269a99ef7107 /app/assets/javascripts/observability | |
parent | 3a105e36e689f7b75482236712f1a47fd5a76814 (diff) |
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/observability')
-rw-r--r-- | app/assets/javascripts/observability/client.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/observability/client.js b/app/assets/javascripts/observability/client.js index 3a793c9dc14..b7e4ae8e8ea 100644 --- a/app/assets/javascripts/observability/client.js +++ b/app/assets/javascripts/observability/client.js @@ -1,3 +1,4 @@ +import { isValidDate } from '~/lib/utils/datetime_utility'; import * as Sentry from '~/sentry/sentry_browser_wrapper'; import axios from '~/lib/utils/axios_utils'; import { logError } from '~/lib/logger'; @@ -128,6 +129,24 @@ function handleAttributeFilter(filterValue, filterOperator, searchParams) { } } +function handlePeriodFilter(rawValue, filterName, filterParams) { + if (rawValue.trim().indexOf(' ') < 0) { + filterParams.append(filterName, rawValue.trim()); + return; + } + + const dateParts = rawValue.split(' - '); + if (dateParts.length === 2) { + const [start, end] = dateParts; + const startDate = new Date(start); + const endDate = new Date(end); + if (isValidDate(startDate) && isValidDate(endDate)) { + filterParams.append('start_time', startDate.toISOString()); + filterParams.append('end_time', endDate.toISOString()); + } + } +} + /** * Builds URLSearchParams from a filter object of type { [filterName]: undefined | null | Array<{operator: String, value: any} } * e.g: @@ -154,6 +173,8 @@ function filterObjToQueryParams(filterObj) { validFilters.forEach(({ operator, value: rawValue }) => { if (filterName === 'attribute') { handleAttributeFilter(rawValue, operator, filterParams); + } else if (filterName === 'period') { + handlePeriodFilter(rawValue, filterName, filterParams); } else { const paramName = getFilterParamName(filterName, operator); let value = rawValue; |