Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit b3ea46a4 authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

ajout graphique traces par jour

parent 718f9ebb
......@@ -51,6 +51,35 @@ async function downloadTraces(){
//provide the name for the CSV file to be downloaded
hiddenElement.download = filename
hiddenElement.click();
}
\ No newline at end of file
hiddenElement.click();
}
// DISPLAY LOG CHART
let listvalues = []
for (key in day2traces) {
listvalues.push(parseInt(day2traces[key]))
}
var ctx = document.getElementById('logChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: Object.keys(day2traces),
datasets: [{
label: 'Nombre de traces par jour',
data: listvalues,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
......@@ -11,6 +11,8 @@
<script type="text/javascript">
var username = "{{ data.user.username | escapejs }}"
console.log(username)
let day2traces = JSON.parse("{{ data.day2traces | escapejs }}")
</script>
<div style="text-align: left; background-color: cornsilk; padding:5px; border:1px transparent solid;border-radius:5px;">
......@@ -26,6 +28,7 @@
<h1>Traces de {{ data.user.username }}</h1>
<p>Dernière trace enregistrée : {{ data.lastTrace | date:'d/m/Y e H:i:s' }}</p>
<p>Nombre de traces pour cet utilisateur : {{ data.nbTraces }}</p>
<canvas id="logChart" width="400px" height="130px"></canvas>
</div>
</div>
</div>
......@@ -77,6 +80,7 @@
{% block javascript %}
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"></script>
<script type="text/javascript" src="{% static 'js/datatables.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/interface_basic.js' %}"></script>
<script type="text/javascript" src="{% static 'js/userInfo.js' %}"></script>
......
......@@ -15,6 +15,7 @@ from .decorators import unauthenticated_user, allowed_users
from user_agents import parse
import json, datetime, csv
import numpy as np
@unauthenticated_user
def register(request):
......@@ -289,10 +290,21 @@ def userInfo(request, username):
nbTraces = len(traces)
lastTrace = traces[nbTraces-1].date if nbTraces > 0 else 0
daylist = np.arange('2021-02-15', np.datetime64('today', 'D'), dtype='datetime64[D]')
day2traces = {}
# Initialisation liste vide
for day in daylist:
day2traces[str(day)] = 0
# Remplissage avec les dates des traces
for trace in traces:
day2traces[trace.date.strftime("%Y-%m-%d")] += 1
dataUser = {
'user': user,
'traces': traces,
'day2traces': json.dumps(day2traces),
'nbTraces': nbTraces,
'lastTrace': lastTrace
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment