mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Moooaaar button (user delete)
This commit is contained in:
parent
49bd488e5e
commit
7ea2f37b89
3 changed files with 40 additions and 40 deletions
|
@ -63,7 +63,44 @@
|
||||||
// Show user information
|
// Show user information
|
||||||
app.get('#/users/:user', function (c) {
|
app.get('#/users/:user', function (c) {
|
||||||
c.api('GET', '/users/'+ c.params['user'], {}, function(data) {
|
c.api('GET', '/users/'+ c.params['user'], {}, function(data) {
|
||||||
c.view('user/user_info', data);
|
c.view('user/user_info', data, function() {
|
||||||
|
|
||||||
|
// Configure delete button behavior
|
||||||
|
$('button[data-action="delete"]').on("click", function() {
|
||||||
|
var user = $(this).data("user");
|
||||||
|
|
||||||
|
var params = {};
|
||||||
|
|
||||||
|
// make confirm content
|
||||||
|
var purgeCheckbox = '<div><input type="checkbox" id="purge-user-data" name="purge-user-data"> <label for="purge-user-data">'+ y18n.t('purge_user_data_checkbox', [user]) +'</label></div>';
|
||||||
|
var purgeAlertMessage = '<div class="danger" style="display: none">⚠ '+ y18n.t('purge_user_data_warning') +'</div>';
|
||||||
|
var confirmModalContent = $('<div>'+ y18n.t('confirm_delete', [user]) +'<br><br>'+ purgeCheckbox +'<br>'+ purgeAlertMessage +'</div>');
|
||||||
|
|
||||||
|
// display confirm modal
|
||||||
|
c.confirm(
|
||||||
|
y18n.t('users'),
|
||||||
|
confirmModalContent,
|
||||||
|
function(){
|
||||||
|
c.api('DELETE', '/users/'+ user, params, function(data) {
|
||||||
|
c.redirect_to('#/users');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// toggle purge warning and parameter
|
||||||
|
confirmModalContent.find("input").click(function(){
|
||||||
|
|
||||||
|
if (confirmModalContent.find("input").is(':checked')) {
|
||||||
|
params.purge = "";
|
||||||
|
confirmModalContent.find(".danger").show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete params.purge;
|
||||||
|
confirmModalContent.find(".danger").hide();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -188,41 +225,4 @@
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove existing user
|
|
||||||
app.get('#/users/:user/delete', function (c) {
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
|
|
||||||
// make confirm content
|
|
||||||
var purgeCheckbox = '<div><input type="checkbox" id="purge-user-data" name="purge-user-data"> <label for="purge-user-data">'+ y18n.t('purge_user_data_checkbox', [c.params['user']]) +'</label></div>';
|
|
||||||
var purgeAlertMessage = '<div class="danger" style="display: none">⚠ '+ y18n.t('purge_user_data_warning') +'</div>';
|
|
||||||
var confirmModalContent = $('<div>'+ y18n.t('confirm_delete', [c.params['user']]) +'<br><br>'+ purgeCheckbox +'<br>'+ purgeAlertMessage +'</div>');
|
|
||||||
|
|
||||||
// display confirm modal
|
|
||||||
c.confirm(
|
|
||||||
y18n.t('users'),
|
|
||||||
confirmModalContent,
|
|
||||||
function(){
|
|
||||||
c.api('DELETE', '/users/'+ c.params['user'], params, function(data) {
|
|
||||||
c.redirect_to('#/users');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// toggle purge warning and parameter
|
|
||||||
confirmModalContent.find("input").click(function(){
|
|
||||||
|
|
||||||
if (confirmModalContent.find("input").is(':checked')) {
|
|
||||||
params.purge = "";
|
|
||||||
confirmModalContent.find(".warning").show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete params.purge;
|
|
||||||
confirmModalContent.find(".warning").hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -428,6 +428,6 @@
|
||||||
"appslists_last_update": "Last update",
|
"appslists_last_update": "Last update",
|
||||||
"appslists_unknown_list": "Unknown apps list: %s",
|
"appslists_unknown_list": "Unknown apps list: %s",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"purge_user_data_checkbox": "Purge %s's data? (This will remove the content of it's home and mail directories.)",
|
"purge_user_data_checkbox": "Purge %s's data? (This will remove the content of its home and mail directories.)",
|
||||||
"purge_user_data_warning": "Purging user's data is not reversible. Be sure you know what you're doing!"
|
"purge_user_data_warning": "Purging user's data is not reversible. Be sure you know what you're doing!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</table>
|
</table>
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
<a role="button" href="#/users/{{username}}/edit" class="btn btn-info slide"><span class="fa-pencil-square-o"/> {{t 'user_username_edit' username}}</a>
|
<a role="button" href="#/users/{{username}}/edit" class="btn btn-info slide"><span class="fa-pencil-square-o"/> {{t 'user_username_edit' username}}</a>
|
||||||
<a role="button" href="#/users/{{username}}/delete" class="btn btn-danger slide back"><span class="fa-trash-o"/> {{t 'delete'}}</a>
|
<button class="btn btn-danger" data-action="delete" data-user="{{username}}"><span class="fa-trash-o"/> {{t 'delete'}}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue