refactoring urls
[osm/LW-UI.git] / static / src / userhandler / user_list.js
1 function openModalCreateUser(args) {
2 console.log(args)
3 // load projects list
4 select2_groups = $('#projects').select2({
5 placeholder: 'Select Projects',
6 width: '100%',
7 ajax: {
8 url: args.projects_list_url,
9 dataType: 'json',
10 processResults: function (data) {
11 projects = [];
12 if (data['projects']) {
13 for (d in data['projects']) {
14 var project = data['projects'][d];
15 projects.push({id: project['_id'], text: project['name']})
16 }
17 }
18
19 return {
20 results: projects
21 };
22 }
23 }
24 });
25
26 $('#modal_new_user').modal('show');
27 }
28
29 function deleteUser(delete_url) {
30 bootbox.confirm("Are you sure want to delete?", function (confirm) {
31 if (confirm) {
32 var dialog = bootbox.dialog({
33 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
34 closeButton: false
35 });
36 $.ajax({
37 url: delete_url,
38 dataType: "json",
39 contentType: "application/json;charset=utf-8",
40 success: function (result) {
41 //$('#modal_show_vim_body').empty();
42 dialog.modal('hide');
43 location.reload();
44 },
45 error: function (result) {
46 dialog.modal('hide');
47 bootbox.alert("An error occurred.");
48 }
49 });
50 }
51 })
52
53 }