Commit b1e90ab8 authored by Romain Loth's avatar Romain Loth

fix "delete node" in graphexplorer view

parent ab2c76dd
......@@ -19,12 +19,15 @@ def explorer(request, project_id, corpus_id):
# we pass our corpus
corpus = cache.Node[corpus_id]
# get the maplist_id for modifications
maplist_id = corpus.children(typename="MAPLIST").first().id
# and the project just for project.id in corpusBannerTop
project = cache.Node[project_id]
graphurl = "projects/" + str(project_id) + "/corpora/" + str(corpus_id) + "/node_link.json"
# rendered page : journals.html
# rendered page : explorer.html
return render(
template_name = 'graphExplorer/explorer.html',
request = request,
......@@ -35,9 +38,8 @@ def explorer(request, project_id, corpus_id):
'date' : datetime.now(),
'project' : project,
'corpus' : corpus,
#'list_id' : maplist.id,\
'graphfile' : graphurl,\
'maplist_id': maplist_id,
'graphfile' : graphurl,
'view' : 'graph'
},
)
......@@ -23,15 +23,11 @@ function modify_ngrams( classname ) {
console.clear()
var corpus_id = getIDFromURL( "corpora" ) // not used
var list_id = $("#list_id").val()
var list_id = $("#maplist_id").val()
var selected_ngrams = $.extend({}, selections)
console.log( selected_ngrams )
if(classname=="delete") {
CRUD( corpus_id , "/keep" , [] , selected_ngrams , "DELETE" , function(result) {
console.log(" Delete from Map-list: "+result)
CRUD( list_id , "" , Object.keys(selected_ngrams).map(Number) , [] , "DELETE", function(result) {
console.log(" Add to Stop-list "+result)
CRUD(list_id, Object.keys(selected_ngrams), "DELETE", function(success) {
cancelSelection(false)
for(var i in selected_ngrams) {
partialGraph.dropNode( i )
......@@ -40,8 +36,7 @@ function modify_ngrams( classname ) {
}
partialGraph.refresh()
$("#lensButton").click()
});
});
}) ;
}
// if(classname=="group") {
......@@ -53,33 +48,43 @@ function modify_ngrams( classname ) {
// }
}
function CRUD( parent_id , action , nodes , args , http_method , callback) {
var the_url = window.location.origin+"/api/node/"+parent_id+"/ngrams"+action+"/"+nodes.join("+");
the_url = the_url.replace(/\/$/, ""); //remove trailing slash
console.log( the_url )
console.log( args )
if(nodes.length>0 || Object.keys(args).length>0) {
function CRUD( list_id , ngram_ids , http_method , callback) {
// ngramlists/change?node_id=42&ngram_ids=1,2
var the_url = window.location.origin+"/api/ngramlists/change?list="+list_id+"&ngrams="+ngram_ids.join(",");
// debug
// console.log("starting CRUD AJAX => URL: " + the_url + " (" + http_method + ")")
if(ngram_ids.length>0) {
$.ajax({
method: http_method,
url: the_url,
data: args,
// data: args, // currently all data explicitly in the url (like a GET)
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data){
console.log("-- CRUD ----------")
console.log(http_method + " ok!!")
console.log(nodes)
console.log(data)
callback("Success");
console.log(JSON.stringify(data))
console.log("------------------")
callback(true);
},
error: function(result) {
console.log("-- CRUD ----------")
console.log("Data not found in #Save_All");
console.log(result)
callback("Fail");
console.log("------------------")
callback(false);
}
});
} else callback(false);
}
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// Execution: ChangeGraphAppearanceByAtt( true )
......
......@@ -136,7 +136,7 @@
<li>
<a>
<div id="graphid" style="visibility: hidden;">{{graphfile}}</div>
<input type="hidden" id="list_id" value="{{ list_id }}"></input>
<input type="hidden" id="maplist_id" value="{{ maplist_id }}"></input>
<div id="jquerytemplatenb" style="visibility: hidden;">{{user.id}}</div>
</a>
</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment