2020-04-16 06:09:39 +00:00
|
|
|
import * as types from '~/monitoring/stores/mutation_types';
|
|
|
|
import { metricsDashboardPayload } from './fixture_data';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { metricsResult, environmentData, dashboardGitResponse } from './mock_data';
|
2020-04-16 06:09:39 +00:00
|
|
|
|
2020-05-19 21:08:05 +00:00
|
|
|
export const setMetricResult = ({ store, result, group = 0, panel = 0, metric = 0 }) => {
|
|
|
|
const { dashboard } = store.state.monitoringDashboard;
|
2020-04-16 06:09:39 +00:00
|
|
|
const { metricId } = dashboard.panelGroups[group].panels[panel].metrics[metric];
|
|
|
|
|
2020-05-19 21:08:05 +00:00
|
|
|
store.commit(`monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`, {
|
2020-04-16 06:09:39 +00:00
|
|
|
metricId,
|
2020-06-17 12:08:42 +00:00
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result,
|
|
|
|
},
|
2020-04-16 06:09:39 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
const setEnvironmentData = (store) => {
|
2020-05-19 21:08:05 +00:00
|
|
|
store.commit(`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`, environmentData);
|
2020-04-16 06:09:39 +00:00
|
|
|
};
|
|
|
|
|
2020-06-02 15:08:24 +00:00
|
|
|
export const setupAllDashboards = (store, path) => {
|
2020-05-19 21:08:05 +00:00
|
|
|
store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, dashboardGitResponse);
|
2020-06-02 15:08:24 +00:00
|
|
|
if (path) {
|
|
|
|
store.commit(`monitoringDashboard/${types.SET_INITIAL_STATE}`, {
|
|
|
|
currentDashboard: path,
|
|
|
|
});
|
|
|
|
}
|
2020-05-15 12:08:28 +00:00
|
|
|
};
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
export const setupStoreWithDashboard = (store) => {
|
2020-05-19 21:08:05 +00:00
|
|
|
store.commit(
|
2020-04-16 06:09:39 +00:00
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
|
|
|
|
metricsDashboardPayload,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
export const setupStoreWithLinks = (store) => {
|
2020-06-04 21:08:11 +00:00
|
|
|
store.commit(`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`, {
|
|
|
|
...metricsDashboardPayload,
|
|
|
|
links: [
|
|
|
|
{
|
|
|
|
title: 'GitLab Website',
|
|
|
|
url: `https://gitlab.com/website`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
export const setupStoreWithData = (store) => {
|
2020-05-19 21:08:05 +00:00
|
|
|
setupAllDashboards(store);
|
|
|
|
setupStoreWithDashboard(store);
|
2020-04-16 06:09:39 +00:00
|
|
|
|
2020-05-19 21:08:05 +00:00
|
|
|
setMetricResult({ store, result: [], panel: 0 });
|
|
|
|
setMetricResult({ store, result: metricsResult, panel: 1 });
|
|
|
|
setMetricResult({ store, result: metricsResult, panel: 2 });
|
2020-04-16 06:09:39 +00:00
|
|
|
|
2020-05-19 21:08:05 +00:00
|
|
|
setEnvironmentData(store);
|
2020-04-16 06:09:39 +00:00
|
|
|
};
|
2020-06-24 18:09:03 +00:00
|
|
|
|
|
|
|
export const setupStoreWithDataForPanelCount = (store, panelCount) => {
|
|
|
|
const payloadPanelGroup = metricsDashboardPayload.panel_groups[0];
|
|
|
|
|
|
|
|
const panelGroupCustom = {
|
|
|
|
...payloadPanelGroup,
|
|
|
|
panels: payloadPanelGroup.panels.slice(0, panelCount),
|
|
|
|
};
|
|
|
|
|
|
|
|
const metricsDashboardPayloadCustom = {
|
|
|
|
...metricsDashboardPayload,
|
|
|
|
panel_groups: [panelGroupCustom],
|
|
|
|
};
|
|
|
|
|
|
|
|
store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
|
|
|
|
metricsDashboardPayloadCustom,
|
|
|
|
);
|
|
|
|
|
|
|
|
setMetricResult({ store, result: metricsResult, panel: 0 });
|
|
|
|
};
|