added user link to statistic backend and copy to clipboard

This commit is contained in:
tkupek 2016-03-05 12:22:46 +01:00
parent 7c3bd62cbb
commit ef95803e78
4 changed files with 24 additions and 4 deletions

Binary file not shown.

View file

@ -48,7 +48,7 @@ class Option(models.Model):
class User(models.Model):
token = models.CharField(max_length=40, null=True, default=gen_token)
token = models.CharField(max_length=40, null=True, default=gen_token, unique=True)
name = models.CharField(max_length=100, null=False)
last_seen = models.DateTimeField(null=True, blank=True)

View file

@ -25,8 +25,8 @@
<p>Settings are not set. Please configure the service first!</p>
<a id='adminurl' href=""></a>
<script language='javascript' type="text/javascript">
url = location.protocol + '//' + location.host + '/admin';
link = document.getElementById("adminurl");
var url = location.protocol + '//' + location.host + '/admin';
var link = document.getElementById("adminurl");
link.href=url;
link.innerHTML=url;
</script>

View file

@ -16,6 +16,17 @@
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Clipboard.js -->
<script src="https://cdn.jsdelivr.net/clipboard.js/1.5.8/clipboard.min.js"></script>
<script language='javascript' type="text/javascript">
var url = location.protocol + '//' + location.host + '/start';
function getUserUrl(token) {
return url + "?token=" + token;
}
</script>
</head>
<body>
@ -33,12 +44,15 @@
<td>name</td>
<td>questions answered</td>
<td>last seen</td>
<td>url (click to copy)</td>
</tr>
{% for user in users %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.questions_answered }}</td>
<td>{{ user.last_seen }}</td>
<td><a class="userlink" id="userlink{{ user.token }}" href="javascript:void(0)"></a></td>
<script>document.getElementById("userlink{{ user.token }}").innerHTML = getUserUrl('{{ user.token }}')</script>
</tr>
{% endfor %}
</table>
@ -69,7 +83,13 @@
{{ settings.footer }}
</div>
<script language='javascript' type="text/javascript">
new Clipboard('.userlink', {
text: function(trigger) {
return trigger.text;
}
});
</script>
</div>
</body>