Skip to content

Commit

Permalink
Merge pull request #4230 from AllskyTeam/4226-bug-image-resize-parame…
Browse files Browse the repository at this point in the history
…ters-in-web-gui-are-not-saved-and-revert-to-0

4226 bug image resize parameters in web gui are not saved and revert to 0
  • Loading branch information
EricClaeys authored Jan 22, 2025
2 parents 63fe890 + b3a09fb commit 91538ad
Show file tree
Hide file tree
Showing 6 changed files with 412 additions and 283 deletions.
7 changes: 7 additions & 0 deletions config_repo/options.json.repo
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@
"label" : "Width",
"label_prefix" : "Daily Timelapse",
"type" : "integer",
"checkchanges" : true,
"booldependson" : "timelapsegenerate"
},
{
Expand All @@ -1365,6 +1366,7 @@
"label" : "Height",
"label_prefix" : "Daily Timelapse",
"type" : "integer",
"checkchanges" : true,
"booldependson" : "timelapsegenerate"
},
{
Expand All @@ -1376,6 +1378,7 @@
"label" : "Bitrate",
"label_prefix" : "Daily Timelapse",
"type" : "integer",
"checkchanges" : true,
"booldependson" : "timelapsegenerate"
},
{
Expand Down Expand Up @@ -1480,6 +1483,7 @@
"label" : "Width",
"label_prefix" : "Mini-Timelapse",
"type" : "integer",
"checkchanges" : true,
"valuedependson" : "minitimelapsenumimages=[1-9]*"
},
{
Expand All @@ -1491,6 +1495,7 @@
"label" : "Height",
"label_prefix" : "Mini-Timelapse",
"type" : "integer",
"checkchanges" : true,
"valuedependson" : "minitimelapsenumimages=[1-9]*"
},
{
Expand Down Expand Up @@ -1735,6 +1740,7 @@
"description" : "Resized width of uploaded images. <span class='WebUIValue'>0</span> means don't resize.",
"label" : "Resize Uploaded Images Width",
"type" : "integer",
"checkchanges" : true,
"booldependson" : "imageupload"
},
{
Expand All @@ -1745,6 +1751,7 @@
"description" : "Resized height of uploaded images. <span class='WebUIValue'>0</span> means don't resize.",
"label" : "Resize Uploaded Images Height",
"type" : "integer",
"checkchanges" : true,
"booldependson" : "imageupload"
},
{
Expand Down
15 changes: 12 additions & 3 deletions scripts/convertJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
// Limit output to only settings whose "carryforward" is true.
// Output the setting name and setting type.

// --null
// Output "null" for any null setting value. Normally "" would be output.

// --convert
// Convert the field names to all lower case,
// boolean values to true or false,
Expand Down Expand Up @@ -86,6 +89,7 @@ function quoteIt($string, $type)
$options_only = false;
$options_array = null;
$only_in_settings_file = false; // use only settings that are in settings file?
$default_setting_value="";

$rest_index;
$longopts = array(
Expand All @@ -103,6 +107,7 @@ function quoteIt($string, $type)
"options-only",
"convert",
"order",
"null",
"shell",
"debug",
);
Expand Down Expand Up @@ -152,6 +157,9 @@ function quoteIt($string, $type)
} else if ($opt === "order") {
$order = true;

} else if ($opt === "null") {
$default_setting_value = $opt;

} else if ($opt === "delimiter") {
$delimiter = $val;

Expand Down Expand Up @@ -196,14 +204,15 @@ function quoteIt($string, $type)
$type_array = Array();

foreach ($options_array as $option) {
$type = getVariableOrDefault($option, 'type', "");
$type = getVariableOrDefault($option, 'type', "null");
if ($type_to_output !== "" && $type_to_output !== $type) {
continue;
}

$name = $option['name'];
if ($carryforward && getVariableOrDefault($option, 'carryforward', "false") === "true") {
echo "$prefix$name\t$type\n";
$value = getVariableOrDefault($settings_array, $name, $default_setting_value);
echo "$prefix$name\t$type\t$value\n";
continue;
}

Expand Down Expand Up @@ -265,7 +274,7 @@ function quoteIt($string, $type)
// Convert settings names to lowercase.
// Make sure booleans are output without quotes.
// $mode handles no quotes around numbers.
//

$a = Array();
foreach ($settings_array as $name => $value) {
$name = strtolower($name);
Expand Down
42 changes: 23 additions & 19 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ NOT_STARTED_MSG="Can't start Allsky!"
STOPPED_MSG="Allsky Stopped!"
ERROR_MSG_PREFIX="*** ERROR ***\n${STOPPED_MSG}\n"
FATAL_MSG="FATAL ERROR:"

if [[ ${ON_TTY} == "true" ]]; then
export NL="\n"
export SPACES=" "
Expand All @@ -36,6 +37,13 @@ else
export WSVe="</span>"
fi

##### output messages with appropriate color strings
o_() { echo -e "${wOK}${1}${wNC}" ; }
w_() { echo -e "${wWARNING}${1}${wNC}" ; }
e_() { echo -e "${wERROR}${1}${wNC}" ; }
d_() { echo -e "${wDEBUG}DEBUG: ${1}${wNC}" ; }


##### Start and Stop Allsky
function start_Allsky()
{
Expand Down Expand Up @@ -729,6 +737,8 @@ function checkPixelValue()
local MIN=${4}
local MAX="${5}"

[[ ${VALUE} -eq 0 ]] && return 0

local MIN_MSG MAX_MSG
if [[ ${MIN} == "any" ]]; then
MIN="-99999999" # a number we'll never go below
Expand Down Expand Up @@ -759,30 +769,24 @@ function checkPixelValue()
# Assume each number has already been checked, e.g., it's not a string.
function checkWidthHeight()
{
local NAME="${1}"
local NAME_PREFIX="${1}"
local ITEM="${2}"
local WIDTH="${3}"
local HEIGHT="${4}"
local SENSOR_WIDTH="${5}"
local SENSOR_HEIGHT="${6}"
local ERR=""
local ERR

# Width and height must both be 0 or non-zero.
if [[ (${WIDTH} -gt 0 && ${HEIGHT} -eq 0) || (${WIDTH} -eq 0 && ${HEIGHT} -gt 0) ]]; then
ERR+="${WSNs}${NAME} Width${WSNe} (${WSVs}${WIDTH}${WSVe})"
ERR+=" and ${WSNs}${NAME} Height${WSNe} (${WSVs}${HEIGHT}${WSVe})"
ERR+=" must both be either 0 or non-zero.\n"
ERR+="The ${ITEM} will NOT be resized since it would look unnatural.\n"
ERR+="FIX: Either set both numbers to 0 to not resize,"
ERR+=" or set both numbers to something greater than 0."
ERR="${WSNs}${NAME_PREFIX} Width${WSNe} (${WSVs}${WIDTH}${WSVe})"
ERR+=" and ${WSNs}Height${WSNe} (${WSVs}${HEIGHT}${WSVe})"
ERR+=" must both be either 0 or non-zero.${wBR}"
ERR+="The ${ITEM} will NOT be resized since it would look unnatural."

elif [[ ${WIDTH} -gt 0 && ${HEIGHT} -gt 0 &&
${SENSOR_WIDTH} -eq ${WIDTH} && ${SENSOR_HEIGHT} -eq ${HEIGHT} ]]; then
ERR+="Resizing a ${ITEM} to the same size as the sensor does nothing useful.\n"
ERR+="FIX: Check ${WSNs}${NAME} Width${WSNe} (${WIDTH}) and"
ERR+=" ${WSNs}${NAME} Height${WSNe} (${HEIGHT})"
ERR+=" and set them to something other than the sensor size"
ERR+=" (${WSVs}${SENSOR_WIDTH} x ${SENSOR_HEIGHT}${WSVe})."
ERR="Resizing a ${ITEM} to the same size as the sensor does nothing useful."
fi

[[ -z ${ERR} ]] && return 0
Expand All @@ -808,23 +812,23 @@ function checkCropValues()
local ERR=""
if [[ ${CROP_TOP} -lt 0 || ${CROP_RIGHT} -lt 0 ||
${CROP_BOTTOM} -lt 0 || ${CROP_LEFT} -lt 0 ]]; then
ERR+="\nCrop numbers must all be positive."
ERR+="${wBR}Crop numbers must all be positive."
fi
if [[ $((CROP_TOP % 2)) -eq 1 || $((CROP_RIGHT % 2)) -eq 1 ||
$((CROP_BOTTOM % 2)) -eq 1 || $((CROP_LEFT % 2)) -eq 1 ]]; then
ERR+="\nCrop numbers must all be even."
ERR+="${wBR}Crop numbers must all be even."
fi
if [[ ${CROP_TOP} -gt $((MAX_RESOLUTION_Y -2)) ]]; then
ERR+="\nCropping on top (${CROP_TOP}) is larger than the image height (${MAX_RESOLUTION_Y})."
ERR+="${wBR}Cropping on top (${CROP_TOP}) is larger than the image height (${MAX_RESOLUTION_Y})."
fi
if [[ ${CROP_RIGHT} -gt $((MAX_RESOLUTION_X - 2)) ]]; then
ERR+="\nCropping on right (${CROP_RIGHT}) is larger than the image width (${MAX_RESOLUTION_X})."
ERR+="${wBR}Cropping on right (${CROP_RIGHT}) is larger than the image width (${MAX_RESOLUTION_X})."
fi
if [[ ${CROP_BOTTOM} -gt $((MAX_RESOLUTION_Y - 2)) ]]; then
ERR+="\nCropping on bottom (${CROP_BOTTOM}) is larger than the image height (${MAX_RESOLUTION_Y})."
ERR+="${wBR}Cropping on bottom (${CROP_BOTTOM}) is larger than the image height (${MAX_RESOLUTION_Y})."
fi
if [[ ${CROP_LEFT} -gt $((MAX_RESOLUTION_X - 2)) ]]; then
ERR+="\nCropping on left (${CROP_LEFT}) is larger than the image width (${MAX_RESOLUTION_X})."
ERR+="${wBR}Cropping on left (${CROP_LEFT}) is larger than the image width (${MAX_RESOLUTION_X})."
fi

if [[ -z ${ERR} ]]; then
Expand Down
3 changes: 1 addition & 2 deletions scripts/installUpgradeFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ function replace_website_placeholders()

# Keep track if the file changed.
local OLD_SUM="$( sum "${FILE}" )"
"${ALLSKY_SCRIPTS}/updateWebsiteConfig.sh" --verbosity silent \
--config "${FILE}" \
"${ALLSKY_SCRIPTS}/updateJsonFile.sh" --verbosity silent --file "${FILE}" \
config.imageName "imageName" "${IMAGE_NAME}" \
config.latitude "latitude" "${LATITUDE}" \
config.longitude "longitude" "${LONGITUDE}" \
Expand Down
Loading

0 comments on commit 91538ad

Please sign in to comment.