Skip to content

Commit

Permalink
Fixed logs view visualizations issues.
Browse files Browse the repository at this point in the history
Signed-off-by: Saisanju Sreevalsakumar <saisanju_s@persistent.com>
  • Loading branch information
saisanju-s committed Sep 30, 2022
1 parent ad3a1e4 commit a59bb0a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,34 @@ export const Explorer = ({
[GROUPBY]: [{ bucketSize: '', bucketOffset: '' }],
[AGGREGATIONS]: [],
};
case VIS_CHART_TYPES.LogsView: {
const dimensions = [
...statsToken.aggregations
.map((agg) => ({
label: `${agg.function.name}(${agg.function.value_expression})` ?? '',
name: `${agg.function.name}(${agg.function.value_expression})` ?? '',
}))
.concat(
groupByToken.group_fields?.map((agg) => ({
label: agg.name ?? '',
name: agg.name ?? '',
}))
),
];
if (span !== undefined) {
const { time_field, interval, unit } = span;
const timespanField = `span(${time_field[0].name},${interval}${unit[0].value})`;
dimensions.push({
label: timespanField,
name: timespanField,
});
}
return {
[AGGREGATIONS]: [],
[GROUPBY]: dimensions,
};
}

default:
return {
[AGGREGATIONS]: statsToken.aggregations.map((agg) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export const DataConfigPanelItem = ({
},
},
})
);
});
}
};

const isPositionButtonVisible = (sectionName: string) =>
sectionName === AGGREGATIONS &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const LogsViewConfigPanelItem = ({
const { tabId, curVisId, changeVisualizationConfig } = useContext<any>(TabContext);
const explorerFields = useSelector(selectFields)[tabId];
const { data } = visualizations;
const { availableFields, queriedFields, selectedFields } = data.explorer?.explorerFields;
const { userConfigs } = data;

const initialConfigEntry = {
Expand All @@ -64,7 +65,7 @@ export const LogsViewConfigPanelItem = ({
}, [userConfigs?.dataConfig, visualizations.vis.name]);

useEffect(() => {
if (fieldOptionList.length === 0) {
if (queriedFields.length === 0) {
setConfigList({
[AGGREGATIONS]: [],
[GROUPBY]: visualizations?.data?.explorer?.explorerFields?.selectedFields.map((field) => ({
Expand All @@ -76,7 +77,7 @@ export const LogsViewConfigPanelItem = ({
}, [visualizations.data.explorer.explorerFields]);

const handleServiceRemove = (index: number, name: string) => {
if (fieldOptionList.length !== 0) {
if (queriedFields.length !== 0) {
return;
}
const list = { ...configList };
Expand Down Expand Up @@ -141,7 +142,7 @@ export const LogsViewConfigPanelItem = ({
};

const getAvailableLogsViewOptions = () => {
if (fieldOptionList.length !== 0) {
if (queriedFields.length !== 0) {
return [];
}
const dimensionNames = (configList[GROUPBY] as ConfigListEntry[]).map((field) => field.name);
Expand Down Expand Up @@ -188,7 +189,7 @@ export const LogsViewConfigPanelItem = ({
singleSelection={{ asPlainText: true }}
options={getAvailableLogsViewOptions()}
selectedOptions={[{ label: field.label }]}
isDisabled={fieldOptionList.length !== 0}
isDisabled={queriedFields.length !== 0}
onChange={(e) =>
updateLogsViewConfig(e.length > 0 ? e[0].label : '', field as ConfigListEntry)
}
Expand All @@ -206,7 +207,7 @@ export const LogsViewConfigPanelItem = ({
iconType="plusInCircleFilled"
color="primary"
onClick={() => handleServiceAdd(GROUPBY)}
disabled={fieldOptionList.length !== 0}
disabled={queriedFields.length !== 0}
>
Add
</EuiButton>
Expand Down Expand Up @@ -236,7 +237,7 @@ export const LogsViewConfigPanelItem = ({
iconType="play"
onClick={updateChart}
size="s"
isDisabled={fieldOptionList.length !== 0}
isDisabled={queriedFields.length !== 0}
>
Update chart
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,31 @@ const defaultUserConfigs = (queryString, visualizationName: string) => {
},
};
if (visualizationName === VIS_CHART_TYPES.LogsView) {
tempUserConfigs = {
...tempUserConfigs,
[AGGREGATIONS]: [],
[GROUPBY]: statsTokens.aggregations
const dimensions = [
...statsTokens.aggregations
.map((agg) => ({
label: agg.name ?? '',
name: agg.name ?? '',
label: `${agg.function.name}(${agg.function.value_expression})` ?? '',
name: `${agg.function.name}(${agg.function.value_expression})` ?? '',
}))
.concat(
statsTokens.groupby?.group_fields?.map((agg) => ({
statsTokens.groupby.group_fields?.map((agg) => ({
label: agg.name ?? '',
name: agg.name ?? '',
}))
),
];
if (statsTokens.groupby.span !== null) {
const { field, literal_value, time_unit } = statsTokens.groupby.span.span_expression;
const timespanField = `span(${field},${literal_value}${time_unit})`;
dimensions.push({
label: timespanField,
name: timespanField,
});
}
tempUserConfigs = {
...tempUserConfigs,
[AGGREGATIONS]: [],
[GROUPBY]: dimensions,
};
} else if (visualizationName === VIS_CHART_TYPES.HeatMap) {
tempUserConfigs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ export const TreeMap = ({ visualizations, layout, config }: any) => {
: fields[0];

const colorField =
dataConfig?.chartStyles && dataConfig.chartStyles.colorTheme
? dataConfig.chartStyles.colorTheme
: { name: DEFAULT_PALETTE };

const tilingAlgorithm =
dataConfig?.treemapOptions &&
dataConfig.treemapOptions.tilingAlgorithm &&
!isEmpty(dataConfig.treemapOptions.tilingAlgorithm)
? dataConfig.treemapOptions.tilingAlgorithm[0]
: 'squarify';
Expand Down

0 comments on commit a59bb0a

Please sign in to comment.