summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--myadmin/views.py30
-rw-r--r--sbhs.sqlite3bin120832 -> 0 bytes
-rw-r--r--static/img/webcam/__placeholder__.txt0
-rw-r--r--templates/admin/sub_nav.html7
-rw-r--r--templates/admin/testexp.html16
6 files changed, 30 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index b90888a..01fe87d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ sbhs_server/credentials.py
log/
static/img/webcam/
experiments/
+sbhs.sqlite3
diff --git a/myadmin/views.py b/myadmin/views.py
index b868c4f..a15770b 100644
--- a/myadmin/views.py
+++ b/myadmin/views.py
@@ -95,14 +95,14 @@ def reset_device(req):
if usb_path is None:
retVal={"status_code":400,"message":"Invalid MID"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
#trying to connect to device
# check if SBHS device is connected
if not os.path.exists(usb_path):
retVal={"status_code":500,"message":"Device Not connected to defined USB Port"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
try:
board = sbhs.Sbhs()
@@ -111,13 +111,13 @@ def reset_device(req):
board.status = 1
if board.reset_board():
retVal={"status_code":200,"message":board.getTemp()}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
else:
retVal={"status_code":500,"message":"Could not set the parameters.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
except serial.serialutil.SerialException:
retVal={"status_code":500,"message":"Could not connect to the device.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
@csrf_exempt
@@ -135,14 +135,14 @@ def set_device_params(req):
if usb_path is None:
retVal={"status_code":400,"message":"Invalid MID"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
#trying to connect to device
# check if SBHS device is connected
if not os.path.exists(usb_path):
retVal={"status_code":500,"message":"Device Not connected to defined USB Port"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
try:
board = sbhs.Sbhs()
@@ -151,13 +151,13 @@ def set_device_params(req):
board.status = 1
if board.setFan(fan) and board.setHeat(heat):
retVal={"status_code":200,"message":board.getTemp()}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
else:
retVal={"status_code":500,"message":"Could not set the parameters.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
except serial.serialutil.SerialException:
retVal={"status_code":500,"message":"Could not connect to the device.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
@csrf_exempt
def get_device_temp(req):
@@ -172,14 +172,14 @@ def get_device_temp(req):
if usb_path is None:
retVal={"status_code":400,"message":"Invalid MID"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
#trying to connect to device
# check if SBHS device is connected
if not os.path.exists(usb_path):
retVal={"status_code":500,"message":"Device Not connected to defined USB Port"}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
try:
board = sbhs.Sbhs()
@@ -189,10 +189,10 @@ def get_device_temp(req):
temp=board.getTemp()
if temp!=0.0:
retVal={"status_code":200,"message":temp}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
else:
retVal={"status_code":500,"message":"Could not set the parameters.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
except serial.serialutil.SerialException:
retVal={"status_code":500,"message":"Could not connect to the device.Try again."}
- return HttpResponse(json.dumps(retVal))
+ return HttpResponse(json.dumps(retVal),content_type='application/json')
diff --git a/sbhs.sqlite3 b/sbhs.sqlite3
deleted file mode 100644
index e61f6dc..0000000
--- a/sbhs.sqlite3
+++ /dev/null
Binary files differ
diff --git a/static/img/webcam/__placeholder__.txt b/static/img/webcam/__placeholder__.txt
deleted file mode 100644
index e69de29..0000000
--- a/static/img/webcam/__placeholder__.txt
+++ /dev/null
diff --git a/templates/admin/sub_nav.html b/templates/admin/sub_nav.html
index 29d8840..d1e0cb1 100644
--- a/templates/admin/sub_nav.html
+++ b/templates/admin/sub_nav.html
@@ -1,4 +1,5 @@
-<a href="{% url 'admin_index' %}" class="btn">Show all boards</a>
-<a href="{% url 'admin_bookings' %}" class="btn">Show all bookings</a>
-<a href="{% url 'admin_webcam' %}" class="btn">Show all images</a>
+<a href="{% url 'admin_index' %}" class="btn btn-info">Show all boards</a>
+<a href="{% url 'admin_bookings' %}" class="btn btn-info">Show all bookings</a>
+<a href="{% url 'admin_webcam' %}" class="btn btn-info">Show all images</a>
+<a href="{% url 'admin_testing' %}" class="btn btn-info">Test boards</a>
<br><br> \ No newline at end of file
diff --git a/templates/admin/testexp.html b/templates/admin/testexp.html
index fa45cd7..aac5657 100644
--- a/templates/admin/testexp.html
+++ b/templates/admin/testexp.html
@@ -27,9 +27,9 @@
</tbody>
</table>
</div>
- <div class="span5">
+ <div class="span5" style="position: fixed;right: 10%; border: 1px slategray solid; padding: 15px;">
<div>
- <input type="text" id="temp"><br/>
+ <input type="text" id="temp" disabled="true"><br/>
<button class="btn btn-primary" onclick="getTemp()">Get Temperature</button>
</div>
<br><br>
@@ -80,9 +80,11 @@
request.done(function(data){
if (data.status_code == 200) {
document.getElementById("temp").value = data.message;
+ document.getElementById("fan_val").value = 100;
+ document.getElementById("heater_val").value = 0;
}
else {
- alert("Some error occured. Please try again!!");
+ alert(data.message);
}
});
}
@@ -100,6 +102,7 @@
var isInputOK = !isNaN(fan_value) && fan_value >=0 && fan_value <= 250 && !isNaN(heater_value) && heater_value >=0 && heater_value;
if (!isInputOK) {
alert("Please enter a value between 0 and 250");
+ return;
}
var request = $.ajax({
@@ -117,11 +120,11 @@
document.getElementById("temp").value = data.message;
}
else {
- alert("Some error occured. Please try again!!");
+ alert(data.message);
}
});
}
-
+ var mydata;
function getTemp() {
var selected_machine = document.getElementsByClassName("highlight");
if (selected_machine.length == 0) {
@@ -138,11 +141,12 @@
});
request.done(function(data){
+ mydata = data;
if (data.status_code == 200) {
document.getElementById("temp").value = data.message;
}
else {
- alert("Some error occured. Please try again!!");
+ alert(data.message);
}
});
}