Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restoreProvenanceGraph #12

Open
mozark24 opened this issue May 2, 2019 · 2 comments
Open

restoreProvenanceGraph #12

mozark24 opened this issue May 2, 2019 · 2 comments

Comments

@mozark24
Copy link

mozark24 commented May 2, 2019

Hello again,

I'm currently working through the save/restore functionality. The save part is complete. On restore, I've been working on it for a little while but I'm not quite sure how you intend restoreProvenanceGraph() and repopulating the graph to work. Do you have an example with the restore functionality?

Here is the relevant portions of my code:

document.getElementById("file-input").addEventListener("change", async (e) => {
  var file = (<HTMLInputElement>e.target).files[0];
  var reader = new FileReader();
  reader.onload = file => {
      var contents: any = file.target;
      this.text = contents.result; 
      console.log(this.text.toString());    // debug - working up to here

      var graphLoad:SerializedProvenanceGraph = JSON.parse(this.text);
      graph = restoreProvenanceGraph(graphLoad);
  };
    reader.readAsText(file);
}, false);  

This is I get when I try to assign the restored graph.
Types have separate declarations of a private property '_current'.

It has a problem with the last assignment operation, graph is cast as ProvenanceGraph.

@Tommos0
Copy link
Member

Tommos0 commented May 6, 2019

Hi!

There doesn't seem to be anything wrong with your code, I tried it here (https://codesandbox.io/s/qz3k0w34n6) and everything seems fine actually. I can not see the declaration of graph but I assume somewhere is let graph: ProvenanceGraph. Which version of typescript are you using? Are you using provenance-core from the npm package?

@mozark24
Copy link
Author

mozark24 commented Aug 20, 2019

Hello!

I've been out for a little while working on some other core components and lots of writing (I am using a modified core). I just came back to this issue and that segment of code is no longer giving me that error. Not sure why at the moment, but I don't look gift horses in the mouth :)

My fundamental question is: How should the graph from restoreProvenanceGraph intended to be handled to update the vis? The graph re-draw is not triggering.

Code sample:

let graph = new ProvenanceGraph({ name: 'Calculator', version: '1.0.0' });
<< code copied from my example above which modifies graph >>
let fileChange = new Calculator(graph, registry, tracker, traverser);
fileChange.setupBasicGraph().then(() => {
  provenanceTreeVisualization = new ProvenanceTreeVisualization(
    traverser,
    visDiv,
  );
 //Slidedeck stuff
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants