Skip to content

Commit

Permalink
#85 putting 1 node on the canvas with errors
Browse files Browse the repository at this point in the history
Signed-off-by: David Radley <david_radley@uk.ibm.com>
  • Loading branch information
davidradl committed Mar 6, 2021
1 parent fd453b8 commit a46d481
Showing 1 changed file with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */

import React, { useContext, useState } from "react";
import React, { useContext, useState, useEffect } from "react";

import PropTypes from "prop-types";
import PropTypes from "prop-types";
import { IdentificationContext } from "../../../../../../contexts/IdentificationContext";
import { InstancesContext } from "../../contexts/InstancesContext";
import { InstancesContext } from "../../contexts/InstancesContext";
import { withRouter } from "react-router-dom";
import "./instance-retriever.scss"
import "./instance-retriever.scss";
import getNodeType from "../../../properties/NodeTypes";
const InstanceRetrieval = props => {
const InstanceRetrieval = (props) => {
useEffect(
() => {
loadNodeByGUID();
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

const instancesContext = useContext(InstancesContext);
const instancesContext = useContext(InstancesContext);
const identificationContext = useContext(IdentificationContext);

/*
* Function to get node by GUID
/*
* Function to get node by GUID
*/
const loadNodeByGUID = () => {
const urlSegments = props.match.url.split("/")
const loadNodeByGUID = () => {
if (props.match.url) {
const urlSegments = props.match.url.split("/");
const guidToLoad = urlSegments[urlSegments.length - 1];
const secondLastSegment = urlSegments[urlSegments.length - 2];
const secondLastSegment = urlSegments[urlSegments.length - 2];
const nodeTypeKey = secondLastSegment.substring("visualise-".length);
console.log("nodeTypeKey" + nodeTypeKey);

const nodeType = getNodeType(identificationContext.getRestURL("glossary-author"), nodeTypeKey);

const nodeType = getNodeType(
identificationContext.getRestURL("glossary-author"),
nodeTypeKey
);
console.log("nodeType" + nodeType);
//TODO pass through the onSuccess and onErrors
instancesContext.loadNode(guidToLoad, nodeType);

}
};

return (

<div className={props.className}>
{loadNodeByGUID()}

</div>

);

}
return <div className={props.className}></div>;
};

InstanceRetrieval.propTypes = {
className : PropTypes.string
}
InstanceRetrieval.propTypes = {
className: PropTypes.string,
};
export default withRouter(InstanceRetrieval);

0 comments on commit a46d481

Please sign in to comment.