Show user active status on Users table

This commit is contained in:
JonnyWong16 2020-04-10 00:02:30 -07:00
commit f366304c50
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 42 additions and 12 deletions

View file

@ -711,7 +711,6 @@ fieldset[disabled] .form-control {
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1); box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
} }
.users-poster-face { .users-poster-face {
overflow: hidden;
float: left; float: left;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
@ -3119,6 +3118,20 @@ div.dataTables_info {
font-weight: bold; font-weight: bold;
border-radius: 2px; border-radius: 2px;
} }
.inactive-library-tooltip,
.inactive-user-tooltip {
display: inline-block;
position: relative;
width: 100%;
height: 100%;
}
.inactive-library-tooltip i.fa,
.inactive-user-tooltip i.fa {
position: absolute;
right: 0;
bottom: 0;
text-shadow: 0 0 2px rgba(0,0,0,.5);
}
.history-thumbnail-popover { .history-thumbnail-popover {
z-index: 2000; z-index: 2000;
padding: 0; padding: 0;
@ -3808,9 +3821,8 @@ a:hover .overlay-refresh-image:hover {
} }
.svg-icon { .svg-icon {
padding: 10px; background-size: calc(100% - 20px) calc(100% - 20px) !important;
background-origin: content-box !important; background-origin: content-box !important;
background-size: contain !important;
background-repeat: no-repeat !important; background-repeat: no-repeat !important;
background-position: center !important; background-position: center !important;
} }

View file

@ -59,10 +59,12 @@ users_list_table_options = {
"targets": [1], "targets": [1],
"data": "user_thumb", "data": "user_thumb",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
var inactive = '';
if (!rowData['is_active']) { inactive = '<span class="inactive-user-tooltip" data-toggle="tooltip" title="User not on Plex server"><i class="fa fa-exclamation-triangle"></i></span>'; }
if (cellData === '') { if (cellData === '') {
$(td).html('<a href="' + page('user', rowData['user_id']) + '"><div class="users-poster-face" style="background-image: url(../../images/gravatar-default-80x80.png);"></div></a>'); $(td).html('<a href="' + page('user', rowData['user_id']) + '"><div class="users-poster-face" style="background-image: url(../../images/gravatar-default-80x80.png);">' + inactive + '</div></a>');
} else { } else {
$(td).html('<a href="' + page('user', rowData['user_id']) + '"><div class="users-poster-face" style="background-image: url(' + rowData['user_thumb'] + ');"></div></a>'); $(td).html('<a href="' + page('user', rowData['user_id']) + '"><div class="users-poster-face" style="background-image: url(' + rowData['user_thumb'] + ');">' + inactive + '</div></a>');
} }
}, },
"orderable": false, "orderable": false,

View file

@ -51,7 +51,13 @@ DOCUMENTATION :: END
<div class="col-md-12"> <div class="col-md-12">
<div class="table-card-back"> <div class="table-card-back">
<div class="user-info-wrapper"> <div class="user-info-wrapper">
<div class="user-info-poster-face" style="background-image: url(${data['user_thumb']});"></div> <div class="user-info-poster-face" style="background-image: url(${data['user_thumb']});">
% if not data['is_active']:
<span class="inactive-user-tooltip" data-toggle="tooltip" title="User not on Plex server">
<i class="fa fa-lg fa-exclamation-triangle"></i>
</span>
% endif
</div>
<div class="user-info-username"> <div class="user-info-username">
<span class="set-username">${data['friendly_name']}</span> <span class="set-username">${data['friendly_name']}</span>
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
@ -540,6 +546,8 @@ DOCUMENTATION :: END
login_log_table.draw(); login_log_table.draw();
}); });
$(".inactive-user-tooltip").tooltip();
% if _session['user_group'] == 'admin': % if _session['user_group'] == 'admin':
$("#edit-user-tooltip").tooltip(); $("#edit-user-tooltip").tooltip();

View file

@ -130,7 +130,8 @@ class Users(object):
'session_history_media_info.transcode_decision', 'session_history_media_info.transcode_decision',
'users.do_notify as do_notify', 'users.do_notify as do_notify',
'users.keep_history as keep_history', 'users.keep_history as keep_history',
'users.allow_guest as allow_guest' 'users.allow_guest as allow_guest',
'users.is_active as is_active'
] ]
try: try:
query = data_tables.ssp_query(table_name='users', query = data_tables.ssp_query(table_name='users',
@ -196,7 +197,8 @@ class Users(object):
'transcode_decision': item['transcode_decision'], 'transcode_decision': item['transcode_decision'],
'do_notify': helpers.checked(item['do_notify']), 'do_notify': helpers.checked(item['do_notify']),
'keep_history': helpers.checked(item['keep_history']), 'keep_history': helpers.checked(item['keep_history']),
'allow_guest': helpers.checked(item['allow_guest']) 'allow_guest': helpers.checked(item['allow_guest']),
'is_active': item['is_active']
} }
rows.append(row) rows.append(row)
@ -337,6 +339,7 @@ class Users(object):
'friendly_name': 'Local', 'friendly_name': 'Local',
'user_thumb': common.DEFAULT_USER_THUMB, 'user_thumb': common.DEFAULT_USER_THUMB,
'email': '', 'email': '',
'is_active': 1,
'is_admin': '', 'is_admin': '',
'is_home_user': 0, 'is_home_user': 0,
'is_allow_sync': 0, 'is_allow_sync': 0,
@ -357,21 +360,24 @@ class Users(object):
try: try:
if str(user_id).isdigit(): if str(user_id).isdigit():
query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \ query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \
'email, is_admin, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, deleted_user, ' \ 'email, is_active, is_admin, is_home_user, is_allow_sync, is_restricted, ' \
'do_notify, keep_history, deleted_user, ' \
'allow_guest, shared_libraries ' \ 'allow_guest, shared_libraries ' \
'FROM users ' \ 'FROM users ' \
'WHERE user_id = ? ' 'WHERE user_id = ? '
result = monitor_db.select(query, args=[user_id]) result = monitor_db.select(query, args=[user_id])
elif user: elif user:
query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \ query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \
'email, is_admin, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, deleted_user, ' \ 'email, is_active, is_admin, is_home_user, is_allow_sync, is_restricted, ' \
'do_notify, keep_history, deleted_user, ' \
'allow_guest, shared_libraries ' \ 'allow_guest, shared_libraries ' \
'FROM users ' \ 'FROM users ' \
'WHERE username = ? COLLATE NOCASE ' 'WHERE username = ? COLLATE NOCASE '
result = monitor_db.select(query, args=[user]) result = monitor_db.select(query, args=[user])
elif email: elif email:
query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \ query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \
'email, is_admin, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, deleted_user, ' \ 'email, is_active, is_admin, is_home_user, is_allow_sync, is_restricted, ' \
'do_notify, keep_history, deleted_user, ' \
'allow_guest, shared_libraries ' \ 'allow_guest, shared_libraries ' \
'FROM users ' \ 'FROM users ' \
'WHERE email = ? COLLATE NOCASE ' 'WHERE email = ? COLLATE NOCASE '
@ -406,6 +412,7 @@ class Users(object):
'friendly_name': friendly_name, 'friendly_name': friendly_name,
'user_thumb': user_thumb, 'user_thumb': user_thumb,
'email': item['email'], 'email': item['email'],
'is_active': item['is_active'],
'is_admin': item['is_admin'], 'is_admin': item['is_admin'],
'is_home_user': item['is_home_user'], 'is_home_user': item['is_home_user'],
'is_allow_sync': item['is_allow_sync'], 'is_allow_sync': item['is_allow_sync'],
@ -613,7 +620,7 @@ class Users(object):
try: try:
query = 'SELECT user_id, username, friendly_name, thumb, custom_avatar_url, email, ' \ query = 'SELECT user_id, username, friendly_name, thumb, custom_avatar_url, email, ' \
'is_admin, is_home_user, is_allow_sync, is_restricted, ' \ 'is_active, is_admin, is_home_user, is_allow_sync, is_restricted, ' \
'do_notify, keep_history, allow_guest, server_token, shared_libraries, ' \ 'do_notify, keep_history, allow_guest, server_token, shared_libraries, ' \
'filter_all, filter_movies, filter_tv, filter_music, filter_photos ' \ 'filter_all, filter_movies, filter_tv, filter_music, filter_photos ' \
'FROM users WHERE deleted_user = 0' 'FROM users WHERE deleted_user = 0'
@ -629,6 +636,7 @@ class Users(object):
'friendly_name': item['friendly_name'] or item['username'], 'friendly_name': item['friendly_name'] or item['username'],
'thumb': item['custom_avatar_url'] or item['thumb'], 'thumb': item['custom_avatar_url'] or item['thumb'],
'email': item['email'], 'email': item['email'],
'is_active': item['is_active'],
'is_admin': item['is_admin'], 'is_admin': item['is_admin'],
'is_home_user': item['is_home_user'], 'is_home_user': item['is_home_user'],
'is_allow_sync': item['is_allow_sync'], 'is_allow_sync': item['is_allow_sync'],