Fix bugs with media info table

This commit is contained in:
Jonathan Wong 2016-01-15 22:15:45 -08:00
parent 002cb93187
commit 6152a1e913
10 changed files with 55 additions and 60 deletions

View file

@ -35,7 +35,7 @@
$('#date-header').html(moment('${data}','YYYY-MM-DD').format('ddd MMM Do YYYY'));
history_table_modal_options.ajax = {
url: 'get_history',
type: "post",
type: 'post',
data: function ( d ) {
return {
json_data: JSON.stringify(d),

View file

@ -25,6 +25,7 @@ history_table_modal_options = {
"serverSide": true,
"pageLength": 10,
"lengthChange": false,
"autoWidth": false,
"order": [ 0, 'desc'],
"columnDefs": [
{
@ -37,9 +38,9 @@ history_table_modal_options = {
$(td).html(moment(cellData,"X").format(time_format));
}
},
"searchable": false,
"width": "10%",
"className": "no-wrap",
"width": "10%"
"searchable": false
},
{
"targets": [1],
@ -51,9 +52,9 @@ history_table_modal_options = {
$(td).html(moment(cellData,"X").format(time_format));
}
},
"searchable": false,
"width": "10%",
"className": "no-wrap",
"width": "10%"
"searchable": false
},
{
"targets": [2],
@ -69,8 +70,8 @@ history_table_modal_options = {
$(td).html(cellData);
}
},
"className": "no-wrap hidden-xs",
"width": "15%"
"width": "15%",
"className": "no-wrap hidden-xs"
},
{
"targets": [3],
@ -88,8 +89,8 @@ history_table_modal_options = {
$(td).html('<div><a href="#" data-target="#info-modal" data-toggle="modal"><div style="float: left;">' + transcode_dec + '&nbsp' + cellData + '</div></a></div>');
}
},
"className": "no-wrap hidden-sm hidden-xs modal-control",
"width": "20%"
"width": "25%",
"className": "no-wrap hidden-sm hidden-xs modal-control"
},
{
"targets": [4],
@ -116,7 +117,7 @@ history_table_modal_options = {
}
}
},
"width": "30%"
"width": "40%"
}
],
"drawCallback": function (settings) {

View file

@ -397,7 +397,7 @@ function createChildTableMedia(row, rowData) {
});
// Child table expand detailed media info
$('table[id^=media_info_child]').on('click', '> tbody > tr > td.expand-media-info a', function () {
$('table[id^=media_info_child-' + rowData['rating_key'] + ']').on('click', '> tbody > tr > td.expand-media-info a', function () {
var table_id = $(this).closest('table').data('id');
var tr = $(this).closest('tr');
var row = media_info_child_table[table_id].row(tr);

View file

@ -441,13 +441,13 @@ DOCUMENTATION :: END
});
function recentlyWatched() {
var widthVal = $('body').find("#library-recently-watched").width();
var tmp = (widthVal-32) / 180;
var widthVal = $("#library-recently-watched").width();
var tmp = (widthVal-25) / 175;
if (tmp > 0) {
containerSize = parseInt(tmp);
var containerSize = parseInt(tmp);
} else {
containerSize = 1;
var containerSize = 1;
}
// Populate recently watched
@ -465,13 +465,13 @@ DOCUMENTATION :: END
}
function recentlyAdded() {
var widthVal = $('body').find("#library-recently-added").width();
var tmp = (widthVal-32) / 180;
var widthVal = $("#library-recently-added").width();
var tmp = (widthVal-25) / 175;
if (tmp > 0) {
containerSize = parseInt(tmp);
var containerSize = parseInt(tmp);
} else {
containerSize = 1;
var containerSize = 1;
}
// Populate recently added

View file

@ -22,7 +22,7 @@
</div>
</div>
<div class='table-card-back'>
<table class="display" id="sync_table" width="100%">
<table class="display no-fixed" id="sync_table" width="100%">
<thead>
<tr>
<th align='left' id="state">State</th>
@ -54,7 +54,7 @@
<script>
$(document).ready(function() {
sync_table_options.ajax = {
"url": "get_sync"
url: 'get_sync'
}
sync_table = $('#sync_table').DataTable(sync_table_options);
var colvis = new $.fn.dataTable.ColVis( sync_table, { buttonText: '<i class="fa fa-columns"></i> Select columns', buttonClass: 'btn btn-dark' } );

View file

@ -218,7 +218,7 @@ from plexpy import helpers
</div>
</div>
<div class="table-card-back">
<table class="display" id="sync_table" width="100%">
<table class="display no-fixed" id="sync_table" width="100%">
<thead>
<tr>
<th align="left" id="state">State</th>
@ -471,13 +471,13 @@ from plexpy import helpers
});
function recentlyWatched() {
var widthVal = $('body').find("#user-recently-watched").width();
var tmp = (widthVal-32) / 180;
var widthVal = $("#user-recently-watched").width();
var tmp = (widthVal-25) / 175;
if (tmp > 0) {
containerSize = parseInt(tmp);
var containerSize = parseInt(tmp);
} else {
containerSize = 1;
var containerSize = 1;
}
// Populate recently watched

View file

@ -242,8 +242,9 @@ class Libraries(object):
rows = json.load(inFile)
library_count = len(rows)
except IOError as e:
logger.debug(u"PlexPy Libraries :: No JSON file for rating_key %s." % rating_key)
logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for rating_key %s." % rating_key)
#logger.debug(u"PlexPy Libraries :: No JSON file for rating_key %s." % rating_key)
#logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for rating_key %s." % rating_key)
pass
elif section_id:
try:
inFilePath = os.path.join(plexpy.CONFIG.CACHE_DIR,'media_info-%s.json' % section_id)
@ -251,8 +252,9 @@ class Libraries(object):
rows = json.load(inFile)
library_count = len(rows)
except IOError as e:
logger.debug(u"PlexPy Libraries :: No JSON file for library section_id %s." % section_id)
logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for section_id %s." % section_id)
#logger.debug(u"PlexPy Libraries :: No JSON file for library section_id %s." % section_id)
#logger.debug(u"PlexPy Libraries :: Refreshing data and creating new JSON file for section_id %s." % section_id)
pass
if not rows:
# Get the library details
@ -312,13 +314,6 @@ class Libraries(object):
rows = []
for item in children_list:
thumb = item['thumb']
if item['media_type'] == 'episode' or item['media_type'] == 'track':
full_title = 'E%s - %s' % (item['media_index'], item['title'])
else:
full_title = item['title']
watched_item = watched_list.get(item['rating_key'], None)
if watched_item:
last_watched = watched_item['last_watched']
@ -329,18 +324,16 @@ class Libraries(object):
row = {'section_id': library_details['section_id'],
'section_type': library_details['section_type'],
'last_watched': last_watched,
'added_at': item['added_at'],
'media_type': item['media_type'],
'rating_key': item['rating_key'],
'parent_rating_key': item['parent_rating_key'],
'grandparent_rating_key': item['grandparent_rating_key'],
'full_title': full_title,
'title': item['title'],
'year': item['year'],
'media_index': item['media_index'],
'parent_media_index': item['parent_media_index'],
'thumb': thumb,
'thumb': item['thumb'],
'container': item.get('container', ''),
'bitrate': item.get('bitrate', ''),
'video_codec': item.get('video_codec', ''),
@ -349,6 +342,7 @@ class Libraries(object):
'audio_codec': item.get('audio_codec', ''),
'audio_channels': item.get('audio_channels', ''),
'file_size': item.get('file_size', ''),
'last_watched': last_watched,
'play_count': play_count
}
rows.append(row)
@ -384,25 +378,29 @@ class Libraries(object):
filtered_count = len(results)
# Sort results
results = sorted(results, key=lambda k: k['title'])
sort_order = json_data['order']
for order in reversed(sort_order):
sort_key = json_data['columns'][int(order['column'])]['data']
reverse = True if order['dir'] == 'desc' else False
if rating_key and sort_key == 'title':
results = sorted(results, key=lambda k: int(k['media_index']), reverse=reverse)
elif sort_key == 'file_size' or sort_key == 'bitrate':
results = sorted(results, key=lambda k: int(k[sort_key]), reverse=reverse)
else:
results = sorted(results, key=lambda k: k[sort_key], reverse=reverse)
# Paginate results
results = results[json_data['start']:(json_data['start'] + json_data['length'])]
## Find some way to add total disk space used?
dict = {'recordsFiltered': filtered_count,
'recordsTotal': library_count,
'data': results,
'draw': int(json_data['draw'])
}
## Add total disk space used
return dict
def set_config(self, section_id=None, custom_thumb='', do_notify=1, keep_history=1, do_notify_created=1):

View file

@ -292,8 +292,8 @@ class PlexTV(object):
for device in sync_device:
device_user_id = helpers.get_xml_attr(device, 'userID')
try:
device_username = user_data.get_user_details(user_id=device_user_id)['username']
device_friendly_name = user_data.get_user_details(user_id=device_user_id)['friendly_name']
device_username = user_data.get_details(user_id=device_user_id)['username']
device_friendly_name = user_data.get_details(user_id=device_user_id)['friendly_name']
except:
device_username = ''
device_friendly_name = ''

View file

@ -1632,21 +1632,20 @@ class PmsConnect(object):
item_main = []
for item in item_main:
item_info = {'section_id': helpers.get_xml_attr(item, 'key'),
'section_type': helpers.get_xml_attr(item, 'type'),
item_info = {'section_id': helpers.get_xml_attr(a, 'librarySectionID'),
'media_type': helpers.get_xml_attr(item, 'type'),
'rating_key': helpers.get_xml_attr(item, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(item, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(item, 'grandparentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(a, 'grandparentRatingKey'),
'title': helpers.get_xml_attr(item, 'title'),
'parent_title': helpers.get_xml_attr(item, 'parentTitle'),
'grandparent_title': helpers.get_xml_attr(item, 'grandparentTitle'),
'parent_title': helpers.get_xml_attr(a, 'parentTitle'),
'grandparent_title': helpers.get_xml_attr(a, 'grandparentTitle'),
'media_index': helpers.get_xml_attr(item, 'index'),
'parent_media_index': helpers.get_xml_attr(item, 'parentIndex'),
'parent_media_index': helpers.get_xml_attr(a, 'parentIndex'),
'year': helpers.get_xml_attr(item, 'year'),
'thumb': helpers.get_xml_attr(item, 'thumb'),
'parent_thumb': helpers.get_xml_attr(item, 'parentThumb'),
'grandparent_thumb': helpers.get_xml_attr(item, 'grandparentThumb'),
'parent_thumb': helpers.get_xml_attr(a, 'thumb'),
'grandparent_thumb': helpers.get_xml_attr(a, 'grandparentThumb'),
'added_at': helpers.get_xml_attr(item, 'addedAt')
}

View file

@ -883,14 +883,11 @@ class WebInterface(object):
@cherrypy.expose
def get_sync(self, machine_id=None, user_id=None, **kwargs):
pms_connect = pmsconnect.PmsConnect()
server_id = pms_connect.get_server_identity()
if not machine_id:
machine_id = plexpy.CONFIG.PMS_IDENTIFIER
plex_tv = plextv.PlexTV()
if not machine_id:
result = plex_tv.get_synced_items(machine_id=server_id['machine_identifier'], user_id=user_id)
else:
result = plex_tv.get_synced_items(machine_id=machine_id, user_id=user_id)
result = plex_tv.get_synced_items(machine_id=machine_id, user_id=user_id)
if result:
output = {"data": result}