-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lsp count implementation * add mpls count labels * add title to lsp count
- Loading branch information
Showing
9 changed files
with
264 additions
and
81 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/frinx-device-topology/src/__generated__/graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
packages/frinx-device-topology/src/pages/topology/mpls/lsp-count-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { chakra } from '@chakra-ui/react'; | ||
import React, { useRef, VoidFunctionComponent } from 'react'; | ||
import { getCurvePath, getPointAtLength, Line, LspCount } from '../graph.helpers'; | ||
|
||
const G = chakra('g'); | ||
const Circle = chakra('circle'); | ||
const Text = chakra('text'); | ||
|
||
type Props = { | ||
lspCount: LspCount; | ||
linePoints: Line; | ||
}; | ||
|
||
const LspCountItem: VoidFunctionComponent<Props> = ({ linePoints, lspCount }) => { | ||
const edgeRef = useRef<SVGPathElement>(null); | ||
|
||
const { start, end } = linePoints; | ||
|
||
const incomingPosition = getPointAtLength(linePoints, 0.3); | ||
const outcomingPosition = getPointAtLength(linePoints, 0.7); | ||
|
||
return ( | ||
<g> | ||
<path | ||
ref={edgeRef} | ||
strokeWidth={3} | ||
stroke="red" | ||
strokeLinejoin="round" | ||
fill="red" | ||
d={getCurvePath(start, end, [])} | ||
cursor="pointer" | ||
/> | ||
<G transform={`translate3d(${incomingPosition.x}px, ${incomingPosition.y}px, 0)`} transformOrigin="center center"> | ||
<G transform="translate3d(-18px, -18px, 0) scale(1.5)"> | ||
<path | ||
d="M11 9L8 12M8 12L11 15M8 12H16M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" | ||
stroke="#000000" | ||
strokeWidth="1" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
fill="#fff" | ||
/> | ||
</G> | ||
<Circle r="12" fillOpacity={0}> | ||
<title>incoming Laps: {lspCount.incomingLsps}</title> | ||
</Circle> | ||
<Text | ||
height="sm" | ||
textAnchor="middle" | ||
y="-20" | ||
paintOrder="stroke" | ||
strokeWidth={3} | ||
stroke="white" | ||
strokeLinecap="butt" | ||
strokeLinejoin="round" | ||
> | ||
{lspCount.incomingLsps} | ||
</Text> | ||
</G> | ||
<G | ||
transform={`translate3d(${outcomingPosition.x}px, ${outcomingPosition.y}px, 0)`} | ||
transformOrigin="center center" | ||
> | ||
<G transform="translate3d(-18px, -18px, 0) scale(1.5)"> | ||
<path | ||
d="M17 12H7M17 12L13 16M17 12L13 8M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" | ||
stroke="#000000" | ||
strokeWidth="1" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
fill="#fff" | ||
/> | ||
</G> | ||
<Circle r="12" fillOpacity={0}> | ||
<title>outcoming Laps: {lspCount.outcomingLsps}</title> | ||
</Circle> | ||
<Text | ||
height="sm" | ||
textAnchor="middle" | ||
y="-20" | ||
paintOrder="stroke" | ||
strokeWidth={2} | ||
stroke="white" | ||
strokeLinecap="butt" | ||
strokeLinejoin="round" | ||
> | ||
{lspCount.outcomingLsps} | ||
</Text> | ||
</G> | ||
</g> | ||
); | ||
}; | ||
|
||
export default LspCountItem; |
48 changes: 48 additions & 0 deletions
48
packages/frinx-device-topology/src/pages/topology/mpls/lsp-counts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { VoidFunctionComponent } from 'react'; | ||
import { GraphEdgeWithDiff } from '../../../helpers/topology-helpers'; | ||
import { useStateContext } from '../../../state.provider'; | ||
import { getLinePoints, getNameFromNode, isTargetingActiveNode, LspCount } from '../graph.helpers'; | ||
import LspCountItem from './lsp-count-item'; | ||
|
||
type Props = { | ||
edges: GraphEdgeWithDiff[]; | ||
lspCounts: LspCount[]; | ||
}; | ||
|
||
const LspCounts: VoidFunctionComponent<Props> = ({ edges, lspCounts }) => { | ||
const { state } = useStateContext(); | ||
const { | ||
connectedNodeIds, | ||
selectedNode, | ||
mplsNodePositions: nodePositions, | ||
mplsInterfaceGroupPositions: interfaceGroupPositions, | ||
} = state; | ||
|
||
const activeEdges = edges.filter((e) => | ||
isTargetingActiveNode(e, getNameFromNode(selectedNode), interfaceGroupPositions), | ||
); | ||
|
||
const lspCountsMap = new Map(lspCounts.map((c) => [c.deviceName, c])); | ||
|
||
return ( | ||
<g> | ||
{activeEdges.map((edge) => { | ||
const linePoints = getLinePoints({ | ||
edge, | ||
connectedNodeIds, | ||
nodePositions, | ||
interfaceGroupPositions, | ||
}); | ||
|
||
const lspCount = lspCountsMap.get(edge.source.nodeId) ?? null; | ||
if (!linePoints || !lspCount) { | ||
return null; | ||
} | ||
|
||
return <LspCountItem key={`lsp-count-item-${edge.id}`} linePoints={linePoints} lspCount={lspCount} />; | ||
})} | ||
</g> | ||
); | ||
}; | ||
|
||
export default LspCounts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.