2020-08-21 08:10:22 -04:00
|
|
|
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { metricStates } from '~/monitoring/constants';
|
|
|
|
import { mapToDashboardViewModel } from '~/monitoring/stores/utils';
|
|
|
|
import { stateAndPropsFromDataset } from '~/monitoring/utils';
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
import { metricsResult } from './mock_data';
|
|
|
|
|
|
|
|
// Use globally available `getJSONFixture` so this file can be imported by both karma and jest specs
|
|
|
|
export const metricsDashboardResponse = getJSONFixture(
|
|
|
|
'metrics_dashboard/environment_metrics_dashboard.json',
|
|
|
|
);
|
2020-07-15 17:09:26 -04:00
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
export const metricsDashboardPayload = metricsDashboardResponse.dashboard;
|
2020-06-30 08:08:57 -04:00
|
|
|
|
2020-07-01 17:08:51 -04:00
|
|
|
const datasetState = stateAndPropsFromDataset(
|
2020-08-21 08:10:22 -04:00
|
|
|
convertObjectPropsToCamelCase(metricsDashboardResponse.metrics_data),
|
2020-06-30 08:08:57 -04:00
|
|
|
);
|
|
|
|
|
2020-07-15 17:09:26 -04:00
|
|
|
// new properties like addDashboardDocumentationPath prop and alertsEndpoint
|
|
|
|
// was recently added to dashboard.vue component this needs to be
|
|
|
|
// added to fixtures data
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/issues/229256
|
|
|
|
export const dashboardProps = {
|
|
|
|
...datasetState.dataProps,
|
|
|
|
alertsEndpoint: null,
|
|
|
|
};
|
2020-06-30 08:08:57 -04:00
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
export const metricsDashboardViewModel = mapToDashboardViewModel(metricsDashboardPayload);
|
|
|
|
|
|
|
|
export const metricsDashboardPanelCount = 22;
|
2020-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
// Graph data
|
|
|
|
|
|
|
|
const firstPanel = metricsDashboardViewModel.panelGroups[0].panels[0];
|
|
|
|
|
|
|
|
export const graphData = {
|
|
|
|
...firstPanel,
|
2020-12-23 19:10:25 -05:00
|
|
|
metrics: firstPanel.metrics.map((metric) => ({
|
2020-04-21 11:21:10 -04:00
|
|
|
...metric,
|
|
|
|
result: metricsResult,
|
|
|
|
state: metricStates.OK,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
export const graphDataEmpty = {
|
|
|
|
...firstPanel,
|
2020-12-23 19:10:25 -05:00
|
|
|
metrics: firstPanel.metrics.map((metric) => ({
|
2020-04-21 11:21:10 -04:00
|
|
|
...metric,
|
|
|
|
result: [],
|
|
|
|
state: metricStates.NO_DATA,
|
|
|
|
})),
|
|
|
|
};
|