Rework exporter to allow exporting individual files from library

This commit is contained in:
JonnyWong16 2020-10-14 12:48:08 -07:00
parent 034ad05383
commit f3fa9601c0
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
6 changed files with 428 additions and 247 deletions

View file

@ -56,6 +56,14 @@ DOCUMENTATION :: END
</div>
<p class="help-block">Select the export data file format.</p>
</div>
% if not rating_key:
<div class="checkbox">
<label>
<input type="checkbox" id="export_individual_files" name="export_individual_files" value="1"> Export Individual Files
</label>
<p class="help-block">Enable to export one file for each ${media_type}, otherwise only export a single file containing all ${media_type}s.</p>
</div>
% endif
<div class="form-group">
<label for="export_metadata_level">Metadata Export Level</label>
<div class="row">
@ -249,6 +257,7 @@ DOCUMENTATION :: END
$('#export_custom_media_info_fields').val()
].filter(Boolean).join(',');
var export_type = $('#export_export_type').val()
var individual_files = $('#export_individual_files').is(':checked')
$.ajax({
url: 'export_metadata',
@ -262,7 +271,8 @@ DOCUMENTATION :: END
thumb_level: thumb_level,
art_level: art_level,
custom_fields: custom_fields,
export_type: export_type
export_type: export_type,
individual_files: individual_files
},
async: true,
success: function (data) {

View file

@ -40,7 +40,8 @@ export_table_options = {
}
},
"width": "8%",
"className": "no-wrap"
"className": "no-wrap",
"searchable": false
},
{
"targets": [1],
@ -66,13 +67,23 @@ export_table_options = {
},
{
"targets": [3],
"data": "filename",
"data": "title",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
if (rowData['complete'] === 1 && rowData['exists']) {
$(td).html('<a href="view_export?export_id=' + rowData['export_id'] + '" target="_blank">' + cellData + '</a>');
var tooltip;
var filename;
if (!rowData['individual_files']) {
tooltip = '<span data-toggle="tooltip" title="Single File"><i class="fa fa-file-alt fa-fw"></i></span>';
filename = cellData + '.' + rowData['file_format']
} else {
$(td).html(cellData);
tooltip = '<span data-toggle="tooltip" title="Multiple Files"><i class="fa fa-folder fa-fw"></i></span>';
filename = cellData
}
if (rowData['complete'] === 1 && rowData['exists'] && !rowData['individual_files']) {
$(td).html('<a href="view_export?export_id=' + rowData['export_id'] + '" target="_blank">' + tooltip + '&nbsp;' + filename + '</a>');
} else {
$(td).html(tooltip + '&nbsp;' + filename);
}
}
},
@ -136,14 +147,25 @@ export_table_options = {
}
},
"width": "6%",
"className": "no-wrap"
"className": "no-wrap",
"searchable": false
},
{
"targets": [9],
"data": "complete",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData === 1 && rowData['exists']) {
$(td).html('<button class="btn btn-xs btn-success pull-left" data-id="' + rowData['export_id'] + '"><i class="fa fa-file-download fa-fw"></i> Download</button>');
var tooltip_title = '';
var icon = '';
if (rowData['thumb_level'] || rowData['art_level'] || rowData['individual_files']) {
tooltip_title = 'Zip Archive';
icon = 'fa-file-archive';
} else {
tooltip_title = rowData['file_format'].toUpperCase() + ' File';
icon = 'fa-file-download';
}
var icon = (rowData['thumb_level'] || rowData['art_level'] || rowData['individual_files']) ? 'fa-file-archive' : 'fa-file-download';
$(td).html('<button class="btn btn-xs btn-success pull-left" data-id="' + rowData['export_id'] + '"><span data-toggle="tooltip" data-placement="left" title="' + tooltip_title + '"><i class="fa ' + icon + ' fa-fw"></i> Download</span></button>');
} else if (cellData === 0) {
$(td).html('<span class="btn btn-xs btn-dark pull-left export-processing" data-id="' + rowData['export_id'] + '" disabled><i class="fa fa-spinner fa-spin fa-fw"></i> Processing</span>');
} else if (cellData === -1) {
@ -153,7 +175,8 @@ export_table_options = {
}
},
"width": "7%",
"className": "export_download"
"className": "export_download",
"searchable": false
},
{
"targets": [10],
@ -166,7 +189,8 @@ export_table_options = {
}
},
"width": "7%",
"className": "export_delete"
"className": "export_delete",
"searchable": false
}
],
"drawCallback": function (settings) {
@ -174,6 +198,12 @@ export_table_options = {
//$('html,body').scrollTop(0);
$('#ajaxMsg').fadeOut();
// Create the tooltips.
$('body').tooltip({
selector: '[data-toggle="tooltip"]',
container: 'body'
});
if (export_processing_timer) {
clearTimeout(export_processing_timer);
}
@ -208,7 +238,7 @@ $('.export_table').on('click', '> tbody > tr > td.export_delete > button', funct
var row = export_table.row(tr);
var rowData = row.data();
var msg = 'Are you sure you want to delete the following export?<br /><br /><strong>' + rowData['filename'] + '</strong>';
var msg = 'Are you sure you want to delete the following export?<br /><br /><strong>' + rowData['title'] + '</strong>';
var url = 'delete_export?export_id=' + rowData['export_id'];
confirmAjaxCall(url, msg, null, null, redrawExportTable);
});