Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions www/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ ul.tabs li.current {
background-image:url(../img/master.png)
}

.ui-icon-fertigation:after {
background-image:url("data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20width%3D%2214px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2014%2014%22%20enable-background%3D%22new%200%200%2014%2014%22%20xml%3Aspace%3D%22preserve%22%3E%3Cg%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M3.5%2C3.5h-1.2v9h1.2V3.5z%20M3.5%2C3.5h4.5v1.2H4.7v2.5h3.1v1.2H4.7v6.1h-1.2V3.5z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E")
}

.ui-nosvg .ui-icon-fertigation:after {
background-image:url(../img/fertigation.png)
}

.ui-icon-relay:after {
background-image:url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2014%2014%22%3E%3Cg%20stroke%3D%22%23fff%22%20stroke-width%3D%22.75%22%20fill%3D%22none%22%3E%3Cg%3E%3Cpath%20d%3D%22M8.326%206.792%22%2F%3E%3Cpath%20stroke-linecap%3D%22square%22%20d%3D%22M9.726%207.192c0%20.5-.3.9-.7.9s-.7-.4-.7-.9.3-.9.7-.9c.4%200%20.7.4.7.9z%22%2F%3E%3Cpath%20stroke-linecap%3D%22square%22%20d%3D%22M9.926%207.192h4%22%2F%3E%3C%2Fg%3E%3Cg%20stroke-linecap%3D%22square%22%3E%3Cpath%20d%3D%22M4.174%207.192c0%20.5.3.9.7.9.4%200%20.7-.4.7-.9s-.3-.9-.7-.9c-.4%200-.7.4-.7.9z%22%2F%3E%3Cpath%20d%3D%22M3.974%207.192h-4%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3Cpath%20stroke%3D%22%23fff%22%20stroke-width%3D%22.75%22%20fill%3D%22none%22%20d%3D%22M8.3%206.8l-2.7-4%22%2F%3E%3C%2Fsvg%3E")
}
Expand Down
38 changes: 29 additions & 9 deletions www/js/modules/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,19 @@ OSApp.Dashboard.displayPage = function() {
( OSApp.Stations.isSpecial( sid ) ? "" : "hidden" ) + "'></span>";

if ( OSApp.Supported.groups() ) {
cards += "<span class='btn-no-border ui-btn card-icon station-gid " + ( OSApp.Stations.isMaster( sid ) ? "hidden" : "" ) +
cards += "<span class='btn-no-border ui-btn card-icon station-gid " + ( ( OSApp.Stations.isMaster( sid ) || ( OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid ) ) ) ? "hidden" : "" ) +
"'>" + OSApp.Groups.mapGIDValueToName( OSApp.Stations.getGIDValue( sid ) ) + "</span>";
}

cards += "<span class='btn-no-border ui-btn " + ( ( OSApp.Stations.isMaster( sid ) ) ? "ui-icon-master" : "ui-icon-gear" ) +
// Use fertigation icon for settings if it's a fertigation station, master icon if master, otherwise gear icon
var settingsIconClass = "ui-icon-gear";
if ( OSApp.Stations.isMaster( sid ) ) {
settingsIconClass = "ui-icon-master";
} else if ( OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid ) ) {
settingsIconClass = "ui-icon-fertigation";
}

cards += "<span class='btn-no-border ui-btn " + settingsIconClass +
" card-icon ui-btn-icon-notext station-settings' data-station='" + sid + "' id='attrib-" + sid + "' " +
( OSApp.Supported.master( OSApp.Constants.options.MASTER_STATION_1 ) ? ( "data-um='" + ( OSApp.StationAttributes.getMasterOperation( sid, OSApp.Constants.options.MASTER_STATION_1 ) ) + "' " ) : "" ) +
( OSApp.Supported.master( OSApp.Constants.options.MASTER_STATION_2 ) ? ( "data-um2='" + ( OSApp.StationAttributes.getMasterOperation( sid, OSApp.Constants.options.MASTER_STATION_2 ) ) + "' " ) : "" ) +
Expand All @@ -104,7 +112,9 @@ OSApp.Dashboard.displayPage = function() {
( OSApp.Supported.groups() ? ( "data-gid='" + OSApp.Stations.getGIDValue( sid ) + "' " ) : "" ) +
"></span>";

if ( !OSApp.Stations.isMaster( sid ) ) {
// Don't show status line for master or fertigation stations
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( !OSApp.Stations.isMaster( sid ) && !isFertigationStation ) {
if ( isScheduled || isRunning ) {

// Generate status line for station
Expand Down Expand Up @@ -393,7 +403,8 @@ OSApp.Dashboard.displayPage = function() {
( typeof sites[ currentSite ].images[ sid ] !== "string" ? OSApp.Language._( "Add" ) : OSApp.Language._( "Change" ) ) + " " + OSApp.Language._( "Image" ) +
"</button>";

if ( !OSApp.Stations.isMaster( sid ) ) {
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( !OSApp.Stations.isMaster( sid ) && !isFertigationStation ) {
if ( OSApp.Supported.master( OSApp.Constants.options.MASTER_STATION_1 ) ) {
select += "<label for='um'><input class='needsclick' data-iconpos='right' id='um' type='checkbox' " +
( ( button.data( "um" ) === 1 ) ? "checked='checked'" : "" ) + ">" + OSApp.Language._( "Use Master" ) + " " +
Expand Down Expand Up @@ -454,7 +465,8 @@ OSApp.Dashboard.displayPage = function() {
select += "<div id='tab-advanced' class='tab-content'>";

// Create sequential group selection menu
if ( OSApp.Supported.groups() && !OSApp.Stations.isMaster( sid ) ) {
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( OSApp.Supported.groups() && !OSApp.Stations.isMaster( sid ) && !isFertigationStation ) {
select +=
"<div class='ui-bar-a ui-bar seq-container'>" + OSApp.Language._( "Sequential Group" ) + ":</div>" +
"<select id='gid' class='seqgrp' data-mini='true'></select>" +
Expand Down Expand Up @@ -943,11 +955,17 @@ OSApp.Dashboard.displayPage = function() {

card.find( "#station_" + sid ).text( OSApp.Stations.getName( sid) );
card.find( ".special-station" ).removeClass( "hidden" ).addClass( OSApp.Stations.isSpecial( sid ) ? "" : "hidden" );

card.find( ".station-status" ).removeClass( "on off wait" ).addClass( isRunning ? "on" : ( isScheduled ? "wait" : "off" ) );

// Update settings icon based on station type
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( OSApp.Stations.isMaster( sid ) ) {
card.find( ".station-settings" ).removeClass( "ui-icon-gear" ).addClass( "ui-icon-master" );
card.find( ".station-settings" ).removeClass( "ui-icon-gear ui-icon-fertigation" ).addClass( "ui-icon-master" );
} else if ( isFertigationStation ) {
card.find( ".station-settings" ).removeClass( "ui-icon-gear ui-icon-master" ).addClass( "ui-icon-fertigation" );
} else {
card.find( ".station-settings" ).removeClass( "ui-icon-master" ).addClass( "ui-icon-gear" );
card.find( ".station-settings" ).removeClass( "ui-icon-master ui-icon-fertigation" ).addClass( "ui-icon-gear" );
}

card.find( ".station-settings" ).data( {
Expand All @@ -963,7 +981,8 @@ OSApp.Dashboard.displayPage = function() {
gid: OSApp.Supported.groups() ? OSApp.Stations.getGIDValue( sid ) : undefined
} );

if ( !OSApp.Stations.isMaster( sid ) && ( isScheduled || isRunning ) ) {
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( !OSApp.Stations.isMaster( sid ) && !isFertigationStation && ( isScheduled || isRunning ) ) {
line = ( isRunning ? OSApp.Language._( "Running" ) + " " + pname : OSApp.Language._( "Scheduled" ) + " " +
( OSApp.Stations.getStartTime( sid ) ? OSApp.Language._( "for" ) + " " + OSApp.Dates.dateToString( new Date( OSApp.Stations.getStartTime( sid ) * 1000 ) ) : pname ) );
if ( rem > 0 ) {
Expand Down Expand Up @@ -1074,7 +1093,8 @@ OSApp.Dashboard.displayPage = function() {
name = OSApp.Stations.getName( sid ),
question, dialogOptions = {};

if ( OSApp.Stations.isMaster( sid ) ) {
var isFertigationStation = OSApp.Supported.fertigation() && OSApp.Stations.isFertigation( sid );
if ( OSApp.Stations.isMaster( sid ) || isFertigationStation ) {
return false;
}

Expand Down
44 changes: 39 additions & 5 deletions www/js/modules/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,65 @@ OSApp.Dates.Constants = {
// TODO: mellodev some of this should refactor out to programs.js?

OSApp.Dates.getDateRange = function( pid ) {
return OSApp.currentSession.controller.programs.pd[ pid ][ 6 ];
if ( pid === "new" ) {
return [ 0, OSApp.Dates.Constants.minEncodedDate, OSApp.Dates.Constants.maxEncodedDate ];
}

var prog = OSApp.currentSession.controller.programs.pd[ pid ];
if ( !prog ) {
return [ 0, OSApp.Dates.Constants.minEncodedDate, OSApp.Dates.Constants.maxEncodedDate ];
}

// Determine format: if fertigation is supported OR index 5 is an array, use new format
var drIndex;
var useNewFormat = false;
if ( OSApp.Supported && OSApp.Supported.fertigation && OSApp.Supported.fertigation() ) {
useNewFormat = true;
} else if ( prog[ 5 ] && Array.isArray( prog[ 5 ] ) ) {
useNewFormat = true;
}

if ( useNewFormat ) {
// New format: date range at index 7
drIndex = 7;
} else {
// Old format: date range at index 6
drIndex = 6;
}

var dr = prog[ drIndex ];
if ( !dr || !Array.isArray( dr ) ) {
return [ 0, OSApp.Dates.Constants.minEncodedDate, OSApp.Dates.Constants.maxEncodedDate ];
}

return dr;
};

OSApp.Dates.isDateRangeEnabled = function( pid ) {
if ( pid === "new" ) {
return 0;
}

return OSApp.Dates.getDateRange( pid )[ 0 ];
var dr = OSApp.Dates.getDateRange( pid );
return dr && dr[ 0 ] ? 1 : 0;
};

OSApp.Dates.getDateRangeStart = function( pid ) {
if ( pid === "new" ) {
return OSApp.Dates.Constants.minEncodedDate;
}

return OSApp.Dates.getDateRange( pid )[ 1 ];
var dr = OSApp.Dates.getDateRange( pid );
return dr && dr[ 1 ] !== undefined ? dr[ 1 ] : OSApp.Dates.Constants.minEncodedDate;
};

OSApp.Dates.getDateRangeEnd = function( pid ) {
if ( pid === "new" ) {
return OSApp.Dates.Constants.maxEncodedDate; //
return OSApp.Dates.Constants.maxEncodedDate;
}

return OSApp.Dates.getDateRange( pid )[ 2 ];
var dr = OSApp.Dates.getDateRange( pid );
return dr && dr[ 2 ] !== undefined ? dr[ 2 ] : OSApp.Dates.Constants.maxEncodedDate;
};

OSApp.Dates.extractDateFromString = function( inputString ) {
Expand Down
2 changes: 1 addition & 1 deletion www/js/modules/firmware.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ OSApp.Firmware.sendToOS = function( dest, type ) {
type = type || "text";

// Designate AJAX queue based on command type
var isChange = /\/(?:cv|cs|cr|cp|uwa|dp|co|cl|cu|up|cm)/.exec( dest ),
var isChange = /\/(?:cv|cs|cr|cp|uwa|dp|co|cl|cu|up|cm|cf)/.exec( dest ),
queue = isChange ? "change" : "default",

// Use POST when sending data to the controller (requires firmware 2.1.8 or newer)
Expand Down
63 changes: 58 additions & 5 deletions www/js/modules/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,35 @@ OSApp.Options.showOptions = function( expandItem ) {
opt = OSApp.Utils.transformKeys( opt );
$.mobile.loading( "show" );

// Handle fertigation station separately if supported
var fertStationId = null;
if ( OSApp.Supported && OSApp.Supported.fertigation && OSApp.Supported.fertigation() ) {
var fertStationSelect = page.find( "#fertilizer-station-1" );
if ( fertStationSelect.length ) {
fertStationId = parseInt( fertStationSelect.val(), 10 );
}
}

OSApp.Firmware.sendToOS( "/co?pw=&" + $.param( opt ) ).done( function() {
$.mobile.document.one( "pageshow", function() {
OSApp.Errors.showError( OSApp.Language._( "Settings have been saved" ) );
} );
OSApp.UIDom.goBack();
OSApp.Sites.updateController( OSApp.Weather.updateWeather );
// Save fertigation station if configured
if ( fertStationId !== null ) {
OSApp.Stations.setFertilizerStations( fertStationId, function( success ) {
if ( !success ) {
OSApp.Errors.showError( OSApp.Language._( "Error saving fertigation station" ) );
}
$.mobile.document.one( "pageshow", function() {
OSApp.Errors.showError( OSApp.Language._( "Settings have been saved" ) );
} );
OSApp.UIDom.goBack();
OSApp.Sites.updateController( OSApp.Weather.updateWeather );
} );
} else {
$.mobile.document.one( "pageshow", function() {
OSApp.Errors.showError( OSApp.Language._( "Settings have been saved" ) );
} );
OSApp.UIDom.goBack();
OSApp.Sites.updateController( OSApp.Weather.updateWeather );
}
} ).fail( function() {
button.prop( "disabled", false );
page.find( ".submit" ).addClass( "hasChanges" );
Expand Down Expand Up @@ -494,6 +517,36 @@ OSApp.Options.showOptions = function( expandItem ) {
}
}

// Add fertigation station configuration
// Always show fertigation selector - backend will handle unsupported cases
var currentFertStation = 255; // Default to "not configured"
if ( OSApp.currentSession && OSApp.currentSession.controller && OSApp.currentSession.controller.fertigation && OSApp.currentSession.controller.fertigation.fert_station !== undefined ) {
currentFertStation = OSApp.currentSession.controller.fertigation.fert_station;
}

var stationCount = 0;
if ( OSApp.currentSession && OSApp.currentSession.controller && OSApp.currentSession.controller.stations && OSApp.currentSession.controller.stations.snames ) {
stationCount = OSApp.currentSession.controller.stations.snames.length;
}

list += "<hr style='width:95%' class='content-divider'>";
list += "<div class='ui-field-contain ui-field-no-border'><label for='fertilizer-station-1' class='select'>" +
OSApp.Language._( "Fertigation Station" ) +
"</label><select data-mini='true' id='fertilizer-station-1'><option value='255'" + ( currentFertStation === 255 ? " selected" : "" ) + ">" + OSApp.Language._( "None" ) + "</option>";

if ( stationCount > 0 ) {
for ( i = 0; i < stationCount; i++ ) {
if ( !OSApp.Stations.isMaster( i ) ) { // Don't allow master stations as fertigation stations
var stationName = OSApp.Stations.getName( i );
list += "<option " + ( currentFertStation === i ? "selected" : "" ) + " value='" + i + "'>" +
stationName + "</option>";
}
}
} else {
list += "<option value='0'>No stations available</option>";
}
list += "</select></div>";

list += "</fieldset><fieldset data-role='collapsible'" +
( typeof expandItem === "string" && expandItem === "station" ? " data-collapsed='false'" : "" ) + "><legend>" +
OSApp.Language._( "Station Handling" ) + "</legend>";
Expand Down
Loading