-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commissioing package react components (#45)
### [AB#201347](https://dev.azure.com/EquinorASA/bb9bd8cb-74f7-4ffa-b0cb-60eff0a0be58/_workitems/edit/201347) ## Aim of the PR - [x] Make it possible to select equipment, piping components as boundary or internal component - [ ] Make it possible to select piping lines as boundary or internal component - [x] Based on the boundary and the internal component the resulting commissioning package is highlighted - [ ] The piping lines is highlighted as well #### Suggestion I did not reach every goal for this PR. I decided to give up on implementing the highlighting and selection of the piping lines as this was too difficult. In order to achieve highlighting on the piping lines we need to assign the correct rdf IRI on these lines. The logic for which IRI a line should have is connected with what preceding and following siblings the CenterLine element has in the XML. We do not have access to this information anymore since the XML is parsed to react components. I suggest that we address this issue when creating the new RDF format for the front-end. Every component on the new format needs to have the RDF IRI attached to it. With this in place it should be no issue to also add highlighting on the centerlines. ## Implementation ### New components #### CommissioningpackageContext - Added internalIds, boundaryIds as well as state setters to update them. #### handleAddInternal and handleAddBoundary When a component is selected as internal or boundary then these functions are triggered. - They will add the id of the selected component to borderIds or boundaryIds on the commissioning context. - Makes sure that a component cant be selected as internal or boundary at the same time - Updates rdfox #### ClickableComponentProps - Properties for dealing with clickable components, as well as two functions that is used by clickable components for determining highlight color and what actions to take when a component is clicked. #### StyledSvgElement - Creates a svg element with highlighting. ### Logic The functions for creating the PipingComponent and Equipment react components now accepts ClickableComponentProps as argument. The ClickableComponentProps holds information on which function should be triggered on click, and on shift click. The functions handleAddInternal and handleAddBoundary is used as arguments here. The <StyledSvgElement> will also be created if the equipment or piping component is internal, boundary or in the commissioning package. This creates the highlighting. When the context for the commissioning package changes a call is made to rdfox to check if there are any nodes in the commissioning package, if this is true then the context is updated with these new ids. When the context is updated then they will be highlighted in yellow. Upon refresh of the page rdfox is wiped, and the commissioning package context is reset. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Breaking change - [ ] This change requires a documentation update ## How Has This Been Tested? Tested the solution manually by selecting equipment and piping components as both boundary and internal. Checked that the highlighting appeared on the correct elements. Also checked that rdfox and the front-end was in sync by querying rdfox in between selecting boundaries and internals. ## Additional Changes - Previously the SvgElement function required a height as argument. The height parameter has been removed from this function. I therefore removed this argument from where this function was called. - Some refactoring in Triplestore.ts -> moved logic for querying and updating the Triplestore to one function. This function has a method param, when the method is GET it queries rdfox, when the method is POST it will delete or insert new data. - Deleted file named CommissioningPackage.ts -> this information was already present in CommissioningPackageContext.
- Loading branch information
1 parent
e27d963
commit 16628b4
Showing
12 changed files
with
351 additions
and
135 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
PositionProps, | ||
} from "../types/diagram/Common.ts"; | ||
import calculateAngleAndRotation from "../utils/Transformation.ts"; | ||
import { useContext } from "react"; | ||
import PandidContext from "../context/PandidContext.ts"; | ||
import styled from "styled-components" | ||
|
||
interface StyledSvgElementProps { | ||
id: string; | ||
position?: PositionProps; | ||
svg: string; | ||
color: string; | ||
} | ||
|
||
const StyledG = styled.g` | ||
path { | ||
stroke: ${(props) => props.color}; | ||
stroke-width: 5; | ||
opacity: 0.5 ; | ||
} | ||
` | ||
|
||
export default function StyledSvgElement({ | ||
id, | ||
position, | ||
svg, | ||
color | ||
}: StyledSvgElementProps) { | ||
const height = useContext(PandidContext).height; | ||
|
||
return ( | ||
<> | ||
{svg && ( | ||
<StyledG | ||
id={id} | ||
color={color} | ||
transform={ | ||
position | ||
? calculateAngleAndRotation( | ||
position.Reference.X, | ||
position.Reference.Y, | ||
position.Location.X, | ||
height - position.Location.Y, | ||
) | ||
: "" | ||
} | ||
className={".node"} | ||
dangerouslySetInnerHTML={{ __html: svg }} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
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.