c85603cd7950502b770de987282e1ca9423a173d
[osm/LW-UI.git] / static / src / projecthandler / descriptorslist.js
1 function deletePackage(descriptor_type, package_id) {
2
3 bootbox.confirm("Are you sure want to delete?", function (result) {
4 if (result) {
5 var dialog = bootbox.dialog({
6 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
7 closeButton: true
8 });
9 $.ajax({
10 url: '/projects/descriptors/' + descriptor_type + '/' + package_id + '/delete',
11 type: 'GET',
12 dataType: "json",
13 contentType: "application/json;charset=utf-8",
14 success: function (result) {
15 dialog.modal('hide');
16 location.reload();
17 },
18 error: function (result) {
19 dialog.modal('hide');
20 bootbox.alert("An error occurred.");
21 }
22 });
23 }
24 })
25 }
26
27
28 function openPackageContentList(type, pkg_id) {
29 var dialog = bootbox.dialog({
30 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
31 closeButton: true
32 });
33 $.ajax({
34 url: '/projects/descriptors/' + type + '/' + pkg_id + '/action/get_package_files_list',
35 type: 'GET',
36 dataType: "json",
37 contentType: "application/json;charset=utf-8",
38 success: function (result) {
39 //$('#modal_show_vim_body').empty();
40 dialog.modal('hide');
41 build_file_list("Files in " + pkg_id, result.files);
42 },
43 error: function (result) {
44 dialog.modal('hide');
45 bootbox.alert("An error occurred while retrieving the package content.");
46 }
47 });
48 }
49
50
51 function build_file_list(title, list) {
52 $('#files_list_tbody').find('tr:gt(0)').remove();
53 $('#files_list_tbody_title').text(title)
54 for (var i in list) {
55 var template = '<tr><td>-</td><td>' + list[i] + '</td><td><button type="button" class="btn btn-default" onclick="" disabled><i class="fa fa-folder-open"></i></button></td></tr>'
56 $('#files_list_tbody').append(template)
57 }
58 $('#modal_files_list').modal('show');
59 }
60