Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Vcoman/ces demo #6

wants to merge 13 commits into from

Conversation

victorcoman
Copy link
Collaborator

No description provided.

- Added some more fixes

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]>
…instead of the rain accumulated

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']
Copy link
Member

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")),
Copy link
Member

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):
Copy link
Member

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>
Copy link
Member

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) {
Copy link
Member

@rubenmoral rubenmoral Dec 13, 2021

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){
Copy link
Member

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){
Copy link
Member

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"]));
Copy link
Member

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', '');
Copy link
Member

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){
Copy link
Member

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 {.

@rubenmoral
Copy link
Member

Do not commit the source.zip file.

@@ -19,6 +19,7 @@
PARAM_CONTROLLER_ID = "controller_id"
PARAM_FARM_NAME = "farm_name"

ID_ERROR = "error"
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -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)
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -263,9 +270,7 @@ function getFarmStatus(first=true) {
return;
processFarmStatusResponse(data, first);
}
).fail(function(response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -353,8 +432,6 @@ function drawStationsCharts() {
drawMoistureChart(macAddr, true, true);
drawValveChart(macAddr, true, true);
}
}).fail(function(response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -72,8 +45,6 @@ function getTimeFactor() {
selectTimeIcon(currentTimeFactor);
getCurrentTime();
}
}).fail(function(response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@@ -88,27 +59,9 @@ function getCurrentTime() {
};
timeWorker.postMessage(currentTime + "@@@" + currentTimeFactor);
}
}).fail(function(response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

@victorcoman victorcoman force-pushed the vcoman/ces_demo branch 3 times, most recently from e09d50c to 98ae006 Compare December 15, 2021 12:20
@@ -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)
Copy link
Collaborator

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.

0: {title: units},
},
vAxis: {
// viewWindow: {
Copy link
Collaborator

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">-->
Copy link
Collaborator

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.

@@ -905,15 +913,22 @@ function updateWeatherWidget() {
// Updates the current weather data (icon, temperature and status).
function updateCurrentWeather() {
// Calculate average temperature.
calculateAvgTemp();
//calculateAvgTemp();
Copy link
Collaborator

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);
Copy link
Collaborator

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();
Copy link
Collaborator

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>)

Copy link
Collaborator

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.

@@ -0,0 +1,10 @@
<!DOCTYPE html>
Copy link
Collaborator

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>" +
Copy link
Collaborator

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.

dir = "SW"
if (controllerWindDir = 48)
dir = "W"
if (controllerWindDir = 56)
Copy link
Collaborator

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.

@@ -956,7 +958,8 @@ function updateCurrentWeather() {
currentWeatherIcon = SUN_GREEN;
currentWeatherStatus = "sunny";

rain = document.getElementById("rain_acc").innerText;
//rain = document.getElementById("rain_acc").innerText;
Copy link
Collaborator

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> )" +
Copy link
Collaborator

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.

});
} else {
drawChart("valve-" + macAddr + "-chart", valveData[macAddr], "Valve", "Closed/Open", "#0000CC");
}
}

//google.charts.load('current', {
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants