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

[Backport 4.3-7.16] Enhancement/4211 improve visualizations text size #4275

Merged
merged 1 commit into from
Jun 17, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the Wazuh app project will be documented in this file.
### Changed

- Changed the reference from Manager to Wazuh server in the guide to deploy a new agent [#4239](https://github.com/wazuh/wazuh-kibana-app/pull/4239)
- Changed styles in visualizations. [#4254](https://github.com/wazuh/wazuh-kibana-app/pull/4254)

### Fixed

Expand Down
2 changes: 0 additions & 2 deletions public/components/agents/vuls/inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {
EuiFlexItem,
EuiCard,
EuiStat,
EuiText,
EuiIcon,
EuiToolTip,
euiPaletteColorBlind,
} from '@elastic/eui';
Expand Down
2 changes: 1 addition & 1 deletion public/components/agents/vuls/inventory/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import React, { Component } from 'react';
import { Direction, EuiOverlayMask, EuiOutsideClickDetector } from '@elastic/eui';
import { Direction } from '@elastic/eui';
import { FlyoutDetail } from './flyout';
import { filtersToObject, IFilter, IWzSuggestItem } from '../../../wz-search-bar';
import { TableWzAPI } from '../../../../components/common/tables';
Expand Down
48 changes: 24 additions & 24 deletions public/components/common/charts/visualizations/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useCallback, useState} from "react";
import React, { useCallback, useState } from "react";
import { ChartLegend } from "./legend";
import { ChartDonut, ChartDonutProps } from '../charts/donut';
import { EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, EuiLoadingChart, EuiText, EuiSelect, EuiSpacer } from '@elastic/eui';
import { useAsyncActionRunOnStart } from "../../hooks";

export type VisualizationBasicProps = ChartDonutProps & {
type: 'donut',
size: number | string | {width: number | string, height: number | string}
size: number | string | { width: number | string, height: number | string }
showLegend?: boolean
isLoading?: boolean
noDataTitle?: string
noDataMessage?: string | (() => React.node)
errorTitle?: string
errorMessage?: string | (() => React.node)
error?: {message: string}
error?: { message: string }
}

const chartTypes = {
Expand All @@ -37,45 +37,45 @@ export const VisualizationBasic = ({
error
}: VisualizationBasicProps) => {
const { width, height } = typeof size === 'object' ? size : { width: size, height: size };

let visualization = null;

if(isLoading){
if (isLoading) {
visualization = (
<div style={{ textAlign: "center", width, height, position: 'relative'}}>
<EuiLoadingChart size="xl" style={{top: '50%', transform:'translate(-50%, -50%)', position: 'absolute'}}/>
<div style={{ textAlign: "center", width, height, position: 'relative' }}>
<EuiLoadingChart size="xl" style={{ top: '50%', transform: 'translate(-50%, -50%)', position: 'absolute' }} />
</div>
)
}else if(errorMessage || error?.message){
} else if (errorMessage || error?.message) {
visualization = (
<EuiEmptyPrompt
iconType="alert"
title={<h4>{errorTitle}</h4>}
body={errorMessage || error?.message}
/>
)
}else if(!data || (Array.isArray(data) && !data.length)){
} else if (!data || (Array.isArray(data) && !data.length)) {
visualization = (
<EuiEmptyPrompt
iconType="stats"
title={<h4>{noDataTitle}</h4>}
body={typeof noDataMessage === 'function' ? noDataMessage() : noDataMessage}
/>
)
}else{
} else {
const Chart = chartTypes[type];
const chartFlexStyle = {
alignItems: 'flex-end',
paddingRight: '1em'
}
const legendFlexStyle = {
height:'100%',
height: '100%',
paddingLeft: '1em'
}
visualization = (
<EuiFlexGroup responsive={false} style={{ height:'100%'}} gutterSize='none'>
<EuiFlexGroup responsive={false} style={{ height: '100%' }} gutterSize='none'>
<EuiFlexItem style={chartFlexStyle}>
<Chart data={data}/>
<Chart data={data} />
</EuiFlexItem>
{showLegend && (
<EuiFlexItem style={legendFlexStyle}>
Expand All @@ -89,7 +89,7 @@ export const VisualizationBasic = ({
}

return (
<div style={{ width, height}}>
<div style={{ width, height }}>
{visualization}
</div>
)
Expand All @@ -104,26 +104,26 @@ type VisualizationBasicWidgetProps = VisualizationBasicProps & {
/**
* Component that fetch the data and renders the visualization using the visualization basic component
*/
export const VisualizationBasicWidget = ({onFetch, onFetchDependencies, ...rest}: VisualizationBasicWidgetProps) => {
const {running, ...restAsyncAction} = useAsyncActionRunOnStart(onFetch, onFetchDependencies);
export const VisualizationBasicWidget = ({ onFetch, onFetchDependencies, ...rest }: VisualizationBasicWidgetProps) => {
const { running, ...restAsyncAction } = useAsyncActionRunOnStart(onFetch, onFetchDependencies);

return <VisualizationBasic {...rest} {...restAsyncAction} isLoading={running}/>
return <VisualizationBasic {...rest} {...restAsyncAction} isLoading={running} />
}

type VisualizationBasicWidgetSelectorProps = VisualizationBasicWidgetProps & {
selectorOptions: {value: any, text: string}[]
selectorOptions: { value: any, text: string }[]
title?: string
onFetchExtraDependencies?: any[]
}

/**
* Renders a visualization that has a selector to change the resource to fetch data and display it. Use the visualization basic.
*/
export const VisualizationBasicWidgetSelector = ({selectorOptions, title, onFetchExtraDependencies, ...rest}: VisualizationBasicWidgetSelectorProps) => {
export const VisualizationBasicWidgetSelector = ({ selectorOptions, title, onFetchExtraDependencies, ...rest }: VisualizationBasicWidgetSelectorProps) => {
const [selectedOption, setSelectedOption] = useState(selectorOptions[0].value);

const onChange = useCallback((e) => setSelectedOption(e.target.value));

return (
<>
<EuiFlexGroup
Expand All @@ -137,7 +137,7 @@ export const VisualizationBasicWidgetSelector = ({selectorOptions, title, onFetc
)}
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSelect
<EuiSelect style={{ fontSize: '0.793rem' }}
compressed={true}
options={selectorOptions}
value={selectedOption}
Expand All @@ -146,7 +146,7 @@ export const VisualizationBasicWidgetSelector = ({selectorOptions, title, onFetc
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size='s'/>
<EuiSpacer size='s' />
<VisualizationBasicWidget
{...rest}
{...(rest.noDataMessage ?
Expand All @@ -157,8 +157,8 @@ export const VisualizationBasicWidgetSelector = ({selectorOptions, title, onFetc
}
: {}
)}
onFetchDependencies={[selectedOption,...(onFetchExtraDependencies || [])]}
onFetchDependencies={[selectedOption, ...(onFetchExtraDependencies || [])]}
/>
</>
)
)
}
2 changes: 1 addition & 1 deletion public/components/common/charts/visualizations/legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ChartLegendProps = {
*/
export function ChartLegend({ data }: ChartLegendProps) {
const list = data.map(({label, labelColor, value, ...rest}, idx) => ({
label: `${label} (${value})`,
label: <div style={{fontSize: '0.875rem'}}>{`${label} (${value})`}</div>,
icon: <EuiIcon type="dot" size='l' color={labelColor} />,
...rest
}));
Expand Down