Commit 3b4d3e34 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

formatting fixes

parent bbe8eb2d
...@@ -23,26 +23,15 @@ export default { ...@@ -23,26 +23,15 @@ export default {
methods: { methods: {
formatMetricUsage(series) { formatMetricUsage(series) {
const value = const value =
series.values[this.currentDataIndex] && series.values[this.currentDataIndex] && series.values[this.currentDataIndex].value;
series.values[this.currentDataIndex].value;
if (isNaN(value)) { if (isNaN(value)) {
return '-'; return '-';
} }
return `${formatRelevantDigits(value)} ${this.unitOfDisplay}`; return `${formatRelevantDigits(value)} ${this.unitOfDisplay}`;
}, },
createSeriesString(index, series) {
if (series.metricTag) {
return `${series.metricTag} ${this.formatMetricUsage(series)}`;
}
return `${this.legendTitle} series ${index + 1} ${this.formatMetricUsage(
series,
)}`;
},
summaryMetrics(series) { summaryMetrics(series) {
return `Avg: ${formatRelevantDigits(series.average)} ${this.unitOfDisplay}, return `Avg: ${formatRelevantDigits(series.average)} · Max: ${formatRelevantDigits(series.max)}`;
Max: ${formatRelevantDigits(series.max)} ${this.unitOfDisplay}`;
}, },
strokeDashArray(type) { strokeDashArray(type) {
...@@ -80,10 +69,18 @@ export default { ...@@ -80,10 +69,18 @@ export default {
class="legend-metric-title" class="legend-metric-title"
v-if="timeSeries.length > 1" v-if="timeSeries.length > 1"
> >
{{ createSeriesString(index, series) }}, {{ summaryMetrics(series) }} <template v-if="series.metricTag">
<strong>{{ series.metricTag }}</strong>
{{ formatMetricUsage(series) }} {{ summaryMetrics(series) }}
</template>
<template v-else>
<strong>{{ legendTitle }}</strong>
series {{ index + 1 }} {{ formatMetricUsage(series) }} {{ summaryMetrics(series) }}
</template>
</td> </td>
<td v-else> <td v-else>
{{ legendTitle }} {{ formatMetricUsage(series) }}, {{ summaryMetrics(series) }} <strong>{{ legendTitle }}</strong>
{{ formatMetricUsage(series) }} {{ summaryMetrics(series) }}
</td> </td>
</tr> </tr>
</table> </table>
......
...@@ -2,14 +2,9 @@ import Vue from 'vue'; ...@@ -2,14 +2,9 @@ import Vue from 'vue';
import GraphLegend from '~/monitoring/components/graph/legend.vue'; import GraphLegend from '~/monitoring/components/graph/legend.vue';
import createTimeSeries from '~/monitoring/utils/multiple_time_series'; import createTimeSeries from '~/monitoring/utils/multiple_time_series';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from '../mock_data';
singleRowMetricsMultipleSeries,
convertDatesMultipleSeries,
} from '../mock_data';
const convertedMetrics = convertDatesMultipleSeries( const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries);
singleRowMetricsMultipleSeries,
);
const defaultValuesComponent = {}; const defaultValuesComponent = {};
...@@ -77,9 +72,7 @@ describe('Legend Component', () => { ...@@ -77,9 +72,7 @@ describe('Legend Component', () => {
}); });
it('should container the same number of rows in the table as time series', () => { it('should container the same number of rows in the table as time series', () => {
expect(vm.$el.querySelectorAll('.prometheus-table tr').length).toEqual( expect(vm.$el.querySelectorAll('.prometheus-table tr').length).toEqual(vm.timeSeries.length);
vm.timeSeries.length,
);
}); });
}); });
}); });
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