mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 19:39:02 +08:00
Merge pull request #109 from SigNoz/issues-93
Add default view in dropdown service-picker in ServiceMap
This commit is contained in:
commit
bb155d2356
@ -4,6 +4,7 @@ import { InfoCircleOutlined } from "@ant-design/icons";
|
|||||||
import { Select } from "antd";
|
import { Select } from "antd";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
@ -25,14 +26,25 @@ const Container = styled.div`
|
|||||||
interface SelectServiceProps {
|
interface SelectServiceProps {
|
||||||
services: servicesItem[];
|
services: servicesItem[];
|
||||||
zoomToService: (arg0: string) => void;
|
zoomToService: (arg0: string) => void;
|
||||||
|
zoomToDefault: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultOption = {
|
||||||
|
serviceName: "Default"
|
||||||
|
};
|
||||||
|
|
||||||
const SelectService = (props: SelectServiceProps) => {
|
const SelectService = (props: SelectServiceProps) => {
|
||||||
const [selectedVal, setSelectedVal] = useState<string>();
|
const [selectedVal, setSelectedVal] = useState<string>(defaultOption.serviceName);
|
||||||
const { services, zoomToService } = props;
|
const { zoomToService, zoomToDefault } = props;
|
||||||
|
const services = cloneDeep(props.services);
|
||||||
|
services.unshift(defaultOption)
|
||||||
const handleSelect = (value: string) => {
|
const handleSelect = (value: string) => {
|
||||||
setSelectedVal(value);
|
if(value === defaultOption.serviceName){
|
||||||
|
zoomToDefault()
|
||||||
|
} else {
|
||||||
zoomToService(value);
|
zoomToService(value);
|
||||||
|
}
|
||||||
|
setSelectedVal(value);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
@ -75,6 +75,10 @@ const ServiceMap = (props: ServiceMapProps) => {
|
|||||||
fgRef && fgRef.current.zoomToFit(700, getZoomPx(), (e) => e.id === value);
|
fgRef && fgRef.current.zoomToFit(700, getZoomPx(), (e) => e.id === value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const zoomToDefault = () => {
|
||||||
|
fgRef && fgRef.current.zoomToFit(100, 120);
|
||||||
|
};
|
||||||
|
|
||||||
const { nodes, links } = getGraphData(serviceMap);
|
const { nodes, links } = getGraphData(serviceMap);
|
||||||
const graphData = { nodes, links };
|
const graphData = { nodes, links };
|
||||||
return (
|
return (
|
||||||
@ -82,6 +86,7 @@ const ServiceMap = (props: ServiceMapProps) => {
|
|||||||
<SelectService
|
<SelectService
|
||||||
services={serviceMap.services}
|
services={serviceMap.services}
|
||||||
zoomToService={zoomToService}
|
zoomToService={zoomToService}
|
||||||
|
zoomToDefault={zoomToDefault}
|
||||||
/>
|
/>
|
||||||
<ForceGraph2D
|
<ForceGraph2D
|
||||||
ref={fgRef}
|
ref={fgRef}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user