summaryrefslogtreecommitdiff
path: root/templates/admin
diff options
context:
space:
mode:
authorsriyasainath2017-05-29 14:56:23 +0530
committersriyasainath2017-05-29 14:56:23 +0530
commit5c0587ddf33720cd017a8e7b3a3b2e51ef6b8720 (patch)
treeb107a55bad68f1c3df297e3a102396d8f58c14dc /templates/admin
parent9e08c33cef4542cf222a37488ee8e8887a91080a (diff)
parent9ad308de090c3db0e91d853afe861f5d9b828a8d (diff)
downloadSBHS-2018-Rpi-5c0587ddf33720cd017a8e7b3a3b2e51ef6b8720.tar.gz
SBHS-2018-Rpi-5c0587ddf33720cd017a8e7b3a3b2e51ef6b8720.tar.bz2
SBHS-2018-Rpi-5c0587ddf33720cd017a8e7b3a3b2e51ef6b8720.zip
Merge branch 'deep' of https://github.com/coderick14/sbhs into deep
Diffstat (limited to 'templates/admin')
-rw-r--r--templates/admin/index.html5
-rw-r--r--templates/admin/testexp.html43
2 files changed, 44 insertions, 4 deletions
diff --git a/templates/admin/index.html b/templates/admin/index.html
index 95956f5..3e9ce15 100644
--- a/templates/admin/index.html
+++ b/templates/admin/index.html
@@ -15,6 +15,8 @@
<th>Board MID</th>
<th>Status</th>
<th>Webcam</th>
+ <th>Temperature Profile</th>
+ <th>Download Logs</th>
</tr>
</thead>
<tbody>
@@ -23,7 +25,8 @@
<td>{{ b.mid }}</td>
<td><span class="label label-{% if b.online %}success{% else %}important{% endif %}">{% if b.online %}Online{% else %}Offline{% endif %}</span></td>
<td><a href="{% url 'webcam_show_video_to_admin' b.mid %}" target="_blank">View image</a></td>
- <td><a href="{% url 'admin_profile' b.mid %}">View temperature profile</a></td>
+ <td><a href="{% url 'admin_profile' b.mid %}">View</a></td>
+ <td><a href="{% url 'admin_logs' b.mid %}">Download</a></td>
</tr>
{% endfor %}
</tbody>
diff --git a/templates/admin/testexp.html b/templates/admin/testexp.html
index 39291fa..052cfe9 100644
--- a/templates/admin/testexp.html
+++ b/templates/admin/testexp.html
@@ -63,7 +63,9 @@
</div>
<div class="span5" id="monitor-logs">
- <span>chal raha hain bhai</span>
+ <strong><p id="username"></p></strong>
+ <p id="log-data" style="word-spacing: 4em"></p>
+ <button class="btn btn-primary" onclick="getLogs()">Refresh Logs</button>
</div>
</div>
@@ -150,7 +152,7 @@
}
});
}
- var mydata;
+
function getTemp() {
var selected_machine = document.getElementsByClassName("highlight");
if (selected_machine.length == 0) {
@@ -167,7 +169,6 @@
});
request.done(function(data){
- mydata = data;
if (data.status_code == 200) {
document.getElementById("temp").value = data.message;
}
@@ -176,6 +177,42 @@
}
});
}
+
+ function getLogs() {
+ var selected_machine = document.getElementsByClassName("highlight");
+ if (selected_machine.length == 0) {
+ alert("Please select a machine first");
+ return;
+ }
+ var selected_mid = selected_machine[0].getElementsByTagName('td')[0].innerHTML;
+ var request = $.ajax({
+ url : BASE_URL + '/admin/monitor',
+ method : 'POST',
+ data : {
+ 'mid' : selected_mid
+ }
+ });
+
+ header = "<th>Time</th><th>Fan</th><th>Heat</th><th>Temp</th>"
+ request.done(function(data){
+ if (data.status_code == 200) {
+ console.log(data.message.logs.replace("/\n/g", "<br/>"));
+ document.getElementById("username").innerHTML = "User : " + data.message.user;
+ document.getElementById("log-data").innerHTML = "<pre>Date Time Heater Fan Temp</pre>" + data.message.logs.replace(new RegExp("\n","g"), "<br/>");
+ }
+ else {
+ alert(data.status_code);
+ }
+ });
+ }
+
+ // update status of ongoing experiments
+ setInterval(function() {
+ var now = new Date();
+ if (now.getMinutes() == 56 || now.getMinutes() == 1) {
+ location.reload();
+ }
+ }, 60000);
</script>
{% endblock %}