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