mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-16 21:12:31 -04:00
webui: view / change rights per user
This commit is contained in:
parent
83ff00e77d
commit
4733523b0c
6 changed files with 282 additions and 38 deletions
|
@ -16,6 +16,7 @@ function selAccount(account){
|
|||
m.redraw();
|
||||
rs.request("control/login", {id: curraccount.id}, function(){
|
||||
console.log("login sent");
|
||||
rs.clearCache();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = {view: function(){
|
|||
//console.log("peers:" + peers);
|
||||
|
||||
//waiting for peerlist ...
|
||||
if(peers === undefined){
|
||||
if(peers === undefined || peers == null){
|
||||
return m("div",[
|
||||
m("h2","peers"),
|
||||
m("h3","waiting_server"),
|
||||
|
@ -31,14 +31,14 @@ module.exports = {view: function(){
|
|||
if (location.avatar_address != "" && avatar_address =="") {
|
||||
avatar_address=location.avatar_address;
|
||||
}
|
||||
return m("div",{
|
||||
return m("li",{
|
||||
style:"color:" + (location.is_online ? "lime": "grey")
|
||||
+ ";cursor:pointer",
|
||||
onclick: function(){
|
||||
m.route("/chat?lobby=" + location.chat_id)
|
||||
}
|
||||
|
||||
},location.location);
|
||||
}, location.location);
|
||||
});
|
||||
|
||||
//return friend (peer + locations)
|
||||
|
@ -58,7 +58,7 @@ module.exports = {view: function(){
|
|||
{style:"color:" + (isonline ? "lime": "grey")} ,
|
||||
peer.name
|
||||
),
|
||||
m("div", loclist ),
|
||||
m("ul", loclist ),
|
||||
]),
|
||||
//remove-button
|
||||
m("div", {
|
||||
|
|
|
@ -261,6 +261,12 @@ rs.forceUpdate = function(path, removeCache){
|
|||
}
|
||||
}
|
||||
|
||||
// force reload for all
|
||||
rs.clearCache = function(path, removeCache){
|
||||
cache = {};
|
||||
}
|
||||
|
||||
|
||||
//return api-path
|
||||
rs.apiurl = function(path) {
|
||||
if (path === undefined) {
|
||||
|
@ -372,3 +378,19 @@ rs.sort.bool = function(name, innersort){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// searching a element in a list
|
||||
// items: list to search in
|
||||
// name: name of attribute to lookup
|
||||
// value: attribute's value to compare
|
||||
rs.find = function(items, name, value) {
|
||||
if (items === undefined||items == null) {
|
||||
return null;
|
||||
};
|
||||
for(var i = 0, l = items.length; i < l; ++i) {
|
||||
if (items[i][name] == value) {
|
||||
return items[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,150 @@ function setOption(id,value) {
|
|||
}
|
||||
}
|
||||
|
||||
function setUserOption(serviceid, userid, value) {
|
||||
return function(){
|
||||
rs.request("servicecontrol/user", {
|
||||
service_id: serviceid,
|
||||
peer_id: userid,
|
||||
enabled: value
|
||||
}, function(){
|
||||
rs.forceUpdate("servicecontrol", true)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createSwitch(isOn, width) {
|
||||
if (width === undefined) {
|
||||
width = "2.1em";
|
||||
}
|
||||
return [
|
||||
m("div.menu", {
|
||||
style: {
|
||||
float:"left",
|
||||
width: width,
|
||||
color: "#303030",
|
||||
textAlign: "center",
|
||||
backgroundColor: !isOn
|
||||
? "black"
|
||||
: "lime",
|
||||
}
|
||||
}, "ON"),
|
||||
m("div.menu",{
|
||||
style: {
|
||||
float:"left",
|
||||
width: width,
|
||||
textAlign: "center",
|
||||
marginRight:"5px",
|
||||
color: "#303030",
|
||||
backgroundColor: isOn
|
||||
? "black"
|
||||
: "lime",
|
||||
}
|
||||
}, "OFF"),
|
||||
];
|
||||
}
|
||||
|
||||
function serviceView(serviceid) {
|
||||
var service, liste;
|
||||
service = rs.find(rs("servicecontrol"),"service_id",serviceid);
|
||||
if (service == null) {
|
||||
return m("h3","<please wait ... >");
|
||||
}
|
||||
liste = service.default_allowed
|
||||
? 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("hr"),
|
||||
m("h2",{
|
||||
style:{
|
||||
float:"left",
|
||||
}
|
||||
},[
|
||||
m("div",{
|
||||
style:{
|
||||
float:"left",
|
||||
}
|
||||
},"user rights for: " + service.service_name + ", default: "),
|
||||
m("div", {
|
||||
onclick: setOption(
|
||||
serviceid,
|
||||
!service.default_allowed
|
||||
),
|
||||
style: {
|
||||
float:"left",
|
||||
marginLeft: "0.4em",
|
||||
marginRight: "0.4em",
|
||||
}
|
||||
},createSwitch(service.default_allowed)),
|
||||
]),
|
||||
m("div", {
|
||||
style: {
|
||||
clear:"left",
|
||||
}
|
||||
}),
|
||||
m("ul", rs.list("peers",function(peer){
|
||||
var locs;
|
||||
locs = peer.locations;
|
||||
locs.sort(rs.sort("location"));
|
||||
return peer.locations.map(function(location){
|
||||
var isExcept, isOn;
|
||||
isExcept = liste != null
|
||||
&& liste.indexOf(location.peer_id)>=0;
|
||||
isOn = service.default_allowed ? !isExcept: isExcept;
|
||||
return m("li", {
|
||||
style: {
|
||||
margin: "5px",
|
||||
color: isOn ? "lime" :"red",
|
||||
}
|
||||
}, [
|
||||
m("div"),
|
||||
m("div", {
|
||||
onclick: setUserOption(
|
||||
serviceid,
|
||||
location.peer_id,
|
||||
!isOn
|
||||
),
|
||||
style: {
|
||||
float:"left",
|
||||
},
|
||||
},createSwitch(isOn)),
|
||||
m("div",
|
||||
{
|
||||
style: {
|
||||
color: "lime",
|
||||
float:"left",
|
||||
marginLeft: "5px",
|
||||
marginRight: "5px",
|
||||
fontWeight: "bold",
|
||||
}
|
||||
},
|
||||
peer.name + (location.location
|
||||
? " (" + location.location + ")"
|
||||
: "")
|
||||
),
|
||||
m("div", {
|
||||
style: {
|
||||
clear: "left"
|
||||
}
|
||||
}),
|
||||
]);
|
||||
})
|
||||
}, rs.sort("name")))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
view: function(){
|
||||
if (m.route.param("service_id")) {
|
||||
return serviceView(m.route.param("service_id"));
|
||||
}
|
||||
return m("div", [
|
||||
m("h2","Options / Rights"),
|
||||
m("div.btn2",{
|
||||
|
@ -24,51 +166,70 @@ module.exports = {
|
|||
},"back to options"),
|
||||
m("hr"),
|
||||
m("ul", rs.list("servicecontrol", function(item){
|
||||
//return m("li",item.service_name)
|
||||
if (item.service_name.match("banlist")) {
|
||||
console.log("banlist:" + item.default_allowed);
|
||||
}
|
||||
return m("li", {
|
||||
style: {
|
||||
margin: "2px",
|
||||
margin: "5px",
|
||||
color: item.default_allowed ? "lime" :"red",
|
||||
}
|
||||
}, [
|
||||
m("div"),
|
||||
m("div", {
|
||||
onclick: setOption(
|
||||
item.service_id,
|
||||
!item.default_allowed
|
||||
),
|
||||
}, [
|
||||
m("div.menu", {
|
||||
style: {
|
||||
float:"left",
|
||||
width:"30px",
|
||||
color: "#303030",
|
||||
textAlign: "center",
|
||||
backgroundColor: !item.default_allowed
|
||||
? "black"
|
||||
: "lime",
|
||||
}
|
||||
}, "ON"),
|
||||
m("div.menu",{
|
||||
style: {
|
||||
float:"left",
|
||||
width:"30px",
|
||||
textAlign: "center",
|
||||
marginRight:"5px",
|
||||
color: "#303030",
|
||||
backgroundColor: item.default_allowed
|
||||
? "black"
|
||||
: "lime",
|
||||
}
|
||||
}, "OFF"),
|
||||
]),
|
||||
m("div", {
|
||||
style: {
|
||||
color: "lime",
|
||||
float:"left",
|
||||
}
|
||||
}, item.service_name),
|
||||
},createSwitch(item.default_allowed)),
|
||||
m("div.menu",
|
||||
{
|
||||
style: {
|
||||
color: "lime",
|
||||
float: "left",
|
||||
marginLeft: "5px",
|
||||
marginRight: "5px",
|
||||
paddingLeft: "2px",
|
||||
paddingRight: "2px",
|
||||
},
|
||||
onclick: function(){
|
||||
m.route("/options/servicecontrol/", {
|
||||
service_id: item.service_id,
|
||||
})
|
||||
}
|
||||
}, "more"
|
||||
),
|
||||
m("div",
|
||||
{
|
||||
style: {
|
||||
color: "lime",
|
||||
float:"left",
|
||||
marginLeft: "5px",
|
||||
marginRight: "5px",
|
||||
fontWeight: "bold",
|
||||
}
|
||||
},
|
||||
item.service_name
|
||||
),
|
||||
m("div",
|
||||
{
|
||||
style: {
|
||||
color: "lime",
|
||||
float:"left",
|
||||
marginLeft: "5px",
|
||||
marginRight: "5px",
|
||||
}
|
||||
},
|
||||
(
|
||||
item.default_allowed
|
||||
? ( item.peers_denied != null
|
||||
? "(" + item.peers_denied.length + " denied)"
|
||||
: "")
|
||||
: ( item.peers_allowed != null
|
||||
? "(" + item.peers_allowed.length + " allowed)"
|
||||
: "")
|
||||
)
|
||||
),
|
||||
m("div", {
|
||||
style: {
|
||||
clear: "left"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue