Rename history id to row_id

This commit is contained in:
JonnyWong16 2020-04-10 12:56:50 -07:00
parent c979e78802
commit 377a23478e
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 18 additions and 18 deletions

View file

@ -36,10 +36,10 @@ history_table_options = {
"targets": [0], "targets": [0],
"data": null, "data": null,
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
if (rowData['id'] === null) { if (rowData['row_id'] === null) {
$(td).html(''); $(td).html('');
} else { } else {
$(td).html('<button class="btn btn-xs btn-warning" data-id="' + rowData['id'] + '"><i class="fa fa-trash-o fa-fw"></i> Delete</button>'); $(td).html('<button class="btn btn-xs btn-warning" data-id="' + rowData['row_id'] + '"><i class="fa fa-trash-o fa-fw"></i> Delete</button>');
} }
}, },
"width": "5%", "width": "5%",
@ -317,19 +317,19 @@ history_table_options = {
"rowCallback": function (row, rowData, rowIndex) { "rowCallback": function (row, rowData, rowIndex) {
if (rowData['group_count'] == 1) { if (rowData['group_count'] == 1) {
// if no grouped rows simply toggle the delete button // if no grouped rows simply toggle the delete button
if ($.inArray(rowData['id'], history_to_delete) !== -1) { if ($.inArray(rowData['row_id'], history_to_delete) !== -1) {
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger'); $(row).find('button[data-id="' + rowData['row_id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
} }
} else if (rowData['id'] !== null) { } else if (rowData['row_id'] !== null) {
// if grouped rows // if grouped rows
// toggle the parent button to danger // toggle the parent button to danger
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger'); $(row).find('button[data-id="' + rowData['row_id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
// check if any child rows are not selected // check if any child rows are not selected
var group_ids = rowData['group_ids'].split(',').map(Number); var group_ids = rowData['group_ids'].split(',').map(Number);
group_ids.forEach(function (id) { group_ids.forEach(function (id) {
var index = $.inArray(id, history_to_delete); var index = $.inArray(id, history_to_delete);
if (index == -1) { if (index == -1) {
$(row).find('button[data-id="' + rowData['id'] + '"]').addClass('btn-warning').removeClass('btn-danger'); $(row).find('button[data-id="' + rowData['row_id'] + '"]').addClass('btn-warning').removeClass('btn-danger');
} }
}); });
} }
@ -353,7 +353,7 @@ $('.history_table').on('click', '> tbody > tr > td.modal-control', function () {
var rowData = row.data(); var rowData = row.data();
$.get('get_stream_data', { $.get('get_stream_data', {
row_id: rowData['id'], row_id: rowData['row_id'],
session_key: rowData['session_key'], session_key: rowData['session_key'],
user: rowData['friendly_name'] user: rowData['friendly_name']
}).then(function (jqXHR) { }).then(function (jqXHR) {
@ -382,9 +382,9 @@ $('.history_table').on('click', '> tbody > tr > td.delete-control > button', fun
if (rowData['group_count'] == 1) { if (rowData['group_count'] == 1) {
// if no grouped rows simply add or remove row from history_to_delete // if no grouped rows simply add or remove row from history_to_delete
var index = $.inArray(rowData['id'], history_to_delete); var index = $.inArray(rowData['row_id'], history_to_delete);
if (index === -1) { if (index === -1) {
history_to_delete.push(rowData['id']); history_to_delete.push(rowData['row_id']);
} else { } else {
history_to_delete.splice(index, 1); history_to_delete.splice(index, 1);
} }
@ -549,7 +549,7 @@ function createChildTable(row, rowData) {
var childRowData = childRow.data(); var childRowData = childRow.data();
$.get('get_stream_data', { $.get('get_stream_data', {
row_id: childRowData['id'], row_id: childRowData['row_id'],
user: childRowData['friendly_name'] user: childRowData['friendly_name']
}).then(function (jqXHR) { }).then(function (jqXHR) {
$("#info-modal").html(jqXHR); $("#info-modal").html(jqXHR);
@ -576,9 +576,9 @@ function createChildTable(row, rowData) {
var childRowData = childRow.data(); var childRowData = childRow.data();
// add or remove row from history_to_delete // add or remove row from history_to_delete
var index = $.inArray(childRowData['id'], history_to_delete); var index = $.inArray(childRowData['row_id'], history_to_delete);
if (index === -1) { if (index === -1) {
history_to_delete.push(childRowData['id']); history_to_delete.push(childRowData['row_id']);
} else { } else {
history_to_delete.splice(index, 1); history_to_delete.splice(index, 1);
} }

View file

@ -169,7 +169,7 @@ $('.history_table').on('click', 'td.modal-control', function () {
function showStreamDetails() { function showStreamDetails() {
$.ajax({ $.ajax({
url: 'get_stream_data', url: 'get_stream_data',
data: { row_id: rowData['id'], user: rowData['friendly_name'] }, data: { row_id: rowData['row_id'], user: rowData['friendly_name'] },
cache: false, cache: false,
async: true, async: true,
complete: function (xhr, status) { complete: function (xhr, status) {

View file

@ -64,7 +64,7 @@ class DataFactory(object):
columns = [ columns = [
'session_history.reference_id', 'session_history.reference_id',
'session_history.id', 'session_history.id AS row_id',
'MAX(started) AS date', 'MAX(started) AS date',
'MIN(started) AS started', 'MIN(started) AS started',
'MAX(stopped) AS stopped', 'MAX(stopped) AS stopped',
@ -116,7 +116,7 @@ class DataFactory(object):
columns_union = [ columns_union = [
'NULL AS reference_id', 'NULL AS reference_id',
'NULL AS id', 'NULL AS row_id',
'started AS date', 'started AS date',
'started', 'started',
'stopped', 'stopped',
@ -228,7 +228,7 @@ class DataFactory(object):
platform = common.PLATFORM_NAME_OVERRIDES.get(item['platform'], item['platform']) platform = common.PLATFORM_NAME_OVERRIDES.get(item['platform'], item['platform'])
row = {'reference_id': item['reference_id'], row = {'reference_id': item['reference_id'],
'id': item['id'], 'row_id': item['row_id'],
'date': item['date'], 'date': item['date'],
'started': item['started'], 'started': item['started'],
'stopped': item['stopped'], 'stopped': item['stopped'],

View file

@ -1663,7 +1663,6 @@ class WebInterface(object):
"group_count": 1, "group_count": 1,
"group_ids": "1124", "group_ids": "1124",
"guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en", "guid": "com.plexapp.agents.thetvdb://121361/6/1?lang=en",
"id": 1124,
"ip_address": "xxx.xxx.xxx.xxx", "ip_address": "xxx.xxx.xxx.xxx",
"live": 0, "live": 0,
"media_index": 17, "media_index": 17,
@ -1679,6 +1678,7 @@ class WebInterface(object):
"player": "Castle-PC", "player": "Castle-PC",
"rating_key": 4348, "rating_key": 4348,
"reference_id": 1123, "reference_id": 1123,
"row_id": 1124,
"session_key": null, "session_key": null,
"started": 1462688107, "started": 1462688107,
"state": null, "state": null,