Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
config: allow to disable continous check for new pictures
Browse files Browse the repository at this point in the history
- also allow to adjust the time our database get checked for updates

Change-Id: Ic20cb370b0bd8b1c71c3885e2b3c035aba5ac9a9
  • Loading branch information
andi34 committed Oct 27, 2020
1 parent 946e72a commit 4810829
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
3 changes: 3 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// to detect changes
$resp = array('dbsize'=>getDBSize());
exit(json_encode($resp));

}

$images = getImagesFromDB();
Expand Down Expand Up @@ -101,7 +100,9 @@
<script type="text/javascript" src="resources/js/theme.js"></script>
<script type="text/javascript" src="resources/js/core.js"></script>
<script type="text/javascript" src="resources/js/gallery.js"></script>
<?php if ($config['gallery_db_check_enabled']): ?>
<script type="text/javascript" src="resources/js/gallery_updatecheck.js"></script>
<?php endif; ?>
<script src="node_modules/@andreasremdt/simple-translator/dist/umd/translator.min.js"></script>
<script type="text/javascript" src="resources/js/i18n.js"></script>
</body>
Expand Down
11 changes: 11 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down
11 changes: 7 additions & 4 deletions src/js/gallery_updatecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';

Expand All @@ -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({
Expand Down

0 comments on commit 4810829

Please sign in to comment.