webui: options>settings, playing with colors

This commit is contained in:
zeners 2016-03-23 13:11:14 +01:00
parent 585c43bb25
commit a19a068339
5 changed files with 65 additions and 39 deletions

View File

@ -49,7 +49,11 @@ module.exports = {view: function(){
} else {
// rs.untoken("control/password");
return m("div", [
m("div", "logging in ... (waiting for password-request)"),
m("div", [
"logging in ...",
m("br"),
"(waiting for password-request)",
]),
/*
m("hr"),
m(".btn2", {

View File

@ -85,13 +85,13 @@ module.exports = { nodes: [
})
},
{
name:"options",
name:"settings",
runstate: "running_ok.*",
},
{
name:"servicecontrol",
runstate: "running_ok.*",
path:"/options/servicecontrol",
path:"/settings/servicecontrol",
show: false,
},
{

View File

@ -31,7 +31,7 @@ var upload_url = window.location.protocol + "//" + window.location.hostname + ":
function for_key_in_obj(obj, callback){
var key;
for(key in obj){
callback(key);
callback(key, obj[key]);
}
}
@ -42,8 +42,8 @@ function check_for_changes(){
var tokens = [];
var paths_to_fetch = [];
// console.log("start-check " + Object.keys(cache));
for_key_in_obj(cache, function(path){
var token = cache[path].statetoken;
for_key_in_obj(cache, function(path, item){
var token = item.statetoken;
if(token === undefined || token== null) {
paths_to_fetch.push(path)
} else if (tokens.indexOf(token)<0) {
@ -60,10 +60,10 @@ function check_for_changes(){
req.then(function handle_statetoken_response(response){
// console.log("checking result " + response.data ? Object.keys(response.data) : "<null>") ;
for_key_in_obj(cache, function(path){
for_key_in_obj(cache, function(path, item){
var found = false;
for(var i = 0; i < response.data.length; i++){
if(response.data[i] === cache[path].statetoken){
if(response.data[i] === item.statetoken){
found = true;
}
}
@ -118,8 +118,8 @@ function schedule_request_missing(){
setTimeout(function request_missing(){
update_scheduled = false;
var requests = [];
for_key_in_obj(cache, function(path){
if(!cache[path].requested){
for_key_in_obj(cache, function(path, item){
if(!item.requested){
var req = m.request({
method: "GET",
url: api_url + path,
@ -128,25 +128,25 @@ function schedule_request_missing(){
req.then(function fill_data(response){
// TODO: add errorhandling
cache[path].data = response.data;
cache[path].statetoken = response.statetoken;
if (cache[path].then != undefined && cache[path].then != null) {
item.data = response.data;
item.statetoken = response.statetoken;
if (item.then != undefined && item.then != null) {
try {
cache[path].then(response);
item.then(response);
} catch (ex) {
if (cache[path].errorCallback != undefined && cache[path].errorCallback != null) {
cache[path].errorCallback(ex);
if (item.errorCallback != undefined && item.errorCallback != null) {
item.errorCallback(ex);
};
}
};
}, function errhandling(value){
if (cache[path].errorCallback != undefined && cache[path].errorCallback != null) {
cache[path].errorCallback(value);
if (item.errorCallback != undefined && item.errorCallback != null) {
item.errorCallback(value);
}
});
requests.push(req);
}
cache[path].requested = true;
item.requested = true;
});
m.sync(requests).then(function trigger_render(){
m.startComputation();
@ -205,6 +205,8 @@ function rs(path, args, callback, options){
module.exports = rs;
rs.for_key_in_obj = for_key_in_obj;
// single request for action
rs.request=function(path, args, callback, options){
options = optionsPrep(options, path);

View File

@ -34,8 +34,11 @@ function createSwitch(isOn, width) {
style: {
float:"left",
width: width,
color: "#303030",
textAlign: "center",
color: "#303030",
borderColor: isOn
? "lime"
: "red",
backgroundColor: !isOn
? "black"
: "lime",
@ -48,14 +51,33 @@ function createSwitch(isOn, width) {
textAlign: "center",
marginRight:"5px",
color: "#303030",
borderColor: isOn
? "lime"
: "red",
backgroundColor: isOn
? "black"
: "lime",
: "red",
}
}, "OFF"),
];
}
function breadcrums(name, parts){
var result = [];
rs.for_key_in_obj(parts, function(partname,item){
result.push(
m("span.btn",{
onclick: function(){
m.route(item)
}
},partname)
);
result.push(" / ");
});
result.push(name);
return result;
}
function serviceView(serviceid) {
var service, liste;
service = rs.find(rs("servicecontrol"),"service_id",serviceid);
@ -66,12 +88,10 @@ function serviceView(serviceid) {
? service.peers_denied
: service.peers_allowed;
return m("div", [
m("h2","Options / Rights / " + service.service_name),
m("div.btn2",{
onclick: function(){
m.route("/options/servicecontrol")
},
},"back to options / rights"),
m("h2", breadcrums(service.service_name, {
settings:"/settings",
rights: "/settings/servicecontrol",
})),
m("hr"),
m("h2",{
style:{
@ -129,7 +149,7 @@ function serviceView(serviceid) {
m("div",
{
style: {
color: "lime",
//color: "lime",
float:"left",
marginLeft: "5px",
marginRight: "5px",
@ -158,12 +178,9 @@ module.exports = {
return serviceView(m.route.param("service_id"));
}
return m("div", [
m("h2","Options / Rights"),
m("div.btn2",{
onclick: function(){
m.route("/options")
},
},"back to options"),
m("h2", breadcrums("rights", {
settings:"/settings",
})),
m("hr"),
m("ul", rs.list("servicecontrol", function(item){
return m("li", {
@ -185,7 +202,10 @@ module.exports = {
m("div.menu",
{
style: {
color: "lime",
// color: "lime",
borderColor: item.default_allowed
? "lime"
: "red",
float: "left",
marginLeft: "5px",
marginRight: "5px",
@ -193,7 +213,7 @@ module.exports = {
paddingRight: "2px",
},
onclick: function(){
m.route("/options/servicecontrol/", {
m.route("/settings/servicecontrol/", {
service_id: item.service_id,
})
}
@ -202,7 +222,7 @@ module.exports = {
m("div",
{
style: {
color: "lime",
// color: "lime",
float:"left",
marginLeft: "5px",
marginRight: "5px",

View File

@ -6,11 +6,11 @@ var rs = require("retroshare");
module.exports = {
view: function(){
return m("div", [
m("h2","Options"),
m("h2","settings"),
m("hr"),
m("div.btn2",{
onclick: function(){
m.route("/options/servicecontrol");
m.route("/settings/servicecontrol");
},
}, "rights")
]);