Skip to content

Commit 97ff38e

Browse files
committed
add screensaver and fonts config section
1 parent dac102e commit 97ff38e

38 files changed

+1425
-76
lines changed

admin/components/head.admin.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
<html>
1010
<head>
1111
<meta charset="UTF-8" />
12-
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no, viewport-fit=cover">
13+
<meta name="mobile-web-app-capable" content="yes" />
1314
<meta name="msapplication-TileColor" content="<?=$config['colors']['primary']?>">
14-
<meta name="theme-color" content="<?=$config['colors']['primary']?>">
15+
<meta name="theme-color" content="<?=$config['colors']['status_bar'] ?? '#000000'?>">
16+
<meta name="apple-mobile-web-app-capable" content="yes" />
17+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
1518

1619
<title><?=$pageTitle ?></title>
1720

api/admin.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@
151151
$newConfig['background']['admin'] = $normalizePath($newConfig['background']['admin'] ?? null);
152152
$newConfig['background']['chroma'] = $normalizePath($newConfig['background']['chroma'] ?? null);
153153
$newConfig['collage']['placeholderpath'] = $normalizePath($newConfig['collage']['placeholderpath'] ?? null);
154+
$newConfig['screensaver']['image_source'] = $normalizePath($newConfig['screensaver']['image_source'] ?? null);
155+
$newConfig['screensaver']['video_source'] = $normalizePath($newConfig['screensaver']['video_source'] ?? null);
156+
if (isset($newConfig['screensaver']['switch_minutes'])) {
157+
$newConfig['screensaver']['switch_minutes'] = (int)$newConfig['screensaver']['switch_minutes'];
158+
}
159+
if (isset($newConfig['screensaver']['timeout_minutes'])) {
160+
$newConfig['screensaver']['timeout_minutes'] = (int)$newConfig['screensaver']['timeout_minutes'];
161+
}
162+
if (isset($newConfig['screensaver']['text_backdrop_opacity'])) {
163+
$newConfig['screensaver']['text_backdrop_opacity'] = (float)$newConfig['screensaver']['text_backdrop_opacity'];
164+
}
154165

155166
// Fonts selected via font picker
156167
$newConfig['textonpicture']['font'] = $normalizePath($newConfig['textonpicture']['font'] ?? null);
@@ -187,6 +198,11 @@
187198
$newConfig['login']['pin'] = '';
188199
}
189200

201+
// Normalize screensaver boolean values (checkbox submits strings)
202+
if (isset($newConfig['screensaver']['enabled'])) {
203+
$newConfig['screensaver']['enabled'] = filter_var($newConfig['screensaver']['enabled'], FILTER_VALIDATE_BOOLEAN);
204+
}
205+
190206
if (isset($newConfig['login']['rental_keypad']) && $newConfig['login']['rental_keypad'] == true) {
191207
if (strlen($newConfig['login']['rental_pin']) != 4 || $newConfig['login']['rental_pin'] === $newConfig['login']['pin']) {
192208
$logger->debug('Rental keypad pin reset.', $newConfig['login']);
@@ -327,8 +343,6 @@
327343
'Logo file is not a supported image type [' . $ext . ']. Logo disabled.',
328344
$newConfig['logo'],
329345
);
330-
} else {
331-
$logger->debug('Logo file is a supported image type [' . $ext . '], path saved.', $newConfig['logo']);
332346
}
333347
}
334348
}
@@ -343,7 +357,7 @@
343357
'message' => 'New config saved.',
344358
]);
345359
} catch (\Exception $exception) {
346-
$logger->error('ERROR: Config can not be saved!');
360+
$logger->error('ERROR: Config can not be saved!', ['error' => $exception->getMessage()]);
347361
echo json_encode([
348362
'status' => 'error',
349363
'message' => $exception->getMessage(),

api/settings.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@
4040
if (!empty($config['background']['chroma'])) {
4141
$config['background']['chroma'] = PathUtility::getPublicPath($config['background']['chroma']);
4242
}
43+
if (!empty($config['screensaver']['image_source']) && $config['screensaver']['mode'] !== 'folder') {
44+
$config['screensaver']['image_source'] = PathUtility::getPublicPath($config['screensaver']['image_source']);
45+
}
46+
if (!empty($config['screensaver']['video_source'])) {
47+
$config['screensaver']['video_source'] = PathUtility::getPublicPath($config['screensaver']['video_source']);
48+
}
49+
if (!empty($config['screensaver']['text_font'])) {
50+
$config['screensaver']['text_font'] = PathUtility::getPublicPath($config['screensaver']['text_font']);
51+
}
52+
if (!empty($config['fonts']['start_screen_title'])) {
53+
$config['fonts']['start_screen_title'] = PathUtility::getPublicPath($config['fonts']['start_screen_title']);
54+
}
55+
if (!empty($config['fonts']['event_text'])) {
56+
$config['fonts']['event_text'] = PathUtility::getPublicPath($config['fonts']['event_text']);
57+
}
58+
if (!empty($config['fonts']['screensaver_text'])) {
59+
$config['fonts']['screensaver_text'] = PathUtility::getPublicPath($config['fonts']['screensaver_text']);
60+
}
61+
if (!empty($config['fonts']['gallery_title'])) {
62+
$config['fonts']['gallery_title'] = PathUtility::getPublicPath($config['fonts']['gallery_title']);
63+
}
64+
if (empty($config['screensaver']['text_position'])) {
65+
$config['screensaver']['text_position'] = 'center';
66+
}
4367

4468
echo 'const config = ' . json_encode($config) . ';';
4569
echo 'const environment = ' . json_encode(new Environment()) . ';';

assets/js/admin/buttons.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ $(function () {
7878
});
7979
});
8080

81+
$('#screensaver-preview-btn').on('click', function (e) {
82+
e.preventDefault();
83+
window.open('../?screensaverPreview=1', '_blank');
84+
return false;
85+
});
86+
8187
$('#layout-generator').on('click', function (ev) {
8288
ev.preventDefault();
8389
window.open('../admin/generator');

assets/js/core.js

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint n/no-unsupported-features/node-builtins: "off" */
22
/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM processChromaImage remoteBuzzerClient rotaryController globalGalleryHandle photoboothTools photoboothPreview virtualKeyboard */
33

4+
/* global createScreensaver */
45
const photoBooth = (function () {
56
const PhotoStyle = {
67
PHOTO: 'photo',
@@ -40,6 +41,12 @@ const photoBooth = (function () {
4041
loaderMessage = loader.find('.stage-message'),
4142
loaderImage = loader.find('.stage-image'),
4243
resultPage = $('.stage[data-stage="result"]'),
44+
screensaverOverlay = $('#screensaver-overlay'),
45+
screensaverVideo = $('#screensaver-video'),
46+
screensaverImage = $('#screensaver-image'),
47+
screensaverTextTop = $('#screensaver-text-top'),
48+
screensaverTextCenter = $('#screensaver-text-center'),
49+
screensaverTextBottom = $('#screensaver-text-bottom'),
4350
previewIpcam = $('#preview--ipcam'),
4451
previewVideo = $('#preview--video'),
4552
previewFramePicture = $('#previewframe--picture'),
@@ -58,10 +65,20 @@ const photoBooth = (function () {
5865
config.preview.asBackground &&
5966
config.preview.mode === PreviewMode.DEVICE.valueOf() &&
6067
((config.commands.preview && !config.preview.bsm) || !config.commands.preview),
61-
timeToLive = config.picture.time_to_live * 1000,
68+
timeToLive = parseInt(config.picture.time_to_live, 10) * 1000,
6269
continuousCollageTime = config.collage.continuous_time * 1000,
6370
retryTimeout = config.picture.retry_timeout * 1000,
64-
notificationTimeout = config.ui.notification_timeout * 1000;
71+
notificationTimeout = config.ui.notification_timeout * 1000,
72+
screensaverMode = config.screensaver.mode,
73+
screensaverEnabled =
74+
config.screensaver.enabled &&
75+
config.screensaver.timeout_minutes > 0 &&
76+
(screensaverMode === 'gallery' ||
77+
screensaverMode === 'folder' ||
78+
(screensaverMode === 'video' ? !!config.screensaver.video_source : !!config.screensaver.image_source)),
79+
screensaverTimeoutMs = (config.screensaver.timeout_minutes || 0) * 60000,
80+
screensaverSwitchMs = (config.screensaver.switch_minutes || 1) * 60000,
81+
urlSafe = (src) => (src ? encodeURI(src) : '');
6582

6683
let timeOut,
6784
chromaFile = '',
@@ -86,7 +103,7 @@ const photoBooth = (function () {
86103
};
87104

88105
api.resetTimeOut = function () {
89-
if (timeToLive == 0) {
106+
if (timeToLive === 0) {
90107
return;
91108
}
92109
clearTimeout(timeOut);
@@ -137,8 +154,33 @@ const photoBooth = (function () {
137154
rotaryController.focusSet(startPage);
138155

139156
initPhotoSwipeFromDOM('#galimages');
157+
158+
api.screensaver.resetTimer();
159+
160+
const params = new URLSearchParams(window.location.search);
161+
if (params.has('screensaverPreview')) {
162+
api.screensaver.show(true);
163+
}
140164
};
141165

166+
api.screensaver = createScreensaver({
167+
config,
168+
environment,
169+
startPage,
170+
overlay: screensaverOverlay,
171+
videoEl: screensaverVideo,
172+
imageEl: screensaverImage,
173+
textTop: screensaverTextTop,
174+
textCenter: screensaverTextCenter,
175+
textBottom: screensaverTextBottom,
176+
screensaverEnabled,
177+
screensaverMode,
178+
screensaverTimeoutMs,
179+
screensaverSwitchMs,
180+
urlSafe,
181+
photoboothTools
182+
});
183+
142184
api.navbar = {
143185
open: function () {
144186
filternav.addClass('sidenav--open');
@@ -504,6 +546,7 @@ const photoBooth = (function () {
504546
videoBackground.hide();
505547
startPage.removeClass('stage--active');
506548
loader.addClass('stage--active');
549+
api.screensaver.hide();
507550

508551
if (config.get_request.countdown) {
509552
let getMode;
@@ -1254,6 +1297,8 @@ const photoBooth = (function () {
12541297
if (config.commands.post_photo) {
12551298
api.shellCommand('post-command', filename);
12561299
}
1300+
1301+
api.screensaver.resetTimer();
12571302
};
12581303

12591304
api.addImage = function (imageName) {
@@ -1470,6 +1515,17 @@ const photoBooth = (function () {
14701515
rotaryController.focusSet(startPage);
14711516
});
14721517

1518+
if (screensaverEnabled) {
1519+
$(document).on('click touchstart keydown mousemove', function () {
1520+
api.screensaver.resetTimer();
1521+
});
1522+
1523+
screensaverOverlay.on('click touchstart', function (e) {
1524+
e.preventDefault();
1525+
api.screensaver.resetTimer();
1526+
});
1527+
}
1528+
14731529
$('.cups-button').on('click', function (ev) {
14741530
ev.preventDefault();
14751531

0 commit comments

Comments
 (0)