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): 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) name = models.CharField(max_length=100, null=False)
last_seen = models.DateTimeField(null=True, blank=True) 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> <p>Settings are not set. Please configure the service first!</p>
<a id='adminurl' href=""></a> <a id='adminurl' href=""></a>
<script language='javascript' type="text/javascript"> <script language='javascript' type="text/javascript">
url = location.protocol + '//' + location.host + '/admin'; var url = location.protocol + '//' + location.host + '/admin';
link = document.getElementById("adminurl"); var link = document.getElementById("adminurl");
link.href=url; link.href=url;
link.innerHTML=url; link.innerHTML=url;
</script> </script>

View file

@ -16,6 +16,17 @@
<!-- Optional theme --> <!-- 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"> <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> </head>
<body> <body>
@ -33,12 +44,15 @@
<td>name</td> <td>name</td>
<td>questions answered</td> <td>questions answered</td>
<td>last seen</td> <td>last seen</td>
<td>url (click to copy)</td>
</tr> </tr>
{% for user in users %} {% for user in users %}
<tr> <tr>
<td>{{ user.name }}</td> <td>{{ user.name }}</td>
<td>{{ user.questions_answered }}</td> <td>{{ user.questions_answered }}</td>
<td>{{ user.last_seen }}</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> </tr>
{% endfor %} {% endfor %}
</table> </table>
@ -69,7 +83,13 @@
{{ settings.footer }} {{ settings.footer }}
</div> </div>
<script language='javascript' type="text/javascript">
new Clipboard('.userlink', {
text: function(trigger) {
return trigger.text;
}
});
</script>
</div> </div>
</body> </body>