webui: searchresult cross-checking with downloads

This commit is contained in:
zeners 2016-03-27 20:13:47 +02:00
parent 3bbd370242
commit bbdb04fd78

View file

@ -18,6 +18,16 @@ module.exports = {
} }
}); });
} }
var dl_ids = [];
var downloads =rs("transfers/downloads");
if (downloads !== undefined) {
downloads.map(function(item){
dl_ids.push(item.hash);
})
}
return m("div",[ return m("div",[
m("h2","turtle file search results"), m("h2","turtle file search results"),
m("h3", "searchtext: " + searchdetail + " (" + results.length + ")"), m("h3", "searchtext: " + searchdetail + " (" + results.length + ")"),
@ -29,21 +39,29 @@ module.exports = {
m("th",""), m("th",""),
]), ]),
results.map(function(file){ results.map(function(file){
if (dl_ids.indexOf(file.hash)>=0) {
file.state="in download queue"
}
return m("tr",[ return m("tr",[
m("th",file.name), m("th",file.name),
m("th",file.size), m("th",file.size),
m("th",[ m("th",[
m("span.btn", { file.state === undefined
? m("span.btn", {
onclick:function(){ onclick:function(){
rs.request("transfers/control_download", { rs.request("transfers/control_download", {
action: "begin", action: "begin",
name: file.name, name: file.name,
size: file.size, size: file.size,
hash: file.hash, hash: file.hash,
}, function(){
result="added";
}); });
m.startComputation();
m.endComputation();
} }
}, }, "download")
"download") : file.state
]), ]),
]) ])
}) })