summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/monitoring/components/monitoring_flag.vue
blob: 61cbeeebb174b58856edb81aac58a73cae36cb3a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<script>
  import { dateFormat, timeFormat } from '../utils/date_time_formatters';

  export default {
    props: {
      currentXCoordinate: {
        type: Number,
        required: true,
      },
      currentYCoordinate: {
        type: Number,
        required: true,
      },
      currentFlagPosition: {
        type: Number,
        required: true,
      },
      currentData: {
        type: Object,
        required: true,
      },
      graphHeight: {
        type: Number,
        required: true,
      },
      graphHeightOffset: {
        type: Number,
        required: true,
      },
    },

    data() {
      return {
        circleColorRgb: '#8fbce8',
      };
    },

    computed: {
      formatTime() {
        return timeFormat(this.currentData.time);
      },

      formatDate() {
        return dateFormat(this.currentData.time);
      },

      calculatedHeight() {
        return this.graphHeight - this.graphHeightOffset;
      },
    },
  };
</script>
<template>
  <g class="mouse-over-flag">
    <line
      class="selected-metric-line"
      :x1="currentXCoordinate"
      :y1="0"
      :x2="currentXCoordinate"
      :y2="calculatedHeight"
      transform="translate(-5, 20)">
    </line>
    <circle
      class="circle-metric"
      :fill="circleColorRgb"
      stroke="#000"
      :cx="currentXCoordinate"
      :cy="currentYCoordinate"
      r="5"
      transform="translate(-5, 20)">
    </circle>
    <svg
      class="rect-text-metric"
      :x="currentFlagPosition"
      y="0">
      <rect
        class="rect-metric"
        x="4"
        y="1"
        rx="2"
        width="90"
        height="40"
        transform="translate(-3, 20)">
      </rect>
      <text
        class="text-metric text-metric-bold"
        x="16"
        y="35"
        transform="translate(-5, 20)">
        {{formatTime}}
      </text>
      <text
        class="text-metric"
        x="16"
        y="15"
        transform="translate(-5, 20)">
        {{formatDate}}
      </text>
    </svg>
  </g>
</template>