diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
commit | e4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch) | |
tree | 2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /app/assets/javascripts/monitoring/components/charts/gauge.vue | |
parent | ffda4e7bcac36987f936b4ba515995a6698698f0 (diff) |
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'app/assets/javascripts/monitoring/components/charts/gauge.vue')
-rw-r--r-- | app/assets/javascripts/monitoring/components/charts/gauge.vue | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/app/assets/javascripts/monitoring/components/charts/gauge.vue b/app/assets/javascripts/monitoring/components/charts/gauge.vue deleted file mode 100644 index 0477ff19ffe..00000000000 --- a/app/assets/javascripts/monitoring/components/charts/gauge.vue +++ /dev/null @@ -1,110 +0,0 @@ -<script> -import { GlGaugeChart } from '@gitlab/ui/dist/charts'; -import { isFinite, isArray, isInteger } from 'lodash'; -import { getFormatter, SUPPORTED_FORMATS } from '~/lib/utils/unit_format'; -import { graphDataValidatorForValues } from '../../utils'; -import { getValidThresholds } from './options'; - -export default { - components: { - GlGaugeChart, - }, - props: { - graphData: { - type: Object, - required: true, - validator: graphDataValidatorForValues.bind(null, true), - }, - }, - data() { - return { - width: 0, - }; - }, - computed: { - rangeValues() { - let min = 0; - let max = 100; - - const { minValue, maxValue } = this.graphData; - - const isValidMinMax = () => { - return isFinite(minValue) && isFinite(maxValue) && minValue < maxValue; - }; - - if (isValidMinMax()) { - min = minValue; - max = maxValue; - } - - return { - min, - max, - }; - }, - validThresholds() { - const { mode, values } = this.graphData?.thresholds || {}; - const range = this.rangeValues; - - if (!isArray(values)) { - return []; - } - - return getValidThresholds({ mode, range, values }); - }, - queryResult() { - return this.graphData?.metrics[0]?.result[0]?.value[1]; - }, - splitValue() { - const { split } = this.graphData; - const defaultValue = 10; - - return isInteger(split) && split > 0 ? split : defaultValue; - }, - textValue() { - const formatFromPanel = this.graphData.format; - const defaultFormat = SUPPORTED_FORMATS.engineering; - const format = SUPPORTED_FORMATS[formatFromPanel] ?? defaultFormat; - const { queryResult } = this; - - const formatter = getFormatter(format); - - return isFinite(queryResult) ? formatter(queryResult) : '--'; - }, - thresholdsValue() { - /** - * If there are no valid thresholds, a default threshold - * will be set at 90% of the gauge arcs' max value - */ - const { min, max } = this.rangeValues; - - const defaultThresholdValue = [(max - min) * 0.95]; - return this.validThresholds.length ? this.validThresholds : defaultThresholdValue; - }, - value() { - /** - * The gauge chart gitlab-ui component expects a value - * of type number. - * - * So, if the query result is undefined, - * we pass the gauge chart a value of NaN. - */ - return this.queryResult || NaN; - }, - }, -}; -</script> -<template> - <gl-gauge-chart - ref="gaugeChart" - v-bind="$attrs" - :responsive="true" - :value="value" - :min="rangeValues.min" - :max="rangeValues.max" - :thresholds="thresholdsValue" - :text="textValue" - :split-number="splitValue" - :width="width" - /> -</template> |