1 {% extends
"descriptor/descriptor_view_base.html" %}
6 {% block title_header_big %}
8 Onboard new {{ descriptor_type }} package
11 {% block left_sidebar %}
12 {% include 'osm/osm_project_left_sidebar.html' %}
15 {% block breadcrumb_body %}
17 <li><a href=
"{% url 'projects:open_project' project_id=project_id %}">{{project_overview_data.name}}
</a></li>
18 <li><a href=
"{% url 'projects:open_project' project_id=project_id %}descriptors/{{descriptor_type}}">{{ descriptor_type }} Descriptors
</a></li>
19 <li>Create Descriptor
</li>
22 {% block tab_pane_button_list %}
24 <li id=
"file_li" class=
"active"><a href=
"#upload" data-toggle=
"tab"><i class=
"fa fa-upload"></i> Onboard Package
</a></li>
27 {% block nav_buttons_list %}
29 <li class=
"pull-right">
30 <button id=
"cancel" type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"cancel(this.id)"><i
31 class=
"fa fa-times"></i> Cancel
36 {% block tab_pane_list %}
39 <div class=
"tab-pane active" id=
"upload">
41 <h4>Drag and drop file below
</h4>
42 <div class=
"upload-drop-zone" id=
"drop-zone">
43 Just drag and drop files here
49 {% block resource_block %}
53 var descr_list_url = '{% url
"projects:list_descriptors" project_id=project_id descriptor_type=descriptor_type%}';
55 var dropZone = document.getElementById('drop-zone');
56 dropZone.ondrop = function (e) {
58 this.className = 'upload-drop-zone';
59 create(e.dataTransfer.files, true);
62 dropZone.ondragover = function () {
63 this.className = 'upload-drop-zone drop';
67 dropZone.ondragleave = function () {
68 this.className = 'upload-drop-zone';
73 function create(fs, dropzone) {
74 var id = $('.nav-tabs .active').attr('id');
75 if (dropzone) id = 'file_li';
77 var data = new FormData();
83 var files = dropzone ? fs : document.getElementById('js-upload-files').files;
84 if (!files || !files.length) {
85 files = document.getElementById('drop-zone').files;
86 if (!files || !files.length) {
87 alert(
"Select a file");
92 var patt1 = /\.([
0-
9a-z]+)(?:[\?#]|$)/i;
93 console.log(files[
0].name.match(patt1));
94 var extension = files[
0].name.substr(files[
0].name.lastIndexOf('.') +
1);
95 console.log(extension);
96 if (!(extension == 'gz' )) {
97 alert(
"The file must be .tar.gz");
101 data.append('file', files[
0]);
104 data.append('csrfmiddlewaretoken', '{{csrf_token}}');
105 data.append('type', type);
106 data.append('text', text);
107 data.append('id', '{{descriptor_id}}');
116 success: function (result) {
119 window.location.href = descr_list_url
122 error: function (result) {
128 function cancel(id) {
129 window.location.href = descr_list_url
136 {% include
"footer.html" %}