diff --git a/config/config.inc.php b/config/config.inc.php index 8e82879ad..1ed72711b 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -127,6 +127,9 @@ $config['gallery']['date_format'] = 'd.m.Y - G:i'; $config['gallery_pictureTime'] = '3000'; $config['gallery_bottom_bar'] = true; +$config['gallery_db_check_enabled'] = true; +$config['gallery_db_check_time'] = '10'; + // PhotoSwipe $config['pswp_clickToCloseNonZoomable'] = false; $config['pswp_closeOnScroll'] = false; diff --git a/gallery.php b/gallery.php index 5027bf161..b4195cfd1 100644 --- a/gallery.php +++ b/gallery.php @@ -10,7 +10,6 @@ // to detect changes $resp = array('dbsize'=>getDBSize()); exit(json_encode($resp)); - } $images = getImagesFromDB(); @@ -101,7 +100,9 @@ + + diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index 77a2b68c3..8c5b4489d 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -818,6 +818,17 @@ 'name' => 'gallery_pictureTime', 'value' => $config['gallery_pictureTime'] ], + 'gallery_db_check_enabled' => [ + 'type' => 'checkbox', + 'name' => 'gallery_db_check_enabled', + 'value' => $config['gallery_db_check_enabled'] + ], + 'db_check_time' => [ + 'type' => 'input', + 'placeholder' => $defaultConfig['gallery_db_check_time'], + 'name' => 'gallery_db_check_time', + 'value' => $config['gallery_db_check_time'] + ], 'pswp_clickToCloseNonZoomable' => [ 'type' => 'checkbox', 'name' => 'pswp_clickToCloseNonZoomable', diff --git a/resources/lang/en.json b/resources/lang/en.json index 92be4332c..73d81a00e 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -51,6 +51,8 @@ "gallery": "Gallery", "gallery_bottom_bar": "Show button bar inside gallery on bottom", "gallery_date_format": "Date style", + "gallery_db_check_enabled": "Continuously check for new pictures in standalone gallery", + "gallery_db_check_time": "Interval at which the database is checked for new images (in seconds):", "gallery_no_image": "The gallery is still empty. Take some pictures!", "gallery_pictureTime": "Milliseconds an image is displayed at slideshow", "gallery_pswp_bgOpacity": "Background opacity", @@ -144,6 +146,8 @@ "manual_force_buzzer": "If enabled, the take picture and collage buttons disappear. You now get a button which tells to use a buzzer to take a picture or collage.", "manual_gallery_bottom_bar": "If enabled, the button bar is shown in the gallery below.", "manual_gallery_date_format": "Enter your date style.", + "manual_gallery_db_check_enabled": "If enabled, Photobooth continuously checks for new pictures in standalone gallery and reloads the page on inactivity (time of inactivity depends on \"Show image after capture:\" option).", + "manual_gallery_db_check_time": "Add the interval (in seconds) the database get checked for new images.", "manual_gallery_pictureTime": "Add a value which is used as milliseconds an image is displayed at slideshow inside the gallery.", "manual_gallery_pswp_bgOpacity": "Background opacity, low values make the background more transparent.", "manual_general_camera_mode": "Choose between front- or back facing camera mode of your device cam.", diff --git a/src/js/gallery_updatecheck.js b/src/js/gallery_updatecheck.js index 84584dc19..2b8e6a268 100644 --- a/src/js/gallery_updatecheck.js +++ b/src/js/gallery_updatecheck.js @@ -4,8 +4,8 @@ * If changes are detected, the page will automatically be reloaded. * * Needs: - * jQuery - * photoBooth Javascript + * - jQuery + * - photoBooth Javascript * * Remarks: * - Not made for highly demanded pages (as pages is requested regulary @@ -18,7 +18,7 @@ // Size of the DB - is used to determine changes let lastDBSize = -1; // Interval, the page is checked (/ms) -const interval = 1000 * 5; +const interval = 1000 * config.gallery_db_check_time; // URL to request for changes const ajaxurl = 'gallery.php?status'; @@ -34,7 +34,10 @@ function dbUpdated() { const checkForUpdates = function () { if (photoBooth.isTimeOutPending()) { - //If there is user interaction, do not check for updates + // If there is user interaction, do not check for updates + if (config.dev) { + console.log('Timeout pending, waiting to refresh the standalone gallery'); + } return; } $.getJSON({