Early implementation of friendly names. This be aware that this writes a new table to your plexWatch database.

Note: To edit friendly name, go to user page and click the pencil icon next to the user name. Currently only works on home stats and user info page.
Adjust some table styling issues.
Fix bug with user IP modal details not showing.
Fix users default list order.
This commit is contained in:
Tim 2015-06-29 01:35:17 +02:00
parent 762199344c
commit e7b305a1d5
11 changed files with 155 additions and 25 deletions

View file

@ -161,9 +161,7 @@ table.display {
table.display thead th {
white-space:nowrap;
padding: 0px 0px 0px 19px;
border-top: 1px solid #2d2d2d;
border-bottom: 1px solid #0e0e0e;
padding: 0px 0px 0px 18px;
cursor: pointer;
color: #999;
background-color: #212121;
@ -180,6 +178,7 @@ table.display thead .sorting_asc,
table.display thead .sorting_desc {
cursor: pointer;
*cursor: hand;
height: 35px;
}
table.display thead .sorting,
table.display thead .sorting_asc,
@ -216,7 +215,7 @@ table.display tr.heading2 td {
}
table.display td {
padding: 5px 0 5px 20px;
padding: 5px 0 5px 5px;
}
table.display td.title {

View file

@ -0,0 +1,56 @@
<%doc>
USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE
For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/
Filename: edit_user.html
Version: 0.1
Variable names: data [list]
data :: Usable parameters
== Global keys ==
user Return the real Plex username
friendly_name Returns the friendly edited Plex username
DOCUMENTATION :: END
</%doc>
% if data is not None:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h3>Edit user <strong>${data['user']}</strong></h3>
</div>
<div class="modal-body" id="modal-text">
<div class="card-back">
<div class="form-group">
<label for="friendly_name">Friendly Name</label>
<input type="text" id="friendly_name" name="friendly_name" value="${data['friendly_name']}" size="30">
<p class="help-block">Replace all occurances of the username with this name.</p>
</div>
</div>
</div>
<div class="modal-footer">
<div>
<input type="button" id="save_user_name" class="btn btn-primary" value="Save">
<span id="edit-user-status-message"></span>
</div>
</div>
<script>
// Set new friendly name
$("#save_user_name").click(function() {
var friendly_name = $("#friendly_name").val();
$.ajax({
url: 'edit_user',
data: {user: '${data['user']}', friendly_name: friendly_name},
cache: false,
async: true,
success: function(data) {
$("#edit-user-status-message").html(data);
$(".set-username").html(friendly_name);
}
});
});
</script>
% endif

View file

@ -31,10 +31,10 @@ from plexpy import helpers
<th class="never" align='left' id="id">ID</th>
<th class="all" align='left' id="time">Time</th>
<th class="all" align='left' id="user">User</th>
<th class="min-tablet" align='left' id="platform">Platform</th>
<th class="desktop" align='left' id="platform">Platform</th>
<th class="desktop" align='left' id="ip_address">IP Address</th>
<th class="min-tablet" align='left' id="title">Title</th>
<th class="desktop" align='left' id="started">Started</th>
<th class="min-tablet" align='left' id="started">Started</th>
<th class="desktop" align='left' id="paused_counter">Paused</th>
<th class="desktop" align='left' id="stopped">Stopped</th>
<th class="desktop" align='left' id="duration">Duration</th>

View file

@ -28,6 +28,7 @@ users_watched Returns the count for the associated stat.
== Only if 'stat_id' is 'top_user' ==
thumb Returns url of the user's gravatar. Returns '' if none exists.
user Returns the username for the associated stat.
friendly_name Returns the friendly name of the user for the associated stat.
== Only if 'stat_id' is 'top_platform' ==
platform_type Returns the platform name for the associated stat.
@ -112,12 +113,11 @@ DOCUMENTATION :: END
<div class="home-platforms-instance-name">
<h4>Most Active User</h4>
<a href="user?user=${a['rows'][0]['user']}">
<h5>${a['rows'][0]['user']}</h5>
<h5>${a['rows'][0]['friendly_name']}</h5>
</a>
</div>
<div class="user-platforms-instance-playcount">
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
</div>
</li>

View file

@ -190,10 +190,10 @@ from plexpy import helpers
<th class="never" align='left' id="id">ID</th>
<th class="all" align='left' id="time">Time</th>
<th class="all" align='left' id="user">User</th>
<th class="min-tablet" align='left' id="platform">Platform</th>
<th class="desktop" align='left' id="platform">Platform</th>
<th class="desktop" align='left' id="ip_address">IP Address</th>
<th class="min-tablet" align='left' id="title">Title</th>
<th class="desktop" align='left' id="started">Started</th>
<th class="min-tablet" align='left' id="started">Started</th>
<th class="desktop" align='left' id="paused_counter">Paused</th>
<th class="desktop" align='left' id="stopped">Stopped</th>
<th class="desktop" align='left' id="duration">Duration</th>

View file

@ -33,7 +33,7 @@ user_ip_table_options = {
"targets": [1],
"data":"ip_address",
"width": "15%",
"className": "modal-control",
"className": "modal-control no-wrap",
"createdCell": function (td, cellData, rowData, row, col) {
if (isPrivateIP(cellData)) {
if (cellData != '') {
@ -45,8 +45,7 @@ user_ip_table_options = {
$(td).html('<a href="#ip-info-modal" data-toggle="modal"><span data-toggle="ip-tooltip" data-placement="left" title="IP Address Info" id="ip-info"><i class="icon-map-marker icon-white"></i></span>&nbsp' + cellData +'</a>');
}
},
"width": "15%",
"className": "no-wrap"
"width": "15%"
},
{
"targets": [2],

View file

@ -14,7 +14,7 @@ users_list_table_options = {
"processing": false,
"serverSide": true,
"pageLength": 10,
"order": [ 0, 'asc'],
"order": [ 1, 'asc'],
"ajax": {
"url": "get_user_list"
},

View file

@ -10,6 +10,7 @@ Variable names: user [string]
user :: Usable parameters
user Returns the name of the user.
friendly_name Returns the friendly name of the user.
DOCUMENTATION :: END
@ -35,7 +36,7 @@ from plexpy import helpers
<img src="interfaces/default/images/gravatar-default-80x80.png">
</div>
<div class="user-info-username">
${user}
<span class="set-username">${friendly_name}</span> <a href="#edit-user-modal" data-toggle="modal" id="toggle-edit-user-modal"><i class="fa fa-pencil"></i></a>
</div>
<div class="user-info-nav">
<ul class="user-info-nav">
@ -47,6 +48,9 @@ from plexpy import helpers
</div>
</div>
</div>
<div id="edit-user-modal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="edit-user-modal" aria-hidden="true">
</div>
</div>
<div class="tab-content">
<div class="tab-pane active" id="profile">
@ -108,7 +112,7 @@ from plexpy import helpers
<div class="span12">
<div class="table-card-back">
<h3>IP Addresses for <strong>
${user}
<span class="set-username">${friendly_name}</span>
</strong></h3>
</div>
<div class="table-card-back">
@ -164,7 +168,7 @@ from plexpy import helpers
<div class="span12">
<div class="table-card-back">
<h3>Watch History for <strong>
${user}
<span class="set-username">${friendly_name}</span>
</strong></h3>
</div>
<div class="table-card-back">
@ -272,6 +276,19 @@ from plexpy import helpers
}
}
});
// Load edit user modal
$("#toggle-edit-user-modal").click(function() {
$.ajax({
url: 'edit_user',
data: {user: '${user}'},
cache: false,
async: true,
complete: function(xhr, status) {
$("#edit-user-modal").html(xhr.responseText);
}
});
});
});