mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 06:13:25 -07:00
Add show/hide user toggle to database
This commit is contained in:
parent
fcc4575a86
commit
e0f395f2ed
4 changed files with 63 additions and 39 deletions
|
@ -24,9 +24,9 @@ users_list_table_options = {
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
$(td).html('<div class="edit-user-toggles"><button class="btn btn-xs btn-warning" data-id="' + rowData['user_id'] + '" data-toggle="button"><i class="fa fa-eraser fa-fw"></i> Purge</button>   ' +
|
$(td).html('<div class="edit-user-toggles"><button class="btn btn-xs btn-warning" data-id="' + rowData['user_id'] + '" data-toggle="button"><i class="fa fa-eraser fa-fw"></i> Purge</button>   ' +
|
||||||
'<input type="checkbox" id="do_notify-' + rowData['user_id'] + '" name="do_notify" value="1" ' + rowData['do_notify'] + '><label class="edit-tooltip" for="do_notify-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle Notifications"><i class="fa fa-bell fa-lg fa-fw"></i></label> ' +
|
'<input type="checkbox" id="do_notify-' + rowData['user_id'] + '" name="do_notify" value="1" ' + rowData['do_notify'] + '><label class="edit-tooltip" for="do_notify-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle Notifications"><i class="fa fa-bell fa-lg fa-fw"></i></label> ' +
|
||||||
'<input type="checkbox" id="keep_history-' + rowData['user_id'] + '" name="keep_history" value="1" ' + rowData['keep_history'] + '><label class="edit-tooltip" for="keep_history-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle History"><i class="fa fa-history fa-lg fa-fw"></i></label> ');
|
'<input type="checkbox" id="keep_history-' + rowData['user_id'] + '" name="keep_history" value="1" ' + rowData['keep_history'] + '><label class="edit-tooltip" for="keep_history-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle History"><i class="fa fa-history fa-lg fa-fw"></i></label> ' +
|
||||||
// Show/hide user currently doesn't work
|
// Show/hide user currently doesn't work
|
||||||
//'<input type="checkbox" id="show_hide-' + rowData['user_id'] + '" name="show_hide" value="1" checked><label class="edit-tooltip" for="show_hide-' + rowData['user_id'] + '" data-toggle="tooltip" title="Show/Hide User"><i class="fa fa-eye fa-lg fa-fw"></i></label>');
|
'<input type="checkbox" id="show_user-' + rowData['user_id'] + '" name="show_user" value="1" ' + rowData['show_user'] + '><label class="edit-tooltip" for="show_user-' + rowData['user_id'] + '" data-toggle="tooltip" title="Show/Hide User"><i class="fa fa-eye fa-lg fa-fw"></i></label>');
|
||||||
},
|
},
|
||||||
"width": "7%",
|
"width": "7%",
|
||||||
"className": "edit-control no-wrap hidden",
|
"className": "edit-control no-wrap hidden",
|
||||||
|
@ -246,12 +246,16 @@ $('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > inpu
|
||||||
|
|
||||||
var do_notify = 0;
|
var do_notify = 0;
|
||||||
var keep_history = 0;
|
var keep_history = 0;
|
||||||
|
var show_user = 0;
|
||||||
if ($('#do_notify-' + rowData['user_id']).is(':checked')) {
|
if ($('#do_notify-' + rowData['user_id']).is(':checked')) {
|
||||||
do_notify = 1;
|
do_notify = 1;
|
||||||
}
|
}
|
||||||
if ($('#keep_history-' + rowData['user_id']).is(':checked')) {
|
if ($('#keep_history-' + rowData['user_id']).is(':checked')) {
|
||||||
keep_history = 1;
|
keep_history = 1;
|
||||||
}
|
}
|
||||||
|
if ($('#show_user-' + rowData['user_id']).is(':checked')) {
|
||||||
|
show_user = 1;
|
||||||
|
}
|
||||||
|
|
||||||
friendly_name = tr.find('td.edit-user-control > .edit-user-name > input').val();
|
friendly_name = tr.find('td.edit-user-control > .edit-user-name > input').val();
|
||||||
|
|
||||||
|
@ -262,6 +266,7 @@ $('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > inpu
|
||||||
friendly_name: friendly_name,
|
friendly_name: friendly_name,
|
||||||
do_notify: do_notify,
|
do_notify: do_notify,
|
||||||
keep_history: keep_history,
|
keep_history: keep_history,
|
||||||
|
show_user: show_user,
|
||||||
thumb: rowData['user_thumb']
|
thumb: rowData['user_thumb']
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
|
|
|
@ -388,7 +388,15 @@ def dbcheck():
|
||||||
'user_id INTEGER DEFAULT NULL UNIQUE, username TEXT NOT NULL UNIQUE, '
|
'user_id INTEGER DEFAULT NULL UNIQUE, username TEXT NOT NULL UNIQUE, '
|
||||||
'friendly_name TEXT, thumb TEXT, email TEXT, is_home_user INTEGER DEFAULT NULL, '
|
'friendly_name TEXT, thumb TEXT, email TEXT, is_home_user INTEGER DEFAULT NULL, '
|
||||||
'is_allow_sync INTEGER DEFAULT NULL, is_restricted INTEGER DEFAULT NULL, do_notify INTEGER DEFAULT 1, '
|
'is_allow_sync INTEGER DEFAULT NULL, is_restricted INTEGER DEFAULT NULL, do_notify INTEGER DEFAULT 1, '
|
||||||
'keep_history INTEGER DEFAULT 1, custom_avatar_url TEXT)'
|
'keep_history INTEGER DEFAULT 1, custom_avatar_url TEXT, show_user INTEGER DEFAULT 1)'
|
||||||
|
)
|
||||||
|
|
||||||
|
# notify_log table :: This is a table which logs notifications sent
|
||||||
|
c_db.execute(
|
||||||
|
'CREATE TABLE IF NOT EXISTS notify_log (id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||||
|
'session_key INTEGER, rating_key INTEGER, user_id INTEGER, user TEXT, '
|
||||||
|
'agent_id INTEGER, agent_name TEXT, on_play INTEGER, on_stop INTEGER, on_watched INTEGER, '
|
||||||
|
'on_pause INTEGER, on_resume INTEGER, on_buffer INTEGER)'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upgrade sessions table from earlier versions
|
# Upgrade sessions table from earlier versions
|
||||||
|
@ -517,6 +525,18 @@ def dbcheck():
|
||||||
'ALTER TABLE sessions ADD COLUMN transcode_height INTEGER'
|
'ALTER TABLE sessions ADD COLUMN transcode_height INTEGER'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Upgrade sessions table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT buffer_count from sessions')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table sessions.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN buffer_count INTEGER DEFAULT 0'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN buffer_last_triggered INTEGER'
|
||||||
|
)
|
||||||
|
|
||||||
# Upgrade session_history_metadata table from earlier versions
|
# Upgrade session_history_metadata table from earlier versions
|
||||||
try:
|
try:
|
||||||
c_db.execute('SELECT full_title from session_history_metadata')
|
c_db.execute('SELECT full_title from session_history_metadata')
|
||||||
|
@ -535,14 +555,6 @@ def dbcheck():
|
||||||
'ALTER TABLE session_history_metadata ADD COLUMN tagline TEXT'
|
'ALTER TABLE session_history_metadata ADD COLUMN tagline TEXT'
|
||||||
)
|
)
|
||||||
|
|
||||||
# notify_log table :: This is a table which logs notifications sent
|
|
||||||
c_db.execute(
|
|
||||||
'CREATE TABLE IF NOT EXISTS notify_log (id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
|
||||||
'session_key INTEGER, rating_key INTEGER, user_id INTEGER, user TEXT, '
|
|
||||||
'agent_id INTEGER, agent_name TEXT, on_play INTEGER, on_stop INTEGER, on_watched INTEGER, '
|
|
||||||
'on_pause INTEGER, on_resume INTEGER, on_buffer INTEGER)'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Upgrade users table from earlier versions
|
# Upgrade users table from earlier versions
|
||||||
try:
|
try:
|
||||||
c_db.execute('SELECT do_notify from users')
|
c_db.execute('SELECT do_notify from users')
|
||||||
|
@ -561,6 +573,24 @@ def dbcheck():
|
||||||
'ALTER TABLE users ADD COLUMN keep_history INTEGER DEFAULT 1'
|
'ALTER TABLE users ADD COLUMN keep_history INTEGER DEFAULT 1'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Upgrade users table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT custom_avatar_url from users')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table users.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE users ADD COLUMN custom_avatar_url TEXT'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Upgrade users table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT show_user from users')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table users.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE users ADD COLUMN show_user INTEGER DEFAULT 1'
|
||||||
|
)
|
||||||
|
|
||||||
# Upgrade notify_log table from earlier versions
|
# Upgrade notify_log table from earlier versions
|
||||||
try:
|
try:
|
||||||
c_db.execute('SELECT on_pause from notify_log')
|
c_db.execute('SELECT on_pause from notify_log')
|
||||||
|
@ -576,27 +606,6 @@ def dbcheck():
|
||||||
'ALTER TABLE notify_log ADD COLUMN on_buffer INTEGER'
|
'ALTER TABLE notify_log ADD COLUMN on_buffer INTEGER'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upgrade sessions table from earlier versions
|
|
||||||
try:
|
|
||||||
c_db.execute('SELECT buffer_count from sessions')
|
|
||||||
except sqlite3.OperationalError:
|
|
||||||
logger.debug(u"Altering database. Updating database table sessions.")
|
|
||||||
c_db.execute(
|
|
||||||
'ALTER TABLE sessions ADD COLUMN buffer_count INTEGER DEFAULT 0'
|
|
||||||
)
|
|
||||||
c_db.execute(
|
|
||||||
'ALTER TABLE sessions ADD COLUMN buffer_last_triggered INTEGER'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Upgrade users table from earlier versions
|
|
||||||
try:
|
|
||||||
c_db.execute('SELECT custom_avatar_url from users')
|
|
||||||
except sqlite3.OperationalError:
|
|
||||||
logger.debug(u"Altering database. Updating database table users.")
|
|
||||||
c_db.execute(
|
|
||||||
'ALTER TABLE users ADD COLUMN custom_avatar_url TEXT'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add "Local" user to database as default unauthenticated user.
|
# Add "Local" user to database as default unauthenticated user.
|
||||||
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
|
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
|
||||||
if not result.fetchone():
|
if not result.fetchone():
|
||||||
|
|
|
@ -42,7 +42,8 @@ class Users(object):
|
||||||
'session_history_media_info.video_decision',
|
'session_history_media_info.video_decision',
|
||||||
'users.username as user',
|
'users.username as user',
|
||||||
'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.show_user as show_user'
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
query = data_tables.ssp_query(table_name='users',
|
query = data_tables.ssp_query(table_name='users',
|
||||||
|
@ -98,7 +99,8 @@ class Users(object):
|
||||||
"user": item["user"],
|
"user": item["user"],
|
||||||
"user_id": item['user_id'],
|
"user_id": item['user_id'],
|
||||||
"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']),
|
||||||
|
"show_user": helpers.checked(item['show_user'])
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
@ -193,7 +195,7 @@ class Users(object):
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
# TODO: The getter and setter for this needs to become a config getter/setter for more than just friendlyname
|
# TODO: The getter and setter for this needs to become a config getter/setter for more than just friendlyname
|
||||||
def set_user_friendly_name(self, user=None, user_id=None, friendly_name=None, do_notify=0, keep_history=1):
|
def set_user_friendly_name(self, user=None, user_id=None, friendly_name=None, do_notify=0, keep_history=1, show_user=1):
|
||||||
if user_id:
|
if user_id:
|
||||||
if friendly_name.strip() == '':
|
if friendly_name.strip() == '':
|
||||||
friendly_name = None
|
friendly_name = None
|
||||||
|
@ -203,7 +205,8 @@ class Users(object):
|
||||||
control_value_dict = {"user_id": user_id}
|
control_value_dict = {"user_id": user_id}
|
||||||
new_value_dict = {"friendly_name": friendly_name,
|
new_value_dict = {"friendly_name": friendly_name,
|
||||||
"do_notify": do_notify,
|
"do_notify": do_notify,
|
||||||
"keep_history": keep_history}
|
"keep_history": keep_history,
|
||||||
|
"show_user": show_user}
|
||||||
try:
|
try:
|
||||||
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -217,7 +220,8 @@ class Users(object):
|
||||||
control_value_dict = {"username": user}
|
control_value_dict = {"username": user}
|
||||||
new_value_dict = {"friendly_name": friendly_name,
|
new_value_dict = {"friendly_name": friendly_name,
|
||||||
"do_notify": do_notify,
|
"do_notify": do_notify,
|
||||||
"keep_history": keep_history}
|
"keep_history": keep_history,
|
||||||
|
"show_user": show_user}
|
||||||
try:
|
try:
|
||||||
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -194,6 +194,10 @@ class WebInterface(object):
|
||||||
keep_history = kwargs.get('keep_history')
|
keep_history = kwargs.get('keep_history')
|
||||||
else:
|
else:
|
||||||
keep_history = 0
|
keep_history = 0
|
||||||
|
if 'show_user' in kwargs:
|
||||||
|
show_user = kwargs.get('show_user')
|
||||||
|
else:
|
||||||
|
show_user = 0
|
||||||
if 'thumb' in kwargs:
|
if 'thumb' in kwargs:
|
||||||
custom_avatar = kwargs['thumb']
|
custom_avatar = kwargs['thumb']
|
||||||
else:
|
else:
|
||||||
|
@ -205,7 +209,8 @@ class WebInterface(object):
|
||||||
user_data.set_user_friendly_name(user_id=user_id,
|
user_data.set_user_friendly_name(user_id=user_id,
|
||||||
friendly_name=friendly_name,
|
friendly_name=friendly_name,
|
||||||
do_notify=do_notify,
|
do_notify=do_notify,
|
||||||
keep_history=keep_history)
|
keep_history=keep_history,
|
||||||
|
show_user=show_user)
|
||||||
user_data.set_user_profile_url(user_id=user_id,
|
user_data.set_user_profile_url(user_id=user_id,
|
||||||
profile_url=custom_avatar)
|
profile_url=custom_avatar)
|
||||||
|
|
||||||
|
@ -219,7 +224,8 @@ class WebInterface(object):
|
||||||
user_data.set_user_friendly_name(user=user,
|
user_data.set_user_friendly_name(user=user,
|
||||||
friendly_name=friendly_name,
|
friendly_name=friendly_name,
|
||||||
do_notify=do_notify,
|
do_notify=do_notify,
|
||||||
keep_history=keep_history)
|
keep_history=keep_history,
|
||||||
|
show_user=show_user)
|
||||||
user_data.set_user_profile_url(user=user,
|
user_data.set_user_profile_url(user=user,
|
||||||
profile_url=custom_avatar)
|
profile_url=custom_avatar)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue