mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
webui: peers improved, adding peer prepared
This commit is contained in:
parent
4a8db15da6
commit
0f3ec80564
70
libresapi/src/webui-src/app/addpeer.js
Normal file
70
libresapi/src/webui-src/app/addpeer.js
Normal file
@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
|
||||
|
||||
module.exports = {
|
||||
view: function(){
|
||||
return m("h2","add new friend");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
return "peers/self/certificate"
|
||||
|
||||
|
||||
|
||||
RS.request({path: "peers/examine_cert", data: {cert_string: cert_string}}, this.examine_cert_callback);
|
||||
this.setState({page:"waiting", cert_string: cert_string});
|
||||
|
||||
|
||||
RS.request(
|
||||
{
|
||||
path: "peers",
|
||||
data: {
|
||||
cert_string: this.state.cert_string,
|
||||
flags:{
|
||||
allow_direct_download: this.refs.cb_direct_dl.getDOMNode().checked,
|
||||
allow_push: this.refs.cb_push.getDOMNode().checked,
|
||||
// set to false, until the webinterface supports managment of the blacklist/whitelist
|
||||
require_whitelist: false,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
render: function(){
|
||||
if(this.state.page === "start")
|
||||
return(
|
||||
<div>
|
||||
<p>Your own key, give it to your friends</p>
|
||||
<OwnCert/>
|
||||
<p>paste your friends key below</p>
|
||||
<textarea ref="cert" cols="70" rows="16"></textarea><br/>
|
||||
<input
|
||||
type="button"
|
||||
value="read key"
|
||||
onClick={this.add_friend_handler}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
if(this.state.page === "waiting")
|
||||
return(
|
||||
<div>
|
||||
waiting for response from server...
|
||||
</div>
|
||||
);
|
||||
if(this.state.page === "peer")
|
||||
return(
|
||||
<div>
|
||||
<p>Do you want to add {this.state.data.name} to your friendslist?</p>
|
||||
<input className="checkbox" type="checkbox" ref="cb_direct_dl"/> Allow direct downloads from this node<br/>
|
||||
<input className="checkbox" type="checkbox" ref="cb_push"/> Auto download recommended files from this node<br/>
|
||||
<div onClick={this.final_add_handler} className="btn2">add to friendslist</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
*/
|
@ -10,9 +10,12 @@ function goback(){
|
||||
}
|
||||
|
||||
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))
|
||||
&& (menu.path === undefined || !menu.path.contains(":"))) {
|
||||
&& (menu.path === undefined || !menu.path.contains(":"))
|
||||
&& (menu.show === undefined || menu.show)
|
||||
) {
|
||||
if (menu.action === undefined) {
|
||||
return m(tagname , {
|
||||
onclick: function(){
|
||||
|
@ -12,6 +12,11 @@ module.exports = { nodes: [
|
||||
name: "peers",
|
||||
runstate: "running_ok.*",
|
||||
},
|
||||
{
|
||||
name: "addpeer",
|
||||
runstate: "running_ok.*",
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
name:"searchresult",
|
||||
path: "/search/:id",
|
||||
|
@ -7,10 +7,35 @@ module.exports = {view: function(){
|
||||
var peers = rs("peers");
|
||||
console.log("peers:" + peers);
|
||||
if(peers === undefined){
|
||||
return m("div", "waiting_server");
|
||||
return m("div",[
|
||||
m("h2","peers"),
|
||||
m("h3","waiting_server"),
|
||||
]);
|
||||
};
|
||||
var online = 0;
|
||||
var peerlist = peers.map(function(peer){
|
||||
var isonline = false;
|
||||
var loclist = peer.locations.map(function(location){
|
||||
if (location.is_online && ! isonline){
|
||||
online +=1;
|
||||
isonline = true;
|
||||
}
|
||||
return m("div", peers.map(function(peer){
|
||||
return m("div",peer.name)
|
||||
}));
|
||||
return m("li",
|
||||
{style:"color:" + (location.is_online ? "lime": "grey")},
|
||||
location.location);
|
||||
});
|
||||
return [
|
||||
m("h2", {style:"color:" + (isonline ? "lime": "grey")} ,peer.name),
|
||||
m("ul", loclist ),
|
||||
];
|
||||
});
|
||||
|
||||
return m("div",[
|
||||
m("div.btn2",{onclick: function(){m.route("/addpeer")}},"add new friend"),
|
||||
m("h2","peers ( online: " + online +" / " + peers.length + "):"),
|
||||
m("table", [
|
||||
peerlist,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user