Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library Media Stats #2186

Open
wants to merge 12 commits into
base: nightly
Choose a base branch
from
18 changes: 18 additions & 0 deletions data/interfaces/default/css/tautulli.css
Original file line number Diff line number Diff line change
Expand Up @@ -2940,6 +2940,12 @@ a .home-platforms-list-cover-face:hover
max-width: 1750px;
display: flow-root;
}
.table-card-header.spaced {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-content: center;
}
.table-card-back td {
font-size: 12px;
}
Expand All @@ -2951,6 +2957,18 @@ a .home-platforms-list-cover-face:hover
font-weight: bold;
line-height: 34px;
}
.info-bar {
display: inline;
}
.info-element {
display: inline-block;
border-radius: 1rem;
border: 0.2rem solid #242424;
padding: 0.7rem;
background-color: #3B3B3B;
font-style: italic;
color: #676767;
}
.button-bar {
float: right;
}
Expand Down
24 changes: 24 additions & 0 deletions data/interfaces/default/js/tables/libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ libraries_list_table_options = {
"searchable": false,
"width": "10%",
"className": "no-wrap"
},
{
"targets": [11],
"data": "total_storage",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== null && cellData !== '') {
$(td).html(humanFileSize(cellData));
}
},
"searchable": false,
"width": "10%",
"className": "no-wrap"
},
{
"targets": [12],
"data": "total_duration",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== null && cellData !== '') {
$(td).html(humanDuration(cellData));
}
},
"searchable": false,
"width": "10%",
"className": "no-wrap"
}

],
Expand Down
19 changes: 18 additions & 1 deletion data/interfaces/default/js/tables/media_info_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ media_info_table_options = {
},
{
"targets": [10],
"data": "duration",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== null && cellData !== '' && cellData !== 0) {
$(td).html(humanDuration(cellData));
} else {
if (rowData['section_type'] != 'photo' && get_file_sizes != null) {
get_file_sizes = true;
}
}
},
"width": "7%",
"className": "no-wrap",
"searchable": false
},
{
"targets": [11],
"data": "last_played",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== null && cellData !== '') {
Expand All @@ -236,7 +252,7 @@ media_info_table_options = {
"searchable": false
},
{
"targets": [11],
"targets": [12],
"data": "play_count",
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== null && cellData !== '') {
Expand Down Expand Up @@ -457,6 +473,7 @@ function childTableFormatMedia(rowData) {
'<th align="left" id="audio_codec">Audio Codec</th>' +
'<th align="left" id="audio_channels">Audio Channels</th>' +
'<th align="left" id="file_size">File Size</th>' +
'<th align="left" id="duration">Duration</th>' +
'<th align="left" id="last_played">Last Played</th>' +
'<th align="left" id="total_plays">Total Plays</th>' +
'</tr>' +
Expand Down
2 changes: 2 additions & 0 deletions data/interfaces/default/libraries.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<th align="left" id="last_played">Last Played</th>
<th align="left" id="total_plays">Total Plays</th>
<th align="left" id="total_duration">Total Played Duration</th>
<th align="left" id="total_storage">Total Storage</th>
<th align="left" id="total_runtime">Total Runtime</th>
</tr>
</thead>
<tbody>
Expand Down
28 changes: 27 additions & 1 deletion data/interfaces/default/library.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,22 @@
You may leave this page and check back later.
</div>
% endif
<div class='table-card-header'>
<div class='table-card-header spaced'>
<div class="header-bar">
<span>
<i class="fa fa-info-circle"></i> Media Info for <strong>
<span class="set-username">${data['section_name']}</span>
</strong>
</span>
</div>
<div class="info-bar">
<div class="info-element">
<span>Total File Size: <strong><span id="info-element-total-storage" /></strong></span>
</div>
<div class="info-element">
<span>Total Media Runtime: <strong><span id="info-element-total-runtime" /></strong></span>
</div>
</div>
<div class="button-bar">
% if _session['user_group'] == 'admin':
<div class="btn-group">
Expand Down Expand Up @@ -310,6 +318,7 @@
<th align="left" id="audio_codec">Audio Codec</th>
<th align="left" id="audio_channels">Audio Channels</th>
<th align="left" id="file_size">File Size</th>
<th align="left" id="duration">Duration</th>
<th align="left" id="last_played">Last Played</th>
<th align="left" id="total_plays">Total Plays</th>
</tr>
Expand Down Expand Up @@ -852,6 +861,22 @@ <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
clearSearchButton('media_info_table-SID-${data["section_id"]}', media_info_table);
}

$(document).ready(function () {
loadLibraryMediaStats();
});

function loadLibraryMediaStats(refresh) {
// Populate media stats
$.ajax({
url: 'get_library_media_stats',
data: { section_id: section_id, refresh: refresh },
complete: function(xhr, status) {
$("#info-element-total-runtime").html(humanDuration(xhr.responseJSON.total_duration));
$("#info-element-total-storage").html(humanFileSize(xhr.responseJSON.total_storage));
}
});
}

$('#nav-tabs-mediainfo').on('shown.bs.tab', function() {
if (typeof(media_info_table) === 'undefined') {
loadMediaInfoTable();
Expand All @@ -863,6 +888,7 @@ <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
refresh_table = true;
refresh_child_tables = true;
media_info_table.draw();
loadLibraryMediaStats(true);
refresh_table = false;
});

Expand Down