X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=static%2Fsrc%2Fuserhandler%2Fuser_list.js;h=b3d8250f69ee84a9ac5b079e463ce27e2b5c31fd;hb=refs%2Fchanges%2F44%2F8844%2F4;hp=6b36f1124e87650d7a1489911f804fa1b5c39e78;hpb=59989d09abcf5cb7618739b06bdb87496e721fd5;p=osm%2FLW-UI.git diff --git a/static/src/userhandler/user_list.js b/static/src/userhandler/user_list.js index 6b36f11..b3d8250 100644 --- a/static/src/userhandler/user_list.js +++ b/static/src/userhandler/user_list.js @@ -16,55 +16,72 @@ function openModalCreateUser(args) { - select2_groups = $('#projects').select2({ - placeholder: 'Select Projects', - width: '100%', - ajax: { - url: args.projects_list_url, - dataType: 'json', - processResults: function (data) { - projects = []; - if (data['projects']) { - for (d in data['projects']) { - var project = data['projects'][d]; - projects.push({ id: project['_id'], text: project['name'] }) + var dialog = bootbox.dialog({ + message: '
Loading...
', + closeButton: false + }); + $.ajax({ + url: args.domains_list_url, + dataType: "json", + contentType: "application/json;charset=utf-8", + success: function (result_domain) { + domains_list = []; + $('#domain_name').prop('disabled', false).trigger('change'); + if (result_domain['domains']) { + for (d in result_domain['domains']) { + var domain = result_domain['domains'][d]; + if (domain.endsWith(':ro') === false) { + domains_list.push({ id: domain, text: domain }) } - } - return { - results: projects - }; + } } - } - }); - - select2_groups = $('#domain_name').select2({ - placeholder: 'Select Domain', - width: '100%', - ajax: { - url: args.domains_list_url, - dataType: 'json', - processResults: function (data) { - domains_list = []; - - if (data['domains']) { - for (d in data['domains']) { - var domain = data['domains'][d]; - if( domain.endsWith(':ro') === false) { - domains_list.push({ id: domain, text: domain }) + if (domains_list.length == 0) { + $('#domainNameGroupDiv').remove(); + } + dialog.modal('hide'); + select2_groups = $('#projects').select2({ + placeholder: 'Select Projects', + width: '100%', + ajax: { + url: args.projects_list_url, + dataType: 'json', + processResults: function (data) { + projects = []; + if (data['projects']) { + for (d in data['projects']) { + var project = data['projects'][d]; + projects.push({ id: project['_id'], text: project['name'] }) + } } - + + return { + results: projects + }; } } + }); + select2_groups = $('#domain_name').select2({ + placeholder: 'Select Domain', + width: '100%', + "language": { + "noResults": function () { + return "No domains in the platform"; + } + }, + data: domains_list + }); - return { - results: domains_list - }; - } + $('#modal_new_user').modal('show'); + + }, + error: function (result) { + dialog.modal('hide'); + bootbox.alert("An error occurred."); } }); - $('#modal_new_user').modal('show'); + } function openModalEditUserCredentials(args) {