Skip to content

Commit

Permalink
Fix to handle no data in websocket response and call callback or defa…
Browse files Browse the repository at this point in the history
…ult handler (#53)
  • Loading branch information
antonyscerri authored and bricaud committed Nov 24, 2018
1 parent c666f57 commit 7944be3
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions scripts/graphioGremlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ var graphioGremlin = (function(){
success: function(data, textStatus, jqXHR){
var Data = data.result.data;
//console.log(Data)
//console.log("Results received")
if(callback){
callback(Data);
} else {
Expand Down Expand Up @@ -314,12 +315,13 @@ var graphioGremlin = (function(){
"(linking nodes not existing in the DB). </p>");
return 1;
} else {
$('#outputArea').html(response.status.message);
$('#messageArea').html('Server error. No data.');
return 1;
//$('#outputArea').html(response.status.message);
//$('#messageArea').html('Server error. No data.');
//return 1;
}
}
//console.log(data)
//console.log("Results received")
if(callback){
callback(data);
} else {
Expand Down Expand Up @@ -438,17 +440,21 @@ var graphioGremlin = (function(){
// Extract node and edges from the data returned for 'search' and 'click' request
// Create the graph object
var nodes=[], links=[];
for (var key in data){
data[key].forEach(function (item) {
if (!("inV" in item) && idIndex(nodes,item.id) == null){ // if vertex and not already in the list
item.type = "vertex";
nodes.push(extract_infov3(item));
}
if (("inV" in item) && idIndex(links,item.id) == null){
item.type = "edge";
links.push(extract_infov3(item));
if(data!=null) {
for (var key in data){
if(data[key]!=null) {
data[key].forEach(function (item) {
if (!("inV" in item) && idIndex(nodes,item.id) == null){ // if vertex and not already in the list
item.type = "vertex";
nodes.push(extract_infov3(item));
}
if (("inV" in item) && idIndex(links,item.id) == null){
item.type = "edge";
links.push(extract_infov3(item));
}
});
}
});
}
}
return {nodes:nodes, links:links};
}
Expand Down Expand Up @@ -558,4 +564,4 @@ function get_vertex_prop_in_list(vertexProperty){
click_query : click_query,
send_to_server : send_to_server
}
})();
})();

0 comments on commit 7944be3

Please sign in to comment.