Skip to content

Commit

Permalink
[Exploratory View] Polish design and layout fixes (elastic#98123)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
shahzad31 and kibanamachine authored Apr 28, 2021
1 parent d310633 commit 5023dce
Show file tree
Hide file tree
Showing 56 changed files with 705 additions and 454 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ export function PageLoadDistribution() {
const exploratoryViewLink = createExploratoryViewUrl(
{
[`${serviceName}-page-views`]: {
dataType: 'ux',
reportType: 'pld',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName?.[0] as string,
'service.name': serviceName as string[],
},
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
},
},
http?.basePath.get()
);

const showAnalyzeButton = false;

return (
<div data-cy="pageLoadDist">
<EuiFlexGroup responsive={false}>
Expand All @@ -118,18 +121,20 @@ export function PageLoadDistribution() {
dataTestSubj={'pldBreakdownFilter'}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
size="s"
isDisabled={!serviceName?.[0]}
href={exploratoryViewLink}
>
<FormattedMessage
id="xpack.apm.csm.pageViews.analyze"
defaultMessage="Analyze"
/>
</EuiButton>
</EuiFlexItem>
{showAnalyzeButton && (
<EuiFlexItem grow={false}>
<EuiButton
size="s"
isDisabled={!serviceName?.[0]}
href={exploratoryViewLink}
>
<FormattedMessage
id="xpack.apm.csm.pageViews.analyze"
defaultMessage="Analyze"
/>
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
<EuiSpacer size="m" />
<PageLoadDistChart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ export function PageViewsTrend() {
const exploratoryViewLink = createExploratoryViewUrl(
{
[`${serviceName}-page-views`]: {
dataType: 'ux',
reportType: 'kpi',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName?.[0] as string,
'service.name': serviceName as string[],
},
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
},
},
http?.basePath.get()
);

const showAnalyzeButton = false;

return (
<div>
<EuiFlexGroup responsive={false}>
Expand All @@ -89,18 +92,20 @@ export function PageViewsTrend() {
dataTestSubj={'pvBreakdownFilter'}
/>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ width: 170 }}>
<EuiButton
size="s"
isDisabled={!serviceName?.[0]}
href={exploratoryViewLink}
>
<FormattedMessage
id="xpack.apm.csm.pageViews.analyze"
defaultMessage="Analyze"
/>
</EuiButton>
</EuiFlexItem>
{showAnalyzeButton && (
<EuiFlexItem grow={false} style={{ width: 170 }}>
<EuiButton
size="s"
isDisabled={!serviceName?.[0]}
href={exploratoryViewLink}
>
<FormattedMessage
id="xpack.apm.csm.pageViews.analyze"
defaultMessage="Analyze"
/>
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
<EuiSpacer size="s" />
<PageViewsChart data={data} loading={status !== 'success'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const Page = styled(EuiPage)<EuiPageProps>`

const Container = styled.div<{ color?: string }>`
overflow-y: hidden;
min-height: calc(100vh - ${(props) => props.theme.eui.euiHeaderChildSize});
min-height: calc(
100vh - ${(props) => props.theme.eui.euiHeaderHeight + props.theme.eui.euiHeaderHeight}
);
background: ${(props) => props.color};
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,40 @@
*/

import React from 'react';
import { EuiImage, EuiProgress, EuiSpacer, EuiText } from '@elastic/eui';
import { isEmpty } from 'lodash';
import { EuiFlexGroup, EuiFlexItem, EuiProgress, EuiSpacer, EuiText } from '@elastic/eui';
import styled from 'styled-components';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { INITIATING_VIEW } from '../series_builder/series_builder';
import { i18n } from '@kbn/i18n';
import { LOADING_VIEW } from '../series_builder/series_builder';
import { SeriesUrl } from '../types';

export function EmptyView({ loading }: { loading: boolean }) {
const {
services: { http },
} = useKibana();
export function EmptyView({
loading,
height,
series,
}: {
loading: boolean;
height: string;
series: SeriesUrl;
}) {
const { dataType, reportType, reportDefinitions } = series ?? {};

let emptyMessage = EMPTY_LABEL;

if (dataType) {
if (reportType) {
if (isEmpty(reportDefinitions)) {
emptyMessage = CHOOSE_REPORT_DEFINITION;
}
} else {
emptyMessage = SELECT_REPORT_TYPE_BELOW;
}
} else {
emptyMessage = SELECTED_DATA_TYPE_FOR_REPORT;
}

return (
<Wrapper>
<Wrapper height={height}>
{loading && (
<EuiProgress
size="xs"
Expand All @@ -29,21 +51,44 @@ export function EmptyView({ loading }: { loading: boolean }) {
/>
)}
<EuiSpacer />
<ImageWrap
alt="Visulization"
url={http!.basePath.prepend(`/plugins/observability/assets/kibana_dashboard_light.svg`)}
/>
<EuiText>{INITIATING_VIEW}</EuiText>
<FlexGroup justifyContent="center" alignItems="center">
<EuiFlexItem>
<EuiText>{loading ? LOADING_VIEW : emptyMessage}</EuiText>
</EuiFlexItem>
</FlexGroup>
</Wrapper>
);
}

const ImageWrap = styled(EuiImage)`
opacity: 0.4;
`;

const Wrapper = styled.div`
const Wrapper = styled.div<{ height: string }>`
text-align: center;
height: 550px;
height: ${(props) => props.height};
position: relative;
`;

const FlexGroup = styled(EuiFlexGroup)`
height: 100%;
`;

export const EMPTY_LABEL = i18n.translate('xpack.observability.expView.seriesBuilder.emptyview', {
defaultMessage: 'Nothing to display.',
});

export const CHOOSE_REPORT_DEFINITION = i18n.translate(
'xpack.observability.expView.seriesBuilder.emptyReportDefinition',
{
defaultMessage: 'Please choose a report definition below to visualize.',
}
);

export const SELECT_REPORT_TYPE_BELOW = i18n.translate(
'xpack.observability.expView.seriesBuilder.selectReportType.empty',
{
defaultMessage: 'Please Select a report type below to define visualization.',
}
);

const SELECTED_DATA_TYPE_FOR_REPORT = i18n.translate(
'xpack.observability.expView.reportType.selectDataType',
{ defaultMessage: 'Please Select a data type below to start building a series.' }
);
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const FieldLabels: Record<string, string> = {
'monitor.name': 'Monitor name',
'monitor.type': 'Monitor Type',
'url.port': 'Port',
'url.full': 'Url',
'url.full': 'URL',
tags: 'Tags',

// custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export enum URL_KEYS {
DATA_TYPE = 'dt',
OPERATION_TYPE = 'op',
REPORT_TYPE = 'rt',
SERIES_TYPE = 'st',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getDefaultConfigs = ({ reportType, seriesId, indexPattern }: Props)
case 'kpi-trends':
return getKPITrendsLensConfig({ seriesId, indexPattern });
case 'uptime-duration':
return getMonitorDurationConfig({ seriesId });
return getMonitorDurationConfig({ seriesId, indexPattern });
case 'uptime-pings':
return getMonitorPingsConfig({ seriesId, indexPattern });
case 'service-latency':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Lens Attribute', () => {

it('should return expected field type for custom field with passed value', function () {
lnsAttr = new LensAttributes(mockIndexPattern, reportViewConfig, 'line', [], 'count', {
'performance.metric': LCP_FIELD,
'performance.metric': [LCP_FIELD],
});

expect(JSON.stringify(lnsAttr.getFieldMeta('performance.metric'))).toEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
IndexPattern,
} from '../../../../../../../../src/plugins/data/common';
import { FieldLabels } from './constants';
import { DataSeries, UrlFilter } from '../types';
import { DataSeries, UrlFilter, URLReportDefinition } from '../types';

function getLayerReferenceName(layerId: string) {
return `indexpattern-datasource-layer-${layerId}`;
Expand All @@ -49,7 +49,7 @@ function buildNumberColumn(sourceField: string) {
export const parseCustomFieldName = (
sourceField: string,
reportViewConfig: DataSeries,
selectedDefinitions: Record<string, string>
selectedDefinitions: URLReportDefinition
) => {
let fieldName = sourceField;
let columnType;
Expand All @@ -60,7 +60,7 @@ export const parseCustomFieldName = (

if (customField) {
if (selectedDefinitions[fieldName]) {
fieldName = selectedDefinitions[fieldName];
fieldName = selectedDefinitions[fieldName][0];
if (customField?.options)
columnType = customField?.options?.find(({ field }) => field === fieldName)?.columnType;
} else if (customField.defaultValue) {
Expand All @@ -81,15 +81,15 @@ export class LensAttributes {
filters: UrlFilter[];
seriesType: SeriesType;
reportViewConfig: DataSeries;
reportDefinitions: Record<string, string>;
reportDefinitions: URLReportDefinition;

constructor(
indexPattern: IndexPattern,
reportViewConfig: DataSeries,
seriesType?: SeriesType,
filters?: UrlFilter[],
operationType?: OperationType,
reportDefinitions?: Record<string, string>
reportDefinitions?: URLReportDefinition
) {
this.indexPattern = indexPattern;
this.layers = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
* 2.0.
*/

import { DataSeries } from '../../types';
import { ConfigProps, DataSeries } from '../../types';
import { FieldLabels } from '../constants';
import { buildExistsFilter } from '../utils';

interface Props {
seriesId: string;
}

export function getMonitorDurationConfig({ seriesId }: Props): DataSeries {
export function getMonitorDurationConfig({ seriesId, indexPattern }: ConfigProps): DataSeries {
return {
id: seriesId,
reportType: 'uptime-duration',
Expand All @@ -29,7 +26,7 @@ export function getMonitorDurationConfig({ seriesId }: Props): DataSeries {
},
],
hasOperationType: true,
defaultFilters: ['monitor.type', 'observer.geo.name', 'tags', 'monitor.name', 'monitor.id'],
defaultFilters: ['monitor.type', 'observer.geo.name', 'tags'],
breakdowns: [
'observer.geo.name',
'monitor.name',
Expand All @@ -38,11 +35,8 @@ export function getMonitorDurationConfig({ seriesId }: Props): DataSeries {
'tags',
'url.port',
],
filters: [],
filters: [...buildExistsFilter('summary.up', indexPattern)],
reportDefinitions: [
{
field: 'monitor.id',
},
{
field: 'monitor.name',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import { ConfigProps, DataSeries } from '../../types';
import { FieldLabels } from '../constants';
import { buildExistsFilter } from '../utils';

export function getMonitorPingsConfig({ seriesId }: ConfigProps): DataSeries {
export function getMonitorPingsConfig({ seriesId, indexPattern }: ConfigProps): DataSeries {
return {
id: seriesId,
reportType: 'uptime-pings',
Expand All @@ -31,17 +32,14 @@ export function getMonitorPingsConfig({ seriesId }: ConfigProps): DataSeries {
],
yTitle: 'Pings',
hasOperationType: false,
defaultFilters: ['observer.geo.name', 'monitor.type', 'monitor.name', 'monitor.id'],
defaultFilters: ['observer.geo.name', 'monitor.type', 'tags'],
breakdowns: ['observer.geo.name', 'monitor.type'],
filters: [],
filters: [...buildExistsFilter('summary.up', indexPattern)],
palette: { type: 'palette', name: 'status' },
reportDefinitions: [
{
field: 'monitor.name',
},
{
field: 'monitor.id',
},
{
field: 'url.full',
},
Expand Down
Loading

0 comments on commit 5023dce

Please sign in to comment.