From 26717861ef6ffbedbbde3a528d69a0778cd454b5 Mon Sep 17 00:00:00 2001 From: dk-15 Date: Wed, 31 May 2017 17:17:40 +0530 Subject: Add js to update MID in admin panel --- templates/admin/testexp.html | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'templates/admin/testexp.html') diff --git a/templates/admin/testexp.html b/templates/admin/testexp.html index 052cfe9..f857902 100644 --- a/templates/admin/testexp.html +++ b/templates/admin/testexp.html @@ -96,6 +96,9 @@ return; } var selected_mid = selected_machine[0].getElementsByTagName('td')[0].innerHTML; + + $(".btn").prop('disabled',true); + var request = $.ajax({ url : BASE_URL + '/admin/resetdevice', method : 'POST', @@ -113,10 +116,12 @@ else { alert(data.message); } + $(".btn").prop('disabled',false); }); } function setParams() { + var MAX_VALUE = 100; var selected_machine = document.getElementsByClassName("highlight"); if (selected_machine.length == 0) { @@ -127,11 +132,12 @@ var fan_value = document.getElementById("fan_val").value; var heater_value = document.getElementById("heater_val").value; - var isInputOK = !isNaN(fan_value) && fan_value >=0 && fan_value <= MAX_VALUE && !isNaN(heater_value) && heater_value >=0 && heater_value <= MAX_VALUE; + var isInputOK = !isNaN(fan_value) && fan_value != "" && fan_value >=0 && fan_value <= MAX_VALUE && !isNaN(heater_value) && heater_value != "" && heater_value >=0 && heater_value <= MAX_VALUE; if (!isInputOK) { alert("Please enter a value between 0 and " + MAX_VALUE); return; } + $(".btn").prop('disabled',true); var request = $.ajax({ url : BASE_URL + '/admin/setdevice', @@ -150,6 +156,7 @@ else { alert(data.message); } + $(".btn").prop('disabled',false); }); } @@ -160,6 +167,9 @@ return; } var selected_mid = selected_machine[0].getElementsByTagName('td')[0].innerHTML; + + $(".btn").prop('disabled',true); + var request = $.ajax({ url : BASE_URL + '/admin/gettemp', method : 'POST', @@ -175,6 +185,9 @@ else { alert(data.message); } + + $(".btn").prop('disabled',false); + }); } @@ -185,6 +198,9 @@ return; } var selected_mid = selected_machine[0].getElementsByTagName('td')[0].innerHTML; + + $(".btn").prop('disabled',true); + var request = $.ajax({ url : BASE_URL + '/admin/monitor', method : 'POST', @@ -203,6 +219,8 @@ else { alert(data.status_code); } + $(".btn").prop('disabled',false); + }); } -- cgit