mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
webui: searchdetails and searchlist splitted
This commit is contained in:
parent
4c66bb87bb
commit
4a8db15da6
@ -37,7 +37,7 @@ function Page(content, runst){
|
|||||||
} else {
|
} else {
|
||||||
if ("waiting_init|waiting_startup".match(runstate.runstate)) {
|
if ("waiting_init|waiting_startup".match(runstate.runstate)) {
|
||||||
return m("h2","server starting ...")
|
return m("h2","server starting ...")
|
||||||
} else if("waiting_account_select|running_ok*") {
|
} else if("waiting_account_select|running_ok*".match(runstate.runstate)) {
|
||||||
if (runst === undefined || runst.match(runstate.runstate)) {
|
if (runst === undefined || runst.match(runstate.runstate)) {
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("div", menu.view()),
|
m("div", menu.view()),
|
||||||
|
@ -11,7 +11,8 @@ function goback(){
|
|||||||
|
|
||||||
function buildmenu(menu, tagname, runstate, ignore){
|
function buildmenu(menu, tagname, runstate, ignore){
|
||||||
if ((menu.runstate === undefined || runstate.match(menu.runstate))
|
if ((menu.runstate === undefined || runstate.match(menu.runstate))
|
||||||
&& (!ignore.match(menu.name))) {
|
&& (!ignore.match(menu.name))
|
||||||
|
&& (menu.path === undefined || !menu.path.contains(":"))) {
|
||||||
if (menu.action === undefined) {
|
if (menu.action === undefined) {
|
||||||
return m(tagname , {
|
return m(tagname , {
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
|
@ -12,6 +12,11 @@ module.exports = { nodes: [
|
|||||||
name: "peers",
|
name: "peers",
|
||||||
runstate: "running_ok.*",
|
runstate: "running_ok.*",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"searchresult",
|
||||||
|
path: "/search/:id",
|
||||||
|
runstate: "running_ok.*",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "search",
|
name: "search",
|
||||||
runstate: "running_ok.*",
|
runstate: "running_ok.*",
|
||||||
|
@ -170,7 +170,7 @@ function rs(path, args, callback, options){
|
|||||||
allow: options.allow === undefined ? "ok" : options.allow,
|
allow: options.allow === undefined ? "ok" : options.allow,
|
||||||
then: function(response){
|
then: function(response){
|
||||||
console.log(path + ": response: " + response.returncode);
|
console.log(path + ": response: " + response.returncode);
|
||||||
if (!allow.match(response.returncode)) {
|
if (!this.allow.match(response.returncode)) {
|
||||||
requestFail(path, response, null);
|
requestFail(path, response, null);
|
||||||
} else if (callback != undefined && callback != null) {
|
} else if (callback != undefined && callback != null) {
|
||||||
callback(response.data, response.statetoken);
|
callback(response.data, response.statetoken);
|
||||||
|
@ -15,56 +15,37 @@ function dosearch(){
|
|||||||
distant: true,
|
distant: true,
|
||||||
search_string: searchText
|
search_string: searchText
|
||||||
},
|
},
|
||||||
onCreateSearchResponse
|
function(resp){
|
||||||
|
m.route("/search/" + resp.search_id);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreateSearchResponse(resp){
|
|
||||||
state={search_id: resp.search_id};
|
|
||||||
//tracking searchresults
|
|
||||||
rs("filesearch/"+state.search_id,{},null,{allow:"not_set|ok"});
|
|
||||||
//todo: route search/id, caching search-resultlists
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
view: function(){
|
view: function(){
|
||||||
var results = [];
|
var results = rs("filesearch");
|
||||||
if (state.search_id != undefined){
|
if (results === undefined||results == null) {
|
||||||
var searchresult = rs("filesearch/"+state.search_id);
|
results = [];
|
||||||
if (searchresult != undefined) {
|
};
|
||||||
results = searchresult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m("div",[
|
return m("div",[
|
||||||
m("h2","turtle file search"),
|
m("h2","turtle file search"),
|
||||||
m("div", [
|
m("div", [
|
||||||
m("input[type=text]", {onchange:m.withAttr("value", updateText)}),
|
m("input[type=text]", {onchange:m.withAttr("value", updateText)}),
|
||||||
m("input[type=button][value=search]",{onclick:dosearch})
|
m("input[type=button][value=search]",{onclick:dosearch})
|
||||||
]),
|
]),
|
||||||
m("table", [
|
m("hr"),
|
||||||
m("tr" ,[
|
m("h2","previous searches:"),
|
||||||
m("th","name"),
|
m("div", [
|
||||||
m("th","size"),
|
results.map(function(item){
|
||||||
m("th",""),
|
var res = rs("filesearch/" + item.id,{},null,{allow:"not_set|ok"});
|
||||||
]),
|
if (res === undefined) {
|
||||||
results.map(function(file){
|
res =[];
|
||||||
return m("tr",[
|
};
|
||||||
m("th",file.name),
|
return m("div.btn2",{
|
||||||
m("th",file.size),
|
onclick:function(){
|
||||||
m("th",[
|
m.route("/search/" + item.id);
|
||||||
m("span.btn", {
|
}
|
||||||
onclick:function(){
|
}, item.search_string + " (" + res.length + ")");
|
||||||
rs.request("transfers/control_download", {
|
|
||||||
action: "begin",
|
|
||||||
name: file.name,
|
|
||||||
size: file.size,
|
|
||||||
hash: file.hash,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"download")
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
54
libresapi/src/webui-src/app/searchresult.js
Normal file
54
libresapi/src/webui-src/app/searchresult.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
var m = require("mithril");
|
||||||
|
var rs = require("retroshare");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
view: function(){
|
||||||
|
var id=m.route.param("id");
|
||||||
|
console.log("search_id: " + id);
|
||||||
|
var results = rs("filesearch/" + id ,{},null,{allow:"not_set|ok"});
|
||||||
|
if (results === undefined || results.length == undefined) {
|
||||||
|
results = [];
|
||||||
|
}
|
||||||
|
var searches = rs("filesearch");
|
||||||
|
var searchdetail = "<unknown>";
|
||||||
|
if (!(searches === undefined) && !(searches.length === undefined)) {
|
||||||
|
searches.forEach(function(s){
|
||||||
|
if (s.id == id) {
|
||||||
|
searchdetail = s.search_string;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return m("div",[
|
||||||
|
m("h2","turtle file search results"),
|
||||||
|
m("h3", "searchtext: " + searchdetail + " (" + results.length + ")"),
|
||||||
|
m("hr"),
|
||||||
|
m("table", [
|
||||||
|
m("tr" ,[
|
||||||
|
m("th","name"),
|
||||||
|
m("th","size"),
|
||||||
|
m("th",""),
|
||||||
|
]),
|
||||||
|
results.map(function(file){
|
||||||
|
return m("tr",[
|
||||||
|
m("th",file.name),
|
||||||
|
m("th",file.size),
|
||||||
|
m("th",[
|
||||||
|
m("span.btn", {
|
||||||
|
onclick:function(){
|
||||||
|
rs.request("transfers/control_download", {
|
||||||
|
action: "begin",
|
||||||
|
name: file.name,
|
||||||
|
size: file.size,
|
||||||
|
hash: file.hash,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"download")
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
})
|
||||||
|
])
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user