mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
webui: createlogin for existing pgp-key
This commit is contained in:
parent
640345c490
commit
e944ab6045
@ -32,10 +32,15 @@ module.exports = {view: function(){
|
||||
accounts.map(function(account){
|
||||
accountMap.set(account.id,account);
|
||||
return [
|
||||
m("div.btn2", {onclick: m.withAttr("account", selAccount), account:account.id }, account.location + " (" + account.name + ")"),
|
||||
m("div.btn2", {
|
||||
onclick: m.withAttr("account", selAccount),
|
||||
account:account.id
|
||||
},
|
||||
account.location + " (" + account.name + ")"),
|
||||
m("br")
|
||||
]
|
||||
})]);
|
||||
})
|
||||
]);
|
||||
} else {
|
||||
return m("div", "logging in ..." );
|
||||
}
|
||||
|
@ -14,6 +14,9 @@
|
||||
var ui = require("main");
|
||||
var main = document.getElementById("main");
|
||||
ui.init(main);
|
||||
if (m.initControl != undefined) {
|
||||
m.initControl.focus();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
110
libresapi/src/webui-src/app/createlogin.js
Normal file
110
libresapi/src/webui-src/app/createlogin.js
Normal file
@ -0,0 +1,110 @@
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
|
||||
var locationName = "";
|
||||
var password ="";
|
||||
|
||||
function listprofiles(){
|
||||
var locations = rs("control/locations");
|
||||
var knownProfileIds = [];
|
||||
var result = [];
|
||||
if(locations === undefined || locations == null){
|
||||
return m("div", "profiles: waiting_server");
|
||||
}
|
||||
locations.map(function(location) {
|
||||
if (knownProfileIds.indexOf(location.pgp_id)<0){
|
||||
knownProfileIds.push(location.pgp_id);
|
||||
result.push(m(
|
||||
"div.btn2",{
|
||||
onclick: function(){
|
||||
m.route("/createlogin",{
|
||||
id: location.pgp_id,
|
||||
name: location.name,
|
||||
})
|
||||
}
|
||||
},
|
||||
location.name
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function setLocationName(location) {
|
||||
locationName = location;
|
||||
}
|
||||
|
||||
function setPasswd(passwd) {
|
||||
password = passwd;
|
||||
}
|
||||
|
||||
|
||||
function createLocation(loc) {
|
||||
rs.request("control/create_location",loc,function(data){
|
||||
m.route("/accountselect", {});
|
||||
});
|
||||
m.route("/createlogin",{state:wait});
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
view: function(){
|
||||
var profile = m.route.param("id");
|
||||
var state = m.route.param("state");
|
||||
var profname = m.route.param("name");
|
||||
var hidden = m.route.param("hidden");
|
||||
if (state == "wait"){
|
||||
return m("div","waiting ...");
|
||||
} else if (profile === undefined) {
|
||||
return m("div",[
|
||||
m("h2","create login - Step 1 / 2: select profile(PGP-ID)"),
|
||||
m("hr"),
|
||||
m("div.btn2",{} ,"<create new profile>"),
|
||||
m("div.btn2",{} ,"<import profile (drag and drop a profile here)>"),
|
||||
listprofiles()
|
||||
]);
|
||||
};
|
||||
m.initControl = "txtpasswd";
|
||||
return m("div",[
|
||||
m("h2","create login - Step 2 / 2: create location"),
|
||||
m("h3","- for " + profname + " (" +profile + ")"),
|
||||
m("hr"),
|
||||
m("h2","enter password:"),
|
||||
m("input", {
|
||||
id: "txtpasswd",
|
||||
type:"password",
|
||||
onchange: m.withAttr("value",setPasswd),
|
||||
onkeydown: function(event){
|
||||
if (event.keyCode == 13){
|
||||
setPasswd(this.value);
|
||||
document.getElementById("txtlocation").focus();
|
||||
}
|
||||
}
|
||||
}),
|
||||
m("h2","location name:"),
|
||||
m("input",{
|
||||
id: "txtlocation",
|
||||
type:"text",
|
||||
onchange:m.withAttr("value", setLocationName),
|
||||
onkeydown: function(event){
|
||||
if (event.keyCode == 13){
|
||||
createLocation({
|
||||
ssl_name: this.value,
|
||||
pgp_id: profile,
|
||||
pgp_password: password,
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
m("br"),
|
||||
m("input",{
|
||||
type: "button",
|
||||
onclick: function(){
|
||||
createLocation(locationName);
|
||||
},
|
||||
value: "create location",
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
@ -27,12 +27,27 @@ function Page(content, runst){
|
||||
} else if (runstate.runstate == null){
|
||||
return m("h2", "server down");
|
||||
} else if (needpasswd != undefined && needpasswd.want_password === true){
|
||||
m.initControl = "txtpasswd";
|
||||
return m("div",[
|
||||
m("h2","password required"),
|
||||
m("h3",needpasswd.key_name),
|
||||
m("input",{type:"password", onchange:m.withAttr("value", setPasswd)}),
|
||||
m("input",{
|
||||
id: "txtpasswd",
|
||||
type:"password",
|
||||
onchange:m.withAttr("value", setPasswd),
|
||||
onkeydown: function(event){
|
||||
if (event.keyCode == 13){
|
||||
setPasswd(this.value);
|
||||
sendPassword(needpasswd);
|
||||
}
|
||||
}
|
||||
}),
|
||||
m("br"),
|
||||
m("input[type=button][value=send password]",{onclick: function(){sendPassword(needpasswd);}}),
|
||||
m("input[type=button][value=send password]",{
|
||||
onclick: function(){
|
||||
sendPassword(needpasswd);
|
||||
}
|
||||
}),
|
||||
]);
|
||||
} else {
|
||||
if ("waiting_init|waiting_startup".match(runstate.runstate)) {
|
||||
|
@ -8,6 +8,12 @@ module.exports = { nodes: [
|
||||
module: "accountselect",
|
||||
runstate: "waiting_account_select",
|
||||
},
|
||||
{
|
||||
name: "create login",
|
||||
path: "/createlogin",
|
||||
module: "createlogin",
|
||||
runstate: "waiting_account_select",
|
||||
},
|
||||
{
|
||||
name: "peers",
|
||||
runstate: "running_ok.*",
|
||||
|
@ -88,6 +88,7 @@ function check_for_changes(){
|
||||
m.sync(requests).then(function trigger_render(){
|
||||
m.startComputation();
|
||||
m.endComputation();
|
||||
checkFocus();
|
||||
setTimeout(check_for_changes, 500);
|
||||
});
|
||||
}
|
||||
@ -148,10 +149,23 @@ function schedule_request_missing(){
|
||||
m.sync(requests).then(function trigger_render(){
|
||||
m.startComputation();
|
||||
m.endComputation();
|
||||
checkFocus();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function checkFocus(){
|
||||
if (m.initControl != undefined) {
|
||||
var ctrl = document.getElementById(m.initControl);
|
||||
if (ctrl!= null) {
|
||||
ctrl.focus();
|
||||
m.initControl = undefined;
|
||||
} else {
|
||||
console.log("focus-control '" + m.initControl + "' not found!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// called every time, rs or rs.request failed, only response or value is set
|
||||
function requestFail(path, response, value) {
|
||||
rs.error = "error on " + path;
|
||||
|
Loading…
Reference in New Issue
Block a user