diff --git a/data/interfaces/default/graphs.html b/data/interfaces/default/graphs.html index 26378e79..754d96c5 100644 --- a/data/interfaces/default/graphs.html +++ b/data/interfaces/default/graphs.html @@ -51,6 +51,8 @@ +
@@ -121,7 +123,6 @@
- @@ -131,6 +132,34 @@ + diff --git a/data/interfaces/default/history_table_modal.html b/data/interfaces/default/history_table_modal.html new file mode 100644 index 00000000..e5d4f260 --- /dev/null +++ b/data/interfaces/default/history_table_modal.html @@ -0,0 +1,69 @@ +% if data: + + + + + + + + + + + +% else: + +% endif diff --git a/data/interfaces/default/js/graphs/plays_by_day.js b/data/interfaces/default/js/graphs/plays_by_day.js index a147cfc1..e8454d44 100644 --- a/data/interfaces/default/js/graphs/plays_by_day.js +++ b/data/interfaces/default/js/graphs/plays_by_day.js @@ -23,6 +23,18 @@ var hc_plays_by_day_options = { credits: { enabled: false }, + plotOptions: { + series: { + cursor: 'pointer', + point: { + events: { + click: function() { + selectHandler(this.category); + } + } + } + } + }, colors: ['#F9AA03', '#FFFFFF'], xAxis: { type: 'datetime', diff --git a/data/interfaces/default/js/tables/history_table_modal.js b/data/interfaces/default/js/tables/history_table_modal.js new file mode 100644 index 00000000..60bea99a --- /dev/null +++ b/data/interfaces/default/js/tables/history_table_modal.js @@ -0,0 +1,108 @@ +var date_format = 'YYYY-MM-DD'; +var time_format = 'hh:mm a'; + +$.ajax({ + url: 'get_date_formats', + type: 'GET', + success: function(data) { + date_format = data.date_format; + time_format = data.time_format; + } +}); + +history_table_modal_options = { + "destroy": true, + "language": { + "search": "Search: ", + "info":"Showing _START_ to _END_ of _TOTAL_ history items", + "infoEmpty":"Showing 0 to 0 of 0 entries", + "infoFiltered":"", + "emptyTable": "No data in table", + }, + "pagingType": "bootstrap", + "stateSave": false, + "processing": false, + "serverSide": true, + "pageLength": 10, + "lengthChange": false, + "order": [ 0, 'desc'], + "columnDefs": [ + { + "targets": [0], + "data":"started", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData === null) { + $(td).html('Unknown'); + } else { + $(td).html(moment(cellData,"X").format(time_format)); + } + }, + "searchable": false, + "className": "no-wrap", + "width": "5%" + }, + { + "targets": [1], + "data":"stopped", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData === null) { + $(td).html('Unknown'); + } else { + $(td).html(moment(cellData,"X").format(time_format)); + } + }, + "searchable": false, + "className": "no-wrap", + "width": "5%" + }, + { + "targets": [2], + "data":"friendly_name", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + if (rowData['user_id']) { + $(td).html('' + cellData + ''); + } else { + $(td).html('' + cellData + ''); + } + } else { + $(td).html(cellData); + } + }, + "className": "no-wrap hidden-xs" + }, + { + "targets": [3], + "data":"player", + "className": "modal-control no-wrap hidden-sm hidden-xs" + }, + { + "targets": [4], + "data":"full_title", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + if (rowData['media_type'] === 'movie' || rowData['media_type'] === 'episode') { + var transcode_dec = ''; + if (rowData['video_decision'] === 'transcode') { + transcode_dec = ' '; + } + $(td).html('
' + cellData + '
' + transcode_dec + '
'); + } else if (rowData['media_type'] === 'track') { + $(td).html('
' + cellData + '
'); + } else { + $(td).html('' + cellData + ''); + } + } + } + } + ], + "drawCallback": function (settings) { + // Jump to top of page + // $('html,body').scrollTop(0); + $('#ajaxMsg').fadeOut(); + }, + "preDrawCallback": function(settings) { + var msg = "
 Fetching rows...
"; + showMsg(msg, false, false, 0) + } +} \ No newline at end of file diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 7195e6bc..7da23a54 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -524,6 +524,9 @@ class WebInterface(object): if 'grandparent_rating_key' in kwargs: rating_key = kwargs.get('grandparent_rating_key', "") custom_where = [['grandparent_rating_key', rating_key]] + if 'start_date' in kwargs: + start_date = kwargs.get('start_date', "") + custom_where = [['strftime("%Y-%m-%d", datetime(date, "unixepoch", "localtime"))', start_date]] data_factory = datafactory.DataFactory() history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where) @@ -531,6 +534,11 @@ class WebInterface(object): cherrypy.response.headers['Content-type'] = 'application/json' return json.dumps(history) + @cherrypy.expose + def history_table_modal(self, start_date=None, **kwargs): + + return serve_template(templatename="history_table_modal.html", title="History Data", data=start_date) + @cherrypy.expose def shutdown(self): return self.do_state_change('shutdown', 'Shutting Down', 15)