Commit 057e84d6 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Renamed some components

parent 0357726d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import GraphLegend from './graph/legend.vue'; import GraphLegend from './graph/legend.vue';
import GraphFlag from './graph/flag.vue'; import GraphFlag from './graph/flag.vue';
import GraphDeployment from './graph/deployment.vue'; import GraphDeployment from './graph/deployment.vue';
import monitoringPaths from './monitoring_paths.vue'; import GraphPath from './graph_path.vue';
import MonitoringMixin from '../mixins/monitoring_mixins'; import MonitoringMixin from '../mixins/monitoring_mixins';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import measurements from '../utils/measurements'; import measurements from '../utils/measurements';
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
GraphLegend, GraphLegend,
GraphFlag, GraphFlag,
GraphDeployment, GraphDeployment,
monitoringPaths, GraphPath,
}, },
computed: { computed: {
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
class="graph-data" class="graph-data"
:viewBox="innerViewBox" :viewBox="innerViewBox"
ref="graphData"> ref="graphData">
<monitoring-paths <graph-path
v-for="(path, index) in timeSeries" v-for="(path, index) in timeSeries"
:key="index" :key="index"
:generated-line-path="path.linePath" :generated-line-path="path.linePath"
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
:line-color="path.lineColor" :line-color="path.lineColor"
:area-color="path.areaColor" :area-color="path.areaColor"
/> />
<monitoring-deployment <graph-deployment
:show-deploy-info="showDeployInfo" :show-deploy-info="showDeployInfo"
:deployment-data="reducedDeploymentData" :deployment-data="reducedDeploymentData"
:graph-height="graphHeight" :graph-height="graphHeight"
......
...@@ -15,6 +15,9 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr ...@@ -15,6 +15,9 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
let timeSeriesNumber = 1; let timeSeriesNumber = 1;
let lineColor = '#1f78d1'; let lineColor = '#1f78d1';
let areaColor = '#8fbce8'; let areaColor = '#8fbce8';
const lineColors = ['#1f78d1', '#fc9403', '#db3b21', '#1aaa55', '#6666c4'];
const areaColors = ['#8fbce8', '#feca81', '#ed9d90', '#8dd5aa', '#d1d1f0'];
return seriesData.map((timeSeries) => { return seriesData.map((timeSeries) => {
const timeSeriesScaleX = d3.time.scale() const timeSeriesScaleX = d3.time.scale()
.range([0, graphWidth - 70]); .range([0, graphWidth - 70]);
...@@ -35,32 +38,8 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr ...@@ -35,32 +38,8 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
.y1(d => timeSeriesScaleY(d.value)) .y1(d => timeSeriesScaleY(d.value))
.interpolate('linear'); .interpolate('linear');
switch (timeSeriesNumber) { lineColor = lineColors[timeSeriesNumber - 1];
case 1: areaColor = areaColors[timeSeriesNumber - 1];
lineColor = '#1f78d1';
areaColor = '#8fbce8';
break;
case 2:
lineColor = '#fc9403';
areaColor = '#feca81';
break;
case 3:
lineColor = '#db3b21';
areaColor = '#ed9d90';
break;
case 4:
lineColor = '#1aaa55';
areaColor = '#8dd5aa';
break;
case 5:
lineColor = '#6666c4';
areaColor = '#d1d1f0';
break;
default:
lineColor = '#1f78d1';
areaColor = '#8fbce8';
break;
}
if (timeSeriesNumber <= 5) { if (timeSeriesNumber <= 5) {
timeSeriesNumber = timeSeriesNumber += 1; timeSeriesNumber = timeSeriesNumber += 1;
......
--- ---
title: Added support the multiple time series for prometheus monitoring title: Added support for multiple time series
merge_request: !36893 merge_request: !36893
author: author:
type: changed type: changed
import Vue from 'vue'; import Vue from 'vue';
import MonitoringPaths from '~/monitoring/components/monitoring_paths.vue'; import GraphPath from '~/monitoring/components/graph_path.vue';
import createTimeSeries from '~/monitoring/utils/multiple_time_series'; import createTimeSeries from '~/monitoring/utils/multiple_time_series';
import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from './mock_data'; import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from './mock_data';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringPaths); const Component = Vue.extend(GraphPath);
return new Component({ return new Component({
propsData, propsData,
...@@ -14,12 +14,13 @@ const createComponent = (propsData) => { ...@@ -14,12 +14,13 @@ const createComponent = (propsData) => {
const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries);
const timeSeries = createTimeSeries(convertedMetrics[0].queries[0].result, 428, 272, 120); const timeSeries = createTimeSeries(convertedMetrics[0].queries[0].result, 428, 272, 120);
const firstTimeSeries = timeSeries[0];
describe('Monitoring Paths', () => { describe('Monitoring Paths', () => {
it('renders two paths to represent a line and the area underneath it', () => { it('renders two paths to represent a line and the area underneath it', () => {
const component = createComponent({ const component = createComponent({
generatedLinePath: timeSeries[0].linePath, generatedLinePath: firstTimeSeries.linePath,
generatedAreaPath: timeSeries[0].areaPath, generatedAreaPath: firstTimeSeries.areaPath,
lineColor: '#ccc', lineColor: '#ccc',
areaColor: '#fff', areaColor: '#fff',
}); });
...@@ -27,8 +28,8 @@ describe('Monitoring Paths', () => { ...@@ -27,8 +28,8 @@ describe('Monitoring Paths', () => {
const metricLine = component.$el.querySelector('.metric-line'); const metricLine = component.$el.querySelector('.metric-line');
expect(metricArea.getAttribute('fill')).toBe('#fff'); expect(metricArea.getAttribute('fill')).toBe('#fff');
expect(metricArea.getAttribute('d')).toBe(timeSeries[0].areaPath); expect(metricArea.getAttribute('d')).toBe(firstTimeSeries.areaPath);
expect(metricLine.getAttribute('stroke')).toBe('#ccc'); expect(metricLine.getAttribute('stroke')).toBe('#ccc');
expect(metricLine.getAttribute('d')).toBe(timeSeries[0].linePath); expect(metricLine.getAttribute('d')).toBe(firstTimeSeries.linePath);
}); });
}); });
...@@ -3,15 +3,16 @@ import { convertDatesMultipleSeries, singleRowMetricsMultipleSeries } from '../m ...@@ -3,15 +3,16 @@ import { convertDatesMultipleSeries, singleRowMetricsMultipleSeries } from '../m
const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries);
const timeSeries = createTimeSeries(convertedMetrics[0].queries[0].result, 428, 272, 120); const timeSeries = createTimeSeries(convertedMetrics[0].queries[0].result, 428, 272, 120);
const firstTimeSeries = timeSeries[0];
describe('Multiple time series', () => { describe('Multiple time series', () => {
it('createTimeSeries returned array contains an object for each element', () => { it('createTimeSeries returned array contains an object for each element', () => {
expect(typeof timeSeries[0].linePath).toEqual('string'); expect(typeof firstTimeSeries.linePath).toEqual('string');
expect(typeof timeSeries[0].areaPath).toEqual('string'); expect(typeof firstTimeSeries.areaPath).toEqual('string');
expect(typeof timeSeries[0].timeSeriesScaleX).toEqual('function'); expect(typeof firstTimeSeries.timeSeriesScaleX).toEqual('function');
expect(typeof timeSeries[0].areaColor).toEqual('string'); expect(typeof firstTimeSeries.areaColor).toEqual('string');
expect(typeof timeSeries[0].lineColor).toEqual('string'); expect(typeof firstTimeSeries.lineColor).toEqual('string');
expect(timeSeries[0].values instanceof Array).toEqual(true); expect(firstTimeSeries.values instanceof Array).toEqual(true);
}); });
it('createTimeSeries returns an array', () => { it('createTimeSeries returns an array', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment