Add IP address to current activity

This commit is contained in:
Jonathan Wong 2015-11-10 19:28:14 -08:00
parent 0c33e7492a
commit fd9cf7017b
4 changed files with 34 additions and 1 deletions

View file

@ -688,6 +688,14 @@ a:hover .dashboard-activity-poster {
white-space: nowrap; white-space: nowrap;
width: 150px; width: 150px;
} }
.dashboard-activity-poster-info-ip-address {
position: absolute;
bottom: 5px;
left: 10px;
text-align: left;
font-size: 12px;
color: #eee;
}
.dashboard-activity-poster-info-time { .dashboard-activity-poster-info-time {
position: absolute; position: absolute;
bottom: 5px; bottom: 5px;

View file

@ -191,6 +191,9 @@ DOCUMENTATION :: END
</div> </div>
% if a['media_type'] != 'photo': % if a['media_type'] != 'photo':
<div class="dashboard-activity-poster-info-bar"> <div class="dashboard-activity-poster-info-bar">
<div class="dashboard-activity-poster-info-ip-address">
<span>IP: ${a['ip_address']}</span>
</div>
<div class="dashboard-activity-poster-info-time"> <div class="dashboard-activity-poster-info-time">
<span class="progress_time">${a['view_offset']}</span>/<span class="progress_time">${a['duration']}</span> <span class="progress_time">${a['view_offset']}</span>/<span class="progress_time">${a['duration']}</span>
</div> </div>

View file

@ -999,3 +999,20 @@ class DataFactory(object):
return 'No updated rating key needed in database. No changes were made.' return 'No updated rating key needed in database. No changes were made.'
# for debugging # for debugging
#return mapping #return mapping
def get_session_ip(self, session_key=''):
monitor_db = database.MonitorDatabase()
if session_key:
query = 'SELECT CASE WHEN ip_address IS NULL THEN "N/A" ELSE ip_address END ' \
'FROM sessions WHERE session_key = %d' % int(session_key)
result = monitor_db.select(query)
else:
return None
ip_address = 'N/A'
for item in result:
ip_address = item[0]
return ip_address

View file

@ -715,6 +715,11 @@ class WebInterface(object):
return serve_template(templatename="current_activity.html", data=None) return serve_template(templatename="current_activity.html", data=None)
if result: if result:
data_factory = datafactory.DataFactory()
for session in result['sessions']:
ip_address = data_factory.get_session_ip(session['session_key'])
session['ip_address'] = ip_address
return serve_template(templatename="current_activity.html", data=result) return serve_template(templatename="current_activity.html", data=result)
else: else:
logger.warn('Unable to retrieve data.') logger.warn('Unable to retrieve data.')