mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-27 15:57:08 -05:00
webui: RS-reboot / RS-reboot-detection improved
paths without token, are now pulled
This commit is contained in:
parent
60e9f0f35d
commit
585c43bb25
@ -3,39 +3,43 @@
|
|||||||
var m = require("mithril");
|
var m = require("mithril");
|
||||||
var rs = require("retroshare");
|
var rs = require("retroshare");
|
||||||
|
|
||||||
var curraccount = null;
|
|
||||||
var accountMap = new Map();
|
|
||||||
|
|
||||||
function cancel(){
|
function cancel(){
|
||||||
curraccount=null;
|
rs.memory("control/locations").curraccount=null;
|
||||||
m.redraw();
|
m.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selAccount(account){
|
function selAccount(account){
|
||||||
curraccount=accountMap.get(account);
|
rs.memory("control/locations").curraccount=account;
|
||||||
m.redraw();
|
m.redraw();
|
||||||
rs.request("control/login", {id: curraccount.id}, function(){
|
rs.request("control/login", {id: account.id}, function(){
|
||||||
console.log("login sent");
|
console.log("login sent");
|
||||||
rs.clearCache();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function curraccount() {
|
||||||
|
var mem;
|
||||||
|
mem = rs.memory("control/locations");
|
||||||
|
if (mem.curraccount === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return mem.curraccount;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {view: function(){
|
module.exports = {view: function(){
|
||||||
var accounts = rs("control/locations");
|
var accounts = rs("control/locations");
|
||||||
if(accounts === undefined || accounts == null){
|
if(accounts === undefined || accounts == null){
|
||||||
return m("div", "accounts: waiting_server");
|
return m("div", "accounts: waiting_server");
|
||||||
}
|
}
|
||||||
if (curraccount == null) {
|
if (curraccount() == null) {
|
||||||
accountMap.clear();
|
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("h2","login:"),
|
m("h2","login:"),
|
||||||
m("hr"),
|
m("hr"),
|
||||||
accounts.map(function(account){
|
accounts.map(function(account){
|
||||||
accountMap.set(account.id,account);
|
|
||||||
return [
|
return [
|
||||||
m("div.btn2", {
|
m("div.btn2", {
|
||||||
onclick: m.withAttr("account", selAccount),
|
onclick: function(){
|
||||||
account:account.id
|
selAccount(account)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
account.location + " (" + account.name + ")"),
|
account.location + " (" + account.name + ")"),
|
||||||
m("br")
|
m("br")
|
||||||
@ -43,7 +47,18 @@ module.exports = {view: function(){
|
|||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return m("div", "logging in ..." );
|
// rs.untoken("control/password");
|
||||||
|
return m("div", [
|
||||||
|
m("div", "logging in ... (waiting for password-request)"),
|
||||||
|
/*
|
||||||
|
m("hr"),
|
||||||
|
m(".btn2", {
|
||||||
|
onclick: function() {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
},"Cancel " + curraccount().name + " login "),
|
||||||
|
*/
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,6 +33,10 @@ function Page(menu){
|
|||||||
if(runstate === undefined){
|
if(runstate === undefined){
|
||||||
return m("h2", "waiting_server ... ");
|
return m("h2", "waiting_server ... ");
|
||||||
} else if (runstate.runstate == null){
|
} else if (runstate.runstate == null){
|
||||||
|
// try clean reboot ...
|
||||||
|
rs.clearCache();
|
||||||
|
rs("control/runstate"); //reboot detector
|
||||||
|
console.log("i'm down");
|
||||||
return m("h2", "server down");
|
return m("h2", "server down");
|
||||||
} else if (needpasswd != undefined && needpasswd.want_password === true){
|
} else if (needpasswd != undefined && needpasswd.want_password === true){
|
||||||
m.initControl = "txtpasswd";
|
m.initControl = "txtpasswd";
|
||||||
|
@ -8,6 +8,7 @@ module.exports = { nodes: [
|
|||||||
name: "login",
|
name: "login",
|
||||||
module: "accountselect",
|
module: "accountselect",
|
||||||
runstate: "waiting_account_select",
|
runstate: "waiting_account_select",
|
||||||
|
counter: rs.counting("control/locations"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "create login",
|
name: "create login",
|
||||||
|
@ -40,10 +40,13 @@ var last_update_ts = 0;
|
|||||||
|
|
||||||
function check_for_changes(){
|
function check_for_changes(){
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
// console.log("start-check");
|
var paths_to_fetch = [];
|
||||||
|
// console.log("start-check " + Object.keys(cache));
|
||||||
for_key_in_obj(cache, function(path){
|
for_key_in_obj(cache, function(path){
|
||||||
var token = cache[path].statetoken;
|
var token = cache[path].statetoken;
|
||||||
if(token !== undefined){
|
if(token === undefined || token== null) {
|
||||||
|
paths_to_fetch.push(path)
|
||||||
|
} else if (tokens.indexOf(token)<0) {
|
||||||
tokens.push(token);
|
tokens.push(token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -56,8 +59,7 @@ function check_for_changes(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
req.then(function handle_statetoken_response(response){
|
req.then(function handle_statetoken_response(response){
|
||||||
// console.log("checking result " + response);
|
// console.log("checking result " + response.data ? Object.keys(response.data) : "<null>") ;
|
||||||
var paths_to_fetch = [];
|
|
||||||
for_key_in_obj(cache, function(path){
|
for_key_in_obj(cache, function(path){
|
||||||
var found = false;
|
var found = false;
|
||||||
for(var i = 0; i < response.data.length; i++){
|
for(var i = 0; i < response.data.length; i++){
|
||||||
@ -69,7 +71,7 @@ function check_for_changes(){
|
|||||||
paths_to_fetch.push(path);
|
paths_to_fetch.push(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// console.log("generating Results for " + paths_to_fetch.length + " paths");
|
// console.log("generating Results for paths " + paths_to_fetch);
|
||||||
var requests = [];
|
var requests = [];
|
||||||
paths_to_fetch.map(function request_it(path){
|
paths_to_fetch.map(function request_it(path){
|
||||||
var req2 = m.request({
|
var req2 = m.request({
|
||||||
@ -263,7 +265,17 @@ rs.forceUpdate = function(path, removeCache){
|
|||||||
|
|
||||||
// force reload for all
|
// force reload for all
|
||||||
rs.clearCache = function(path, removeCache){
|
rs.clearCache = function(path, removeCache){
|
||||||
|
console.log("clearing Cache ...")
|
||||||
cache = {};
|
cache = {};
|
||||||
|
console.log("update_scheduled: " + update_scheduled);
|
||||||
|
update_scheduled = false;
|
||||||
|
check_for_changes();
|
||||||
|
console.log("Cache cleared.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// dismiss statetoken (= force reload)
|
||||||
|
rs.untoken = function(path) {
|
||||||
|
cache[path].statetoken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user