Files
libopenanal/templates/user.html

195 lines
7.3 KiB
HTML
Raw Normal View History

2018-10-30 22:55:36 +10:00
{% extends "base.html" %}
{% block head %}
{{ super() }}
2018-10-30 22:55:36 +10:00
{% endblock %}
{% block content %}
{{ super() }}
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="/">Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/conf">Conferences</a>
</li>
<li class="nav-item">
2018-12-06 22:17:58 +03:00
<a class="nav-link" href="/words">Words</a>
2018-10-30 22:55:36 +10:00
</li>
<li class="nav-item">
2018-12-06 22:17:58 +03:00
<a class="nav-link" href="/stat">2ch.hk Stats</a>
2018-10-30 22:55:36 +10:00
</li>
</ul>
<br>
<hr>
2018-10-31 19:41:16 +03:00
<h4>{{ user_info.first_name }}'s user data</h4>
2018-10-30 22:55:36 +10:00
<hr>
<div class="card-columns">
<div class="card">
<div class="card-body">
<h5 class="card-title">Identity</h5>
<hr>
<p class="card-text">
<b>First name: </b>{{ user_info.first_name }}<br>
<b>Last name: </b>{% if user_info.last_name != '_null' %}{{ user_info.last_name }}{% else %}
<span class="badge badge-warning">N/D</span>{% endif %}<br>
<b>Username: </b>{% if user_info.username != '_null' %}{{ user_info.username }}{% else %}
<span class="badge badge-warning">N/D</span>{% endif %}<br>
<b>Telegram ID: </b>{{ user_info.id }}<br>
<b>Firstly seen: </b>{{ user_info.first_date }}<br>
</p>
2018-10-28 13:07:06 +03:00
</div>
</div>
2018-10-30 22:55:36 +10:00
<div class="card">
<div class="card-body">
<h5 class="card-title">Activity</h5>
<hr>
<p class="card-text">
<b>First message: </b>{{ user_info.first_date }}<br>
<b>Last message: </b>{{ user_info.last_message }}<br>
<b>Days known: </b>{{ user_info.day_known }}<br>
2018-12-06 22:17:58 +03:00
<b>Words said: </b>{{ user_info.word_count }}<br>
2018-10-30 18:38:39 +03:00
<b>Messages sent: </b>{{ user_info.messages }}<br>
2018-10-30 22:55:36 +10:00
<b>Words per day: </b>{{ '%0.2f'| format((user_info.word_count / user_info.day_known)|float) }}<br>
<b>Words per message: </b>~{{ '%0.2f'| format(user_info.avg|float) }}<br>
</p>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Top</h5>
<hr>
<p class="card-text">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Word</th>
<th scope="col">Said</th>
</tr>
</thead>
<tbody>
{% for word in user_info.top %}
<tr>
<th scope="row">{{ loop.index }}</th>
<td>{{ word[0] }}</td>
{% if not loop.last %}
2018-10-30 22:55:36 +10:00
{% if (word[1]/loop.nextitem[1]) > 2 %}
<td><span class="badge badge-danger" data-toggle="tooltip" data-placement="right" title="Must have been abused">{{
word[1] }} </span></td>
2018-10-30 22:55:36 +10:00
{% else %}
<td><span class="badge badge-secondary">{{ word[1] }} </span></td>
2018-10-30 22:55:36 +10:00
{% endif %}
{% else %}
2018-10-30 22:55:36 +10:00
<td><span class="badge badge-secondary">{{ word[1] }} </span></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
2018-10-30 22:55:36 +10:00
</div>
2018-10-28 13:07:06 +03:00
</div>
2018-10-30 22:55:36 +10:00
<div class="card">
<div class="card-body">
<h5 class="card-title">Chats</h5>
<p class="card-text">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Chat</th>
<th scope="col">Words</th>
<th scope="col">Messages</th>
</tr>
</thead>
<tbody>
{% for chat in user_info.chats %}
<tr>
<th scope="row">{{ loop.index }}</th>
<td>{{ chat[0] }}</td>
<td><span class="badge badge-secondary">{{ chat[1] }} </span></td>
<td><span class="badge badge-secondary">{{ chat[3] }} </span></td>
</tr>
{% endfor %}
</tbody>
</table>
2018-10-30 22:55:36 +10:00
</div>
2018-10-28 13:07:06 +03:00
</div>
2018-12-05 21:13:11 +03:00
2018-10-30 22:55:36 +10:00
</div>
2018-12-05 23:40:05 +03:00
<div class="card">
2018-12-05 21:13:11 +03:00
<div class="card-body">
<h5 class="card-title">Charts</h5>
2018-12-06 00:01:02 +03:00
<hr>
2018-12-05 23:40:05 +03:00
<span class="badge {% if 'bar' == plot_type %} badge-primary {% endif %}" id="bar" onclick="plot_type_changer(this.id)">Bars</span>
<span class="badge {% if 'scatter' == plot_type %} badge-primary {% endif %}" id="scatter" onclick="plot_type_changer(this.id)">Lines</span>
2018-12-05 21:13:11 +03:00
<div id="words_chart">
</div>
<script>
2018-12-05 23:40:05 +03:00
function plot_type_changer(type="bar") {
location.href = URL_add_parameter(location.href, 'plot_type', type);
}
function URL_add_parameter(url, param, value) {
var hash = {};
var parser = document.createElement('a');
parser.href = url;
var parameters = parser.search.split(/\?|&/);
for (var i = 0; i < parameters.length; i++) {
if (!parameters[i])
continue;
var ary = parameters[i].split('=');
hash[ary[0]] = ary[1];
}
hash[param] = value;
var list = [];
Object.keys(hash).forEach(function (key) {
list.push(key + '=' + hash[key]);
});
parser.search = '?' + list.join('&');
return parser.href;
}
2018-12-05 21:13:11 +03:00
var user_id = {{ user_info.id }};
var plot_data = [];
$.ajax({
type: 'GET',
url: '/data',
2018-12-05 23:40:05 +03:00
data: { action: 'user_word_count', user: user_id, plot_type: "{{ plot_type }}" },
2018-12-05 21:13:11 +03:00
dataType: 'json',
success: function (data) {
plot_data[0] = data[0];
2018-12-05 23:40:05 +03:00
_write_plot();
2018-12-05 21:13:11 +03:00
}
});
$.ajax({
type: 'GET',
url: '/data',
2018-12-05 23:40:05 +03:00
data: { action: 'user_message_count', user: user_id, plot_type: "{{ plot_type }}" },
2018-12-05 21:13:11 +03:00
dataType: 'json',
success: function (data) {
plot_data[1] = data[0];
2018-12-05 23:40:05 +03:00
_write_plot();
2018-12-05 21:13:11 +03:00
}
});
2018-12-05 23:40:05 +03:00
function _write_plot() {
2018-12-05 21:13:11 +03:00
var layout = {
2018-12-05 23:40:05 +03:00
title: 'Daily plot',
2018-12-05 21:13:11 +03:00
showlegend: false,
//autosize: false,
//width: 500,
//height: 500,
margin: {
t: 30,
pad: 20
},
};
Plotly.newPlot('words_chart', plot_data, layout, { displayModeBar: false });
}
</script>
</div>
</div>
{% endblock %}