mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-08 09:05:24 -04:00
webui: options>settings, playing with colors
This commit is contained in:
parent
585c43bb25
commit
a19a068339
5 changed files with 65 additions and 39 deletions
|
@ -49,7 +49,11 @@ module.exports = {view: function(){
|
||||||
} else {
|
} else {
|
||||||
// rs.untoken("control/password");
|
// rs.untoken("control/password");
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("div", "logging in ... (waiting for password-request)"),
|
m("div", [
|
||||||
|
"logging in ...",
|
||||||
|
m("br"),
|
||||||
|
"(waiting for password-request)",
|
||||||
|
]),
|
||||||
/*
|
/*
|
||||||
m("hr"),
|
m("hr"),
|
||||||
m(".btn2", {
|
m(".btn2", {
|
||||||
|
|
|
@ -85,13 +85,13 @@ module.exports = { nodes: [
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"options",
|
name:"settings",
|
||||||
runstate: "running_ok.*",
|
runstate: "running_ok.*",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"servicecontrol",
|
name:"servicecontrol",
|
||||||
runstate: "running_ok.*",
|
runstate: "running_ok.*",
|
||||||
path:"/options/servicecontrol",
|
path:"/settings/servicecontrol",
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ var upload_url = window.location.protocol + "//" + window.location.hostname + ":
|
||||||
function for_key_in_obj(obj, callback){
|
function for_key_in_obj(obj, callback){
|
||||||
var key;
|
var key;
|
||||||
for(key in obj){
|
for(key in obj){
|
||||||
callback(key);
|
callback(key, obj[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ function check_for_changes(){
|
||||||
var tokens = [];
|
var tokens = [];
|
||||||
var paths_to_fetch = [];
|
var paths_to_fetch = [];
|
||||||
// console.log("start-check " + Object.keys(cache));
|
// console.log("start-check " + Object.keys(cache));
|
||||||
for_key_in_obj(cache, function(path){
|
for_key_in_obj(cache, function(path, item){
|
||||||
var token = cache[path].statetoken;
|
var token = item.statetoken;
|
||||||
if(token === undefined || token== null) {
|
if(token === undefined || token== null) {
|
||||||
paths_to_fetch.push(path)
|
paths_to_fetch.push(path)
|
||||||
} else if (tokens.indexOf(token)<0) {
|
} else if (tokens.indexOf(token)<0) {
|
||||||
|
@ -60,10 +60,10 @@ function check_for_changes(){
|
||||||
|
|
||||||
req.then(function handle_statetoken_response(response){
|
req.then(function handle_statetoken_response(response){
|
||||||
// console.log("checking result " + response.data ? Object.keys(response.data) : "<null>") ;
|
// 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;
|
var found = false;
|
||||||
for(var i = 0; i < response.data.length; i++){
|
for(var i = 0; i < response.data.length; i++){
|
||||||
if(response.data[i] === cache[path].statetoken){
|
if(response.data[i] === item.statetoken){
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,8 @@ function schedule_request_missing(){
|
||||||
setTimeout(function request_missing(){
|
setTimeout(function request_missing(){
|
||||||
update_scheduled = false;
|
update_scheduled = false;
|
||||||
var requests = [];
|
var requests = [];
|
||||||
for_key_in_obj(cache, function(path){
|
for_key_in_obj(cache, function(path, item){
|
||||||
if(!cache[path].requested){
|
if(!item.requested){
|
||||||
var req = m.request({
|
var req = m.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: api_url + path,
|
url: api_url + path,
|
||||||
|
@ -128,25 +128,25 @@ function schedule_request_missing(){
|
||||||
|
|
||||||
req.then(function fill_data(response){
|
req.then(function fill_data(response){
|
||||||
// TODO: add errorhandling
|
// TODO: add errorhandling
|
||||||
cache[path].data = response.data;
|
item.data = response.data;
|
||||||
cache[path].statetoken = response.statetoken;
|
item.statetoken = response.statetoken;
|
||||||
if (cache[path].then != undefined && cache[path].then != null) {
|
if (item.then != undefined && item.then != null) {
|
||||||
try {
|
try {
|
||||||
cache[path].then(response);
|
item.then(response);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (cache[path].errorCallback != undefined && cache[path].errorCallback != null) {
|
if (item.errorCallback != undefined && item.errorCallback != null) {
|
||||||
cache[path].errorCallback(ex);
|
item.errorCallback(ex);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, function errhandling(value){
|
}, function errhandling(value){
|
||||||
if (cache[path].errorCallback != undefined && cache[path].errorCallback != null) {
|
if (item.errorCallback != undefined && item.errorCallback != null) {
|
||||||
cache[path].errorCallback(value);
|
item.errorCallback(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
requests.push(req);
|
requests.push(req);
|
||||||
}
|
}
|
||||||
cache[path].requested = true;
|
item.requested = true;
|
||||||
});
|
});
|
||||||
m.sync(requests).then(function trigger_render(){
|
m.sync(requests).then(function trigger_render(){
|
||||||
m.startComputation();
|
m.startComputation();
|
||||||
|
@ -205,6 +205,8 @@ function rs(path, args, callback, options){
|
||||||
|
|
||||||
module.exports = rs;
|
module.exports = rs;
|
||||||
|
|
||||||
|
rs.for_key_in_obj = for_key_in_obj;
|
||||||
|
|
||||||
// single request for action
|
// single request for action
|
||||||
rs.request=function(path, args, callback, options){
|
rs.request=function(path, args, callback, options){
|
||||||
options = optionsPrep(options, path);
|
options = optionsPrep(options, path);
|
||||||
|
|
|
@ -34,8 +34,11 @@ function createSwitch(isOn, width) {
|
||||||
style: {
|
style: {
|
||||||
float:"left",
|
float:"left",
|
||||||
width: width,
|
width: width,
|
||||||
color: "#303030",
|
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
|
color: "#303030",
|
||||||
|
borderColor: isOn
|
||||||
|
? "lime"
|
||||||
|
: "red",
|
||||||
backgroundColor: !isOn
|
backgroundColor: !isOn
|
||||||
? "black"
|
? "black"
|
||||||
: "lime",
|
: "lime",
|
||||||
|
@ -48,14 +51,33 @@ function createSwitch(isOn, width) {
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
marginRight:"5px",
|
marginRight:"5px",
|
||||||
color: "#303030",
|
color: "#303030",
|
||||||
|
borderColor: isOn
|
||||||
|
? "lime"
|
||||||
|
: "red",
|
||||||
backgroundColor: isOn
|
backgroundColor: isOn
|
||||||
? "black"
|
? "black"
|
||||||
: "lime",
|
: "red",
|
||||||
}
|
}
|
||||||
}, "OFF"),
|
}, "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) {
|
function serviceView(serviceid) {
|
||||||
var service, liste;
|
var service, liste;
|
||||||
service = rs.find(rs("servicecontrol"),"service_id",serviceid);
|
service = rs.find(rs("servicecontrol"),"service_id",serviceid);
|
||||||
|
@ -66,12 +88,10 @@ function serviceView(serviceid) {
|
||||||
? service.peers_denied
|
? service.peers_denied
|
||||||
: service.peers_allowed;
|
: service.peers_allowed;
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("h2","Options / Rights / " + service.service_name),
|
m("h2", breadcrums(service.service_name, {
|
||||||
m("div.btn2",{
|
settings:"/settings",
|
||||||
onclick: function(){
|
rights: "/settings/servicecontrol",
|
||||||
m.route("/options/servicecontrol")
|
})),
|
||||||
},
|
|
||||||
},"back to options / rights"),
|
|
||||||
m("hr"),
|
m("hr"),
|
||||||
m("h2",{
|
m("h2",{
|
||||||
style:{
|
style:{
|
||||||
|
@ -129,7 +149,7 @@ function serviceView(serviceid) {
|
||||||
m("div",
|
m("div",
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
color: "lime",
|
//color: "lime",
|
||||||
float:"left",
|
float:"left",
|
||||||
marginLeft: "5px",
|
marginLeft: "5px",
|
||||||
marginRight: "5px",
|
marginRight: "5px",
|
||||||
|
@ -158,12 +178,9 @@ module.exports = {
|
||||||
return serviceView(m.route.param("service_id"));
|
return serviceView(m.route.param("service_id"));
|
||||||
}
|
}
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("h2","Options / Rights"),
|
m("h2", breadcrums("rights", {
|
||||||
m("div.btn2",{
|
settings:"/settings",
|
||||||
onclick: function(){
|
})),
|
||||||
m.route("/options")
|
|
||||||
},
|
|
||||||
},"back to options"),
|
|
||||||
m("hr"),
|
m("hr"),
|
||||||
m("ul", rs.list("servicecontrol", function(item){
|
m("ul", rs.list("servicecontrol", function(item){
|
||||||
return m("li", {
|
return m("li", {
|
||||||
|
@ -185,7 +202,10 @@ module.exports = {
|
||||||
m("div.menu",
|
m("div.menu",
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
color: "lime",
|
// color: "lime",
|
||||||
|
borderColor: item.default_allowed
|
||||||
|
? "lime"
|
||||||
|
: "red",
|
||||||
float: "left",
|
float: "left",
|
||||||
marginLeft: "5px",
|
marginLeft: "5px",
|
||||||
marginRight: "5px",
|
marginRight: "5px",
|
||||||
|
@ -193,7 +213,7 @@ module.exports = {
|
||||||
paddingRight: "2px",
|
paddingRight: "2px",
|
||||||
},
|
},
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
m.route("/options/servicecontrol/", {
|
m.route("/settings/servicecontrol/", {
|
||||||
service_id: item.service_id,
|
service_id: item.service_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -202,7 +222,7 @@ module.exports = {
|
||||||
m("div",
|
m("div",
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
color: "lime",
|
// color: "lime",
|
||||||
float:"left",
|
float:"left",
|
||||||
marginLeft: "5px",
|
marginLeft: "5px",
|
||||||
marginRight: "5px",
|
marginRight: "5px",
|
||||||
|
|
|
@ -6,11 +6,11 @@ var rs = require("retroshare");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
view: function(){
|
view: function(){
|
||||||
return m("div", [
|
return m("div", [
|
||||||
m("h2","Options"),
|
m("h2","settings"),
|
||||||
m("hr"),
|
m("hr"),
|
||||||
m("div.btn2",{
|
m("div.btn2",{
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
m.route("/options/servicecontrol");
|
m.route("/settings/servicecontrol");
|
||||||
},
|
},
|
||||||
}, "rights")
|
}, "rights")
|
||||||
]);
|
]);
|
Loading…
Add table
Add a link
Reference in a new issue