Commit 3a9eea3c authored by Tristan Read's avatar Tristan Read Committed by Natalia Tepluhina

Remove underscore from prometheus metrics files

parent 353dd40c
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape } from 'lodash';
import { s__, n__, sprintf } from '~/locale'; import { s__, n__, sprintf } from '~/locale';
import axios from '../lib/utils/axios_utils'; import axios from '../lib/utils/axios_utils';
import PANEL_STATE from './constants'; import PANEL_STATE from './constants';
...@@ -69,13 +69,13 @@ export default class PrometheusMetrics { ...@@ -69,13 +69,13 @@ export default class PrometheusMetrics {
if (metric.active_metrics > 0) { if (metric.active_metrics > 0) {
totalExporters += 1; totalExporters += 1;
this.$monitoredMetricsList.append( this.$monitoredMetricsList.append(
`<li>${_.escape(metric.group)}<span class="badge">${_.escape( `<li>${escape(metric.group)}<span class="badge">${escape(
metric.active_metrics, metric.active_metrics,
)}</span></li>`, )}</span></li>`,
); );
totalMonitoredMetrics += metric.active_metrics; totalMonitoredMetrics += metric.active_metrics;
if (metric.metrics_missing_requirements > 0) { if (metric.metrics_missing_requirements > 0) {
this.$missingEnvVarMetricsList.append(`<li>${_.escape(metric.group)}</li>`); this.$missingEnvVarMetricsList.append(`<li>${escape(metric.group)}</li>`);
totalMissingEnvVarMetrics += 1; totalMissingEnvVarMetrics += 1;
} }
} }
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape, sortBy } from 'lodash';
import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics'; import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics';
import PANEL_STATE from './constants'; import PANEL_STATE from './constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -61,7 +61,7 @@ export default class EEPrometheusMetrics extends PrometheusMetrics { ...@@ -61,7 +61,7 @@ export default class EEPrometheusMetrics extends PrometheusMetrics {
} }
setVisible(...els) { setVisible(...els) {
this.setHidden(_.difference(this.$els, els)); this.setHidden(this.$els.filter(el => !els.includes(el)));
els.forEach(el => el.removeClass('hidden')); els.forEach(el => el.removeClass('hidden'));
} }
...@@ -90,12 +90,12 @@ export default class EEPrometheusMetrics extends PrometheusMetrics { ...@@ -90,12 +90,12 @@ export default class EEPrometheusMetrics extends PrometheusMetrics {
} }
populateCustomMetrics() { populateCustomMetrics() {
const sortedMetrics = _(this.customMetrics) const capitalizeGroup = metric => ({
.chain() ...metric,
.map(metric => ({ ...metric, group: capitalizeFirstCharacter(metric.group) })) group: capitalizeFirstCharacter(metric.group),
.sortBy('title') });
.sortBy('group')
.value(); const sortedMetrics = sortBy(this.customMetrics.map(capitalizeGroup), ['group', 'title']);
sortedMetrics.forEach(metric => { sortedMetrics.forEach(metric => {
this.$monitoredCustomMetricsList.append(EEPrometheusMetrics.customMetricTemplate(metric)); this.$monitoredCustomMetricsList.append(EEPrometheusMetrics.customMetricTemplate(metric));
...@@ -146,8 +146,8 @@ export default class EEPrometheusMetrics extends PrometheusMetrics { ...@@ -146,8 +146,8 @@ export default class EEPrometheusMetrics extends PrometheusMetrics {
static customMetricTemplate(metric) { static customMetricTemplate(metric) {
return ` return `
<li class="custom-metric"> <li class="custom-metric">
<a href="${_.escape(metric.edit_path)}" class="custom-metric-link-bold"> <a href="${escape(metric.edit_path)}" class="custom-metric-link-bold">
${_.escape(metric.group)} / ${_.escape(metric.title)} (${_.escape(metric.unit)}) ${escape(metric.group)} / ${escape(metric.title)} (${escape(metric.unit)})
</a> </a>
</li> </li>
`; `;
......
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