Skip to content

Commit

Permalink
add mp4 support on alert, fix token refresh, fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
emnbdx committed Feb 24, 2025
1 parent 1057049 commit 859e83d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
envkey_DBUSER: ${{ secrets.SANDBOX_DBUSER }}
envkey_DBPASSWORD: ${{ secrets.SANDBOX_DBPASSWORD }}
envkey_DBPREFIX: "sandbox_"
envkey_LOGLEVEL: "ERROR"
envkey_LOGLEVEL: "DEBUG"
envkey_BLOB_URL: "https://stockagehaovh.blob.core.windows.net"
envkey_BLOB_CONNECTION_STRING: ${{ secrets.SANDBOX_BLOB_CONNECTION_STRING }}
envkey_HA_URL: "https://www.helloasso-sandbox.com"
Expand Down
6 changes: 5 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@
if (!session_id())
@session_start();

$errorMiddleware = $app->addErrorMiddleware(false, true, true, $container->get(Logger::class));
if ($_SERVER['LOGLEVEL'] == "DEBUG") {
$errorMiddleware = $app->addErrorMiddleware(true, true, true, $container->get(Logger::class));
} else {
$errorMiddleware = $app->addErrorMiddleware(false, true, true, $container->get(Logger::class));
}

$app->get('/', [HomeController::class, 'index'])->setName('app_index');
$app->get('/forgot_password', [HomeController::class, 'forgotPassword'])->setName('app_forgot_password');
Expand Down
26 changes: 19 additions & 7 deletions public/js/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,23 @@ function processAlertQueue() {
var container = document.querySelector('.widget-alert-box');
container.innerHTML = '';

var img = document.createElement('img');
img.src = window.image;
img.style.maxWidth = '100%';
img.classList.add('fade');
container.appendChild(img);
let mediaElement;
if (window.image.endsWith('.mp4')) {
mediaElement = document.createElement('video');
mediaElement.src = window.image;
mediaElement.autoplay = true;
mediaElement.loop = true;
mediaElement.muted = false;
mediaElement.style.maxWidth = '100%';
mediaElement.classList.add('fade');
} else {
mediaElement = document.createElement('img');
mediaElement.src = window.image;
mediaElement.style.maxWidth = '100%';
mediaElement.classList.add('fade');
}

container.appendChild(mediaElement);

let eur = new Intl.NumberFormat('fr-FR', {
style: 'currency',
Expand All @@ -40,15 +52,15 @@ function processAlertQueue() {
var audio = new Audio(window.sound);

setTimeout(function () {
img.classList.add('show');
mediaElement.classList.add('show');
messageTemplate.classList.add('show');

audio.volume = window.sound_volume;
audio.play();
}, 100)

setTimeout(function () {
img.classList.remove('show');
mediaElement.classList.remove('show');
messageTemplate.classList.remove('show');
audio.pause();
audio.currentTime = 0;
Expand Down
2 changes: 1 addition & 1 deletion public/js/alert.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions src/Controllers/WidgetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function widgetEventDonation(Request $request, Response $response, array
);

$streamCache['amount'] = $result['amount'];
$streamCache['continuation_token'] = $result['continuationToken'];
$streamCache['continuation_token'] = $result['continuation_token'];

$totalAmount += $result['amount'];
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public function widgetEventDonationFetch(Request $request, Response $response, a
);

$streamCache['amount'] = $result['amount'];
$streamCache['continuation_token'] = $result['continuationToken'];
$streamCache['continuation_token'] = $result['continuation_token'];

$totalAmount += $result['amount'];
}
Expand Down Expand Up @@ -196,12 +196,12 @@ public function widgetAlert(Request $request, Response $response, array $args):
$charityStream->organization_slug,
$charityStream->form_slug,
0,
$cacheData->continuation_token,
$cacheData["continuation_token"],
);

if ($cacheData->continuation_token != $result['continuationToken']) {
if ($cacheData["continuation_token"] != $result['continuation_token']) {
$this->widgetRepository->updateAlertWidgetCacheData($charityStream->guid, [
"continuation_token" => $result['continuationToken']
"continuation_token" => $result['continuation_token']
]);
}

Expand Down Expand Up @@ -235,12 +235,12 @@ public function widgetAlertFetch(Request $request, Response $response, array $ar
$charityStream->organization_slug,
$charityStream->form_slug,
0,
$cacheData->continuation_token
$cacheData['continuation_token']
);

if ($cacheData->continuation_token != $result['continuationToken']) {
if ($cacheData['continuation_token'] != $result['continuation_token']) {
$this->widgetRepository->updateAlertWidgetCacheData($charityStream->guid, [
"continuation_token" => $result['continuationToken']
"continuation_token" => $result['continuation_token']
]);
}

Expand Down Expand Up @@ -280,14 +280,14 @@ public function widgetDonation(Request $request, Response $response, array $args
$result = $this->apiWrapper->getAllOrders(
$charityStream->organization_slug,
$charityStream->form_slug,
$cacheData->amount,
$cacheData->continuation_token,
$cacheData['amount'],
$cacheData['continuation_token'],
);

if ($cacheData->continuation_token != $result['continuationToken']) {
if ($cacheData['continuation_token'] != $result['continuation_token']) {
$this->widgetRepository->updateStreamDonationWidgetCacheData($charityStream->guid, [
"amount" => $result['amount'],
"continuation_token" => $result['continuationToken']
"continuation_token" => $result['continuation_token']
]);
}

Expand Down Expand Up @@ -320,14 +320,14 @@ public function widgetDonationFetch(Request $request, Response $response, array
$result = $this->apiWrapper->getAllOrders(
$charityStream->organization_slug,
$charityStream->form_slug,
$cacheData->amount,
$cacheData->continuation_token
$cacheData['amount'],
$cacheData['continuation_token']
);

if ($cacheData->continuation_token != $result['continuationToken']) {
if ($cacheData['continuation_token'] != $result['continuation_token']) {
$this->widgetRepository->updateStreamDonationWidgetCacheData($charityStream->guid, [
"amount" => $result['amount'],
"continuation_token" => $result['continuationToken']
"continuation_token" => $result['continuation_token']
]);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Repositories/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ private function checkType($formdata, $ext, $mimes)

private function isPicture($formdata)
{
$ext = ["gif", "heic", "heif", "jpg", "jpeg", "png", "webp"];
$ext = ["gif", "heic", "heif", "jpg", "jpeg", "png", "webp", "mp4"];
$mimes = [
"image/gif",
"image/heic",
"image/heif",
"image/jpeg",
"image/png",
"image/webp"
"image/webp",
"video/mp4"
];
$this->checkType($formdata, $ext, $mimes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/ApiWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public function getAllOrders($organizationSlug, $formSlug, $currentAmount = 0, $
return [
'amount' => $currentAmount,
'donations' => $donations,
'continuationToken' => $continuationToken
'continuation_token' => $continuationToken
];
}
}
2 changes: 1 addition & 1 deletion src/views/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Mot de passe réinitilisé</strong>
<strong class="me-auto">Mot de passe réinitialisé</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Expand Down
4 changes: 2 additions & 2 deletions src/views/stream/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@

<script>
var image = '{{ alertBoxWidgetPictureUrl }}';
var message_template = '{{ alertBoxWidget.message_template }}';
var message_template = '{{ alertBoxWidget.message_template | raw }}';
var sound = '{{ alertBoxWidgetSoundUrl }}';
var sound_volume = {{ alertBoxWidget.sound_volume / 100 }};
var alert_duration = {{ alertBoxWidget.alert_duration * 1000 }};
</script>

<script src="/js/main.min.js"></script>
<script src="/js/admin.min.js"></script>
<script src="/js/alert.min.js"></script>
<script src="/js/stream.min.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/views/stream/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<th>Guid</th>
<th>Titre</th>
<th>Admin</th>
<th>Slug formuaire</th>
<th>Slug formulaire</th>
<th>Slug association</th>
<th>Actions</th>
</tr>
Expand Down

0 comments on commit 859e83d

Please sign in to comment.