diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 12:08:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 12:08:16 +0300 |
commit | 6044caed20964a70c1ac6c5a3365d567ed96dfde (patch) | |
tree | 3fe8f14b4acbd542265544843efeb6f59b5d3efe /app/assets/javascripts/monitoring/components/embed.vue | |
parent | 92077e0f8d70c70a908395808b16f98ecd3a5fcd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/monitoring/components/embed.vue')
-rw-r--r-- | app/assets/javascripts/monitoring/components/embed.vue | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/app/assets/javascripts/monitoring/components/embed.vue b/app/assets/javascripts/monitoring/components/embed.vue deleted file mode 100644 index 6182b570e76..00000000000 --- a/app/assets/javascripts/monitoring/components/embed.vue +++ /dev/null @@ -1,99 +0,0 @@ -<script> -import { mapActions, mapState, mapGetters } from 'vuex'; -import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue'; -import { convertToFixedRange } from '~/lib/utils/datetime_range'; -import { timeRangeFromUrl, removeTimeRangeParams } from '../utils'; -import { sidebarAnimationDuration } from '../constants'; -import { defaultTimeRange } from '~/vue_shared/constants'; - -let sidebarMutationObserver; - -export default { - components: { - PanelType, - }, - props: { - dashboardUrl: { - type: String, - required: true, - }, - }, - data() { - const timeRange = timeRangeFromUrl(this.dashboardUrl) || defaultTimeRange; - return { - timeRange: convertToFixedRange(timeRange), - elWidth: 0, - }; - }, - computed: { - ...mapState('monitoringDashboard', ['dashboard']), - ...mapGetters('monitoringDashboard', ['metricsWithData']), - charts() { - if (!this.dashboard || !this.dashboard.panelGroups) { - return []; - } - const groupWithMetrics = this.dashboard.panelGroups.find(group => - group.panels.find(chart => this.chartHasData(chart)), - ) || { panels: [] }; - - return groupWithMetrics.panels.filter(chart => this.chartHasData(chart)); - }, - isSingleChart() { - return this.charts.length === 1; - }, - }, - mounted() { - this.setInitialState(); - this.setTimeRange(this.timeRange); - this.fetchDashboard(); - - sidebarMutationObserver = new MutationObserver(this.onSidebarMutation); - sidebarMutationObserver.observe(document.querySelector('.layout-page'), { - attributes: true, - childList: false, - subtree: false, - }); - }, - beforeDestroy() { - if (sidebarMutationObserver) { - sidebarMutationObserver.disconnect(); - } - }, - methods: { - ...mapActions('monitoringDashboard', [ - 'setTimeRange', - 'fetchDashboard', - 'setEndpoints', - 'setFeatureFlags', - 'setShowErrorBanner', - ]), - chartHasData(chart) { - return chart.metrics.some(metric => this.metricsWithData().includes(metric.metricId)); - }, - onSidebarMutation() { - setTimeout(() => { - this.elWidth = this.$el.clientWidth; - }, sidebarAnimationDuration); - }, - setInitialState() { - this.setEndpoints({ - dashboardEndpoint: removeTimeRangeParams(this.dashboardUrl), - }); - this.setShowErrorBanner(false); - }, - }, -}; -</script> -<template> - <div class="metrics-embed" :class="{ 'd-inline-flex col-lg-6 p-0': isSingleChart }"> - <div v-if="charts.length" class="row w-100 m-n2 pb-4"> - <panel-type - v-for="(graphData, graphIndex) in charts" - :key="`panel-type-${graphIndex}`" - class="w-100" - :graph-data="graphData" - :group-id="dashboardUrl" - /> - </div> - </div> -</template> |