Skip to content

Conversation

@victorcoman
Copy link

No description provided.

Signed-off-by: Victor Coman <victor.coman@digi.com>
- Added some more fixes

Signed-off-by: Victor Coman <victor.coman@digi.com>
Signed-off-by: Victor Coman <victor.coman@digi.com>
… controls.

Signed-off-by: Victor Coman <victor.coman@digi.com>
… controls.

Signed-off-by: Victor Coman <victor.coman@digi.com>
…ature intervals

Signed-off-by: Victor Coman <victor.coman@digi.com>
- Wind direction in dashboard
- Server errors in history
- Accumulated rain in dashboard
- Rain limits
- Reduce refreshing time

Signed-off-by: Victor Coman <victor.coman@digi.com>
Signed-off-by: Victor Coman <victor.coman@digi.com>
…instead of the rain accumulated

Signed-off-by: Victor Coman <victor.coman@digi.com>
Signed-off-by: Victor Coman <victor.coman@digi.com>
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.


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.

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.

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.

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.

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.

Signed-off-by: Victor Coman <victor.coman@digi.com>
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.

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

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.

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.

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.

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.

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.

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

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.

};
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
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.

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


// 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?

" <hr/>" +
" <div class='marker-info-element'>" +
" <div class='marker-info-icon'>" +
" <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.

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

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

}
}

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

Signed-off-by: Victor Coman <victor.coman@digi.com>
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.

5 participants