Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes when user deletes Aggregation field #1047

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Aggregations extends PPLNode {
all_num: this.allNum,
delim: this.delim,
aggregations: this.aggExprList.map((aggTerm) => aggTerm.getTokens()),
groupby: this.groupExprList.getTokens(),
groupby: !isEmpty(this.groupExprList) ? this.groupExprList.getTokens() : '',
dedup_split_value: this.dedupSplitValue,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ $vis-editor-sidebar-min-width: 350px;
}
}

.info-icon {
margin-left: 7px;
margin-top: 5px;
}

#vis__mainContent .vis__leftPanel {
overflow-y: unset; // unset default setting
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EuiText,
EuiFieldNumber,
htmlIdGenerator,
EuiToolTip,
} from '@elastic/eui';
import { useDispatch, batch } from 'react-redux';
import { changeQuery } from '../../../../../redux/slices/query_slice';
Expand Down Expand Up @@ -249,11 +250,18 @@ export const DataConfigPanelItem = ({
labelAppend={
visualizations.vis.name !== VIS_CHART_TYPES.HeatMap && (
<EuiText size="xs">
<EuiIcon
type="cross"
color="danger"
onClick={() => handleServiceRemove(index, sectionName)}
/>
<EuiToolTip
position="bottom"
content="At least one metric is required to render a chart"
delay="regular"
anchorClassName="eui-textTruncate"
>
<EuiIcon
type="cross"
color="danger"
onClick={() => handleServiceRemove(index, sectionName)}
/>
</EuiToolTip>
</EuiText>
)
}
Expand Down Expand Up @@ -503,9 +511,19 @@ export const DataConfigPanelItem = ({
<EuiSpacer size="s" />
{visualizations.vis.name !== VIS_CHART_TYPES.Histogram ? (
<>
<EuiTitle size="xxs">
<h3>Series</h3>
</EuiTitle>
<div style={{ display: 'flex' }}>
<EuiTitle size="xxs">
<h3>Series</h3>
</EuiTitle>
<EuiToolTip
position="right"
content="At least one metric is required to render a chart"
delay="regular"
anchorClassName="eui-textTruncate"
>
<EuiIcon type="iInCircle" color="text" size="m" className="info-icon" />
</EuiToolTip>
</div>
<EuiSpacer size="s" />
{getCommonUI(configList[AGGREGATIONS], AGGREGATIONS)}
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const TreemapConfigPanelItem = ({

const unselectedFields = fieldOptionList.filter((field) => !selectedFields[field.label]);
return sectionName === AGGREGATIONS
? unselectedFields.filter((field) => NUMERICAL_TYPES.includes(field.type))
? unselectedFields.filter((field) => NUMERICAL_TYPES?.includes(field.type))
: unselectedFields;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const Bar = ({ visualizations, layout, config }: any) => {
* prepare data for visualization, map x-xais to y-xais
*/
const chartAxis = useMemo(() => {
return Array.isArray(queriedVizData[`${yaxes[0].aggregation}(${yaxes[0].name})`])
return yaxes[0] && Array.isArray(queriedVizData[`${yaxes[0].aggregation}(${yaxes[0].name})`])
? queriedVizData[`${yaxes[0].aggregation}(${yaxes[0].name})`].map((_, idx) => {
// let combineXaxis = '';
const xaxisName = xaxes.map((xaxis) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Gauge = ({ visualizations, layout, config }: any) => {
calculatedGaugeData = series.map((seriesItem: any) => {
return {
field_name: seriesItem.name,
value: queriedVizData[seriesItem.name][0],
value: queriedVizData[seriesItem.name] ? queriedVizData[seriesItem.name][0] : '',
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const Line = ({ visualizations, layout, config }: any) => {
}: IVisualizationContainerProps = visualizations;
const { dataConfig = {}, layoutConfig = {}, availabilityConfig = {} } = userConfigs;

const yaxis = dataConfig[AGGREGATIONS] ? dataConfig[AGGREGATIONS].filter((item) => item.label) : [];
const yaxis = dataConfig[AGGREGATIONS]
? dataConfig[AGGREGATIONS].filter((item) => item.label)
: [];
const tooltipMode =
dataConfig?.tooltipOptions?.tooltipMode !== undefined
? dataConfig.tooltipOptions.tooltipMode
Expand Down Expand Up @@ -86,13 +88,12 @@ export const Line = ({ visualizations, layout, config }: any) => {
const timestampField = find(fields, (field) => field.type === 'timestamp');

if (dataConfig.span && dataConfig.span.time_field && timestampField) {
xaxis = [timestampField, ...dataConfig[GROUPBY]];
xaxis = dataConfig[GROUPBY] ? [timestampField, ...dataConfig[GROUPBY]] : [timestampField, []];
} else {
xaxis = dataConfig[GROUPBY];
}

if (isEmpty(xaxis) || isEmpty(yaxis))
return <EmptyPlaceholder icon={visMetaData?.icontype} />;
if (isEmpty(xaxis) || isEmpty(yaxis)) return <EmptyPlaceholder icon={visMetaData?.icontype} />;

let valueSeries;
if (!isEmpty(xaxis) && !isEmpty(yaxis)) {
Expand Down Expand Up @@ -206,7 +207,9 @@ export const Line = ({ visualizations, layout, config }: any) => {
const mapToLine = (list: ThresholdUnitType[] | AvailabilityUnitType[], lineStyle: any) => {
return list.map((thr: ThresholdUnitType) => {
thresholdTraces.x.push(
queriedVizData[!isEmpty(xaxis) ? xaxis[xaxis.length - 1]?.label : fields[lastIndex].name][0]
queriedVizData[
!isEmpty(xaxis) ? xaxis[xaxis.length - 1]?.label : fields[lastIndex].name
][0]
);
thresholdTraces.y.push(thr.value * (1 + 0.06));
thresholdTraces.text.push(thr.name);
Expand Down