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

fix everything and get ui working well #149

Closed
wants to merge 1 commit into from
Closed
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 @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiHorizontalRule, EuiPanel } from '@elastic/eui';
import { EuiButtonGroup, EuiHorizontalRule, EuiPanel, EuiFlexGroup, EuiSpacer } from '@elastic/eui';
import moment from 'moment';
import React, { useMemo } from 'react';
import React, { useMemo, useState } from 'react';
import { Plt } from '../../../../visualizations/plotly/plot';
import {
fixedIntervalToMilli,
Expand All @@ -18,6 +18,9 @@ export function ErrorRatePlt(props: {
items: { items: Plotly.Data[]; fixedInterval: string };
setStartTime: (startTime: string) => void;
setEndTime: (endTime: string) => void;
setIdSelected: (mode: string) => void;
idSelected: string;
toggleButtons: any[];
}) {
const getLayout = () =>
({
Expand Down Expand Up @@ -89,8 +92,17 @@ export function ErrorRatePlt(props: {
return (
<>
<EuiPanel style={{ minWidth: 433, minHeight: 308 }}>
<PanelTitle title="Trace error rate over time" />
<EuiHorizontalRule margin="m" />
<EuiFlexGroup justifyContent='spaceBetween' gutterSize='xs'>
<PanelTitle title="Trace error rate over time" />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
<EuiSpacer size="m" />
{props.items?.items?.length > 0 ? (
<Plt data={props.items.items} layout={layout} onClickHandler={onClick} />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiHorizontalRule, EuiPanel } from '@elastic/eui';
import { EuiButtonGroup, EuiFlexGroup, EuiHorizontalRule, EuiPanel } from '@elastic/eui';
import moment from 'moment';
import React, { useMemo } from 'react';
import { Plt } from '../../../../visualizations/plotly/plot';
Expand All @@ -18,6 +18,9 @@ export function ThroughputPlt(props: {
items: { items: Plotly.Data[]; fixedInterval: string };
setStartTime: (startTime: string) => void;
setEndTime: (endTime: string) => void;
setIdSelected: (mode: string) => void;
idSelected: string;
toggleButtons: any[];
}) {
const layout = useMemo(
() =>
Expand Down Expand Up @@ -85,7 +88,16 @@ export function ThroughputPlt(props: {
return (
<>
<EuiPanel style={{ minWidth: 433, minHeight: 308 }}>
<EuiFlexGroup justifyContent='spaceBetween' gutterSize='xs'>
<PanelTitle title="Traces over time" />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id: string) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
<EuiHorizontalRule margin="m" />
{props.items?.items?.length > 0 ? (
<Plt data={props.items.items} layout={layout} onClickHandler={onClick} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { EuiButtonEmpty, EuiPopover, EuiPopoverTitle, EuiSelectable } from "@elastic/eui";
import React, { useEffect, useState } from "react";
import { TraceAnalyticsMode } from "../../home";

export type mode = {
id: string;
title: string;
}

const labels = new Map([['jaeger', 'Jaeger'], ['data_prepper', 'Data Prepper']]);


export function DataSourcePicker(props: {modes: {
id: string;
title: string;
}[], selectedMode: TraceAnalyticsMode, setMode : (mode: TraceAnalyticsMode) => void}) {
const { modes, selectedMode, setMode } = props;
const [isPopoverOpen, setPopoverIsOpen] = useState(false);
const [selected, setSelected] = useState(selectedMode);

const trigger = {
label: labels.get(selected),
title: selected,
'data-test-subj': 'indexPattern-switch-link',
className: 'dscIndexPattern__triggerButton',
}

const createTrigger = () => {
const { label, title, ...rest } = trigger;
return (
<EuiButtonEmpty
flush="left"
color="text"
iconSide="right"
iconType="arrowDown"
title={title}
onClick={() => setPopoverIsOpen(!isPopoverOpen)}
{...rest}
>
{label}
</EuiButtonEmpty>
);
};

return (
<>
<EuiPopover
button={createTrigger()}
isOpen={isPopoverOpen}
closePopover={() => setPopoverIsOpen(false)}
className="eui-textTruncate"
anchorClassName="eui-textTruncate"
display="inlineBlock"
panelPaddingSize="s"
ownFocus
>
<div className="popOverContainer">
<EuiPopoverTitle>
{"Choose data type"}
</EuiPopoverTitle>
<EuiSelectable
data-test-subj="indexPattern-switcher"
searchable
singleSelection="always"
options={modes.map((x) => ({
label: x.title,
key: x.id,
value: x.id,
checked: x.id === selected ? 'on' : undefined,
}))}
onChange={(choices) => {
const choice = (choices.find(({ checked }) => checked) as unknown) as {
value: string;
label: string;
key: TraceAnalyticsMode;
};
setMode(choice.key);
setSelected(choice.key);
setPopoverIsOpen(false);
sessionStorage.setItem('TraceAnalyticsMode', choice.key);
}}
searchProps={{
compressed: true,
}}
>
{(list, search) => (
<>
{search}
{list}
</>
)}
</EuiSelectable>
</div>
</EuiPopover>
</>
);
}
Loading