user: list, create, delete
[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
27
28 $('#modal_new_user').modal('show');
29 }
30
31 function deleteUser(delete_url) {
32 bootbox.confirm("Are you sure want to delete?", function (confirm) {
33 if (confirm) {
34 var dialog = bootbox.dialog({
35 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
36 closeButton: false
37 });
38 $.ajax({
39 url: delete_url,
40 dataType: "json",
41 contentType: "application/json;charset=utf-8",
42 success: function (result) {
43 //$('#modal_show_vim_body').empty();
44 dialog.modal('hide');
45 location.reload();
46 },
47 error: function (result) {
48 dialog.modal('hide');
49 bootbox.alert("An error occurred.");
50 }
51 });
52 }
53 })
54
55 }