Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Mar 15, 2021
1 parent 9677edd commit e715ace
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { AppDataType, ReportViewType, ReportViewTypeId } from '../types';
import { AppDataType, ReportViewTypeId } from '../types';

export const METRIC_TYPE = 'mt';
export const REPORT_TYPE = 'rt';
Expand All @@ -24,12 +24,14 @@ export const FieldLabels: Record<string, string> = {
'monitor.status': 'Monitor Status',
};

export const DataViewLabels: Record<ReportViewType, string> = {
'page-load-dist': 'Page load distribution',
'page-views': 'Page views',
'uptime-duration': 'Uptime monitor duration',
'uptime-pings': 'Uptime pings',
'service-latency': 'APM Service latency',
export const DataViewLabels: Record<ReportViewTypeId, string> = {
pld: 'Page load distribution',
pgv: 'Page views',
upd: 'Uptime monitor duration',
upp: 'Uptime pings',
svl: 'APM Service latency',
kpi: 'Business KPI',
tpt: 'APM Service throughput',
};

export const ReportToDataTypeMap: Record<ReportViewTypeId, AppDataType> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class LensAttributes {
reportViewConfig: DataSeries,
seriesType: string,
filters: UrlFilter[],
metricType: string
metricType?: string
) {
this.indexPattern = indexPattern;
this.layers = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ import React from 'react';
import { EuiLoadingSpinner, EuiPageContentBody, EuiPanel } from '@elastic/eui';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { ObservabilityClientPluginsStart } from '../../../plugin';
import { IndexPattern } from '../../../../../../../src/plugins/data/common';
import { ExploratoryViewHeader } from './header/header';
import { SeriesEditor } from './series_editor/series_editor';
import { useUrlStorage } from './hooks/use_url_strorage';
import { useLensAttributes } from './hooks/use_lens_attributes';
import styled from 'styled-components';
import { EmptyView } from './components/empty_view';
import { useIndexPatternContext } from '../../../hooks/use_default_index_pattern';

export interface Props {
indexPattern?: IndexPattern | null;
}

export const ExploratoryView = ({ indexPattern }: Props) => {
export const ExploratoryView = () => {
const {
services: { lens },
} = useKibana<ObservabilityClientPluginsStart>();

const { indexPattern } = useIndexPatternContext();

const LensComponent = lens.EmbeddableComponent;

const { firstSeriesId: seriesId, firstSeries: series } = useUrlStorage();
Expand All @@ -44,7 +42,7 @@ export const ExploratoryView = ({ indexPattern }: Props) => {
{lensAttributes && seriesId ? (
<LensComponent
id=""
style={{ height: 500 }}
style={{ height: 550 }}
timeRange={series?.time}
attributes={lensAttributes}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
*/

import React from 'react';
import { useParams } from 'react-router-dom';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { TypedLensByValueInput } from '../../../../../../lens/public';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { ObservabilityClientPluginsStart } from '../../../../plugin';
import { ChartTemplates } from '../chart_templates/chart_templates';
import { ChartTypes } from './chart_types';
import { ReportViewType } from '../types';
import { DataViewLabels } from '../configurations/constants';
import { DataViewLabels, REPORT_TYPE } from '../configurations/constants';
import { useUrlStorage } from '../hooks/use_url_strorage';
import { MetricSelection } from './metric_selection';

Expand All @@ -28,15 +26,13 @@ export function ExploratoryViewHeader({ seriesId, lensAttributes }: Props) {
services: { lens },
} = useKibana<ObservabilityClientPluginsStart>();

const { dataViewType } = useParams<{ dataViewType: ReportViewType }>();

const { series } = useUrlStorage(seriesId);

return (
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
<EuiFlexItem>
<EuiText>
<h2>{DataViewLabels[dataViewType]}</h2>
<h2>{DataViewLabels[series[REPORT_TYPE]]}</h2>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useInitExploratoryView = (storage: IKbnUrlStateStorage) => {

const { data: indexPattern, status } = useFetcher(() => {
const obsvIndexP = new ObservabilityIndexPatterns(data);
return obsvIndexP.getIndexPattern(ReportToDataTypeMap[firstSeries?.[REPORT_TYPE]]);
return obsvIndexP.getIndexPattern(ReportToDataTypeMap[firstSeries?.[REPORT_TYPE]] ?? 'apm');
}, [firstSeries?.[REPORT_TYPE]]);

return useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const ExploratoryViewPage = () => {
>
<IndexPatternContextProvider indexPattern={indexPattern!}>
<UrlStorageContextProvider storage={kbnUrlStateStorage}>
<ExploratoryView indexPattern={indexPattern} />
<ExploratoryView />
</UrlStorageContextProvider>
</IndexPatternContextProvider>
</WithHeaderLayout>
Expand Down

0 comments on commit e715ace

Please sign in to comment.