2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2019-12-21 20:55:43 +05:30
|
|
|
import _ from 'underscore';
|
|
|
|
import { mapActions, mapState } from 'vuex';
|
|
|
|
import VueDraggable from 'vuedraggable';
|
2019-10-12 21:52:04 +05:30
|
|
|
import {
|
|
|
|
GlButton,
|
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
|
|
|
GlFormGroup,
|
|
|
|
GlModal,
|
|
|
|
GlModalDirective,
|
|
|
|
GlTooltipDirective,
|
|
|
|
} from '@gitlab/ui';
|
|
|
|
import { __, s__ } from '~/locale';
|
2019-12-21 20:55:43 +05:30
|
|
|
import createFlash from '~/flash';
|
2018-11-08 19:23:39 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import { getParameterValues, mergeUrlParams, redirectTo } from '~/lib/utils/url_utility';
|
2019-09-04 21:01:54 +05:30
|
|
|
import invalidUrl from '~/lib/utils/invalid_url';
|
2019-12-04 20:38:33 +05:30
|
|
|
import PanelType from 'ee_else_ce/monitoring/components/panel_type.vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import DateTimePicker from './date_time_picker/date_time_picker.vue';
|
2019-12-04 20:38:33 +05:30
|
|
|
import MonitorTimeSeriesChart from './charts/time_series.vue';
|
2019-09-30 21:07:59 +05:30
|
|
|
import MonitorSingleStatChart from './charts/single_stat.vue';
|
2018-05-09 12:01:36 +05:30
|
|
|
import GraphGroup from './graph_group.vue';
|
|
|
|
import EmptyState from './empty_state.vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import { sidebarAnimationDuration } from '../constants';
|
|
|
|
import TrackEventDirective from '~/vue_shared/directives/track_event';
|
|
|
|
import { getTimeDiff, isValidDate, downloadCSVOptions, generateLinkToChartOptions } from '../utils';
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
let sidebarMutationObserver;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
2019-12-21 20:55:43 +05:30
|
|
|
VueDraggable,
|
2019-12-04 20:38:33 +05:30
|
|
|
MonitorTimeSeriesChart,
|
2019-09-30 21:07:59 +05:30
|
|
|
MonitorSingleStatChart,
|
|
|
|
PanelType,
|
2018-05-09 12:01:36 +05:30
|
|
|
GraphGroup,
|
|
|
|
EmptyState,
|
2018-11-08 19:23:39 +05:30
|
|
|
Icon,
|
2019-07-31 22:56:46 +05:30
|
|
|
GlButton,
|
2019-07-07 11:18:12 +05:30
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
2019-10-12 21:52:04 +05:30
|
|
|
GlFormGroup,
|
2019-07-31 22:56:46 +05:30
|
|
|
GlModal,
|
2019-12-21 20:55:43 +05:30
|
|
|
DateTimePicker,
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2019-10-12 21:52:04 +05:30
|
|
|
GlModal: GlModalDirective,
|
|
|
|
GlTooltip: GlTooltipDirective,
|
2019-12-21 20:55:43 +05:30
|
|
|
TrackEvent: TrackEventDirective,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
props: {
|
2019-09-04 21:01:54 +05:30
|
|
|
externalDashboardUrl: {
|
2019-07-31 22:56:46 +05:30
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
hasMetrics: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
showPanels: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
documentationPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
settingsPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
clustersPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
tagsPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
projectPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
metricsEndpoint: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
deploymentsEndpoint: {
|
2018-05-09 12:01:36 +05:30
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
emptyGettingStartedSvgPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
emptyLoadingSvgPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
emptyNoDataSvgPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
emptyUnableToConnectSvgPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
environmentsEndpoint: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
currentEnvironmentName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
customMetricsAvailable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
customMetricsPath: {
|
|
|
|
type: String,
|
2019-09-30 21:07:59 +05:30
|
|
|
required: false,
|
|
|
|
default: invalidUrl,
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
|
|
|
validateQueryPath: {
|
|
|
|
type: String,
|
2019-09-30 21:07:59 +05:30
|
|
|
required: false,
|
|
|
|
default: invalidUrl,
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
dashboardEndpoint: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: invalidUrl,
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
currentDashboard: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
smallEmptyState: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-12-04 20:38:33 +05:30
|
|
|
alertsEndpoint: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
prometheusAlertsAvailable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
rearrangePanelsAvailable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
state: 'gettingStarted',
|
2018-12-05 23:21:45 +05:30
|
|
|
elWidth: 0,
|
2019-07-31 22:56:46 +05:30
|
|
|
formIsValid: null,
|
2019-12-21 20:55:43 +05:30
|
|
|
selectedTimeWindow: {},
|
|
|
|
isRearrangingPanels: false,
|
2018-05-09 12:01:36 +05:30
|
|
|
};
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
computed: {
|
|
|
|
canAddMetrics() {
|
|
|
|
return this.customMetricsAvailable && this.customMetricsPath.length;
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
...mapState('monitoringDashboard', [
|
|
|
|
'groups',
|
|
|
|
'emptyState',
|
|
|
|
'showEmptyState',
|
|
|
|
'environments',
|
|
|
|
'deploymentData',
|
|
|
|
'metricsWithData',
|
|
|
|
'useDashboardEndpoint',
|
2019-09-30 21:07:59 +05:30
|
|
|
'allDashboards',
|
|
|
|
'additionalPanelTypesEnabled',
|
2019-09-04 21:01:54 +05:30
|
|
|
]),
|
2019-10-12 21:52:04 +05:30
|
|
|
firstDashboard() {
|
|
|
|
return this.allDashboards[0] || {};
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
selectedDashboardText() {
|
2019-10-12 21:52:04 +05:30
|
|
|
return this.currentDashboard || this.firstDashboard.display_name;
|
2019-09-30 21:07:59 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
showRearrangePanelsBtn() {
|
|
|
|
return !this.showEmptyState && this.rearrangePanelsAvailable;
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
addingMetricsAvailable() {
|
|
|
|
return IS_EE && this.canAddMetrics && !this.showEmptyState;
|
|
|
|
},
|
|
|
|
alertWidgetAvailable() {
|
|
|
|
return IS_EE && this.prometheusAlertsAvailable && this.alertsEndpoint;
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
created() {
|
2019-09-04 21:01:54 +05:30
|
|
|
this.setEndpoints({
|
2018-05-09 12:01:36 +05:30
|
|
|
metricsEndpoint: this.metricsEndpoint,
|
2018-11-08 19:23:39 +05:30
|
|
|
environmentsEndpoint: this.environmentsEndpoint,
|
2019-09-04 21:01:54 +05:30
|
|
|
deploymentsEndpoint: this.deploymentsEndpoint,
|
|
|
|
dashboardEndpoint: this.dashboardEndpoint,
|
2019-09-30 21:07:59 +05:30
|
|
|
currentDashboard: this.currentDashboard,
|
|
|
|
projectPath: this.projectPath,
|
2018-05-09 12:01:36 +05:30
|
|
|
});
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2019-03-02 22:35:43 +05:30
|
|
|
if (sidebarMutationObserver) {
|
|
|
|
sidebarMutationObserver.disconnect();
|
|
|
|
}
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (!this.hasMetrics) {
|
2019-09-04 21:01:54 +05:30
|
|
|
this.setGettingStartedEmptyState();
|
2018-05-09 12:01:36 +05:30
|
|
|
} else {
|
2019-10-12 21:52:04 +05:30
|
|
|
const defaultRange = getTimeDiff();
|
|
|
|
const start = getParameterValues('start')[0] || defaultRange.start;
|
|
|
|
const end = getParameterValues('end')[0] || defaultRange.end;
|
|
|
|
|
|
|
|
const range = {
|
|
|
|
start,
|
|
|
|
end,
|
|
|
|
};
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
this.selectedTimeWindow = range;
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
if (!isValidDate(start) || !isValidDate(end)) {
|
|
|
|
this.showInvalidDateError();
|
|
|
|
} else {
|
|
|
|
this.fetchData(range);
|
|
|
|
}
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
sidebarMutationObserver = new MutationObserver(this.onSidebarMutation);
|
|
|
|
sidebarMutationObserver.observe(document.querySelector('.layout-page'), {
|
|
|
|
attributes: true,
|
|
|
|
childList: false,
|
|
|
|
subtree: false,
|
|
|
|
});
|
2018-05-09 12:01:36 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-09-04 21:01:54 +05:30
|
|
|
...mapActions('monitoringDashboard', [
|
|
|
|
'fetchData',
|
|
|
|
'setGettingStartedEmptyState',
|
|
|
|
'setEndpoints',
|
|
|
|
'setDashboardEnabled',
|
|
|
|
]),
|
|
|
|
chartsWithData(charts) {
|
|
|
|
if (!this.useDashboardEndpoint) {
|
|
|
|
return charts;
|
|
|
|
}
|
|
|
|
return charts.filter(chart =>
|
|
|
|
chart.metrics.some(metric => this.metricsWithData.includes(metric.metric_id)),
|
|
|
|
);
|
|
|
|
},
|
2019-10-12 21:52:04 +05:30
|
|
|
csvText(graphData) {
|
|
|
|
const chartData = graphData.queries[0].result[0].values;
|
|
|
|
const yLabel = graphData.y_label;
|
|
|
|
const header = `timestamp,${yLabel}\r\n`; // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
|
|
|
|
return chartData.reduce((csv, data) => {
|
|
|
|
const row = data.join(',');
|
|
|
|
return `${csv}${row}\r\n`;
|
|
|
|
}, header);
|
|
|
|
},
|
|
|
|
downloadCsv(graphData) {
|
|
|
|
const data = new Blob([this.csvText(graphData)], { type: 'text/plain' });
|
|
|
|
return window.URL.createObjectURL(data);
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
// TODO: BEGIN, Duplicated code with panel_type until feature flag is removed
|
2019-12-04 20:38:33 +05:30
|
|
|
// Issue number: https://gitlab.com/gitlab-org/gitlab-foss/issues/63845
|
2019-07-07 11:18:12 +05:30
|
|
|
getGraphAlerts(queries) {
|
|
|
|
if (!this.allAlerts) return {};
|
|
|
|
const metricIdsForChart = queries.map(q => q.metricId);
|
|
|
|
return _.pick(this.allAlerts, alert => metricIdsForChart.includes(alert.metricId));
|
|
|
|
},
|
|
|
|
getGraphAlertValues(queries) {
|
|
|
|
return Object.values(this.getGraphAlerts(queries));
|
2019-02-15 15:39:39 +05:30
|
|
|
},
|
2019-10-12 21:52:04 +05:30
|
|
|
showToast() {
|
2019-12-21 20:55:43 +05:30
|
|
|
this.$toast.show(__('Link copied'));
|
2019-10-12 21:52:04 +05:30
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
// TODO: END
|
2019-12-21 20:55:43 +05:30
|
|
|
removeGraph(metrics, graphIndex) {
|
|
|
|
// At present graphs will not be removed, they should removed using the vuex store
|
|
|
|
// See https://gitlab.com/gitlab-org/gitlab/issues/27835
|
|
|
|
metrics.splice(graphIndex, 1);
|
|
|
|
},
|
|
|
|
showInvalidDateError() {
|
|
|
|
createFlash(s__('Metrics|Link contains an invalid time window.'));
|
|
|
|
},
|
2019-10-12 21:52:04 +05:30
|
|
|
generateLink(group, title, yLabel) {
|
|
|
|
const dashboard = this.currentDashboard || this.firstDashboard.path;
|
|
|
|
const params = _.pick({ dashboard, group, title, y_label: yLabel }, value => value != null);
|
|
|
|
return mergeUrlParams(params, window.location.href);
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
hideAddMetricModal() {
|
|
|
|
this.$refs.addMetricModal.hide();
|
2019-07-07 11:18:12 +05:30
|
|
|
},
|
2019-03-02 22:35:43 +05:30
|
|
|
onSidebarMutation() {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.elWidth = this.$el.clientWidth;
|
|
|
|
}, sidebarAnimationDuration);
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
toggleRearrangingPanels() {
|
|
|
|
this.isRearrangingPanels = !this.isRearrangingPanels;
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
setFormValidity(isValid) {
|
|
|
|
this.formIsValid = isValid;
|
|
|
|
},
|
|
|
|
submitCustomMetricsForm() {
|
|
|
|
this.$refs.customMetricsForm.submit();
|
|
|
|
},
|
2019-10-12 21:52:04 +05:30
|
|
|
groupHasData(group) {
|
|
|
|
return this.chartsWithData(group.metrics).length > 0;
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
onDateTimePickerApply(timeWindowUrlParams) {
|
|
|
|
return redirectTo(mergeUrlParams(timeWindowUrlParams, window.location.href));
|
|
|
|
},
|
|
|
|
downloadCSVOptions,
|
|
|
|
generateLinkToChartOptions,
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
|
|
|
addMetric: {
|
|
|
|
title: s__('Metrics|Add metric'),
|
|
|
|
modalId: 'add-metric',
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-09-30 21:07:59 +05:30
|
|
|
<div class="prometheus-graphs">
|
2019-12-21 20:55:43 +05:30
|
|
|
<div class="prometheus-graphs-header gl-p-3 pb-0 border-bottom bg-gray-light">
|
2019-10-12 21:52:04 +05:30
|
|
|
<div class="row">
|
|
|
|
<template v-if="environmentsEndpoint">
|
|
|
|
<gl-form-group
|
|
|
|
:label="__('Dashboard')"
|
|
|
|
label-size="sm"
|
|
|
|
label-for="monitor-dashboards-dropdown"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="col-sm-12 col-md-6 col-lg-2"
|
2019-09-30 21:07:59 +05:30
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<gl-dropdown
|
|
|
|
id="monitor-dashboards-dropdown"
|
|
|
|
class="mb-0 d-flex js-dashboards-dropdown"
|
|
|
|
toggle-class="dropdown-menu-toggle"
|
|
|
|
:text="selectedDashboardText"
|
2019-09-30 21:07:59 +05:30
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<gl-dropdown-item
|
|
|
|
v-for="dashboard in allDashboards"
|
|
|
|
:key="dashboard.path"
|
|
|
|
:active="dashboard.path === currentDashboard"
|
|
|
|
active-class="is-active"
|
|
|
|
:href="`?dashboard=${dashboard.path}`"
|
|
|
|
>{{ dashboard.display_name || dashboard.path }}</gl-dropdown-item
|
|
|
|
>
|
|
|
|
</gl-dropdown>
|
|
|
|
</gl-form-group>
|
|
|
|
|
|
|
|
<gl-form-group
|
|
|
|
:label="s__('Metrics|Environment')"
|
|
|
|
label-size="sm"
|
|
|
|
label-for="monitor-environments-dropdown"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="col-sm-6 col-md-6 col-lg-2"
|
2019-07-07 11:18:12 +05:30
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<gl-dropdown
|
|
|
|
id="monitor-environments-dropdown"
|
|
|
|
class="mb-0 d-flex js-environments-dropdown"
|
|
|
|
toggle-class="dropdown-menu-toggle"
|
|
|
|
:text="currentEnvironmentName"
|
|
|
|
:disabled="environments.length === 0"
|
2019-07-31 22:56:46 +05:30
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<gl-dropdown-item
|
|
|
|
v-for="environment in environments"
|
|
|
|
:key="environment.id"
|
|
|
|
:active="environment.name === currentEnvironmentName"
|
|
|
|
active-class="is-active"
|
|
|
|
:href="environment.metrics_path"
|
|
|
|
>{{ environment.name }}</gl-dropdown-item
|
|
|
|
>
|
|
|
|
</gl-dropdown>
|
|
|
|
</gl-form-group>
|
|
|
|
|
|
|
|
<gl-form-group
|
|
|
|
v-if="!showEmptyState"
|
|
|
|
:label="s__('Metrics|Show last')"
|
|
|
|
label-size="sm"
|
|
|
|
label-for="monitor-time-window-dropdown"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="col-sm-6 col-md-6 col-lg-4"
|
2019-07-31 22:56:46 +05:30
|
|
|
>
|
2019-12-21 20:55:43 +05:30
|
|
|
<date-time-picker
|
|
|
|
:selected-time-window="selectedTimeWindow"
|
|
|
|
@onApply="onDateTimePickerApply"
|
|
|
|
/>
|
2019-10-12 21:52:04 +05:30
|
|
|
</gl-form-group>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<gl-form-group
|
2019-12-21 20:55:43 +05:30
|
|
|
v-if="addingMetricsAvailable || showRearrangePanelsBtn || externalDashboardUrl.length"
|
2019-10-12 21:52:04 +05:30
|
|
|
label-for="prometheus-graphs-dropdown-buttons"
|
2019-12-21 20:55:43 +05:30
|
|
|
class="dropdown-buttons col-md d-md-flex col-lg d-lg-flex align-items-end"
|
2019-07-31 22:56:46 +05:30
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<div id="prometheus-graphs-dropdown-buttons">
|
2019-12-21 20:55:43 +05:30
|
|
|
<gl-button
|
|
|
|
v-if="showRearrangePanelsBtn"
|
|
|
|
:pressed="isRearrangingPanels"
|
|
|
|
variant="default"
|
|
|
|
class="mr-2 mt-1 js-rearrange-button"
|
|
|
|
@click="toggleRearrangingPanels"
|
|
|
|
>
|
|
|
|
{{ __('Arrange charts') }}
|
|
|
|
</gl-button>
|
2019-10-12 21:52:04 +05:30
|
|
|
<gl-button
|
|
|
|
v-if="addingMetricsAvailable"
|
|
|
|
v-gl-modal="$options.addMetric.modalId"
|
2019-12-21 20:55:43 +05:30
|
|
|
variant="outline-success"
|
|
|
|
class="mr-2 mt-1 js-add-metric-button"
|
2019-10-12 21:52:04 +05:30
|
|
|
>
|
|
|
|
{{ $options.addMetric.title }}
|
|
|
|
</gl-button>
|
|
|
|
<gl-modal
|
|
|
|
v-if="addingMetricsAvailable"
|
|
|
|
ref="addMetricModal"
|
|
|
|
:modal-id="$options.addMetric.modalId"
|
|
|
|
:title="$options.addMetric.title"
|
|
|
|
>
|
|
|
|
<form ref="customMetricsForm" :action="customMetricsPath" method="post">
|
|
|
|
<custom-metrics-form-fields
|
|
|
|
:validate-query-path="validateQueryPath"
|
|
|
|
form-operation="post"
|
|
|
|
@formValidation="setFormValidity"
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
<div slot="modal-footer">
|
|
|
|
<gl-button @click="hideAddMetricModal">{{ __('Cancel') }}</gl-button>
|
|
|
|
<gl-button
|
|
|
|
:disabled="!formIsValid"
|
|
|
|
variant="success"
|
|
|
|
@click="submitCustomMetricsForm"
|
|
|
|
>
|
|
|
|
{{ __('Save changes') }}
|
|
|
|
</gl-button>
|
|
|
|
</div>
|
|
|
|
</gl-modal>
|
|
|
|
|
|
|
|
<gl-button
|
|
|
|
v-if="externalDashboardUrl.length"
|
|
|
|
class="mt-1 js-external-dashboard-link"
|
|
|
|
variant="primary"
|
|
|
|
:href="externalDashboardUrl"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
{{ __('View full dashboard') }}
|
|
|
|
<icon name="external-link" />
|
|
|
|
</gl-button>
|
|
|
|
</div>
|
|
|
|
</gl-form-group>
|
2018-11-08 19:23:39 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
<div v-if="!showEmptyState">
|
|
|
|
<graph-group
|
2019-10-12 21:52:04 +05:30
|
|
|
v-for="(groupData, index) in groups"
|
|
|
|
:key="`${groupData.group}.${groupData.priority}`"
|
2019-09-30 21:07:59 +05:30
|
|
|
:name="groupData.group"
|
|
|
|
:show-panels="showPanels"
|
2019-10-12 21:52:04 +05:30
|
|
|
:collapse-group="groupHasData(groupData)"
|
2019-07-07 11:18:12 +05:30
|
|
|
>
|
2019-09-30 21:07:59 +05:30
|
|
|
<template v-if="additionalPanelTypesEnabled">
|
2019-12-21 20:55:43 +05:30
|
|
|
<vue-draggable
|
|
|
|
:list="groupData.metrics"
|
|
|
|
group="metrics-dashboard"
|
|
|
|
:component-data="{ attrs: { class: 'row mx-0 w-100' } }"
|
|
|
|
:disabled="!isRearrangingPanels"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="(graphData, graphIndex) in groupData.metrics"
|
|
|
|
:key="`panel-type-${graphIndex}`"
|
|
|
|
class="col-12 col-lg-6 px-2 mb-2 draggable"
|
|
|
|
:class="{ 'draggable-enabled': isRearrangingPanels }"
|
|
|
|
>
|
|
|
|
<div class="position-relative draggable-panel js-draggable-panel">
|
|
|
|
<div
|
|
|
|
v-if="isRearrangingPanels"
|
|
|
|
class="draggable-remove js-draggable-remove p-2 w-100 position-absolute d-flex justify-content-end"
|
|
|
|
@click="removeGraph(groupData.metrics, graphIndex)"
|
|
|
|
>
|
|
|
|
<a class="mx-2 p-2 draggable-remove-link" :aria-label="__('Remove')"
|
|
|
|
><icon name="close"
|
|
|
|
/></a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<panel-type
|
|
|
|
:clipboard-text="
|
|
|
|
generateLink(groupData.group, graphData.title, graphData.y_label)
|
|
|
|
"
|
|
|
|
:graph-data="graphData"
|
|
|
|
:dashboard-width="elWidth"
|
|
|
|
:alerts-endpoint="alertsEndpoint"
|
|
|
|
:prometheus-alerts-available="prometheusAlertsAvailable"
|
|
|
|
:index="`${index}-${graphIndex}`"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</vue-draggable>
|
2019-09-30 21:07:59 +05:30
|
|
|
</template>
|
|
|
|
<template v-else>
|
2019-12-04 20:38:33 +05:30
|
|
|
<monitor-time-series-chart
|
2019-09-30 21:07:59 +05:30
|
|
|
v-for="(graphData, graphIndex) in chartsWithData(groupData.metrics)"
|
|
|
|
:key="graphIndex"
|
2019-12-04 20:38:33 +05:30
|
|
|
class="col-12 col-lg-6 pb-3"
|
2019-09-30 21:07:59 +05:30
|
|
|
:graph-data="graphData"
|
|
|
|
:deployment-data="deploymentData"
|
|
|
|
:thresholds="getGraphAlertValues(graphData.queries)"
|
|
|
|
:container-width="elWidth"
|
|
|
|
:project-path="projectPath"
|
2019-12-04 20:38:33 +05:30
|
|
|
group-id="monitor-time-series-chart"
|
2019-09-30 21:07:59 +05:30
|
|
|
>
|
2019-12-21 20:55:43 +05:30
|
|
|
<div
|
|
|
|
class="d-flex align-items-center"
|
|
|
|
:class="alertWidgetAvailable ? 'justify-content-between' : 'justify-content-end'"
|
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
<alert-widget
|
|
|
|
v-if="alertWidgetAvailable && graphData"
|
|
|
|
:modal-id="`alert-modal-${index}-${graphIndex}`"
|
|
|
|
:alerts-endpoint="alertsEndpoint"
|
|
|
|
:relevant-queries="graphData.queries"
|
|
|
|
:alerts-to-manage="getGraphAlerts(graphData.queries)"
|
|
|
|
@setAlerts="setAlerts"
|
|
|
|
/>
|
|
|
|
<gl-dropdown
|
|
|
|
v-gl-tooltip
|
2019-12-21 20:55:43 +05:30
|
|
|
class="ml-2 mr-3"
|
2019-10-12 21:52:04 +05:30
|
|
|
toggle-class="btn btn-transparent border-0"
|
|
|
|
:right="true"
|
|
|
|
:no-caret="true"
|
|
|
|
:title="__('More actions')"
|
|
|
|
>
|
|
|
|
<template slot="button-content">
|
|
|
|
<icon name="ellipsis_v" class="text-secondary" />
|
|
|
|
</template>
|
2019-12-21 20:55:43 +05:30
|
|
|
<gl-dropdown-item
|
|
|
|
v-track-event="downloadCSVOptions(graphData.title)"
|
|
|
|
:href="downloadCsv(graphData)"
|
|
|
|
download="chart_metrics.csv"
|
|
|
|
>
|
2019-10-12 21:52:04 +05:30
|
|
|
{{ __('Download CSV') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<gl-dropdown-item
|
2019-12-21 20:55:43 +05:30
|
|
|
v-track-event="
|
|
|
|
generateLinkToChartOptions(
|
|
|
|
generateLink(groupData.group, graphData.title, graphData.y_label),
|
|
|
|
)
|
|
|
|
"
|
2019-10-12 21:52:04 +05:30
|
|
|
class="js-chart-link"
|
|
|
|
:data-clipboard-text="
|
|
|
|
generateLink(groupData.group, graphData.title, graphData.y_label)
|
|
|
|
"
|
|
|
|
@click="showToast"
|
|
|
|
>
|
|
|
|
{{ __('Generate link to chart') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="alertWidgetAvailable"
|
|
|
|
v-gl-modal="`alert-modal-${index}-${graphIndex}`"
|
|
|
|
>
|
|
|
|
{{ __('Alerts') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
</gl-dropdown>
|
|
|
|
</div>
|
2019-12-04 20:38:33 +05:30
|
|
|
</monitor-time-series-chart>
|
2019-09-30 21:07:59 +05:30
|
|
|
</template>
|
|
|
|
</graph-group>
|
|
|
|
</div>
|
|
|
|
<empty-state
|
|
|
|
v-else
|
|
|
|
:selected-state="emptyState"
|
|
|
|
:documentation-path="documentationPath"
|
|
|
|
:settings-path="settingsPath"
|
|
|
|
:clusters-path="clustersPath"
|
|
|
|
:empty-getting-started-svg-path="emptyGettingStartedSvgPath"
|
|
|
|
:empty-loading-svg-path="emptyLoadingSvgPath"
|
|
|
|
:empty-no-data-svg-path="emptyNoDataSvgPath"
|
|
|
|
:empty-unable-to-connect-svg-path="emptyUnableToConnectSvgPath"
|
|
|
|
:compact="smallEmptyState"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</div>
|
|
|
|
</template>
|