webui: adding and listing identities

This commit is contained in:
zeners 2016-01-31 18:16:26 +01:00
parent 94b02943e6
commit 57d1d0868a
7 changed files with 113 additions and 10 deletions

View File

@ -0,0 +1,51 @@
"use strict";
var m = require("mithril");
var rs = require("retroshare");
function createidentity(){
var data = {
name: document.getElementById("txtname").value,
pgp_linked: document.getElementById("chklinked").checked,
};
m.route("/waiting");
rs.request("identity/create_identity",data, function(){
m.route("/identities");
})
}
module.exports = {view: function(){
m.initControl = "txtname";
return m("div",
m("h2","create identity"),
m("hr"),
m("h3","name"),
m("input", {
type: "text",
id: "txtname",
/*
onkeydown: function(event){
if (event.keyCode == 13){
setPasswd(this.value);
sendPassword(needpasswd);
}
}
*/
}),
m("b","linked with pgp-id: "),
m("input", {
type: "checkbox",
id: "chklinked",
style: {
fontweight:"bold",
width: "0%",
}
}),
m("p"," "),
m("input.btn2", {
onclick: createidentity,
type: "button",
value: "create new identity",
})
)
}}

View File

@ -61,7 +61,7 @@ module.exports = {
}
};
return m("div",[
m("h2","add new friend (Step 2/3)"),
m("h2","add new friend (Step 3/3)"),
m("p","Do you want to add "
+ m.route.param("name")
+ " (" + m.route.param("location") + ")"
@ -79,6 +79,7 @@ module.exports = {
}), "Auto download recommended files from this node",
m("div.btn2",{
onclick: function(){
m.route("/waiting");
rs.request("peers",result,function(data, responsetoken){
m.route("/peers");
})

View File

@ -189,9 +189,7 @@ module.exports = {
m("br"),
m("input",{
type: "button",
onclick: function(){
createLocation();
},
onclick: createLocation,
value: "create location",
}),
]);
@ -228,9 +226,7 @@ module.exports = {
m("br"),
m("input",{
type: "button",
onclick: function(){
createLocation();
},
onclick: createLocation,
value: "create location",
}),
]);

View File

@ -0,0 +1,21 @@
"use strict";
var m = require("mithril");
var rs = require("retroshare");
module.exports = {view: function(){
return m("div",[
m("h2","identities"),
m("hr"),
m("div.btn2", {
onclick: function (){
m.route("/addidentity");
}
},"< create new identity >"),
m("ul",
rs.list("identity/own", function(item){
return m("li",[m("h2",item.name)]);
})
)
]);
}}

View File

@ -39,6 +39,16 @@ module.exports = { nodes: [
runstate: "running_ok.*",
show: false,
},
{
name: "identities",
runstate: "running_ok.*",
counter: rs.counting("identity/own"),
},
{
name: "addidentity",
runstate: "running_ok.*",
show: false,
},
{
name:"searchresult",
path: "/search/:id",
@ -51,9 +61,7 @@ module.exports = { nodes: [
{
name: "downloads",
runstate: "running_ok.*",
counter: rs.counting("transfers/downloads", function(data) {
return data.length;
})
counter: rs.counting("transfers/downloads")
},
{
name: "chat",
@ -70,5 +78,9 @@ module.exports = { nodes: [
});
}
},
{
name: "waiting",
show: false,
},
]
}

View File

@ -203,6 +203,7 @@ function rs(path, args, callback, options){
module.exports = rs;
// single request for action
rs.request=function(path, args, callback, options){
if (options === undefined) {
options = {};
@ -226,6 +227,7 @@ rs.request=function(path, args, callback, options){
return req;
};
// force reload for path
rs.forceUpdate = function(path){
cache[path].requested=false;
}
@ -241,13 +243,25 @@ rs.apiurl = function(path) {
return api_url + path;
}
// counting in menu
rs.counting = function(path, counterfnkt) {
return function () {
var data=rs(path);
if (data != undefined) {
if (counterfnkt === undefined) {
return " (" + data.length + ")";
}
return " (" + counterfnkt(data) + ")";
}
return "";
}
}
// listing data-elements
rs.list = function(path, buildfktn){
var list = rs(path);
if (list === undefined) {
return "< waiting for server ... >"
}
return list.map(buildfktn);
}

View File

@ -0,0 +1,8 @@
"use strict";
var m = require("mithril");
var rs = require("retroshare");
module.exports = {view: function(){
return m("h2","please wait ...");
}}