From 569ff39ade38b5804e14f9a1db419edd4bc06ede Mon Sep 17 00:00:00 2001 From: Marco <51787428+MarcoMruz@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:24:21 +0100 Subject: [PATCH] Add ptp diff (#1496) * implement version diff for ptp and synce * handle null value in version select * refactor used type in redux reducers --- .../src/__generated__/graphql.ts | 42 ++++- .../components/node-icons/ptp-node-icon.tsx | 18 +- .../components/node-icons/synce-node-icon.tsx | 22 ++- .../version-select/version-select.tsx | 5 +- .../src/helpers/topology-helpers.ts | 168 +++++++++++++++++- .../src/pages/topology/ptp/ptp-nodes.tsx | 5 +- .../topology/ptp/ptp-topology.container.tsx | 25 ++- .../src/pages/topology/synce/synce-nodes.tsx | 5 +- .../synce/synce-topology.container.tsx | 27 ++- .../src/pages/topology/topology.tsx | 28 +-- .../src/state.actions.ts | 160 ++++++++++++++++- .../src/state.reducer.ts | 50 +++++- 12 files changed, 501 insertions(+), 54 deletions(-) diff --git a/packages/frinx-device-topology/src/__generated__/graphql.ts b/packages/frinx-device-topology/src/__generated__/graphql.ts index b6e040831..7ec66a200 100644 --- a/packages/frinx-device-topology/src/__generated__/graphql.ts +++ b/packages/frinx-device-topology/src/__generated__/graphql.ts @@ -1978,7 +1978,7 @@ export type WorkflowDefinition = BaseWorkflowDefinition & Node & { ownerEmail: Maybe; restartable: Scalars['Boolean']['output']; tasks: Array; - tasksJson: Scalars['JSON']['output']; + tasksJson: Maybe; timeoutPolicy: Maybe; timeoutSeconds: Maybe; updatedAt: Maybe; @@ -3047,15 +3047,17 @@ export type DeviceInventoryQuery = { locations: LocationConnection; netTopology: Maybe; node: Maybe; + phyTopologyVersionData: TopologyVersionData; ptpDiffSynce: PtpDiffSynce; ptpPathToGrandMaster: Maybe>; ptpTopology: Maybe; + ptpTopologyVersionData: TopologyVersionData; shortestPath: Array; syncePathToGrandMaster: Maybe>; synceTopology: Maybe; + synceTopologyVersionData: TopologyVersionData; topology: Maybe; topologyCommonNodes: Maybe; - topologyVersionData: TopologyVersionData; topologyVersions: Maybe>; transactions: Array; uniconfigShellSession: Maybe; @@ -3123,11 +3125,21 @@ export type DeviceInventoryQueryNodeArgs = { }; +export type DeviceInventoryQueryPhyTopologyVersionDataArgs = { + version: Scalars['String']['input']; +}; + + export type DeviceInventoryQueryPtpPathToGrandMasterArgs = { deviceFrom: Scalars['String']['input']; }; +export type DeviceInventoryQueryPtpTopologyVersionDataArgs = { + version: Scalars['String']['input']; +}; + + export type DeviceInventoryQueryShortestPathArgs = { from: Scalars['String']['input']; to: Scalars['String']['input']; @@ -3139,6 +3151,11 @@ export type DeviceInventoryQuerySyncePathToGrandMasterArgs = { }; +export type DeviceInventoryQuerySynceTopologyVersionDataArgs = { + version: Scalars['String']['input']; +}; + + export type DeviceInventoryQueryTopologyArgs = { filter?: InputMaybe; }; @@ -3149,11 +3166,6 @@ export type DeviceInventoryQueryTopologyCommonNodesArgs = { }; -export type DeviceInventoryQueryTopologyVersionDataArgs = { - version: Scalars['String']['input']; -}; - - export type DeviceInventoryQueryZonesArgs = { after?: InputMaybe; before?: InputMaybe; @@ -3708,7 +3720,21 @@ export type TopologyVersionDataQueryVariables = Exact<{ }>; -export type TopologyVersionDataQuery = { __typename?: 'Query', deviceInventory: { __typename?: 'deviceInventoryQuery', topologyVersionData: { __typename?: 'TopologyVersionData', edges: Array<{ __typename?: 'GraphVersionEdge', id: string, source: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string }, target: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string } }>, nodes: Array<{ __typename?: 'GraphVersionNode', id: string, name: string, interfaces: Array<{ __typename?: 'GraphNodeInterface', id: string, status: GraphEdgeStatus, name: string }>, coordinates: { __typename?: 'GraphNodeCoordinates', x: number, y: number } }> } } }; +export type TopologyVersionDataQuery = { __typename?: 'Query', deviceInventory: { __typename?: 'deviceInventoryQuery', phyTopologyVersionData: { __typename?: 'TopologyVersionData', edges: Array<{ __typename?: 'GraphVersionEdge', id: string, source: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string }, target: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string } }>, nodes: Array<{ __typename?: 'GraphVersionNode', id: string, name: string, interfaces: Array<{ __typename?: 'GraphNodeInterface', id: string, status: GraphEdgeStatus, name: string }>, coordinates: { __typename?: 'GraphNodeCoordinates', x: number, y: number } }> } } }; + +export type PtpTopologyVersionDataQueryVariables = Exact<{ + version: Scalars['String']['input']; +}>; + + +export type PtpTopologyVersionDataQuery = { __typename?: 'Query', deviceInventory: { __typename?: 'deviceInventoryQuery', ptpTopologyVersionData: { __typename?: 'TopologyVersionData', edges: Array<{ __typename?: 'GraphVersionEdge', id: string, source: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string }, target: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string } }>, nodes: Array<{ __typename?: 'GraphVersionNode', id: string, name: string, interfaces: Array<{ __typename?: 'GraphNodeInterface', id: string, status: GraphEdgeStatus, name: string }>, coordinates: { __typename?: 'GraphNodeCoordinates', x: number, y: number } }> } } }; + +export type SynceTopologyVersionDataQueryVariables = Exact<{ + version: Scalars['String']['input']; +}>; + + +export type SynceTopologyVersionDataQuery = { __typename?: 'Query', deviceInventory: { __typename?: 'deviceInventoryQuery', synceTopologyVersionData: { __typename?: 'TopologyVersionData', edges: Array<{ __typename?: 'GraphVersionEdge', id: string, source: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string }, target: { __typename?: 'EdgeSourceTarget', nodeId: string, interface: string } }>, nodes: Array<{ __typename?: 'GraphVersionNode', id: string, name: string, interfaces: Array<{ __typename?: 'GraphNodeInterface', id: string, status: GraphEdgeStatus, name: string }>, coordinates: { __typename?: 'GraphNodeCoordinates', x: number, y: number } }> } } }; export type PtpTopologyQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/packages/frinx-device-topology/src/components/node-icons/ptp-node-icon.tsx b/packages/frinx-device-topology/src/components/node-icons/ptp-node-icon.tsx index 7b93af135..06feb42cf 100644 --- a/packages/frinx-device-topology/src/components/node-icons/ptp-node-icon.tsx +++ b/packages/frinx-device-topology/src/components/node-icons/ptp-node-icon.tsx @@ -1,10 +1,11 @@ import { chakra } from '@chakra-ui/react'; import React, { PointerEvent, VoidFunctionComponent } from 'react'; +import { PtpGraphNodeWithDiff } from '../../helpers/topology-helpers'; import { GraphPtpNodeInterface, PositionsWithGroupsMap } from '../../pages/topology/graph.helpers'; import { TopologyMode } from '../../state.actions'; -import { GraphEdge, PtpGraphNode } from '../../__generated__/graphql'; +import { GraphEdge } from '../../__generated__/graphql'; import NodeIconImage from './node-icon-image'; -import { getDeviceNodeTransformProperties, getNodeInterfaceGroups } from './node-icon.helpers'; +import { getDeviceNodeTransformProperties, getNodeBackgroundColor, getNodeInterfaceGroups } from './node-icon.helpers'; import NodeInterface from './node-interface'; type Props = { @@ -12,9 +13,10 @@ type Props = { ptpDiffSynceIds: string[]; positions: PositionsWithGroupsMap; isFocused: boolean; + isSelected: boolean; isSelectedForGmPath: boolean; isGmPath: boolean; - node: PtpGraphNode; + node: PtpGraphNodeWithDiff; topologyMode: TopologyMode; selectedEdge: GraphEdge | null; onPointerDown: (event: PointerEvent) => void; @@ -31,6 +33,7 @@ const PtpNodeIcon: VoidFunctionComponent = ({ isPtpDiffSynceShown, ptpDiffSynceIds, isFocused, + isSelected, isSelectedForGmPath, isGmPath, node, @@ -44,7 +47,10 @@ const PtpNodeIcon: VoidFunctionComponent = ({ const interfaceGroups = getNodeInterfaceGroups(node.name, positions.interfaceGroups); const { circleDiameter, sizeTransform } = getDeviceNodeTransformProperties('MEDIUM'); - const ptpDiffSynceNodeColor = isPtpDiffSynceShown && ptpDiffSynceIds?.includes(node.nodeId) ? 'red.200' : 'gray.400'; + const ptpNodeBackgroundColor = + isPtpDiffSynceShown && ptpDiffSynceIds?.includes(node.nodeId) + ? 'red.200' + : getNodeBackgroundColor({ isSelected, change: node.change }); return ( = ({ ) => void; onPointerMove: (event: PointerEvent) => void; onPointerUp: (event: PointerEvent) => void; selectedEdge: GraphEdge | null; + isSelected: boolean; }; const G = chakra('g'); @@ -35,6 +37,7 @@ const SynceNodeIcon: VoidFunctionComponent = ({ onPointerMove, onPointerUp, selectedEdge, + isSelected, }) => { const { x, y } = positions.nodes[node.name]; const interfaceGroups = getNodeInterfaceGroups(node.name, positions.interfaceGroups); @@ -57,7 +60,18 @@ const SynceNodeIcon: VoidFunctionComponent = ({ transition="all .2s ease-in-out" /> - + { const handleSelectVersionChange = (event: ChangeEvent) => { const { value } = event.currentTarget; dispatch(setSelectedVersion(value === 'none' ? null : value)); + dispatch(setSynceDiffVisibility(false)); }; if (isFetchingVersions) { @@ -37,7 +38,7 @@ const VersionSelect: VoidFunctionComponent = () => { return ( <> Compare current topology with: - {versions.map((v) => (