mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
webui: adding prototype for main, accountselect, menu
This commit is contained in:
parent
ddbf7c8fa2
commit
d60fcfec3d
59
libresapi/src/webui-src/app/accountselect.js
Normal file
59
libresapi/src/webui-src/app/accountselect.js
Normal file
@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
|
||||
var curraccount = null;
|
||||
var currentpasswd = null;
|
||||
var accountMap = new Map();
|
||||
|
||||
function login(){
|
||||
alert("login:" + curraccount.location + "; passwort: " + currentpasswd);
|
||||
}
|
||||
|
||||
function cancel(){
|
||||
curraccount=null;
|
||||
m.redraw();
|
||||
}
|
||||
|
||||
function selAccount(account){
|
||||
curraccount=accountMap.get(account);
|
||||
m.redraw();
|
||||
}
|
||||
|
||||
function setPasswd(password) {
|
||||
currentpasswd = password
|
||||
}
|
||||
|
||||
module.exports = {view: function(){
|
||||
var accounts = rs("control/locations");
|
||||
console.log("accounts: " + accounts);
|
||||
if(accounts === undefined){
|
||||
return m("div", "accounts: waiting_server");
|
||||
}
|
||||
if (curraccount == null) {
|
||||
accountMap.clear();
|
||||
return m("div", [
|
||||
m("h2","accounts:"),
|
||||
m("hr"),
|
||||
accounts.map(function(account){
|
||||
console.log("adding: " + account.id);
|
||||
accountMap.set(account.id,account);
|
||||
return [
|
||||
m("div", {onclick: m.withAttr("account", selAccount), account:account.id }, account.location + " (" + account.name + ")"),
|
||||
m("br")
|
||||
]
|
||||
})]);
|
||||
} else {
|
||||
return m("div", [
|
||||
m("h2","login:"),
|
||||
m("hr"),
|
||||
m("h2","account:" + curraccount.location + " (" + curraccount.name + ")"),
|
||||
m("input",{type:"password", onchange:m.withAttr("value", setPasswd)}),
|
||||
m("br"),
|
||||
m("button",{onclick: function(){login();}},"login"),
|
||||
m("button",{onclick: function(){cancel();}},"cancel")
|
||||
]);
|
||||
}
|
||||
}
|
||||
};
|
@ -11,7 +11,7 @@
|
||||
<script type="text/javascript">
|
||||
function load_ui(){
|
||||
var m = require("mithril");
|
||||
var ui = require("peers");
|
||||
var ui = require("main");
|
||||
var main = document.getElementById("main");
|
||||
m.mount(main, ui);
|
||||
}
|
||||
|
40
libresapi/src/webui-src/app/main.js
Normal file
40
libresapi/src/webui-src/app/main.js
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
var menu =require("menu");
|
||||
|
||||
module.exports = {view: function(){
|
||||
var runstate = rs("control/runstate");
|
||||
console.log("runstate: " + runstate);
|
||||
if(runstate === undefined){
|
||||
return m("div", "waiting_server");
|
||||
} else {
|
||||
if (rs.content === undefined) {
|
||||
rs.content = null;
|
||||
}
|
||||
|
||||
if(runstate.runstate =="waiting_account_select") {
|
||||
return m("div", [
|
||||
m("div", menu.view()),
|
||||
m("hr"),
|
||||
m("div", require("accountselect").view())
|
||||
]);
|
||||
} else if (runstate.runstate == "waiting_startup") {
|
||||
return m("div","RetroShare starting ... please wait ...");
|
||||
} else if(runstate.runstate =="running_ok" || runstate.runstate=="running_ok_no_full_control") {
|
||||
return m("div", [
|
||||
m("div", menu.view()),
|
||||
m("hr"),
|
||||
m("div", rs.content == null ? null : rs.content.view())
|
||||
]);
|
||||
} else {
|
||||
return m("div", "unknown runstate: " + runstate.runstate);
|
||||
}
|
||||
|
||||
return m("div", peers.map(function(peer){
|
||||
return m("div",peer.name)
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
42
libresapi/src/webui-src/app/menu.js
Normal file
42
libresapi/src/webui-src/app/menu.js
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
var m = require("mithril");
|
||||
var rs = require("retroshare");
|
||||
|
||||
function shutdown(){
|
||||
rs("control/shutdown",{args:[]});
|
||||
}
|
||||
|
||||
function goback(){
|
||||
rs.content=null;
|
||||
m.redraw();
|
||||
}
|
||||
|
||||
function peers(){
|
||||
rs.content=require("peers");
|
||||
}
|
||||
|
||||
function chat(){
|
||||
rs.content=require("chat");
|
||||
}
|
||||
|
||||
module.exports = {view: function(){
|
||||
if (rs.content!=undefined && rs.content != null) {
|
||||
return m("div", {onclick:goback}, "back");
|
||||
}
|
||||
var nodes = [];
|
||||
var runstate = rs("control/runstate");
|
||||
if (runstate.runstate == "running_ok_no_full_control"||runstate.runstate =="running_ok") {
|
||||
nodes.push(m("div",{onclick:function(){peers();}},"peers"));
|
||||
nodes.push(m("div",{onclick:function(){chat();}},"chat"));
|
||||
}
|
||||
if (runstate.runstate == "waiting_account_select"||runstate.runstate == "running_ok"){
|
||||
nodes.push(m("div",{onclick:shutdown},"shutdown"));
|
||||
}
|
||||
return m("div", [
|
||||
m("h2","menu:"),
|
||||
m("hr"),
|
||||
nodes
|
||||
])
|
||||
}
|
||||
};
|
@ -5,7 +5,7 @@ var rs = require("retroshare");
|
||||
|
||||
module.exports = {view: function(){
|
||||
var peers = rs("peers");
|
||||
console.log(peers);
|
||||
console.log("peers:" + peers);
|
||||
if(peers === undefined){
|
||||
return m("div", "waiting_server");
|
||||
}
|
||||
@ -13,4 +13,4 @@ module.exports = {view: function(){
|
||||
return m("div",peer.name)
|
||||
}));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -70,13 +70,9 @@ function check_for_changes(){
|
||||
var requests = [];
|
||||
paths_to_fetch.map(function request_it(path){
|
||||
var req2 = m.request({
|
||||
|
||||
method: "GET",
|
||||
|
||||
url: api_url + path,
|
||||
|
||||
background: true,
|
||||
|
||||
url: api_url + path,
|
||||
background: true,
|
||||
});
|
||||
req2 = req2.then(function fill_in_result(response){
|
||||
cache[path].data = response.data;
|
||||
@ -146,22 +142,13 @@ function rs(path, optionen){
|
||||
}
|
||||
return cache[path].data;
|
||||
} else if (optionen.args != undefined) {
|
||||
var req = m.request({
|
||||
method: "GET",
|
||||
|
||||
url: api_url + path,
|
||||
|
||||
args: optionen.args,
|
||||
|
||||
background: false,
|
||||
|
||||
callback: {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return m.request({
|
||||
method: "GET",
|
||||
url: api_url + path,
|
||||
args: optionen.args,
|
||||
background: false,
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = rs;
|
||||
module.exports = rs;
|
||||
|
Loading…
Reference in New Issue
Block a user