mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 17:22:56 -07:00
Add users page
Set 10 results per page as default on Datatables Fix missing metadata bug
This commit is contained in:
parent
fa696adc79
commit
650e0963e2
5 changed files with 241 additions and 7 deletions
|
@ -80,6 +80,105 @@ class WebInterface(object):
|
|||
return serve_template(templatename="history.html", title="History", date_format=date_format,
|
||||
time_format=time_format)
|
||||
|
||||
@cherrypy.expose
|
||||
def users(self):
|
||||
return serve_template(templatename="users.html", title="Users")
|
||||
|
||||
@cherrypy.expose
|
||||
def get_user_list(self, start=0, length=100, **kwargs):
|
||||
start = int(start)
|
||||
length = int(length)
|
||||
filtered = []
|
||||
totalcount = 0
|
||||
search_value = ""
|
||||
search_regex = ""
|
||||
order_column = 1
|
||||
order_dir = "desc"
|
||||
|
||||
if 'order[0][dir]' in kwargs:
|
||||
order_dir = kwargs.get('order[0][dir]', "desc")
|
||||
|
||||
if 'order[0][column]' in kwargs:
|
||||
order_column = kwargs.get('order[0][column]', "1")
|
||||
|
||||
if 'search[value]' in kwargs:
|
||||
search_value = kwargs.get('search[value]', "")
|
||||
|
||||
if 'search[regex]' in kwargs:
|
||||
search_regex = kwargs.get('search[regex]', "")
|
||||
|
||||
sortcolumn = 'user'
|
||||
if order_column == '2':
|
||||
sortcolumn = 'time'
|
||||
elif order_column == '3':
|
||||
sortcolumn = 'ip_address'
|
||||
elif order_column == '4':
|
||||
sortcolumn = 'plays'
|
||||
|
||||
myDB = db.DBConnection()
|
||||
db_table = db.DBConnection().get_history_table_name()
|
||||
|
||||
if search_value == "":
|
||||
query = 'SELECT COUNT(title) as plays, user, time, \
|
||||
SUM(time) as timeTotal, SUM(stopped) as stoppedTotal, \
|
||||
SUM(paused_counter) as paused_counterTotal, platform, \
|
||||
ip_address, xml \
|
||||
from %s GROUP by user ORDER by %s COLLATE NOCASE %s' % (db_table, sortcolumn, order_dir)
|
||||
filtered = myDB.select(query)
|
||||
totalcount = len(filtered)
|
||||
else:
|
||||
query = 'SELECT COUNT(title) as plays, user, time, \
|
||||
SUM(time) as timeTotal, SUM(stopped) as stoppedTotal, \
|
||||
SUM(paused_counter) as paused_counterTotal, platform, \
|
||||
ip_address, xml \
|
||||
from ' + db_table + ' WHERE user LIKE "%' + search_value + '%" \
|
||||
GROUP by user' + ' ORDER by %s COLLATE NOCASE %s' % (sortcolumn, order_dir)
|
||||
filtered = myDB.select(query)
|
||||
totalcount = myDB.select('SELECT COUNT(*) from %s' % db_table)[0][0]
|
||||
|
||||
users = filtered[start:(start + length)]
|
||||
rows = []
|
||||
for item in users:
|
||||
row = {"plays": item['plays'],
|
||||
"time": item['time'],
|
||||
"user": item["user"],
|
||||
"timeTotal": item["timeTotal"],
|
||||
"ip_address": item["ip_address"],
|
||||
"stoppedTotal": item["stoppedTotal"],
|
||||
"paused_counterTotal": item["paused_counterTotal"],
|
||||
"platform": item["platform"]
|
||||
}
|
||||
|
||||
try:
|
||||
xml_parse = minidom.parseString(helpers.latinToAscii(item['xml']))
|
||||
except IOError, e:
|
||||
logger.warn("Error parsing XML in PlexWatch db: %s" % e)
|
||||
|
||||
xml_head = xml_parse.getElementsByTagName('User')
|
||||
if not xml_head:
|
||||
logger.warn("Error parsing XML in PlexWatch db: %s" % e)
|
||||
|
||||
for s in xml_head:
|
||||
if s.getAttribute('thumb'):
|
||||
row['user_thumb'] = s.getAttribute('thumb')
|
||||
else:
|
||||
row['user_thumb'] = ""
|
||||
if s.getAttribute('id'):
|
||||
row['user_id'] = s.getAttribute('id')
|
||||
else:
|
||||
row['user_id'] = ""
|
||||
|
||||
rows.append(row)
|
||||
|
||||
dict = {'recordsFiltered': len(filtered),
|
||||
'recordsTotal': totalcount,
|
||||
'data': rows,
|
||||
}
|
||||
s = json.dumps(dict)
|
||||
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
return s
|
||||
|
||||
@cherrypy.expose
|
||||
def checkGithub(self):
|
||||
from plexpy import versioncheck
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue