mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Add support for protected permission in webadmin and show label instead of permission name
This commit is contained in:
parent
d426831b3f
commit
8817890a05
2 changed files with 20 additions and 22 deletions
|
@ -119,7 +119,7 @@
|
||||||
app.get('#/groups', function (c) {
|
app.get('#/groups', function (c) {
|
||||||
c.api('GET', '/users/groups?full&include_primary_groups', {}, function(data_groups) {
|
c.api('GET', '/users/groups?full&include_primary_groups', {}, function(data_groups) {
|
||||||
c.api('GET', '/users', {}, function(data_users) {
|
c.api('GET', '/users', {}, function(data_users) {
|
||||||
c.api('GET', '/users/permissions?short', {}, function(data_permissions) {
|
c.api('GET', '/users/permissions?full', {}, function(data_permissions) {
|
||||||
//var perms = data_permissions.permissions;
|
//var perms = data_permissions.permissions;
|
||||||
var specific_perms = {};
|
var specific_perms = {};
|
||||||
var all_perms = data_permissions.permissions;
|
var all_perms = data_permissions.permissions;
|
||||||
|
@ -128,10 +128,11 @@
|
||||||
// Enrich groups data with primary group indicator and inversed items list
|
// Enrich groups data with primary group indicator and inversed items list
|
||||||
for (var group in data_groups.groups) {
|
for (var group in data_groups.groups) {
|
||||||
data_groups.groups[group].primary = users.indexOf(group) !== -1;
|
data_groups.groups[group].primary = users.indexOf(group) !== -1;
|
||||||
data_groups.groups[group].permissionsInv = all_perms.filter(function(item) {
|
data_groups.groups[group].permissionsInv = Object.keys(all_perms).filter(function(item) {
|
||||||
return data_groups.groups[group].permissions.indexOf(item) === -1;
|
return data_groups.groups[group].permissions.indexOf(item) === -1;
|
||||||
}).filter(function(item) {
|
}).filter(function(item) {
|
||||||
return group != "visitors" || (item != "mail.main" && item != "xmpp.main"); // Remove 'email' and 'xmpp' in visitors's permission choice list
|
// Remove 'email', 'xmpp' and protected permission in visitors's permission choice list
|
||||||
|
return group != "visitors" || (item != "mail.main" && item != "xmpp.main" && ! all_perms[item].protected == true);
|
||||||
});
|
});
|
||||||
data_groups.groups[group].membersInv = users.filter(function(item) {
|
data_groups.groups[group].membersInv = users.filter(function(item) {
|
||||||
return data_groups.groups[group].members.indexOf(item) === -1;
|
return data_groups.groups[group].members.indexOf(item) === -1;
|
||||||
|
@ -147,23 +148,18 @@
|
||||||
data = {
|
data = {
|
||||||
'groups':data_groups.groups,
|
'groups':data_groups.groups,
|
||||||
'displayPermission': function (text) {
|
'displayPermission': function (text) {
|
||||||
// Display a permission correctly for a human
|
return all_perms[text].label;
|
||||||
text = text.replace('.main', '');
|
|
||||||
if (text.indexOf('.') > -1)
|
|
||||||
text = text.replace('.', ' (') + ')';
|
|
||||||
|
|
||||||
if (text == "mail")
|
|
||||||
text = "E-mail";
|
|
||||||
else if (text == "xmpp")
|
|
||||||
text = "XMPP";
|
|
||||||
else
|
|
||||||
text = toTitleCase(text);
|
|
||||||
|
|
||||||
return text;
|
|
||||||
},
|
},
|
||||||
'displayUser': function (text) {
|
'displayUser': function (text) {
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
'is_protected': function (item, type, group) {
|
||||||
|
if (type == 'permission' && group == 'visitors') {
|
||||||
|
return all_perms[item].protected;
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
updateView(data);
|
updateView(data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,15 +18,17 @@
|
||||||
<span class="fa-fw fa-{{icon}}"></span>
|
<span class="fa-fw fa-{{icon}}"></span>
|
||||||
{{text}}
|
{{text}}
|
||||||
<button data-type="{{type}}s" data-action="remove" data-item="{{value}}" data-group="{{group}}">
|
<button data-type="{{type}}s" data-action="remove" data-item="{{value}}" data-group="{{group}}">
|
||||||
<span class="fa-close" style="margin-left:5px"></span>
|
{{#unless protected}}
|
||||||
<span class="sr-only">{{t 'delete'}}</span>
|
<span class="fa-close" style="margin-left:5px"></span>
|
||||||
|
<span class="sr-only">{{t 'delete'}}</span>
|
||||||
|
{{/unless}}
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
{{/inline}}
|
{{/inline}}
|
||||||
|
|
||||||
{{#*inline "labelsLine"}}
|
{{#*inline "labelsLine"}}
|
||||||
{{#each items}}
|
{{#each items}}
|
||||||
{{> label text=(call ../display .) value=. icon=../icon type=../type item=. group=../group}}
|
{{> label text=(call ../display .) value=. icon=../icon type=../type item=. group=../group protected=(call ../is_protected . ../type ../group)}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#if inv}}
|
{{#if inv}}
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
|
@ -73,7 +75,7 @@
|
||||||
<div style="font-style:italic">{{t 'group_explain_visitors_needed_for_external_client'}}</div>
|
<div style="font-style:italic">{{t 'group_explain_visitors_needed_for_external_client'}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{> labelsLine display=../displayUser icon="user" type="member" items=members inv=membersInv group=@key}}
|
{{> labelsLine display=../displayUser icon="user" type="member" items=members inv=membersInv group=@key is_protected=../is_protected}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
<h3>{{t 'permissions'}}</h3>
|
<h3>{{t 'permissions'}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
{{> labelsLine display=../displayPermission icon="key-modern" type="permission" items=permissions inv=permissionsInv group=@key}}
|
{{> labelsLine display=../displayPermission icon="key-modern" type="permission" items=permissions inv=permissionsInv group=@key is_protected=../is_protected}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,7 +113,7 @@
|
||||||
<h3><span class="fa-fw fa-user"></span> {{@key}}</h3>
|
<h3><span class="fa-fw fa-user"></span> {{@key}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
{{> labelsLine display=../displayPermission icon="key-modern" type="permission" items=permissions inv=permissionsInv group=@key}}
|
{{> labelsLine display=../displayPermission icon="key-modern" type="permission" items=permissions inv=permissionsInv group=@key is_protected=../is_protected}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
Loading…
Add table
Reference in a new issue