diff --git a/frontend/src/modules/Servicemap/ServiceMap.tsx b/frontend/src/modules/Servicemap/ServiceMap.tsx index f6098cd994..da67cd9dbb 100644 --- a/frontend/src/modules/Servicemap/ServiceMap.tsx +++ b/frontend/src/modules/Servicemap/ServiceMap.tsx @@ -10,7 +10,8 @@ import { import { Spin } from "antd"; import styled from "styled-components"; import { StoreState } from "../../store/reducers"; -import { getGraphData } from "./utils"; +import { getZoomPx, getGraphData } from "./utils"; +import { getGraphData, getTooltip } from "./utils"; import SelectService from "./SelectService"; import { ForceGraph2D } from "react-force-graph"; @@ -72,7 +73,7 @@ const ServiceMap = (props: ServiceMapProps) => { } const zoomToService = (value: string) => { - fgRef && fgRef.current.zoomToFit(700, 380, (e) => e.id === value); + fgRef && fgRef.current.zoomToFit(700, getZoomPx(), (e) => e.id === value); }; const { nodes, links } = getGraphData(serviceMap); @@ -90,7 +91,7 @@ const ServiceMap = (props: ServiceMapProps) => { fgRef.current.zoomToFit(100, 120); }} graphData={graphData} - nodeLabel="id" + nodeLabel={getTooltip} linkAutoColorBy={(d) => d.target} linkDirectionalParticles="value" linkDirectionalParticleSpeed={(d) => d.value} @@ -112,21 +113,7 @@ const ServiceMap = (props: ServiceMapProps) => { onNodeClick={(node) => { const tooltip = document.querySelector(".graph-tooltip"); if (tooltip && node) { - tooltip.innerHTML = `
-
${node.id}
-
-
P99 latency:
-
${node.p99 / 1000000}ms
-
-
-
Request:
-
${node.callRate}/sec
-
-
-
Error Rate:
-
${node.errorRate}%
-
-
`; + tooltip.innerHTML = getTooltip(node); } }} nodePointerAreaPaint={(node, color, ctx) => { diff --git a/frontend/src/modules/Servicemap/utils.ts b/frontend/src/modules/Servicemap/utils.ts index 296cd05060..7caf5862aa 100644 --- a/frontend/src/modules/Servicemap/utils.ts +++ b/frontend/src/modules/Servicemap/utils.ts @@ -73,3 +73,37 @@ export const getGraphData = (serviceMap: serviceMapStore): graphDataType => { links, }; }; + +export const getZoomPx = (): number => { + const width = window.screen.width; + if (width < 1400) { + return 190; + } else if (width > 1400 && width < 2500) { + return 380; + } else if (width > 2500) { + return 360; + } + +export const getTooltip = (node: { + p99: number; + errorRate: number; + callRate: number; + id: string; +}) => { + return `
+
${node.id}
+
+
P99 latency:
+
${node.p99 / 1000000}ms
+
+
+
Request:
+
${node.callRate}/sec
+
+
+
Error Rate:
+
${node.errorRate}%
+
+
`; + +}; diff --git a/frontend/src/store/actions/serviceMap.ts b/frontend/src/store/actions/serviceMap.ts index a8a660d423..fbad4148c3 100644 --- a/frontend/src/store/actions/serviceMap.ts +++ b/frontend/src/store/actions/serviceMap.ts @@ -38,6 +38,11 @@ export interface servicesAction { export const getServiceMapItems = (globalTime: GlobalTime) => { return async (dispatch: Dispatch) => { + dispatch({ + type: ActionTypes.getServiceMapItems, + payload: [], + }); + let request_string = "/serviceMapDependencies?start=" + globalTime.minTime + @@ -45,7 +50,7 @@ export const getServiceMapItems = (globalTime: GlobalTime) => { globalTime.maxTime; const response = await api.get(apiV1 + request_string); - + dispatch({ type: ActionTypes.getServiceMapItems, payload: response.data, @@ -55,11 +60,16 @@ export const getServiceMapItems = (globalTime: GlobalTime) => { export const getDetailedServiceMapItems = (globalTime: GlobalTime) => { return async (dispatch: Dispatch) => { + dispatch({ + type: ActionTypes.getServices, + payload: [], + }); + let request_string = "/services?start=" + globalTime.minTime + "&end=" + globalTime.maxTime; const response = await api.get(apiV1 + request_string); - + dispatch({ type: ActionTypes.getServices, payload: response.data,