Welcome to mirror list, hosted at ThFree Co, Russian Federation.

alert_metrics.vue « components « alert_management « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd4faa03c00525d70935fc9a3b417e67a7eccfd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script>
import Vue from 'vue';
import Vuex from 'vuex';
import * as Sentry from '~/sentry/wrapper';

Vue.use(Vuex);

export default {
  props: {
    dashboardUrl: {
      type: String,
      required: false,
      default: '',
    },
  },
  data() {
    return {
      metricEmbedComponent: null,
      namespace: 'alertMetrics',
    };
  },
  mounted() {
    if (this.dashboardUrl) {
      Promise.all([
        import('~/monitoring/components/embeds/metric_embed.vue'),
        import('~/monitoring/stores'),
      ])
        .then(([{ default: MetricEmbed }, { monitoringDashboard }]) => {
          this.$store = new Vuex.Store({
            modules: {
              [this.namespace]: monitoringDashboard,
            },
          });
          this.metricEmbedComponent = MetricEmbed;
        })
        .catch((e) => Sentry.captureException(e));
    }
  },
};
</script>

<template>
  <div class="gl-py-3">
    <div v-if="dashboardUrl" ref="metricsChart">
      <component
        :is="metricEmbedComponent"
        v-if="metricEmbedComponent"
        :dashboard-url="dashboardUrl"
        :namespace="namespace"
      />
    </div>
    <div v-else ref="emptyState">
      {{ s__("AlertManagement|Metrics weren't available in the alerts payload.") }}
    </div>
  </div>
</template>