Add export modal and buttons to library and info page

This commit is contained in:
JonnyWong16 2020-08-03 20:55:50 -07:00
parent 621fb95227
commit 43fefcf748
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 129 additions and 3 deletions

View file

@ -0,0 +1,78 @@
<%doc>
USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE
For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/
Filename: export_modal.html
Version: 0.1
Variable names: data [list]
data :: Usable parameters
== Global keys ==
DOCUMENTATION :: END
</%doc>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="info-modal-title">
${title}
</h4>
</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 ''}" />
<div class="form-group">
<label for="export_level">Export Level</label>
<div class="row">
<div class="col-md-12">
<select class="form-control" id="export_level" name="export_level">
<option value="1">Level 1 - Basic Metadata</option>
<option value="2">Level 2 - Extended Metadata</option>
<option value="3">Level 3 - Basic Media Info</option>
<option value="4">Level 4 - Extended Media Info</option>
<option value="9">Level 9 - Everything</option>
<option value="-999">Custom</option>
</select>
</div>
</div>
<p class="help-block">Select the export level.</p>
</div>
</form>
</div>
<div class="modal-footer">
<div>
<input type="button" class="btn btn-bright btn-ok" data-dismiss="modal" id="export_metadata" value="Export">
</div>
</div>
</div>
</div>
<script>
$("#export_metadata").click(function() {
var section_id = $('#section_id').val();
var rating_key = $('#rating_key').val();
$.ajax({
url: 'export_metadata',
data: {
section_id: section_id,
rating_key: rating_key
},
async: true,
success: function (data) {
if (data.result === 'success') {
if (typeof export_table !== 'undefined') {
redrawExportTable();
}
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);
}
}
});
});
</script>

View file

@ -510,6 +510,12 @@ 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-id="${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>
@ -629,6 +635,8 @@ DOCUMENTATION :: END
</div>
</div>
% endif
<div id="export-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="export-modal">
</div>
</%def>
<%def name="javascriptIncludes()">
@ -770,7 +778,7 @@ DOCUMENTATION :: END
data: {
rating_key: rating_key,
notifier_id: $('#send-notification-notifier option:selected').val()
},
},
async: true,
success: function (data) {
if (data.result === 'success') {
@ -832,6 +840,19 @@ DOCUMENTATION :: END
return '<div class="channel-thumbnail" style="background-image: url(' + $(this).data('img') + ');" />';
}
});
$("#toggle-export-modal").click(function() {
$.ajax({
url: 'export_metadata_modal',
data: { rating_key: $(this).data('id') },
cache: false,
async: true,
complete: function(xhr, status) {
$("#export-modal").html(xhr.responseText);
}
});
});
</script>
% if data.get('poster_url'):
<script>

View file

@ -320,6 +320,12 @@ DOCUMENTATION :: END
</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-id="${data['section_id']}">
<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
@ -403,6 +409,8 @@ DOCUMENTATION :: END
</div>
</div>
</div>
<div id="export-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="export-modal">
</div>
</%def>
<%def name="javascriptIncludes()">
@ -551,6 +559,18 @@ DOCUMENTATION :: END
});
});
$("#toggle-export-modal").click(function() {
$.ajax({
url: 'export_metadata_modal',
data: { section_id: $(this).data('id') },
cache: false,
async: true,
complete: function(xhr, status) {
$("#export-modal").html(xhr.responseText);
}
});
});
$('#row-edit-mode').on('click', function() {
$('#row-edit-mode-alert').fadeIn(200);

View file

@ -865,7 +865,7 @@ def export(section_id=None, rating_key=None, file_format='json'):
plex = Plex(plexpy.CONFIG.PMS_URL, plexpy.CONFIG.PMS_TOKEN)
if section_id:
logger.debug("Tautulli Exporter :: Exporting called with section_id %s", section_id)
logger.debug("Tautulli Exporter :: Export called with section_id %s", section_id)
library = plex.get_library(section_id)
media_type = library.type
@ -875,7 +875,7 @@ def export(section_id=None, rating_key=None, file_format='json'):
items = library.all()
elif rating_key:
logger.debug("Tautulli Exporter :: Exporting called with rating_key %s", rating_key)
logger.debug("Tautulli Exporter :: Export called with rating_key %s", rating_key)
item = plex.get_item(helpers.cast_to_int(rating_key))
media_type = item.type

View file

@ -6478,6 +6478,13 @@ class WebInterface(object):
return status
@cherrypy.expose
@requireAuth()
def export_metadata_modal(self, section_id=None, rating_key=None, **kwargs):
return serve_template(templatename="export_modal.html", title="Export Metadata",
section_id=section_id, rating_key=rating_key)
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))