clone packages
[osm/LW-UI.git] / static / src / projecthandler / descriptorslist.js
1 function deletePackage(descriptor_type, package_id, package_name) {
2
3 bootbox.confirm("Are you sure want to delete " + package_name + "?", 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 function clonePackage(descriptor_type, package_id) {
28
29 bootbox.confirm("Are you sure want to clone?", function (result) {
30 if (result) {
31 var dialog = bootbox.dialog({
32 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
33 closeButton: true
34 });
35 $.ajax({
36 url: '/projects/descriptors/' + descriptor_type + '/' + package_id + '/clone',
37 type: 'GET',
38 dataType: "json",
39 contentType: "application/json;charset=utf-8",
40 success: function (result) {
41 dialog.modal('hide');
42 location.reload();
43 },
44 error: function (result) {
45 dialog.modal('hide');
46 bootbox.alert("An error occurred.");
47 }
48 });
49 }
50 })
51 }
52
53
54 function openPackageContentList(type, pkg_id) {
55 var dialog = bootbox.dialog({
56 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
57 closeButton: true
58 });
59 $.ajax({
60 url: '/projects/descriptors/' + type + '/' + pkg_id + '/action/get_package_files_list',
61 type: 'GET',
62 dataType: "json",
63 contentType: "application/json;charset=utf-8",
64 success: function (result) {
65 //$('#modal_show_vim_body').empty();
66 dialog.modal('hide');
67 build_file_list("Files in " + pkg_id, result.files);
68 },
69 error: function (result) {
70 dialog.modal('hide');
71 bootbox.alert("An error occurred while retrieving the package content.");
72 }
73 });
74 }
75
76
77 function build_file_list(title, list) {
78 $('#files_list_tbody').find('tr:gt(0)').remove();
79 $('#files_list_tbody_title').text(title)
80 for (var i in list) {
81 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>'
82 $('#files_list_tbody').append(template)
83 }
84 $('#modal_files_list').modal('show');
85 }
86