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