summaryrefslogtreecommitdiff
path: root/templates/admin
diff options
context:
space:
mode:
Diffstat (limited to 'templates/admin')
-rw-r--r--templates/admin/booking_index.html2
-rw-r--r--templates/admin/changeMID.html6
-rw-r--r--templates/admin/index.html121
-rw-r--r--templates/admin/log_does_not_exist.html12
-rw-r--r--templates/admin/sub_nav.html7
-rw-r--r--templates/admin/switch_on_all_board.html90
-rw-r--r--templates/admin/testexp.html15
-rw-r--r--templates/admin/user_logs.html15
-rw-r--r--templates/admin/webcam_index.html6
9 files changed, 248 insertions, 26 deletions
diff --git a/templates/admin/booking_index.html b/templates/admin/booking_index.html
index 58b9e1c..db9b41e 100644
--- a/templates/admin/booking_index.html
+++ b/templates/admin/booking_index.html
@@ -19,7 +19,7 @@
<tbody>
{% for b in bookings %}
<tr>
- <td>{{ b.booking_date|date:"M d, Y" }}</td>
+ <td>{{ b.booking_date }}</td>
<td>{{ b.slot }}</td>
<td>{{ b.account.board.mid }}</td>
<td>{{ b.account.name }}</td>
diff --git a/templates/admin/changeMID.html b/templates/admin/changeMID.html
index b788ff1..125bc48 100644
--- a/templates/admin/changeMID.html
+++ b/templates/admin/changeMID.html
@@ -31,7 +31,7 @@
function updateMID() {
$("#update-btn").prop('disabled',true);
- var BASE_URL = window.location.origin + "/sbhs-rpi";
+ var BASE_URL = window.location.origin + "/sbhs";
var username = $("#username").val().split(" ")[0];
var board_id = $("#mid").children(":selected").attr("id");
@@ -67,7 +67,7 @@
// for live search of usernames
if (sessionStorage.getItem("fetchedUsers") == null) {
-var BASE_URL = window.location.origin + "/sbhs-rpi";
+var BASE_URL = window.location.origin + "/sbhs";
var request = $.ajax({
url: BASE_URL + '/admin/getusers',
method: 'POST'
@@ -115,4 +115,4 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
appendUsers();
</script>
</div>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/templates/admin/index.html b/templates/admin/index.html
index a28935f..b08d5aa 100644
--- a/templates/admin/index.html
+++ b/templates/admin/index.html
@@ -1,6 +1,51 @@
{% extends "layout.html" %}
{% load staticfiles %}
-
+{% block style_block %}
+ <style>
+ .default {
+ background-color: #999;
+ }
+ .default[href]:hover,
+ .default[href]:focus {
+ background-color: #808080;
+ }
+ .primary {
+ background-color: #428bca;
+ }
+ .primary[href]:hover,
+ .primary[href]:focus {
+ background-color: #3071a9;
+ }
+ .success {
+ background-color: #5cb85c;
+ }
+ .success[href]:hover,
+ .success[href]:focus {
+ background-color: #449d44;
+ }
+ .info {
+ background-color: #5bc0de;
+ }
+ .info[href]:hover,
+ .info[href]:focus {
+ background-color: #31b0d5;
+ }
+ .warning {
+ background-color: #f0ad4e;
+ }
+ .warning[href]:hover,
+ .warning[href]:focus {
+ background-color: #ec971f;
+ }
+ .danger {
+ background-color: #d9534f;
+ }
+ .danger[href]:hover,
+ .danger[href]:focus {
+ background-color: #c9302c;
+ }
+ </style>
+{% endblock %}
{% block content %}
<div class="container">
<div class="row">
@@ -14,16 +59,19 @@
<tr>
<th>Board MID</th>
<th>Status</th>
+ <th>Power Status</th>
<th>Webcam</th>
<th>Temperature Profile</th>
<th>Download Logs</th>
+
</tr>
</thead>
<tbody>
{% for b in boards %}
<tr>
- <td>{{ b.mid }}</td>
+ <td class = "board_id">{{ b.mid }}</td>
<td><span style="cursor: pointer;" class="label label-{% if not b.online %}important{% elif b.temp_offline %}warning{% else %}success{% endif %}">{% if not b.online %}Offline{% elif b.temp_offline %}Temp Offline{% else %}Online{% endif %}</span></td>
+ <td><span style = "cursor: pointer;" class = "label {% if not b.power_status %}danger{% else %}success{% endif %}">{% if not b.power_status %}OFF{% else %}ON{% 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</a></td>
<td><a href="{% url 'admin_logs' b.mid %}">Download</a></td>
@@ -38,16 +86,21 @@
<script type="text/javascript">
$(".label-success").click(toggleState);
$(".label-warning").click(toggleState);
-
+ $(".success").click(togglePowerState);
+ $(".danger").click(togglePowerState);
function toggleState() {
-var BASE_URL = window.location.origin + "/sbhs-rpi";
+ console.log('inside toggleState')
+ var BASE_URL = window.location.origin + "";
if (window.confirm("Are you sure you want to toggle the state?")) {
+
var element = $(this);
+ console.log('element '+element)
var board_class = element.attr("class");
+ console.log('board_class '+board_class);
var selected_mid = element.parent().prev().html();
-
+ console.log('selected_mid '+selected_mid)
var request = $.ajax({
- url : BASE_URL + '/admin/toggledevice',
+ url : BASE_URL + '/sbhs/admin/toggledevice',
method : 'POST',
data : {
'mid' : selected_mid
@@ -55,6 +108,7 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
});
request.done(function(data){
+
if (data.status_code == 200) {
if (board_class.indexOf("label-success") > -1) {
element.removeClass("label-success");
@@ -68,10 +122,61 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
}
}
else {
- alert("Sorry! The state could not be toggled.");
+ alert("Sorry! The state could not be toggled. "+data.message);
}
});
}
}
+ function togglePowerState(){
+ console.log('togglePowerState!');
+ var BASE_URL = window.location.origin + "";
+ if (window.confirm("Are you sure you want to toggle the state?")) {
+
+ var element = $(this);
+ console.log('element '+element)
+ var board_class = element.attr("class");
+ console.log('board_class '+board_class);
+ // var selected_mid = element.parent().prev().html();
+ var selected_mid = element.parent().siblings('td.board_id').html()
+ console.log('selected_mid '+selected_mid)
+ var request = $.ajax({
+ url : BASE_URL + '/sbhs/admin/togglePowerState',
+ method : 'POST',
+ data : {
+ 'mid' : selected_mid
+ }
+ });
+
+ request.done(function(data){
+ if (data.status_code == 200) {
+ if (board_class.indexOf("success") > -1) {
+ element.removeClass("success");
+ element.addClass("danger");
+ element.html("OFF");
+
+ }
+ else {
+ element.removeClass("danger");
+ element.addClass("success");
+ element.html("ON");
+ }
+ }
+ else {
+ alert("Sorry! The state could not be toggled. "+data.message);
+ }
+ });
+ }
+ }
+ // $(window).bind("beforeunload",function(event){
+ // return "Please don't refresh. This will change the state of off devices to disconnected."
+ // });
+
+ // This function does not allow to refresh the admin page. Refreshing admin Page will change the state of device
+ function disableF5(e){
+ if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e. preventDefault();
+ };
+ $(document).ready(function(){
+ $(document).on("keydown",disableF5);
+ });
</script>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/templates/admin/log_does_not_exist.html b/templates/admin/log_does_not_exist.html
new file mode 100644
index 0000000..8d3d3e0
--- /dev/null
+++ b/templates/admin/log_does_not_exist.html
@@ -0,0 +1,12 @@
+{% extends "layout.html" %}
+{% load staticfiles %}
+{% block content %}
+<div class="container">
+ <div class="row">
+ {% include "account/sub_nav.html" %}
+ <div class="span12">
+ <h2>Log File Does not exists for this profile</h2>
+ </div>
+ </div>
+</div>
+{% endblock %} \ No newline at end of file
diff --git a/templates/admin/sub_nav.html b/templates/admin/sub_nav.html
index c77205b..9e8e361 100644
--- a/templates/admin/sub_nav.html
+++ b/templates/admin/sub_nav.html
@@ -4,4 +4,9 @@
<a href="{% url 'admin_testing' %}" class="btn btn-info">Test boards</a>
<a href="{% url 'admin_getmids' %}" class="btn btn-info">Update MID</a>
<a href="{% url 'admin_viewlogs' %}" class="btn btn-info">Fetch Logs</a>
-<br><br> \ No newline at end of file
+<a href="{% url 'admin_viewlogfolders' %}" class = "btn btn-info">Download Experiments Directory</a>
+<a href="{% url 'admin_switch_on' %}" class = "btn btn-info">Switch ON All Boards</a>
+<hr/>
+<a href="{% url 'admin_switch_off' %}" class = "btn btn-info">Switch Off All Boards</a>
+<a href="{% url 'atomated_slot_booking' %}" class = "btn btn-info">Automated Slot Booking</a>
+<br><br>
diff --git a/templates/admin/switch_on_all_board.html b/templates/admin/switch_on_all_board.html
new file mode 100644
index 0000000..4f5298c
--- /dev/null
+++ b/templates/admin/switch_on_all_board.html
@@ -0,0 +1,90 @@
+{% extends "layout.html" %}
+{% load staticfiles %}
+{% block style_block %}
+ <style>
+ .default {
+ background-color: #999;
+ }
+ .default[href]:hover,
+ .default[href]:focus {
+ background-color: #808080;
+ }
+ .primary {
+ background-color: #428bca;
+ }
+ .primary[href]:hover,
+ .primary[href]:focus {
+ background-color: #3071a9;
+ }
+ .success {
+ background-color: #5cb85c;
+ }
+ .success[href]:hover,
+ .success[href]:focus {
+ background-color: #449d44;
+ }
+ .info {
+ background-color: #5bc0de;
+ }
+ .info[href]:hover,
+ .info[href]:focus {
+ background-color: #31b0d5;
+ }
+ .warning {
+ background-color: #f0ad4e;
+ }
+ .warning[href]:hover,
+ .warning[href]:focus {
+ background-color: #ec971f;
+ }
+ .danger {
+ background-color: #d9534f;
+ }
+ .danger[href]:hover,
+ .danger[href]:focus {
+ background-color: #c9302c;
+ }
+ </style>
+{% endblock %}
+{% block content %}
+<div class="container">
+ <div class="row">
+ {% include "account/sub_nav.html" %}
+ <div class="span12">
+ {% include "admin/sub_nav.html" %}
+ <h1>Board status</h1>
+ <table class="table table-bordered">
+ <thead>
+ <tr>
+ <th>Board MID</th>
+ <th>Status</th>
+ <th>Power Status</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for b in boards %}
+ <tr>
+ <td class = "board_id">{{ b.mid }}</td>
+ <td><span style="cursor: pointer;" class="label label-{% if not b.online %}important{% elif b.temp_offline %}warning{% else %}success{% endif %}">{% if not b.online %}Offline{% elif b.temp_offline %}Temp Offline{% else %}Online{% endif %}</span></td>
+ <td><span style = "cursor: pointer;" class = "label {% if not b.power_status %}danger{% else %}success{% endif %}">{% if not b.power_status %}OFF{% else %}ON{% endif %}</span></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
+<script>
+ // $(window).bind("beforeunload",function(event){
+ // return "Please don't refresh. This will change the state of off devices to disconnected."
+ // });
+
+ // This function does not allow to refresh the admin page. Refreshing admin Page will change the state of device
+ function disableF5(e){
+ if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e. preventDefault();
+ };
+ $(document).ready(function(){
+ $(document).on("keydown",disableF5);
+ });
+</script>
+{% endblock %} \ No newline at end of file
diff --git a/templates/admin/testexp.html b/templates/admin/testexp.html
index 807e0f2..e3388f5 100644
--- a/templates/admin/testexp.html
+++ b/templates/admin/testexp.html
@@ -15,7 +15,7 @@
}
#log-data > span {
word-spacing: 5em;
- margin-left: 3em;
+ margin-left: 3em;
}
</style>
<div class="container">
@@ -45,6 +45,7 @@
</tbody>
</table>
</div>
+
<!-- Modal code starts here -->
<div class="modal hide fade" id="test-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@@ -89,10 +90,11 @@
</div>
</div>
<!-- Modal code ends here -->
+
</div>
</div>
<script>
-var BASE_URL = window.location.origin + "/sbhs-rpi";
+ var BASE_URL = window.location.origin + "/sbhs";
$("#tableId").on("click", "tr", function(e) {
$("#tableId").find("tr.highlight").removeClass("highlight");
$(this).addClass("highlight");
@@ -102,8 +104,8 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
if (isSelectedMachineVacant) {
$("#temp").val("");
- $("#heater-val").val("");
$("#fan-val").val("");
+ $("#heater-val").val("");
$("#test-modal").modal();
}
else {
@@ -185,6 +187,7 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
function getTemp() {
var selected_machine = document.getElementsByClassName("highlight");
+ console.log('Inside getTemp function');
if (selected_machine.length == 0) {
alert("Please select a machine first");
return;
@@ -192,7 +195,7 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
var selected_mid = selected_machine[0].getElementsByTagName('td')[0].innerHTML;
$(".btn").prop('disabled',true);
-
+ console.log('mid'+selected_mid);
var request = $.ajax({
url : BASE_URL + '/admin/gettemp',
method : 'POST',
@@ -200,8 +203,9 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
'mid' : selected_mid
}
});
-
+ //console.log('mid'+mid)
request.done(function(data){
+ console.log('data.status_code',data.status_code);
if (data.status_code == 200) {
document.getElementById("temp").value = data.message;
}
@@ -240,6 +244,7 @@ var BASE_URL = window.location.origin + "/sbhs-rpi";
document.getElementById("log-data").innerHTML = "<pre>Iteration Heater Fan Temp</pre><span>" + data.message.logs.replace(new RegExp("\n","g"), "</span><br/><span>") + "</span>";
}
else {
+ console.log(data.message);
alert(data.message);
}
$(".btn").prop('disabled',false);
diff --git a/templates/admin/user_logs.html b/templates/admin/user_logs.html
index 453eb33..194c16b 100644
--- a/templates/admin/user_logs.html
+++ b/templates/admin/user_logs.html
@@ -88,8 +88,9 @@
</div>
</div>
</div>
- <h4 id="file-count"></h4>
- <table id="logs-table" class="table table-condensed" style="display: none;">
+
+ <h4 id="file-count"></h4>
+ <table id="logs-table" class="table table-condensed" style="display : none;">
<thead>
<tr>
<th>Sl No</th>
@@ -120,7 +121,6 @@ var endDate = "{{ nowdate }}";
}).on('changeDate', function(ev) {
var newDate = new Date(ev.date);
startDate = newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + newDate.getDate();
- $(this).datepicker('hide');
}).data('datepicker');
var DP2 = $('#dp2').datepicker({
@@ -130,16 +130,15 @@ var endDate = "{{ nowdate }}";
}).on('changeDate', function(ev) {
var newDate = new Date(ev.date);
endDate = newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + newDate.getDate();
- $(this).datepicker('hide');
}).data('datepicker');
})();
function fetchFileNames() {
var startTime = $("#start-time").val();
var endTime = $("#end-time").val();
- var BASE_URL = window.location.origin + "/sbhs-rpi";
+ var BASE_URl = window.location.origin + "/sbhs";
var request = $.ajax({
- url : BASE_URL + "/admin/rangelogs",
+ url : BASE_URl + "/admin/rangelogs",
method : "POST",
data : {
"start_date" : startDate,
@@ -154,7 +153,7 @@ function fetchFileNames() {
htmlContent = "";
ctr=1;
for (item of data.message) {
- htmlContent += "<tr>" + "<td>" + ctr + "</td>" + "<td>" + item.log.split("/")[0] +"</td>" + "<td><a href='" + BASE_URL + "/admin/explogs/" + item.id + "'>" + item.log.split("/")[1] +"</a></td>" + "</tr>";
+ htmlContent += "<tr>" + "<td>" + ctr + "</td>" + "<td>" + item.log.split("/").slice(-2)[0] +"</td>" + "<td><a href='" + BASE_URl + "/admin/explogs/" + item.id + "'>" + item.log.split("/").slice(-1)[0] +"</a></td>" + "</tr>";
ctr+=1;
}
$("#file-count").html(data.message.length + " results found");
@@ -169,4 +168,4 @@ function fetchFileNames() {
});
}
</script>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/templates/admin/webcam_index.html b/templates/admin/webcam_index.html
index 85356d1..a64221d 100644
--- a/templates/admin/webcam_index.html
+++ b/templates/admin/webcam_index.html
@@ -19,4 +19,10 @@
{% endfor %}
</div>
</div>
+
+<script type="text/javascript">
+ var timer = setInterval(function(){
+ location.reload();
+ }, 25000);
+</script>
{% endblock %} \ No newline at end of file