Skip to content

Commit

Permalink
Bug fixes and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harshada8989 committed Oct 17, 2022
1 parent 0d9fb00 commit ae71080
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
4 changes: 2 additions & 2 deletions dashboards-observability/common/query_manager/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const composeAggregations = (
},
})),
groupby: {
group_fields: aggConfig.dimensions.map((dimension) => ({ name: dimension.name })),
group_fields: aggConfig?.dimensions.map((dimension) => ({ name: dimension.name })),
...(aggConfig.span &&
JSON.stringify(aggConfig.span) !== '{}' && { span: composeSpan(aggConfig.span) }),
JSON.stringify(aggConfig?.span) !== '{}' && { span: composeSpan(aggConfig.span) }),
},
partitions: staleStats?.partitions ?? {},
all_num: staleStats?.all_num ?? {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const DataConfigPanelFields = ({
<EuiLink
role="button"
tabIndex={0}
onClick={() => handleServiceEdit(list.length, GROUPBY, true)}
onClick={() => handleServiceEdit(list.length - 1, GROUPBY, true)}
>
{`${SPAN}(${time_field[0]?.name}, ${interval} ${unit[0]?.value})`}
</EuiLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
EuiTitle,
htmlIdGenerator,
} from '@elastic/eui';
import { filter } from 'lodash';
import { filter, isEmpty } from 'lodash';
import { batch, useDispatch } from 'react-redux';
import {
AGGREGATIONS,
Expand Down Expand Up @@ -154,7 +154,7 @@ export const DataConfigPanelItem = ({
[name]:
name !== `${BREAKDOWNS}`
? [
...configList[name],
...(configList[name] ?? []),
name === AGGREGATIONS ? initialSeriesEntry : initialDimensionEntry,
]
: configList[name] !== undefined
Expand All @@ -179,25 +179,27 @@ export const DataConfigPanelItem = ({

const handleClosePanel = () => {
const { index, name } = selectedConfigItem;
const selectedObj = configList[name][index];
const list = { ...configList };
if (
selectedObj?.aggregation !== 'count' &&
(selectedObj?.aggregation === '' || selectedObj?.name === '')
) {
list[name].splice(index, 1);
}
if (isTimeStampSelected) {
if (selectedObj?.name !== '') {
const updConfig = [...configList[name]];
updConfig.splice(index, 1);
list[GROUPBY] = [...updConfig];
if (index > -1) {
const selectedObj = configList[name][index] ?? [];
const list = { ...configList };
if (
selectedObj?.aggregation !== 'count' &&
(selectedObj?.aggregation === '' || selectedObj?.name === '')
) {
list[name].splice(index, 1);
}
if (configList.span?.interval === 0 || configList.span?.unit?.length === 0) {
delete list[SPAN];
if (isTimeStampSelected) {
if (selectedObj?.name !== '') {
const updConfig = [...configList[name]];
updConfig.splice(index, 1);
list[GROUPBY] = [...updConfig];
}
if (configList.span?.interval === 0 || configList.span?.unit?.length === 0) {
delete list[SPAN];
}
}
setConfigList(list);
}
setConfigList(list);
setIsTimeStampSelected(false);
setIsAddConfigClicked(false);
};
Expand Down Expand Up @@ -246,7 +248,10 @@ export const DataConfigPanelItem = ({
[GROUPBY]: updatedConfigList[GROUPBY],
[AGGREGATIONS]: updatedConfigList[AGGREGATIONS],
[BREAKDOWNS]: updatedConfigList[BREAKDOWNS],
span: updatedConfigList?.span,
[SPAN]:
!isEmpty(updatedConfigList[GROUPBY]) && !isEmpty(updatedConfigList[AGGREGATIONS])
? updatedConfigList?.span
: undefined,
},
},
})
Expand All @@ -261,7 +266,7 @@ export const DataConfigPanelItem = ({
visualizations.vis.name === VIS_CHART_TYPES.Scatter);

const getTimeStampFilteredFields = (options: IField[]) =>
filter(options, (i) => i.type !== TIMESTAMP);
filter(options, (i: IField) => i.type !== TIMESTAMP);

const getOptionsAvailable = (sectionName: string) => {
const selectedFields = {};
Expand All @@ -273,7 +278,7 @@ export const DataConfigPanelItem = ({
visualizations.vis.name === VIS_CHART_TYPES.Scatter
)
return filter(unselectedFields, (i) => i.type === TIMESTAMP);
if (!isTimeStampSelected && configList.span?.time_field.length > 0)
if (!isTimeStampSelected && !isEmpty(configList.span?.time_field))
return getTimeStampFilteredFields(unselectedFields);
if (
(selectedConfigItem.name === GROUPBY && selectedConfigItem.index === 0) ||
Expand Down Expand Up @@ -373,7 +378,7 @@ export const DataConfigPanelItem = ({
}
: { ...configList[SPAN], [field]: value },
};
if (field === TIME_FIELD) {
if (field === TIME_FIELD && index > -1) {
handleServiceRemove(index, name);
}
setIsTimeStampSelected(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ const defaultUserConfigs = (queryString, visualizationName: string) => {
[GROUPBY]: [],
};
} else {
tempUserConfigs = { ...(statsTokens.groupby?.span !== null && getSpanValue(statsTokens)) };
tempUserConfigs = {
...(statsTokens.groupby !== '' &&
statsTokens.groupby?.span !== null &&
getSpanValue(statsTokens)),
};
if (visualizationName === VIS_CHART_TYPES.LogsView) {
const dimensions = statsTokens.aggregations
.map((agg) => {
Expand Down

0 comments on commit ae71080

Please sign in to comment.