2020-04-16 02:09:39 -04:00
|
|
|
import * as types from '~/monitoring/stores/mutation_types';
|
2020-05-15 08:08:28 -04:00
|
|
|
import { metricsResult, environmentData, dashboardGitResponse } from './mock_data';
|
2020-04-16 02:09:39 -04:00
|
|
|
import { metricsDashboardPayload } from './fixture_data';
|
|
|
|
|
|
|
|
export const setMetricResult = ({ $store, result, group = 0, panel = 0, metric = 0 }) => {
|
|
|
|
const { dashboard } = $store.state.monitoringDashboard;
|
|
|
|
const { metricId } = dashboard.panelGroups[group].panels[panel].metrics[metric];
|
|
|
|
|
|
|
|
$store.commit(`monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`, {
|
|
|
|
metricId,
|
|
|
|
result,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const setEnvironmentData = $store => {
|
|
|
|
$store.commit(`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`, environmentData);
|
|
|
|
};
|
|
|
|
|
2020-05-15 08:08:28 -04:00
|
|
|
export const setupAllDashboards = $store => {
|
|
|
|
$store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, dashboardGitResponse);
|
|
|
|
};
|
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
export const setupStoreWithDashboard = $store => {
|
|
|
|
$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
|
|
|
|
metricsDashboardPayload,
|
|
|
|
);
|
2020-05-15 08:08:28 -04:00
|
|
|
$store.commit(
|
|
|
|
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
|
|
|
|
metricsDashboardPayload,
|
|
|
|
);
|
2020-04-16 02:09:39 -04:00
|
|
|
};
|
|
|
|
|
2020-05-11 11:09:37 -04:00
|
|
|
export const setupStoreWithVariable = $store => {
|
2020-05-13 17:08:55 -04:00
|
|
|
$store.commit(`monitoringDashboard/${types.SET_VARIABLES}`, {
|
2020-05-11 11:09:37 -04:00
|
|
|
label1: 'pod',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
export const setupStoreWithData = $store => {
|
2020-05-15 08:08:28 -04:00
|
|
|
setupAllDashboards($store);
|
2020-04-16 02:09:39 -04:00
|
|
|
setupStoreWithDashboard($store);
|
|
|
|
|
|
|
|
setMetricResult({ $store, result: [], panel: 0 });
|
|
|
|
setMetricResult({ $store, result: metricsResult, panel: 1 });
|
|
|
|
setMetricResult({ $store, result: metricsResult, panel: 2 });
|
|
|
|
|
|
|
|
setEnvironmentData($store);
|
|
|
|
};
|