X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=static%2Fsrc%2Frolehandler%2Frole_list.js;h=5ee1b35cd8184a242147d3b3f4dd902b0e10f356;hb=refs%2Ftags%2Fv7.1.0rc1;hp=fc19f5217db150aaa372c4483d9e202ec9e93bdf;hpb=8da2313d9791c27c6e67511bb0e392aec73ec7c4;p=osm%2FLW-UI.git
diff --git a/static/src/rolehandler/role_list.js b/static/src/rolehandler/role_list.js
index fc19f52..5ee1b35 100644
--- a/static/src/rolehandler/role_list.js
+++ b/static/src/rolehandler/role_list.js
@@ -16,18 +16,48 @@
function openModalCreateRole(args) {
-
-
$('#modal_new_role').modal('show');
}
function openModalEditRole(args) {
var url = '/admin/roles/' + args.role_id;
+ var url_update = '/admin/roles/' + args.role_id+'/update';
+ var dialog = bootbox.dialog({
+ message: '
Loading...
',
+ closeButton: false
+ });
+ $.ajax({
+ url: url,
+ type: 'GET',
+ headers: {
+ "Accept": 'application/json'
+ },
+ contentType: false,
+ processData: false
+ })
+ .done(function (response,textStatus, jqXHR) {
+ dialog.modal('hide');
+ $("#formEditRole").attr("action", url_update);
+ $('#modal_edit_role').modal('show');
+ $('#edit_rolename').val(response['name'])
+ $('#edit_permissions').val(JSON.stringify(response['permissions']))
+ if(response['root'] === true){
+ $("#edit_root").attr("checked", true);
+ }
+ else {
+ $("#edit_root").attr("checked", false);
+ }
+ }).fail(function(result){
+ dialog.modal('hide');
+ var data = result.responseJSON;
+ var title = "Error " + (data.code ? data.code: 'unknown');
+ var message = data.detail ? data.detail: 'No detail available.';
+ bootbox.alert({
+ title: title,
+ message: message
+ });
+ });
- $("#formEditRole").attr("action", url);
-
-
- $('#modal_edit_role').modal('show');
}
function deleteRole(role_id, name) {
@@ -40,17 +70,31 @@ function deleteRole(role_id, name) {
});
$.ajax({
url: delete_url,
- dataType: "json",
- contentType: "application/json;charset=utf-8",
- success: function (result) {
- //$('#modal_show_vim_body').empty();
- dialog.modal('hide');
- table.ajax.reload();
+ type: 'GET',
+ headers: {
+ "Accept": 'application/json'
},
- error: function (result) {
- dialog.modal('hide');
- bootbox.alert("An error occurred.");
- }
+ contentType: false,
+ processData: false
+ })
+ .done(function (response,textStatus, jqXHR) {
+ bootbox.alert({
+ title: "Result",
+ message: "Role deleted.",
+ callback: function () {
+ dialog.modal('hide');
+ table.ajax.reload();
+ }
+ });
+ }).fail(function(result){
+ dialog.modal('hide');
+ var data = result.responseJSON;
+ var title = "Error " + (data.code ? data.code: 'unknown');
+ var message = data.detail ? data.detail: 'No detail available.';
+ bootbox.alert({
+ title: title,
+ message: message
+ });
});
}
})