Add nick-history functionality
hover a nickname to show previous nicks
This commit is contained in:
parent
6366d3ebb1
commit
22f6402bce
|
@ -70,6 +70,7 @@ class Client(object):
|
||||||
# public
|
# public
|
||||||
self.identifier = identifier
|
self.identifier = identifier
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
|
self.nick_history = set()
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.onlinetime = datetime.timedelta()
|
self.onlinetime = datetime.timedelta()
|
||||||
self.kicks = 0
|
self.kicks = 0
|
||||||
|
|
|
@ -143,7 +143,11 @@ def _parse_details(log_path, ident_map=None, clients=None, online_dc=True):
|
||||||
continue
|
continue
|
||||||
nick, clid = match.group('nick'), match.group('clid')
|
nick, clid = match.group('nick'), match.group('clid')
|
||||||
client = clients.setdefault(clid, Client(clid, nick))
|
client = clients.setdefault(clid, Client(clid, nick))
|
||||||
client.nick = nick # set nick to display changes
|
# set current nick
|
||||||
|
client.nick = nick
|
||||||
|
# add nick to history
|
||||||
|
client.nick_history.add(nick)
|
||||||
|
|
||||||
action = match.group('action')
|
action = match.group('action')
|
||||||
if action == 'connected':
|
if action == 'connected':
|
||||||
client.connect(logdatetime)
|
client.connect(logdatetime)
|
||||||
|
|
|
@ -20,7 +20,7 @@ def prepare_clients(clients, onlinetime_threshold=-1):
|
||||||
'''
|
'''
|
||||||
Prepare `clients` for rendering
|
Prepare `clients` for rendering
|
||||||
|
|
||||||
sort them and convert onlinetime to string
|
sort them, clean their nick-history and convert onlinetime to string
|
||||||
|
|
||||||
:param clients: List of clients to prepare
|
:param clients: List of clients to prepare
|
||||||
:param onlinetime_threshold: threshold for clients onlinetime
|
:param onlinetime_threshold: threshold for clients onlinetime
|
||||||
|
@ -31,6 +31,12 @@ def prepare_clients(clients, onlinetime_threshold=-1):
|
||||||
:return: `clients` sorted by onlinetime, kics, pkicks, bans and pbans
|
:return: `clients` sorted by onlinetime, kics, pkicks, bans and pbans
|
||||||
:rtype: tsstats.template.SortedClients
|
:rtype: tsstats.template.SortedClients
|
||||||
'''
|
'''
|
||||||
|
# drop current nick from nick-history
|
||||||
|
[
|
||||||
|
c.nick_history.remove(c.nick)
|
||||||
|
for c in clients
|
||||||
|
if c.nick in c.nick_history
|
||||||
|
]
|
||||||
# sort by onlinetime
|
# sort by onlinetime
|
||||||
onlinetime_ = sort_clients(
|
onlinetime_ = sort_clients(
|
||||||
clients, lambda c: c.onlinetime.total_seconds()
|
clients, lambda c: c.onlinetime.total_seconds()
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{% for client, value in clients %}
|
{% for client, value in clients %}
|
||||||
{% set id = [headline_id, client.nick|striptags]|join('.') %}
|
{% set id = [headline_id, client.nick|striptags]|join('.') %}
|
||||||
<li id="{{ id }}" onclick="window.location = '#{{ id }}'" class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}">
|
<li id="{{ id }}" onclick="window.location = '#{{ id }}'" class="list-group-item{{ ' list-group-item-success' if client.connected else loop.cycle('" style="background-color: #eee;', '') }}">
|
||||||
<span>{{ client.nick }}{{ " (" + client.identifier + ")" if debug }}</span>
|
<span class="hint--right" data-hint="{{ client.nick_history|join(', ') }}">{{ client.nick }}{{ " (" + client.identifier + ")" if debug }}</span>
|
||||||
<span class="badge"><div{% if not client.connected and headline == 'Onlinetime' %} class="hint--left" data-hint="{{ client.last_seen|frmttime }}"{% endif %}>{{ value }}</div></span>
|
<span class="badge"><div{% if not client.connected and headline == 'Onlinetime' %} class="hint--left" data-hint="{{ client.last_seen|frmttime }}"{% endif %}>{{ value }}</div></span>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue