|
Lines 3-8
Link Here
|
| 3 |
[% USE Koha %] |
3 |
[% USE Koha %] |
| 4 |
[% SET footerjs = 1 %] |
4 |
[% SET footerjs = 1 %] |
| 5 |
[% INCLUDE 'doc-head-open.inc' %] |
5 |
[% INCLUDE 'doc-head-open.inc' %] |
|
|
6 |
[% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %] |
| 6 |
[% IF plugin %] |
7 |
[% IF plugin %] |
| 7 |
<title>Upload plugin</title> |
8 |
<title>Upload plugin</title> |
| 8 |
[% ELSE %] |
9 |
[% ELSE %] |
|
Lines 47-52
Link Here
|
| 47 |
<input type="file" id="fileToUpload" name="fileToUpload" multiple/> |
48 |
<input type="file" id="fileToUpload" name="fileToUpload" multiple/> |
| 48 |
</div> |
49 |
</div> |
| 49 |
</li> |
50 |
</li> |
|
|
51 |
<li> |
| 52 |
<label for="fileChecksum">Add file checksum to the uploaded filename: </label> |
| 53 |
<label class="radio"> |
| 54 |
Yes <input type="radio" name="checksum" id="checksum" value="1" checked /> |
| 55 |
No <input type="radio" name="checksum" id="checksum" value="0" /> |
| 56 |
</label> |
| 57 |
</li> |
| 58 |
[% IF uploadpaths %] |
| 59 |
<li> |
| 60 |
<label for="uploadpath">Upload Path: </label> |
| 61 |
<select id="uploadpath" name="uploadpath"> |
| 62 |
[% IF !plugin %] |
| 63 |
<option value=""></option> |
| 64 |
[% END %] |
| 65 |
[% FOREACH dir IN uploadpaths %] |
| 66 |
<option value="[% dir.code | html %]">[% dir.name | html %]</option> |
| 67 |
[% END %] |
| 68 |
</select> |
| 69 |
</li> |
| 70 |
[% END %] |
| 50 |
[% IF uploadcategories %] |
71 |
[% IF uploadcategories %] |
| 51 |
<li> |
72 |
<li> |
| 52 |
<label for="uploadcategory">Category: </label> |
73 |
<label for="uploadcategory">Category: </label> |
|
Lines 149-161
Link Here
|
| 149 |
[% END %] |
170 |
[% END %] |
| 150 |
[% END %] |
171 |
[% END %] |
| 151 |
|
172 |
|
|
|
173 |
[% BLOCK upload_paths %] |
| 174 |
<fieldset class="rows"> |
| 175 |
<legend>Search uploads by file tree</legend> |
| 176 |
<ol> |
| 177 |
<li> |
| 178 |
<table id="uploadpathtable"> |
| 179 |
<caption> |
| 180 |
<span class="actions"><a href="#" id="expand_all">Expand all</a> |
| 181 |
| <a href="#" id="collapse_all">Collapse all</a> |
| 182 |
</span> |
| 183 |
</caption> |
| 184 |
<thead> |
| 185 |
<tr> |
| 186 |
<th>Path</th> |
| 187 |
</tr> |
| 188 |
</thead> |
| 189 |
<tbody> |
| 190 |
[% FOREACH up IN paths %] |
| 191 |
<tr data-pathname="[% up.pathname | $raw %]" data-tt-id="[% loop.count | html %]" data-tt-branch="true"> |
| 192 |
<td>[% up.name | html %]</td> |
| 193 |
</tr> |
| 194 |
[% END %] |
| 195 |
</tbody> |
| 196 |
</table> |
| 197 |
</li> |
| 198 |
</ol> |
| 199 |
</fieldset> |
| 200 |
[% END %] |
| 201 |
|
| 152 |
[% BLOCK table_results %] |
202 |
[% BLOCK table_results %] |
| 153 |
<table id="uploadresults"> |
203 |
<table id="uploadresults"> |
| 154 |
<thead> |
204 |
<thead> |
| 155 |
<tr> |
205 |
<tr> |
| 156 |
<th>Filename</th> |
206 |
<th>Filename</th> |
| 157 |
<th>Size</th> |
207 |
<th>Size</th> |
|
|
208 |
<th>File checksum</th> |
| 158 |
<th>Hashvalue</th> |
209 |
<th>Hashvalue</th> |
|
|
210 |
<th>Upload path</th> |
| 159 |
<th>Category</th> |
211 |
<th>Category</th> |
| 160 |
[% IF !plugin %]<th>Public</th>[% END %] |
212 |
[% IF !plugin %]<th>Public</th>[% END %] |
| 161 |
[% IF !plugin %]<th>Temporary</th>[% END %] |
213 |
[% IF !plugin %]<th>Temporary</th>[% END %] |
|
Lines 167-173
Link Here
|
| 167 |
<tr> |
219 |
<tr> |
| 168 |
<td>[% record.filename | html %]</td> |
220 |
<td>[% record.filename | html %]</td> |
| 169 |
<td>[% record.filesize | html %]</td> |
221 |
<td>[% record.filesize | html %]</td> |
|
|
222 |
<td>[% IF record.checksum %] Yes [% ELSE %] No [% END %]</td> |
| 170 |
<td>[% record.hashvalue | html %]</td> |
223 |
<td>[% record.hashvalue | html %]</td> |
|
|
224 |
<td>[% record.dir | html %]</td> |
| 171 |
<td>[% record.uploadcategorycode | html %]</td> |
225 |
<td>[% record.uploadcategorycode | html %]</td> |
| 172 |
[% IF !plugin %] |
226 |
[% IF !plugin %] |
| 173 |
<td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> |
227 |
<td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> |
|
Lines 222-227
Link Here
|
| 222 |
[% IF mode == 'new' || mode == 'deleted' %] |
276 |
[% IF mode == 'new' || mode == 'deleted' %] |
| 223 |
[% PROCESS form_new %] |
277 |
[% PROCESS form_new %] |
| 224 |
[% PROCESS form_search %] |
278 |
[% PROCESS form_search %] |
|
|
279 |
[% PROCESS upload_paths %] |
| 225 |
[% PROCESS closer %] |
280 |
[% PROCESS closer %] |
| 226 |
[% ELSIF mode == 'report' %] |
281 |
[% ELSIF mode == 'report' %] |
| 227 |
[% IF uploads %] |
282 |
[% IF uploads %] |
|
Lines 256-261
Link Here
|
| 256 |
[% Asset.js("js/tools-menu.js") | $raw %] |
311 |
[% Asset.js("js/tools-menu.js") | $raw %] |
| 257 |
[% INCLUDE 'datatables.inc' %] |
312 |
[% INCLUDE 'datatables.inc' %] |
| 258 |
[% Asset.js("js/file-upload.js") | $raw %] |
313 |
[% Asset.js("js/file-upload.js") | $raw %] |
|
|
314 |
[% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %] |
| 259 |
<script> |
315 |
<script> |
| 260 |
function StartUpload() { |
316 |
function StartUpload() { |
| 261 |
if( $('#fileToUpload').prop('files').length == 0 ) return; |
317 |
if( $('#fileToUpload').prop('files').length == 0 ) return; |
|
Lines 270-285
Link Here
|
| 270 |
$("#searchfile").hide(); |
326 |
$("#searchfile").hide(); |
| 271 |
$("#lastbreadcrumb").text( _("Add a new upload") ); |
327 |
$("#lastbreadcrumb").text( _("Add a new upload") ); |
| 272 |
|
328 |
|
| 273 |
var cat, xtra=''; |
329 |
var dir, cat, xtra=''; |
| 274 |
if( $("#uploadcategory").val() ) |
330 |
if( $("#uploadcategory").val() ) |
| 275 |
cat = encodeURIComponent( $("#uploadcategory").val() ); |
331 |
cat = encodeURIComponent( $("#uploadcategory").val() ); |
| 276 |
if( cat ) xtra= 'category=' + cat + '&'; |
332 |
if( cat ) xtra= 'category=' + cat + '&'; |
| 277 |
[% IF plugin %] |
333 |
[% IF plugin %] |
| 278 |
xtra = xtra + 'public=1&temp=0'; |
334 |
xtra = xtra + 'public=1&temp=0&'; |
| 279 |
[% ELSE %] |
335 |
[% ELSE %] |
| 280 |
if( !cat ) xtra = 'temp=1&'; |
336 |
if( !cat ) xtra = 'temp=1&'; |
| 281 |
if( $('#public').prop('checked') ) xtra = xtra + 'public=1'; |
337 |
if( $('#public').prop('checked') ) xtra = xtra + 'public=1&'; |
| 282 |
[% END %] |
338 |
[% END %] |
|
|
339 |
if( $("#uploadpath").val() ) |
| 340 |
dir = encodeURIComponent( $("#uploadpath").val() ); |
| 341 |
if( dir ) xtra= xtra + 'dir=' + dir + '&'; |
| 342 |
xtra = xtra + 'checksum=' + $('#checksum:checked').val(); |
| 283 |
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload ); |
343 |
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload ); |
| 284 |
} |
344 |
} |
| 285 |
function CancelUpload() { |
345 |
function CancelUpload() { |
|
Lines 381-387
Link Here
|
| 381 |
[% END %] |
441 |
[% END %] |
| 382 |
window.close(); |
442 |
window.close(); |
| 383 |
} |
443 |
} |
|
|
444 |
|
| 384 |
$(document).ready(function() { |
445 |
$(document).ready(function() { |
|
|
446 |
var oTable = $("#uploadpathtable"); |
| 447 |
|
| 448 |
$(oTable).treetable({ |
| 449 |
expandable: true, |
| 450 |
onNodeCollapse: function() { |
| 451 |
var node = this; |
| 452 |
oTable.treetable("unloadBranch", node); |
| 453 |
}, |
| 454 |
onNodeExpand: function() { |
| 455 |
var node = this; |
| 456 |
var id = node.id; |
| 457 |
var pathname = node.row.data('pathname'); |
| 458 |
$.ajax({ |
| 459 |
type: 'POST', |
| 460 |
url: "/cgi-bin/koha/svc/uploadpath", |
| 461 |
data: { |
| 462 |
pathname: pathname , |
| 463 |
[% IF plugin %] public: 1[% END %] |
| 464 |
}, |
| 465 |
success: function(data) { |
| 466 |
var childNodes = data.success; |
| 467 |
if(childNodes) { |
| 468 |
var parentNode = $("#uploadpathtable").treetable("node", id); |
| 469 |
for (var i = 0; i < childNodes.length; i++) { |
| 470 |
var node = childNodes[i]; |
| 471 |
var nodeToAdd = $("#uploadpathtable").treetable("node",id+"."+node['id']); |
| 472 |
// check if node already exists. If not add row to parent node |
| 473 |
if (!nodeToAdd) { |
| 474 |
var row ='<tr data-pathname="' + node['pathname'] + '" data-tt-id="' + id + '.' + ( i+1) + '" data-tt-parent-id="' + id + '" '; |
| 475 |
var search = ''; |
| 476 |
if (node['type'] == 'branch' ) { |
| 477 |
row += ' data-tt-branch="true" '; |
| 478 |
search = "<a href='/cgi-bin/koha/tools/upload.pl?op=search&"; |
| 479 |
[% IF plugin %] |
| 480 |
search += "plugin=1&"; |
| 481 |
[% END %] |
| 482 |
search += "term="+ node['path'] + "'>" + node['path'] + "</a>"; |
| 483 |
}else { |
| 484 |
[% IF plugin %] |
| 485 |
search += ' <button class="btn btn-default btn-xs" onclick="Choose(\'' + node['hashvalue'] + '\');"><i class="fa fa-plus"></i> Choose</button>'; |
| 486 |
[% END %] |
| 487 |
search += ' <button class="btn btn-default btn-xs " onclick="SubmitMe( \'download\', ' + node['fileID'] + ');"><i class="fa fa-download"></i> Download</button>'; |
| 488 |
search += " " + node['path']; |
| 489 |
} |
| 490 |
row += ' >'; |
| 491 |
row += "<td>" + search + "</td>"; |
| 492 |
row +="</tr>"; |
| 493 |
$("#uploadpathtable").treetable("loadBranch", parentNode, row); |
| 494 |
} |
| 495 |
} |
| 496 |
} |
| 497 |
}, |
| 498 |
}); |
| 499 |
} |
| 500 |
}); |
| 501 |
$("#expand_all").click(function(e){ |
| 502 |
e.preventDefault(); |
| 503 |
$(oTable).treetable('expandAll'); |
| 504 |
}); |
| 505 |
$("#collapse_all").click(function(e){ |
| 506 |
e.preventDefault(); |
| 507 |
$(oTable).treetable('collapseAll'); |
| 508 |
}); |
| 509 |
|
| 385 |
$("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, { |
510 |
$("#uploadresults").dataTable($.extend(true, {}, dataTablesDefaults, { |
| 386 |
"aoColumnDefs": [ |
511 |
"aoColumnDefs": [ |
| 387 |
{ 'bSortable': false, 'aTargets': [ 'nosort' ] } |
512 |
{ 'bSortable': false, 'aTargets': [ 'nosort' ] } |
|
Lines 389-395
Link Here
|
| 389 |
"sPaginationType": "four_button" |
514 |
"sPaginationType": "four_button" |
| 390 |
})); |
515 |
})); |
| 391 |
[% IF msg %] |
516 |
[% IF msg %] |
| 392 |
ShowAlerts( [% msg | html %] ); |
517 |
ShowAlerts( [% msg | $raw %] ); |
| 393 |
[% END %] |
518 |
[% END %] |
| 394 |
$("#fileuploadcancel").hide(); |
519 |
$("#fileuploadcancel").hide(); |
| 395 |
$("#public_cb").click(function() { |
520 |
$("#public_cb").click(function() { |