X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=static%2Fsrc%2Frolehandler%2Frole_list.js;fp=static%2Fsrc%2Frolehandler%2Frole_list.js;h=5145a04b6f31167af5a0ea4890335022f4fe7b27;hb=55d48e7d9a12c290048fa3214bcf16e6ff0d22e7;hp=fc19f5217db150aaa372c4483d9e202ec9e93bdf;hpb=fb0edf0369dbd3b06783a2ce95d5dbecddfad143;p=osm%2FLW-UI.git
diff --git a/static/src/rolehandler/role_list.js b/static/src/rolehandler/role_list.js
index fc19f52..5145a04 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_definition').val(JSON.stringify(response['definition']))
+ 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
+ });
});
}
})