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

monitoring_mixins.js « mixins « monitoring « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b555165d354686a4235350cb1a430f4d751b168 (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
import { bisectDate } from '../utils/date_time_formatters';

const mixins = {
  methods: {
    mouseOverDeployInfo(mouseXPos) {
      if (!this.reducedDeploymentData) return false;

      let dataFound = false;
      this.reducedDeploymentData = this.reducedDeploymentData.map((d) => {
        const deployment = d;
        if (d.xPos >= mouseXPos - 10 && d.xPos <= mouseXPos + 10 && !dataFound) {
          dataFound = d.xPos + 1;
          debugger

          deployment.showDeploymentFlag = true;
        } else {
          deployment.showDeploymentFlag = false;
        }
        return deployment;
      });

      return dataFound;
    },

    formatDeployments() {
      this.reducedDeploymentData = this.deploymentData.reduce((deploymentDataArray, deployment) => {
        const time = new Date(deployment.created_at);
        const xPos = Math.floor(this.activeTimeSeries[0].timeSeriesScaleX(time));

        time.setSeconds(this.activeTimeSeries[0].values[0].time.getSeconds());

        if (xPos >= 0) {
          const seriesIndex = bisectDate(this.timeSeries[0].values, time);

          deploymentDataArray.push({
            id: deployment.id,
            time,
            sha: deployment.sha,
            commitUrl: `${this.projectPath}/commit/${deployment.sha}`,
            tag: deployment.tag,
            tagUrl: deployment.tag ? `${this.tagsPath}/${deployment.ref.name}` : null,
            ref: deployment.ref.name,
            xPos,
            seriesIndex,
            showDeploymentFlag: false,
          });
        }

        return deploymentDataArray;
      }, []);
    },

    positionFlag() {
      const timeSeries = this.activeTimeSeries[0];
      if (!timeSeries) return;
      const hoveredDataIndex = bisectDate(timeSeries.values, this.hoverData.hoveredDate);

      this.currentData = timeSeries.values[hoveredDataIndex] || {};
      if (!this.currentData || !timeSeries) {
        return;
      }
      this.currentXCoordinate = Math.floor(timeSeries.timeSeriesScaleX(this.currentData.time));

      this.currentCoordinates = this.activeTimeSeries.map((series) => {
        const currentDataIndex = bisectDate(series.values, this.hoverData.hoveredDate);
        const currentData = series.values[currentDataIndex];
        if  (!currentData) { debugger; return null; }
        const currentX = Math.floor(series.timeSeriesScaleX(currentData.time));
        const currentY = Math.floor(series.timeSeriesScaleY(currentData.value));

        return {
          currentX,
          currentY,
          currentDataIndex,
        };
      });

      if (this.hoverData.currentDeployXPos) {
        this.showFlag = false;
      } else {
        this.showFlag = true;
      }
    },
  },
};

export default mixins;