mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 18:47:19 -07:00
Rewrite of the Datatables class, should be a lot more secure now and maybe slightly faster.
Please clear your browser cache after this update.
This commit is contained in:
parent
a439cdb626
commit
76279928bd
10 changed files with 301 additions and 419 deletions
|
@ -28,7 +28,6 @@ from plexpy import helpers
|
|||
<table class="display" id="history_table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="never" align='left' id="id">ID</th>
|
||||
<th class="all" align='left' id="time">Time</th>
|
||||
<th class="all" align='left' id="friendly_name">User</th>
|
||||
<th class="desktop" align='left' id="platform">Platform</th>
|
||||
|
@ -39,12 +38,6 @@ from plexpy import helpers
|
|||
<th class="desktop" align='left' id="stopped">Stopped</th>
|
||||
<th class="desktop" align='left' id="duration">Duration</th>
|
||||
<th class="desktop" align='left' id="percent_complete"></th>
|
||||
<th class="never" align='left' id="grandparent_rating_key">grandparentRatingKey</th>
|
||||
<th class="never" align='left' id="rating_key">RatingKey</th>
|
||||
<th class="never" align='left' id="user"></th>
|
||||
<th class="never" align='left' id="media_type"></th>
|
||||
<th class="never" align='left' id="video_decision"></th>
|
||||
<th class="never" align='left' id="user_id"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -71,7 +64,11 @@ from plexpy import helpers
|
|||
<script>
|
||||
$(document).ready(function() {
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history"
|
||||
"url": "get_history",
|
||||
type: "post",
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ) };
|
||||
}
|
||||
}
|
||||
|
||||
history_table = $('#history_table').DataTable(history_table_options);
|
||||
|
|
|
@ -173,7 +173,6 @@ from plexpy import helpers
|
|||
<table class="display" id="history_table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="never" align='left' id="id">ID</th>
|
||||
<th class="all" align='left' id="time">Time</th>
|
||||
<th class="all" align='left' id="friendly_name">User</th>
|
||||
<th class="desktop" align='left' id="platform">Platform</th>
|
||||
|
@ -184,12 +183,6 @@ from plexpy import helpers
|
|||
<th class="desktop" align='left' id="stopped">Stopped</th>
|
||||
<th class="desktop" align='left' id="duration">Duration</th>
|
||||
<th class="desktop" align='left' id="percent_complete"></th>
|
||||
<th class="never" align='left' id="grandparent_rating_key">grandparentRatingKey</th>
|
||||
<th class="never" align='left' id="rating_key">RatingKey</th>
|
||||
<th class="never" align='left' id="user"></th>
|
||||
<th class="never" align='left' id="media_type"></th>
|
||||
<th class="never" align='left' id="video_decision"></th>
|
||||
<th class="never" align='left' id="user_id"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -246,8 +239,11 @@ from plexpy import helpers
|
|||
$(document).ready(function () {
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history",
|
||||
"data": function(d) {
|
||||
d.rating_key = ${data['rating_key']};
|
||||
type: 'post',
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ),
|
||||
'rating_key': ${data['rating_key']}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,8 +260,11 @@ from plexpy import helpers
|
|||
$(document).ready(function () {
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history",
|
||||
"data": function(d) {
|
||||
d.grandparent_rating_key = ${data['rating_key']};
|
||||
type: 'post',
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ),
|
||||
'grandparent_rating_key': ${data['grandparent_rating_key']}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,17 +28,10 @@ history_table_options = {
|
|||
"processing": false,
|
||||
"serverSide": true,
|
||||
"pageLength": 25,
|
||||
"order": [ 1, 'desc'],
|
||||
"order": [ 0, 'desc'],
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [0],
|
||||
"data":"id",
|
||||
"visible": false,
|
||||
"searchable": false,
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [1],
|
||||
"data":"date",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (rowData['stopped'] === null) {
|
||||
|
@ -52,7 +45,7 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [2],
|
||||
"targets": [1],
|
||||
"data":"friendly_name",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData !== '') {
|
||||
|
@ -68,8 +61,8 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [3],
|
||||
"data":"platform",
|
||||
"targets": [2],
|
||||
"data":"player",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData !== '') {
|
||||
$(td).html('<a href="#info-modal" data-toggle="modal"><span data-toggle="tooltip" data-placement="left" title="Stream Info" id="stream-info"><i class="fa fa-lg fa-info-circle"></i></span></a> '+cellData);
|
||||
|
@ -78,7 +71,7 @@ history_table_options = {
|
|||
"className": "modal-control no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [4],
|
||||
"targets": [3],
|
||||
"data":"ip_address",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if ((cellData == '') || (cellData == '0')) {
|
||||
|
@ -88,9 +81,8 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [5],
|
||||
"targets": [4],
|
||||
"data":"full_title",
|
||||
"name":"full_title",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData !== '') {
|
||||
if (rowData['media_type'] === 'movie' || rowData['media_type'] === 'episode') {
|
||||
|
@ -108,7 +100,7 @@ history_table_options = {
|
|||
}
|
||||
},
|
||||
{
|
||||
"targets": [6],
|
||||
"targets": [5],
|
||||
"data":"started",
|
||||
"render": function ( data, type, full ) {
|
||||
return moment(data, "X").format(time_format);
|
||||
|
@ -117,16 +109,20 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [7],
|
||||
"targets": [6],
|
||||
"data":"paused_counter",
|
||||
"render": function ( data, type, full ) {
|
||||
return Math.round(moment.duration(data, 'seconds').as('minutes')) + ' mins';
|
||||
if (data !== null) {
|
||||
return Math.round(moment.duration(data, 'seconds').as('minutes')) + ' mins';
|
||||
} else {
|
||||
return '0 mins';
|
||||
}
|
||||
},
|
||||
"searchable": false,
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [8],
|
||||
"targets": [7],
|
||||
"data":"stopped",
|
||||
"render": function ( data, type, full ) {
|
||||
if (data !== null) {
|
||||
|
@ -139,7 +135,7 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [9],
|
||||
"targets": [8],
|
||||
"data":"duration",
|
||||
"render": function ( data, type, full ) {
|
||||
if (data !== null) {
|
||||
|
@ -152,15 +148,13 @@ history_table_options = {
|
|||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [10],
|
||||
"targets": [9],
|
||||
"data":"percent_complete",
|
||||
"render": function ( data, type, full ) {
|
||||
if (data > 80) {
|
||||
return '<i class="fa fa-lg fa-circle"></i>'
|
||||
//return '<span class="badge">'+Math.round(data)+'%</span>';
|
||||
} else if (data > 40) {
|
||||
return '<i class="fa fa-lg fa-adjust"></i>'
|
||||
//return '<span class="badge">100%</span>';
|
||||
return '<i class="fa fa-lg fa-adjust fa-rotate-180"></i>'
|
||||
} else {
|
||||
return '<i class="fa fa-lg fa-circle-o"></i>'
|
||||
}
|
||||
|
@ -168,45 +162,7 @@ history_table_options = {
|
|||
"searchable": false,
|
||||
"orderable": true,
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [11],
|
||||
"data":"grandparent_rating_key",
|
||||
"visible": false,
|
||||
"searchable": false
|
||||
},
|
||||
{
|
||||
"targets": [12],
|
||||
"data":"rating_key",
|
||||
"visible": false,
|
||||
"searchable": false
|
||||
},
|
||||
{
|
||||
"targets": [13],
|
||||
"data":"media_type",
|
||||
"searchable":false,
|
||||
"visible":false
|
||||
},
|
||||
{
|
||||
"targets": [14],
|
||||
"data":"user",
|
||||
"searchable":false,
|
||||
"visible":false
|
||||
},
|
||||
{
|
||||
"targets": [15],
|
||||
"data":"video_decision",
|
||||
"searchable":false,
|
||||
"visible":false
|
||||
},
|
||||
{
|
||||
"targets": [16],
|
||||
"data":"user_id",
|
||||
"searchable":false,
|
||||
"visible":false
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
"drawCallback": function (settings) {
|
||||
// Jump to top of page
|
||||
|
|
|
@ -50,7 +50,7 @@ users_list_table_options = {
|
|||
},
|
||||
{
|
||||
"targets": [2],
|
||||
"data": "time",
|
||||
"data": "started",
|
||||
"render": function ( data, type, full ) {
|
||||
return moment(data, "X").fromNow();
|
||||
}
|
||||
|
@ -63,12 +63,6 @@ users_list_table_options = {
|
|||
{
|
||||
"targets": [4],
|
||||
"data": "plays"
|
||||
},
|
||||
{
|
||||
"targets": [5],
|
||||
"data": "user",
|
||||
"searchable": false,
|
||||
"visible": false
|
||||
}
|
||||
|
||||
],
|
||||
|
|
|
@ -182,7 +182,6 @@ from plexpy import helpers
|
|||
<table class="display" id="history_table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="never" align='left' id="id">ID</th>
|
||||
<th class="all" align='left' id="time">Time</th>
|
||||
<th class="never" align='left' id="friendly_name">User</th>
|
||||
<th class="desktop" align='left' id="platform">Platform</th>
|
||||
|
@ -193,12 +192,6 @@ from plexpy import helpers
|
|||
<th class="desktop" align='left' id="stopped">Stopped</th>
|
||||
<th class="desktop" align='left' id="duration">Duration</th>
|
||||
<th class="desktop" align='left' id="percent_complete"></th>
|
||||
<th class="never" align='left' id="grandparent_rating_key">grandparentRatingKey</th>
|
||||
<th class="never" align='left' id="rating_key">RatingKey</th>
|
||||
<th class="never" align='left' id="user"></th>
|
||||
<th class="never" align='left' id="media_type"></th>
|
||||
<th class="never" align='left' id="video_decision"></th>
|
||||
<th class="never" align='left' id="user_id"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -301,9 +294,12 @@ from plexpy import helpers
|
|||
// Build watch history table
|
||||
history_table_options.ajax = {
|
||||
"url": "get_history",
|
||||
"data": function(d) {
|
||||
d.user_id = user_id;
|
||||
d.user = "${data['username']}";
|
||||
type: 'post',
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ),
|
||||
'user_id': user_id,
|
||||
'user': "${data['username']}"
|
||||
};
|
||||
}
|
||||
}
|
||||
history_table = $('#history_table').DataTable(history_table_options);
|
||||
|
@ -314,9 +310,12 @@ from plexpy import helpers
|
|||
// Build user IP table
|
||||
user_ip_table_options.ajax = {
|
||||
"url": "get_user_ips",
|
||||
"data": function(d) {
|
||||
d.user_id = user_id;
|
||||
d.user = "${data['username']}";
|
||||
type: 'post',
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ),
|
||||
'user_id': user_id,
|
||||
'user': "${data['username']}"
|
||||
};
|
||||
}
|
||||
}
|
||||
user_ip_table = $('#user_ip_table').DataTable(user_ip_table_options);
|
||||
|
|
|
@ -37,7 +37,6 @@ from plexpy import helpers
|
|||
<th class="min-tablet" align="left" id="last_seen">Last Seen</th>
|
||||
<th class="min-tablet" align="left" id="last_known_ip">Last Known IP</th>
|
||||
<th class="min-tablet" align="left" id="total_plays">Total Plays</th>
|
||||
<th class="never" align="left" id="user"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -59,7 +58,11 @@ from plexpy import helpers
|
|||
<script src="interfaces/default/js/tables/users.js"></script>
|
||||
<script>
|
||||
users_list_table_options.ajax = {
|
||||
"url": "get_user_list"
|
||||
"url": "get_user_list",
|
||||
type: "post",
|
||||
data: function ( d ) {
|
||||
return { 'json_data': JSON.stringify( d ) };
|
||||
}
|
||||
}
|
||||
|
||||
var users_list_table = $('#users_list_table').DataTable(users_list_table_options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue