mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
webui: adding and listing identities
This commit is contained in:
parent
94b02943e6
commit
57d1d0868a
51
libresapi/src/webui-src/app/addidentity.js
Normal file
51
libresapi/src/webui-src/app/addidentity.js
Normal 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",
|
||||
})
|
||||
)
|
||||
}}
|
@ -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");
|
||||
})
|
||||
|
@ -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",
|
||||
}),
|
||||
]);
|
||||
|
21
libresapi/src/webui-src/app/identities.js
Normal file
21
libresapi/src/webui-src/app/identities.js
Normal 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)]);
|
||||
})
|
||||
)
|
||||
]);
|
||||
}}
|
@ -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,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
8
libresapi/src/webui-src/app/waiting.js
Normal file
8
libresapi/src/webui-src/app/waiting.js
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
|
||||
module.exports = {view: function(){
|
||||
return m("h2","please wait ...");
|
||||
}}
|
Loading…
Reference in New Issue
Block a user