mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Drop legacy app permission interface, point to the new one
This commit is contained in:
parent
02933e1962
commit
dc0db65ae4
4 changed files with 20 additions and 256 deletions
|
@ -202,20 +202,23 @@
|
|||
// Get app information
|
||||
app.get('#/apps/:app', function (c) {
|
||||
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9
|
||||
// Presentation
|
||||
data.settings.allowed_users = (data.settings.allowed_users) ? data.settings.allowed_users.replace(',', ', ')+"." : y18n.t('everyone_has_access');
|
||||
c.api('/users/permissions', function(data_permissions) {
|
||||
|
||||
// Multilingual description
|
||||
data.description = (typeof data.manifest.description[y18n.locale] !== 'undefined') ?
|
||||
data.manifest.description[y18n.locale] :
|
||||
data.manifest.description['en']
|
||||
;
|
||||
// Permissions
|
||||
data.permissions = data_permissions.permissions[c.params['app']+".main"]["allowed"];
|
||||
|
||||
// Multi Instance settings
|
||||
data.manifest.multi_instance = data.manifest.multi_instance ? y18n.t('yes') : y18n.t('no');
|
||||
data.install_time = new Date(data.settings.install_time * 1000);
|
||||
// Multilingual description
|
||||
data.description = (typeof data.manifest.description[y18n.locale] !== 'undefined') ?
|
||||
data.manifest.description[y18n.locale] :
|
||||
data.manifest.description['en']
|
||||
;
|
||||
|
||||
c.view('app/app_info', data);
|
||||
// Multi Instance settings
|
||||
data.manifest.multi_instance = data.manifest.multi_instance ? y18n.t('yes') : y18n.t('no');
|
||||
data.install_time = new Date(data.settings.install_time * 1000);
|
||||
|
||||
c.view('app/app_info', data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -619,150 +622,6 @@
|
|||
);
|
||||
});
|
||||
|
||||
// Manage app access
|
||||
app.get('#/apps/:app/access', function (c) {
|
||||
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9
|
||||
c.api('/users', function(dataUsers) {
|
||||
|
||||
// allowed_users as array
|
||||
if (typeof data.settings.allowed_users !== 'undefined') {
|
||||
if (data.settings.allowed_users.length === 0) {
|
||||
// Force empty array, means no user has access
|
||||
data.settings.allowed_users = [];
|
||||
}
|
||||
else {
|
||||
data.settings.allowed_users = data.settings.allowed_users.split(',');
|
||||
}
|
||||
} else {
|
||||
data.settings.allowed_users = []; // Force array
|
||||
// if 'allowed_users' is undefined, everyone has access
|
||||
// that means that undefined is different from empty array
|
||||
data.settings.allow_everyone = true;
|
||||
}
|
||||
|
||||
// Available users
|
||||
data.users = [];
|
||||
$.each(dataUsers.users, function(username, user){
|
||||
// Do not list allowed_users in select list
|
||||
if ( data.settings.allowed_users.indexOf(username) === -1 ) {
|
||||
data.users.push({
|
||||
value: username,
|
||||
label: user.fullname+' ('+user.mail+')'
|
||||
});
|
||||
} else {
|
||||
// Complete allowed_users data
|
||||
data.settings.allowed_users[data.settings.allowed_users.indexOf(username)] = {
|
||||
username: username,
|
||||
fullname: user.fullname,
|
||||
mail: user.mail,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
c.view('app/app_access', data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Remove all access
|
||||
app.get('#/apps/:app/access/remove', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_access_remove_all', [c.params['app']]),
|
||||
function() {
|
||||
var params = {
|
||||
apps: c.params['app'],
|
||||
users: []
|
||||
};
|
||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}, 'DELETE', params);
|
||||
},
|
||||
function() {
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Remove access to a specific user
|
||||
app.get('#/apps/:app/access/remove/:user', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_access_remove_user', [c.params['app'], c.params['user']]),
|
||||
function() {
|
||||
var params = {
|
||||
apps: c.params['app'],
|
||||
users: c.params['user']
|
||||
};
|
||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}, 'DELETE', params); // passing 'params' here is useless because jQuery doesn't handle ajax datas for DELETE requests. Passing parameters through uri.
|
||||
},
|
||||
function() {
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Grant all access
|
||||
app.get('#/apps/:app/access/add', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_access_add', [c.params['app']]),
|
||||
function() {
|
||||
var params = {
|
||||
apps: c.params['app'],
|
||||
users: null
|
||||
};
|
||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||
}, 'PUT', params);
|
||||
},
|
||||
function() {
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Grant access for a specific user
|
||||
app.post('#/apps/:app/access/add', function (c) {
|
||||
var params = {
|
||||
users: c.params['user'],
|
||||
apps: c.params['app']
|
||||
};
|
||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||
}, 'PUT', params);
|
||||
});
|
||||
|
||||
// Clear access (reset)
|
||||
app.get('#/apps/:app/access/clear', function (c) {
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_access_clear', [c.params['app']]),
|
||||
function() {
|
||||
var params = {
|
||||
apps: c.params['app']
|
||||
};
|
||||
c.api('/access', function() { //
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||
}, 'POST', params);
|
||||
},
|
||||
function() {
|
||||
store.clear('slide');
|
||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Make app default
|
||||
app.get('#/apps/:app/default', function (c) {
|
||||
c.confirm(
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"app_change_url": "Change URL",
|
||||
"app_debug_no_logs": "Application's logs are not available",
|
||||
"app_debug_tab": "Display debug information",
|
||||
"app_info_access_desc": "Manage user access. Allowed users: %s",
|
||||
"app_info_access_desc": "Groups / users currently allowed to access this app:",
|
||||
"app_info_changelabel_desc": "Change app label in the portal.",
|
||||
"app_info_debug_desc": "Display debugging information for this application.",
|
||||
"app_info_default_desc": "Redirect domain root to this application (%s).",
|
||||
|
@ -245,6 +245,7 @@
|
|||
"no_installed_apps": "No installed apps.",
|
||||
"no_log": "No log.",
|
||||
"no_user_to_add": "No more users to add.",
|
||||
"nobody": "Nobody",
|
||||
"non_compatible_api": "Non-compatible API",
|
||||
"ok": "OK",
|
||||
"only_highquality_apps": "Only high-quality apps",
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
<div class="btn-breadcrumb">
|
||||
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
|
||||
<a href="#/apps" class="hidden-xs">{{t 'applications'}}</a>
|
||||
<a href="#/apps" class="visible-xs">…</a>
|
||||
<a href="#/apps/{{settings.id}}">{{settings.label}}</a>
|
||||
<a href="#/apps/{{settings.id}}/access">{{t 'app_access'}}</a>
|
||||
</div>
|
||||
|
||||
<div class="separator"></div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title"><span class="fa-fw fa-users"></span> {{t 'allowed_users'}}</h2>
|
||||
</div>
|
||||
{{#if settings.allowed_users}}
|
||||
<div class="list-group">
|
||||
{{#each settings.allowed_users}}
|
||||
<div class="list-group-item">
|
||||
<a role="button" href="#/apps/{{settings.id}}/access/remove/{{username}}" class="btn btn-danger slide back pull-right">
|
||||
<span class="fa-trash-o"></span> {{t 'remove_access'}}
|
||||
</a>
|
||||
<h3 class="list-group-item-heading">{{fullname}} ({{mail}})</h3>
|
||||
<a href="#/users/{{username}}">{{t 'view_user_profile' username}}</a>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="panel-body">
|
||||
{{#if settings.allow_everyone}}
|
||||
<p class="text-success">{{t 'everyone_has_access'}}</p>
|
||||
{{else}}
|
||||
<p class="text-warning">{{t 'no_allowed_users'}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="panel-footer">
|
||||
{{#if users}}
|
||||
<form method="POST" action="#/apps/{{settings.id}}/access/add" class="row">
|
||||
<input type="hidden" name="app" value="{{settings.id}}">
|
||||
<div class="col-sm-6">
|
||||
<select name="user" required class="form-control">
|
||||
<option value="" default disabled selected>{{t 'select_user'}}</option>
|
||||
{{#users}}<option value="{{value}}">{{label}}</option>{{/users}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<br class="visible-xs" />
|
||||
<input type="submit" class="btn btn-success slide back" value="{{t 'add'}}">
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<p class="text-warning">{{t 'no_user_to_add'}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
<span class="fa-fw fa-wrench"></span> {{t 'operations'}}
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="collapseOne" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
{{#if users}}
|
||||
<div class="container">
|
||||
<p>{{t 'app_access_addall_desc' settings.label}}</p>
|
||||
<a role="button" href="#/apps/{{settings.id}}/access/add" class="btn btn-success slide back">
|
||||
<span class="fa-plus"></span> {{t 'app_access_addall_btn'}}
|
||||
</a>
|
||||
</div>
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{#if settings.allowed_users}}
|
||||
<div class="container">
|
||||
<p>{{t 'app_access_removeall_desc' settings.label}}</p>
|
||||
<a role="button" href="#/apps/{{settings.id}}/access/remove" class="btn btn-danger slide back">
|
||||
<span class="fa-trash-o"></span> {{t 'app_access_removeall_btn'}}
|
||||
</a>
|
||||
</div>
|
||||
<hr>
|
||||
{{/if}}
|
||||
{{#unless settings.allow_everyone}}
|
||||
<div class="container">
|
||||
<p>{{t 'app_access_clearall_desc' settings.label}}</p>
|
||||
<a role="button" href="#/apps/{{settings.id}}/access/clear" class="btn btn-primary slide back">
|
||||
<span class="fa-unlock-alt"></span> {{t 'app_access_clearall_btn'}}
|
||||
</a>
|
||||
</div>
|
||||
{{/unless}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -48,9 +48,10 @@
|
|||
</div>
|
||||
<hr>
|
||||
<div class="container">
|
||||
<p>{{t 'app_info_access_desc' settings.allowed_users}}</p>
|
||||
<a role="button" href="#/apps/{{settings.id}}/access" class="btn btn-info slide">
|
||||
<span class="fa-lock"></span> {{t 'app_access'}}
|
||||
<p>{{t 'app_info_access_desc'}} {{#each permissions}} {{ucwords .}}{{#unless @last}}, {{/unless}} {{ else }} {{t 'nobody'}} {{/each}}
|
||||
</p>
|
||||
<a role="button" href="#/groups" class="btn btn-info slide">
|
||||
<span class="fa-key-modern"></span> {{t 'groups_and_permissions_manage'}}
|
||||
</a>
|
||||
</div>
|
||||
<hr>
|
||||
|
|
Loading…
Add table
Reference in a new issue