";
// 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 +=
"
" + OSApp.Language._( "Sequential Group" ) + ":
" +
"
" +
@@ -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( {
@@ -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 ) {
@@ -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;
}
diff --git a/www/js/modules/dates.js b/www/js/modules/dates.js
index 519aa0dea..361ace839 100644
--- a/www/js/modules/dates.js
+++ b/www/js/modules/dates.js
@@ -25,7 +25,38 @@ 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 ) {
@@ -33,7 +64,8 @@ OSApp.Dates.isDateRangeEnabled = function( pid ) {
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 ) {
@@ -41,15 +73,17 @@ OSApp.Dates.getDateRangeStart = function( pid ) {
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 ) {
diff --git a/www/js/modules/firmware.js b/www/js/modules/firmware.js
index 2bf634e77..170e067bc 100644
--- a/www/js/modules/firmware.js
+++ b/www/js/modules/firmware.js
@@ -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)
diff --git a/www/js/modules/options.js b/www/js/modules/options.js
index f470489e7..882fd743a 100644
--- a/www/js/modules/options.js
+++ b/www/js/modules/options.js
@@ -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" );
@@ -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 += "
";
+ list += "
";
+
list += "
";
+ } else if ( fertigationSupported && OSApp.Stations.isFertigation( i ) ) {
+ // Fertigation station - disabled like master station
list += "