From d60fcfec3db9b66aefcf630203ed93f03537b83c Mon Sep 17 00:00:00 2001 From: zeners Date: Sun, 3 Jan 2016 23:40:57 +0100 Subject: [PATCH] webui: adding prototype for main, accountselect, menu --- libresapi/src/webui-src/app/accountselect.js | 59 +++++++++++++++++++ libresapi/src/webui-src/app/assets/index.html | 2 +- libresapi/src/webui-src/app/main.js | 40 +++++++++++++ libresapi/src/webui-src/app/menu.js | 42 +++++++++++++ libresapi/src/webui-src/app/peers.js | 4 +- libresapi/src/webui-src/app/retroshare.js | 31 +++------- 6 files changed, 153 insertions(+), 25 deletions(-) create mode 100644 libresapi/src/webui-src/app/accountselect.js create mode 100644 libresapi/src/webui-src/app/main.js create mode 100644 libresapi/src/webui-src/app/menu.js diff --git a/libresapi/src/webui-src/app/accountselect.js b/libresapi/src/webui-src/app/accountselect.js new file mode 100644 index 000000000..14d5fae7b --- /dev/null +++ b/libresapi/src/webui-src/app/accountselect.js @@ -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") + ]); + } +} +}; diff --git a/libresapi/src/webui-src/app/assets/index.html b/libresapi/src/webui-src/app/assets/index.html index b490e4cb4..ff74cd369 100644 --- a/libresapi/src/webui-src/app/assets/index.html +++ b/libresapi/src/webui-src/app/assets/index.html @@ -11,7 +11,7 @@