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

memory_graph.vue « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af0b85cc6e4accf4511f676a8275c78ecf0215db (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
<script>
import { GlSparklineChart } from '@gitlab/ui/dist/charts';
import { formatDate, secondsToMilliseconds } from '~/lib/utils/datetime_utility';

export default {
  name: 'MemoryGraph',
  components: {
    GlSparklineChart,
  },
  props: {
    metrics: { type: Array, required: true },
    width: { type: Number, required: true },
    height: { type: Number, required: true },
  },
  computed: {
    chartData() {
      return this.metrics.map(([x, y]) => [
        this.getFormattedDeploymentTime(x),
        this.getMemoryUsage(y),
      ]);
    },
  },
  methods: {
    getFormattedDeploymentTime(timestamp) {
      return formatDate(new Date(secondsToMilliseconds(timestamp)), 'mmm dd yyyy HH:MM:s');
    },
    getMemoryUsage(MBs) {
      return Number(MBs).toFixed(2);
    },
  },
};
</script>

<template>
  <div class="memory-graph-container p-1" :style="{ width: `${width}px` }">
    <gl-sparkline-chart
      :height="height"
      :tooltip-label="__('MB')"
      :show-last-y-value="false"
      :data="chartData"
    />
  </div>
</template>