mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 01:31:30 -05: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",[
|
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("p","Do you want to add "
|
||||||
+ m.route.param("name")
|
+ m.route.param("name")
|
||||||
+ " (" + m.route.param("location") + ")"
|
+ " (" + m.route.param("location") + ")"
|
||||||
@ -79,6 +79,7 @@ module.exports = {
|
|||||||
}), "Auto download recommended files from this node",
|
}), "Auto download recommended files from this node",
|
||||||
m("div.btn2",{
|
m("div.btn2",{
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
|
m.route("/waiting");
|
||||||
rs.request("peers",result,function(data, responsetoken){
|
rs.request("peers",result,function(data, responsetoken){
|
||||||
m.route("/peers");
|
m.route("/peers");
|
||||||
})
|
})
|
||||||
|
@ -189,9 +189,7 @@ module.exports = {
|
|||||||
m("br"),
|
m("br"),
|
||||||
m("input",{
|
m("input",{
|
||||||
type: "button",
|
type: "button",
|
||||||
onclick: function(){
|
onclick: createLocation,
|
||||||
createLocation();
|
|
||||||
},
|
|
||||||
value: "create location",
|
value: "create location",
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
@ -228,9 +226,7 @@ module.exports = {
|
|||||||
m("br"),
|
m("br"),
|
||||||
m("input",{
|
m("input",{
|
||||||
type: "button",
|
type: "button",
|
||||||
onclick: function(){
|
onclick: createLocation,
|
||||||
createLocation();
|
|
||||||
},
|
|
||||||
value: "create location",
|
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.*",
|
runstate: "running_ok.*",
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "identities",
|
||||||
|
runstate: "running_ok.*",
|
||||||
|
counter: rs.counting("identity/own"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "addidentity",
|
||||||
|
runstate: "running_ok.*",
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name:"searchresult",
|
name:"searchresult",
|
||||||
path: "/search/:id",
|
path: "/search/:id",
|
||||||
@ -51,9 +61,7 @@ module.exports = { nodes: [
|
|||||||
{
|
{
|
||||||
name: "downloads",
|
name: "downloads",
|
||||||
runstate: "running_ok.*",
|
runstate: "running_ok.*",
|
||||||
counter: rs.counting("transfers/downloads", function(data) {
|
counter: rs.counting("transfers/downloads")
|
||||||
return data.length;
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "chat",
|
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;
|
module.exports = rs;
|
||||||
|
|
||||||
|
// single request for action
|
||||||
rs.request=function(path, args, callback, options){
|
rs.request=function(path, args, callback, options){
|
||||||
if (options === undefined) {
|
if (options === undefined) {
|
||||||
options = {};
|
options = {};
|
||||||
@ -226,6 +227,7 @@ rs.request=function(path, args, callback, options){
|
|||||||
return req;
|
return req;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// force reload for path
|
||||||
rs.forceUpdate = function(path){
|
rs.forceUpdate = function(path){
|
||||||
cache[path].requested=false;
|
cache[path].requested=false;
|
||||||
}
|
}
|
||||||
@ -241,13 +243,25 @@ rs.apiurl = function(path) {
|
|||||||
return api_url + path;
|
return api_url + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// counting in menu
|
||||||
rs.counting = function(path, counterfnkt) {
|
rs.counting = function(path, counterfnkt) {
|
||||||
return function () {
|
return function () {
|
||||||
var data=rs(path);
|
var data=rs(path);
|
||||||
if (data != undefined) {
|
if (data != undefined) {
|
||||||
|
if (counterfnkt === undefined) {
|
||||||
|
return " (" + data.length + ")";
|
||||||
|
}
|
||||||
return " (" + counterfnkt(data) + ")";
|
return " (" + counterfnkt(data) + ")";
|
||||||
}
|
}
|
||||||
return "";
|
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…
x
Reference in New Issue
Block a user