Add export table to info page

This commit is contained in:
JonnyWong16 2020-09-27 13:59:11 -07:00
parent acebf96d2f
commit be82c8f6d9
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 77 additions and 22 deletions

View file

@ -24,8 +24,8 @@ DOCUMENTATION :: END
</div>
<div class="modal-body">
<form method="post" class="form" id="export_metadata_form">
<input type="hidden" id="section_id" name="section_id" value="${section_id or ''}" />
<input type="hidden" id="rating_key" name="rating_key" value="${rating_key or ''}" />
<input type="hidden" id="export_section_id" name="export_section_id" value="${section_id or ''}" />
<input type="hidden" id="export_rating_key" name="export_rating_key" value="${rating_key or ''}" />
<div class="form-group">
<label for="metadata_export_level_select">Metadata Export Level</label>
<div class="row">
@ -88,8 +88,8 @@ DOCUMENTATION :: END
</div>
<script>
$("#export_metadata").click(function() {
var section_id = $('#section_id').val();
var rating_key = $('#rating_key').val();
var section_id = $('#export_section_id').val();
var rating_key = $('#export_rating_key').val();
var metadata_export_level = $('#metadata_export_level_select option:selected').val();
var media_info_export_level = $('#media_info_export_level_select option:selected').val();
var file_format = $('#file_format_select option:selected').val();
@ -108,13 +108,8 @@ DOCUMENTATION :: END
async: true,
success: function (data) {
if (data.result === 'success') {
var msg = '';
if (typeof export_table !== 'undefined') {
redrawExportTable();
} else {
msg = '<br>View the export from the <a href="library?section_id=' + section_id +'#tab_tabs-export">library page</a>.'
}
showMsg('<i class="fa fa-check"></i> ' + data.message + msg, false, true, 5000);
showMsg('<i class="fa fa-check"></i> ' + data.message, false, true, 5000);
} else {
showMsg('<i class="fa fa-exclamation-circle"></i> ' + data.message, false, true, 5000, true);
}

View file

@ -518,17 +518,11 @@ DOCUMENTATION :: END
</button>
</div>
% endif
<div class="btn-group">
<button class="btn btn-dark export-button" id="toggle-export-modal" data-toggle="modal" data-target="#export-modal"
data-section_id="${data['section_id']}" data-rating_key="${data['rating_key']}">
<i class="fa fa-file-export"></i> Export Metadata
</button>
</div>
% endif
<div class="btn-group">
<button class="btn btn-dark refresh-history-button" id="refresh-history-list"><i class="fa fa-refresh"></i> Refresh history</button>
</div>
<div class="btn-group colvis-button-bar"></div>
<div class="btn-group colvis-button-bar" id="button-bar-history"></div>
</div>
</div>
<div class="table-card-back">
@ -555,6 +549,48 @@ DOCUMENTATION :: END
</div>
</div>
% endif
% if _session['user_group'] == 'admin':
<div class="col-md-12">
<div class="table-card-header">
<div class="header-bar">
<span>Metadata Exports for <strong>${data['title']}</strong></span>
</div>
<div class="button-bar">
% if _session['user_group'] == 'admin':
<div class="btn-group">
<button class="btn btn-dark export-button" id="toggle-export-modal" data-toggle="modal" data-target="#export-modal"
data-section_id="${data['section_id']}" data-rating_key="${data['rating_key']}">
<i class="fa fa-file-export"></i> Export Metadata
</button>
</div>
<div class="btn-group">
<button class="btn btn-dark refresh-export-table-button" id="refresh-export-table">
<i class="fa fa-refresh"></i> Refresh exports
</button>
</div>
% endif
<div class="btn-group colvis-button-bar" id="button-bar-export"></div>
</div>
</div>
<div class="table-card-back">
<table class="display export_table" id="export_table-RK-${data['rating_key']}" width="100%">
<thead>
<tr>
<th align="left" id="timestamp">Exported At</th>
<th align="left" id="media_type_title">Media Type</th>
<th align="left" id="rating_key">Rating Key</th>
<th align="left" id="filename">Filename</th>
<th align="left" id="file_format">File Format</th>
<th align="left" id="file_size">File Size</th>
<th align="left" id="complete">Download</th>
<th align="left" id="delete">Delete</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
% endif
</div>
</div>
</div>
@ -659,6 +695,7 @@ DOCUMENTATION :: END
data = defaultdict(None, **metadata)
%>
<script src="${http_root}js/tables/history_table.js${cache_param}"></script>
<script src="${http_root}js/tables/export_table.js${cache_param}"></script>
% if data['live']:
<script>
function get_history() {
@ -730,7 +767,7 @@ DOCUMENTATION :: END
get_history();
history_table = $('#history_table-RK-${data["rating_key"]}').DataTable(history_table_options);
var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark', exclude: [0, 12] });
$(colvis.button()).appendTo('div.colvis-button-bar');
$(colvis.button()).appendTo('#button-bar-history');
clearSearchButton('history_table-RK-${data["rating_key"]}', history_table);
@ -864,6 +901,29 @@ DOCUMENTATION :: END
});
});
function loadExportTable() {
// Build export table
export_table_options.ajax = {
url: 'get_library_export',
type: 'POST',
data: function ( d ) {
return {
json_data: JSON.stringify( d ),
rating_key: "${data['rating_key']}"
};
}
};
export_table = $('#export_table-RK-${data["rating_key"]}').DataTable(export_table_options);
var colvis = new $.fn.dataTable.ColVis(export_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' });
$(colvis.button()).appendTo('#button-bar-export');
clearSearchButton('export_table-RK-${data["rating_key"]}', export_table);
}
$(document).ready(function () {
loadExportTable();
});
</script>
% if data.get('poster_url'):
<script>

View file

@ -144,8 +144,8 @@ export_table_options = {
if (timer) {
clearTimeout(timer);
}
if ($('.export-processing').length && $("#tabs-export").hasClass("active")) {
timer = setTimeout(redrawExportTable.bind(null, false), 5000);
if ($('.export-processing').length) {
timer = setTimeout(redrawExportTable.bind(null, false), 2000);
}
},
"preDrawCallback": function(settings) {

View file

@ -313,7 +313,7 @@ DOCUMENTATION :: END
<div class='table-card-header'>
<div class="header-bar">
<span>
<i class="fa fa-file-export"></i> Exports for <strong>
<i class="fa fa-file-export"></i> Metadata Exports for <strong>
<span class="set-username">${data['section_name']}</span>
</strong>
</span>