mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -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 rs = require("retroshare");
|
||||
|
||||
var curraccount = null;
|
||||
var accountMap = new Map();
|
||||
|
||||
function cancel(){
|
||||
curraccount=null;
|
||||
rs.memory("control/locations").curraccount=null;
|
||||
m.redraw();
|
||||
}
|
||||
|
||||
function selAccount(account){
|
||||
curraccount=accountMap.get(account);
|
||||
rs.memory("control/locations").curraccount=account;
|
||||
m.redraw();
|
||||
rs.request("control/login", {id: curraccount.id}, function(){
|
||||
rs.request("control/login", {id: account.id}, function(){
|
||||
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(){
|
||||
var accounts = rs("control/locations");
|
||||
if(accounts === undefined || accounts == null){
|
||||
return m("div", "accounts: waiting_server");
|
||||
}
|
||||
if (curraccount == null) {
|
||||
accountMap.clear();
|
||||
if (curraccount() == null) {
|
||||
return m("div", [
|
||||
m("h2","login:"),
|
||||
m("hr"),
|
||||
accounts.map(function(account){
|
||||
accountMap.set(account.id,account);
|
||||
return [
|
||||
m("div.btn2", {
|
||||
onclick: m.withAttr("account", selAccount),
|
||||
account:account.id
|
||||
onclick: function(){
|
||||
selAccount(account)
|
||||
}
|
||||
},
|
||||
account.location + " (" + account.name + ")"),
|
||||
m("br")
|
||||
@ -43,7 +47,18 @@ module.exports = {view: function(){
|
||||
})
|
||||
]);
|
||||
} 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){
|
||||
return m("h2", "waiting_server ... ");
|
||||
} 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");
|
||||
} else if (needpasswd != undefined && needpasswd.want_password === true){
|
||||
m.initControl = "txtpasswd";
|
||||
|
@ -8,6 +8,7 @@ module.exports = { nodes: [
|
||||
name: "login",
|
||||
module: "accountselect",
|
||||
runstate: "waiting_account_select",
|
||||
counter: rs.counting("control/locations"),
|
||||
},
|
||||
{
|
||||
name: "create login",
|
||||
|
@ -40,10 +40,13 @@ var last_update_ts = 0;
|
||||
|
||||
function check_for_changes(){
|
||||
var tokens = [];
|
||||
// console.log("start-check");
|
||||
var paths_to_fetch = [];
|
||||
// console.log("start-check " + Object.keys(cache));
|
||||
for_key_in_obj(cache, function(path){
|
||||
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);
|
||||
}
|
||||
});
|
||||
@ -56,8 +59,7 @@ function check_for_changes(){
|
||||
});
|
||||
|
||||
req.then(function handle_statetoken_response(response){
|
||||
// console.log("checking result " + response);
|
||||
var paths_to_fetch = [];
|
||||
// console.log("checking result " + response.data ? Object.keys(response.data) : "<null>") ;
|
||||
for_key_in_obj(cache, function(path){
|
||||
var found = false;
|
||||
for(var i = 0; i < response.data.length; i++){
|
||||
@ -69,7 +71,7 @@ function check_for_changes(){
|
||||
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 = [];
|
||||
paths_to_fetch.map(function request_it(path){
|
||||
var req2 = m.request({
|
||||
@ -263,7 +265,17 @@ rs.forceUpdate = function(path, removeCache){
|
||||
|
||||
// force reload for all
|
||||
rs.clearCache = function(path, removeCache){
|
||||
console.log("clearing 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