delete and refresh graph done

1123
ZhangGe6 4 years ago
parent a52a90c45e
commit 8b6e3321e7

@ -206,6 +206,7 @@ sidebar.NodeSidebar = class {
this._addButton('Delete'); this._addButton('Delete');
this._addButton('Recover'); this._addButton('Recover');
this._addButton('Download'); this._addButton('Download');
this._addButton('RefreshGraph');
// console.log(this._host._view._graph._nodes) // console.log(this._host._view._graph._nodes)
// console.log(node) // console.log(node)
@ -331,6 +332,14 @@ sidebar.NodeSidebar = class {
}); });
} }
if (title === 'RefreshGraph') {
// console.log('pressed')
buttonElement.addEventListener('click', () => {
this._host._view._updateGraph();
});
}
} }

@ -468,13 +468,25 @@ view.View = class {
} }
_updateGraph(model, graphs) { _updateGraph(model, graphs) {
console.log('view._updateGraph() is called')
// console.log(model); // console.log(model);
// console.log(graphs); // console.log(graphs);
const lastModel = this._model; const lastModel = this._model;
const lastGraphs = this._graphs; const lastGraphs = this._graphs;
this._model = model; // console.log(lastNodeState)
this._graphs = graphs; // update graph if and only if `model` and `graphs` are provided
if (model && graphs) {
this._model = model;
this._graphs = graphs;
}
const graph = this.activeGraph; const graph = this.activeGraph;
this.lastViewGraph = this._graph;
// if (lastViewGraph) {
// console.log(this._graph)
// this.lastModelNodeName2State = lastViewGraph._modelNodeName2State;
// }
// console.log("_updateGraph is called"); // console.log("_updateGraph is called");
return this._timeout(100).then(() => { return this._timeout(100).then(() => {
if (graph && graph != lastGraphs[0]) { if (graph && graph != lastGraphs[0]) {
@ -569,7 +581,14 @@ view.View = class {
const viewGraph = new view.Graph(this, model, groups, options); const viewGraph = new view.Graph(this, model, groups, options);
// console.log(viewGraph) // console.log(viewGraph)
if (this.lastViewGraph) {
console.log(this.lastViewGraph._modelNodeName2ViewNode)
console.log('node state of lastViewGraph is loaded')
viewGraph._modelNodeName2State = this.lastViewGraph._modelNodeName2State;
}
console.log(viewGraph._modelNodeName2State)
viewGraph.add(graph); viewGraph.add(graph);
// console.log(viewGraph._arguments) // console.log(viewGraph._arguments)
// Workaround for Safari background drag/zoom issue: // Workaround for Safari background drag/zoom issue:
@ -917,6 +936,11 @@ view.Graph = class extends grapher.Graph {
for (const node of graph.nodes) { for (const node of graph.nodes) {
// console.log(node) // console.log(node)
// My code
if (this._modelNodeName2State.get(node.name) == 'Deleted') {
console.log(this._modelNodeName2State.get(node.name))
continue;
}
const viewNode = this.createNode(node); const viewNode = this.createNode(node);

Loading…
Cancel
Save