-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vcoman/ces demo #6
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Victor Coman <[email protected]>
- Added some more fixes Signed-off-by: Victor Coman <[email protected]>
Signed-off-by: Victor Coman <[email protected]>
… controls. Signed-off-by: Victor Coman <[email protected]>
… controls. Signed-off-by: Victor Coman <[email protected]>
…apps into vcoman/ces_demo
…ature intervals Signed-off-by: Victor Coman <[email protected]>
- Wind direction in dashboard - Server errors in history - Accumulated rain in dashboard - Rain limits - Reduce refreshing time Signed-off-by: Victor Coman <[email protected]>
Signed-off-by: Victor Coman <[email protected]>
…instead of the rain accumulated Signed-off-by: Victor Coman <[email protected]>
Signed-off-by: Victor Coman <[email protected]>
@@ -39,7 +39,7 @@ | |||
# SECURITY WARNING: don't run with debug turned on in production! | |||
DEBUG = True | |||
|
|||
ALLOWED_HOSTS = [] | |||
ALLOWED_HOSTS = ['127.0.0.1', 'agriculturedemodigi-env-1.us-west-2.elasticbeanstalk.com', 'django-env5.us-west-2.elasticbeanstalk.com', '172.31.27.57', '172.31.18.186'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use '*'
, we should not use fixed URLs.
@@ -31,6 +31,9 @@ | |||
from django.urls import include, path | |||
|
|||
urlpatterns = [ | |||
|
|||
# path("index.html", include("app.urls")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be committed.
@@ -146,41 +148,6 @@ def get_device_cloud_session(session): | |||
base_url=user_serialized.server) | |||
|
|||
|
|||
def check_ajax_request(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all these changes (until line 543)?
@@ -0,0 +1,10 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be committed, remove it.
@@ -240,9 +243,7 @@ | |||
if (data["redirect"]) | |||
window.location.replace(data["redirect"]); | |||
} | |||
).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
currentWeatherIcon = RAIN_GREEN; | ||
currentWeatherStatus = "rainy"; | ||
} else if ($("#weather-cloudy-logo").hasClass("selected-icon-widget")) { | ||
} | ||
else if(rain == 0 && luminosity < 4000){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: whitespace after else if
and before {
.
dataTable.addColumn("number", ""); | ||
dataTable.addColumn('date', ''); | ||
dataTable.addColumn("number", title); | ||
if (data2 != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: add whitespace before {
.
|
||
$.each(data, function(k, v) { | ||
dataTable.setCell(k, 0, new Date(v["timestamp"])); | ||
dataTable.setCell(k, 1, v["data"]); | ||
dataTable.setCell(k, 0, new Date(v["timestamp"])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indentation, it should be 8 spaces.
return; | ||
|
||
var dataTable = new google.visualization.DataTable(); | ||
dataTable.addColumn("date", ""); | ||
dataTable.addColumn("number", ""); | ||
dataTable.addColumn('date', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: use double quotes for consistency.
y: { | ||
Data: { | ||
label: units | ||
if(data2 != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: add whitespaces after all if
's and before all {
.
Do not commit the |
5c940b1
to
ab49210
Compare
Signed-off-by: Victor Coman <[email protected]>
ab49210
to
be00e8b
Compare
agriculture/agriculturecore/views.py
Outdated
@@ -19,6 +19,7 @@ | |||
PARAM_CONTROLLER_ID = "controller_id" | |||
PARAM_FARM_NAME = "farm_name" | |||
|
|||
ID_ERROR = "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
@@ -252,10 +253,13 @@ def get_smart_farms(request): | |||
:class:`.JsonResponse`: A JSON response with the list of the Smart | |||
Farms within the DRM account. | |||
""" | |||
# Check if the AJAX request is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/agriculturecore/views.py
Outdated
@@ -433,7 +452,7 @@ def refill_tank(request): | |||
new_value = refill_tank_request(request, controller_id) | |||
if new_value is not None: | |||
return JsonResponse({"value": new_value}, status=200) | |||
return JsonResponse({ID_ERROR: "Could not set the valve."}, status=400) | |||
return JsonResponse({"error": "Could not set the valve."}, status=400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert until here.
@@ -544,10 +605,13 @@ def check_farm_connection_status(request): | |||
Returns: | |||
A JSON with the status of the farm or the error. | |||
""" | |||
# Check if the AJAX request is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/dashboard.js
Outdated
@@ -263,9 +270,7 @@ function getFarmStatus(first=true) { | |||
return; | |||
processFarmStatusResponse(data, first); | |||
} | |||
).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/history.js
Outdated
@@ -268,64 +297,114 @@ function drawValveChart(macAddr, refresh=false, showProgress=false) { | |||
valveData[macAddr] = response.data; | |||
drawValveChart(macAddr); | |||
$("#valve-" + macAddr + "-chart-loading").hide(); | |||
}).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/history.js
Outdated
@@ -353,8 +432,6 @@ function drawStationsCharts() { | |||
drawMoistureChart(macAddr, true, true); | |||
drawValveChart(macAddr, true, true); | |||
} | |||
}).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/widgets.js
Outdated
@@ -59,8 +34,6 @@ function setTimeFactor(e) { | |||
$.post("/ajax/set_factor", getJsonData(selected)).fail(function(response) { | |||
// If the operation fails, get the real factor. | |||
getTimeFactor(); | |||
}).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/widgets.js
Outdated
@@ -72,8 +45,6 @@ function getTimeFactor() { | |||
selectTimeIcon(currentTimeFactor); | |||
getCurrentTime(); | |||
} | |||
}).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
agriculture/static/js/widgets.js
Outdated
@@ -88,27 +59,9 @@ function getCurrentTime() { | |||
}; | |||
timeWorker.postMessage(currentTime + "@@@" + currentTimeFactor); | |||
} | |||
}).fail(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
e09d50c
to
98ae006
Compare
@@ -283,10 +287,13 @@ def get_irrigation_stations(request): | |||
Stations corresponding to the controller with the ID provided in | |||
the request. | |||
""" | |||
# Check if the AJAX request is valid. | |||
error = check_ajax_request(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method does the same as the code you have placed below. Why was the call removed and the code replicated? If you want to change the way the method works, you can always create a new method and reuse it everywhere, that way you just write the code once and reuse everywhere.
agriculture/static/js/history.js
Outdated
0: {title: units}, | ||
}, | ||
vAxis: { | ||
// viewWindow: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to remove comments that are not useful. This only adds complexity to the code.
</button> | ||
</div> | ||
</div> | ||
<!-- <div class="card">--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, just remove this, if we wanted to recover it we can always go back to a previous commit that had this piece of code.
agriculture/static/js/dashboard.js
Outdated
@@ -905,15 +913,22 @@ function updateWeatherWidget() { | |||
// Updates the current weather data (icon, temperature and status). | |||
function updateCurrentWeather() { | |||
// Calculate average temperature. | |||
calculateAvgTemp(); | |||
//calculateAvgTemp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
@@ -188,14 +188,14 @@ | |||
}); | |||
|
|||
// Add 'click' callbacks to the weather and time buttons. | |||
$(".weather-button").click(setWeatherCondition); | |||
// $(".weather-button").click(setWeatherCondition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this if it is not necessary
// Get the weather condition and time factor from the irrigation controller. | ||
getWeatherCondition(); | ||
// Get the time factor from the irrigation controller. | ||
// getWeatherCondition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this if it is not necessary
<td><span id="wind_speed"><i class="fas fa-circle-notch fa-spin"></i></span> km/h</td> | ||
<td><span id="rain_diff"><i class="fas fa-circle-notch fa-spin"></i></span> L/m²</td> | ||
<td><span id="wind_speed"><i class="fas fa-circle-notch fa-spin"></i></span> km/h (<span id="wind_direction"><i class="fas fa-circle-notch fa-spin"></i></span>) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either fill this space with the tag contained in the or put the tag right after the to avoid having this blank line.
agriculture/index.html
Outdated
@@ -0,0 +1,10 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file required?
@@ -63,7 +63,8 @@ const INFO_WINDOW_CONTENT_CONTROLLER = "" + | |||
" <span class='digi-icon-color fas fa-wind fa-2x'></span>" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don´t know how to put this comment in source3.zip and source4.zip, so I put it here: Those files should not be committed.
agriculture/static/js/dashboard.js
Outdated
dir = "SW" | ||
if (controllerWindDir = 48) | ||
dir = "W" | ||
if (controllerWindDir = 56) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, this was fixed in a later commit, but just in case, use == to compare in an if block.
agriculture/static/js/dashboard.js
Outdated
@@ -956,7 +958,8 @@ function updateCurrentWeather() { | |||
currentWeatherIcon = SUN_GREEN; | |||
currentWeatherStatus = "sunny"; | |||
|
|||
rain = document.getElementById("rain_acc").innerText; | |||
//rain = document.getElementById("rain_acc").innerText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
@@ -64,7 +64,7 @@ const INFO_WINDOW_CONTENT_CONTROLLER = "" + | |||
" </div>" + | |||
" <div class='marker-info-value'>" + | |||
" <span id='infow-wind'>@@WIND@@</span> km/h (" + | |||
" <span id='infow-wind_dir'>@@WIND_DIR@@</span>)" + | |||
" <span id='infow-wind_dir'>@@WIND_DIR@@</span> )" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: The whitespace at the end may not be needed.
agriculture/static/js/history.js
Outdated
}); | ||
} else { | ||
drawChart("valve-" + macAddr + "-chart", valveData[macAddr], "Valve", "Closed/Open", "#0000CC"); | ||
} | ||
} | ||
|
||
//google.charts.load('current', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these lines if they are not needed.
98ae006
to
580ba0e
Compare
Signed-off-by: Victor Coman <[email protected]>
580ba0e
to
43d9741
Compare
No description provided.