Web-Push mit VAPID und Erinnerungs-Endpoint
This commit is contained in:
parent
67a1614081
commit
b50267e4f0
24 changed files with 1703 additions and 50 deletions
|
|
@ -1,6 +1,13 @@
|
|||
<?php
|
||||
/** @var array $errors */
|
||||
/** @var array|null $employee */
|
||||
/** @var bool $pushEnabled */
|
||||
/** @var bool $pushEligible */
|
||||
/** @var string|null $pushPublicKey */
|
||||
/** @var int $pushDeviceCount */
|
||||
/** @var string $pushSubscribeUrl */
|
||||
/** @var string $pushUnsubscribeUrl */
|
||||
/** @var string $pushTestUrl */
|
||||
$mustChange = (int) ($user['must_change_password'] ?? 0) === 1;
|
||||
?>
|
||||
<div class="page-head page-head--compact">
|
||||
|
|
@ -66,3 +73,58 @@ $mustChange = (int) ($user['must_change_password'] ?? 0) === 1;
|
|||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
<section class="card push-card"
|
||||
data-push
|
||||
data-vapid-key="<?= e($pushPublicKey ?? '') ?>"
|
||||
data-subscribe-url="<?= e($pushSubscribeUrl) ?>"
|
||||
data-unsubscribe-url="<?= e($pushUnsubscribeUrl) ?>"
|
||||
data-test-url="<?= e($pushTestUrl) ?>">
|
||||
<div class="card__head card__head--row">
|
||||
<div>
|
||||
<h2><svg class="ico ico--inline" aria-hidden="true"><use href="#i-bell"/></svg> App-Erinnerungen</h2>
|
||||
<p>Übergaben und Rücknahmen direkt aufs Smartphone – 8 Tage vor Mietbeginn, 1 Tag vor Mietbeginn und 1 Tag vor Mietende.</p>
|
||||
</div>
|
||||
<span class="pill <?= $pushDeviceCount > 0 ? 'pill--green' : 'pill--grey' ?>" data-push-count>
|
||||
<?= $pushDeviceCount > 0 ? $pushDeviceCount . ' Gerät' . ($pushDeviceCount === 1 ? '' : 'e') . ' aktiv' : 'nicht aktiviert' ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php if (!$pushEligible): ?>
|
||||
<div class="alert alert--warning">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-alert"/></svg>
|
||||
<div><strong>Kein Mitarbeiterkonto verknüpft.</strong> Push-Erinnerungen werden über das zuständige Mitarbeiterkonto zugeordnet. Ein Administrator kann das in der Benutzerverwaltung nachholen.</div>
|
||||
</div>
|
||||
<?php elseif (!$pushEnabled): ?>
|
||||
<div class="alert alert--warning">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-alert"/></svg>
|
||||
<div><strong>Push ist noch nicht eingerichtet.</strong> Der Administrator muss zuerst die VAPID-Schlüssel hinterlegen.</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="push-browser-hint" data-push-browser-hint>
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-download"/></svg>
|
||||
<div>
|
||||
<strong>Nur in der installierten App verfügbar.</strong>
|
||||
<p>Installiere Drink it cold über das Browser-Menü bzw. auf dem iPhone über „Zum Home-Bildschirm“. Danach kannst du hier Push-Erinnerungen für dieses Gerät aktivieren.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="push-controls" data-push-controls hidden>
|
||||
<label class="check check--boxed push-toggle">
|
||||
<input type="checkbox" data-push-toggle>
|
||||
<span>
|
||||
<strong>Erinnerungen auf diesem Gerät empfangen</strong>
|
||||
<small>Die Benachrichtigungs-Erlaubnis wird beim Aktivieren abgefragt.</small>
|
||||
</span>
|
||||
</label>
|
||||
<div class="push-status" data-push-status role="status" aria-live="polite"></div>
|
||||
<div class="push-actions">
|
||||
<button class="btn small" type="button" data-push-test hidden>
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-bell"/></svg> Test-Erinnerung senden
|
||||
</button>
|
||||
<span class="muted small">Die Zuordnung erfolgt über dein Mitarbeiterkonto.</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
/** @var array $values */
|
||||
/** @var array $errors */
|
||||
/** @var array $employees */
|
||||
/** @var int $pushCount */
|
||||
/** @var bool $pushAvailable */
|
||||
$isSelf = $editing !== null && (int) $editing['id'] === (int) auth_user()['id'];
|
||||
$fieldError = static fn (string $key): string => (string) ($errors[$key] ?? '');
|
||||
?>
|
||||
|
|
@ -130,6 +132,17 @@ $fieldError = static fn (string $key): string => (string) ($errors[$key] ?? '');
|
|||
<div><dt>Nachname</dt><dd><?= e($values['last_name'] ?: '–') ?></dd></div>
|
||||
<div><dt>Rolle</dt><dd><?= $values['role'] === 'admin' ? 'Administrator' : 'Mitarbeiter' ?></dd></div>
|
||||
<div><dt>Status</dt><dd><?= $values['status'] === 'active' ? 'aktiv' : 'deaktiviert' ?></dd></div>
|
||||
<?php if ($editing): ?>
|
||||
<div><dt>App-Erinnerungen</dt><dd>
|
||||
<?php if ($pushCount > 0): ?>
|
||||
<span class="pill pill--green"><svg class="ico" aria-hidden="true"><use href="#i-bell"/></svg> <?= (int) $pushCount ?> Gerät<?= $pushCount === 1 ? '' : 'e' ?></span>
|
||||
<?php elseif ($pushAvailable): ?>
|
||||
<span class="muted small">nicht aktiviert</span>
|
||||
<?php else: ?>
|
||||
<span class="muted small">Push nicht konfiguriert</span>
|
||||
<?php endif; ?>
|
||||
</dd></div>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
<div class="form-actions">
|
||||
<button class="btn primary btn--block" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-check"/></svg> Speichern</button>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
/** @var array $users */
|
||||
/** @var array $pushCounts */
|
||||
/** @var array $pushLastUpdate */
|
||||
/** @var bool $pushConfigured */
|
||||
?>
|
||||
<div class="page-head page-head--compact">
|
||||
<div>
|
||||
|
|
@ -30,6 +33,7 @@
|
|||
<th>Rolle</th>
|
||||
<th>Mitarbeiterkonto</th>
|
||||
<th>Status</th>
|
||||
<th>App-Erinnerungen</th>
|
||||
<th>Letzte Anmeldung</th>
|
||||
<th class="ta-right">Aktionen</th>
|
||||
</tr>
|
||||
|
|
@ -47,6 +51,19 @@
|
|||
<td><span class="pill <?= $row['role'] === 'admin' ? 'pill--blue' : 'pill--grey' ?>"><?= $row['role'] === 'admin' ? 'Administrator' : 'Mitarbeiter' ?></span></td>
|
||||
<td><?= e($row['employee_name'] ?: '–') ?></td>
|
||||
<td><span class="pill <?= $row['status'] === 'active' ? 'pill--green' : 'pill--red' ?>"><?= $row['status'] === 'active' ? 'aktiv' : 'deaktiviert' ?></span></td>
|
||||
<td>
|
||||
<?php $devices = (int) ($pushCounts[(int) $row['id']] ?? 0); ?>
|
||||
<?php if ($devices > 0): ?>
|
||||
<span class="pill pill--green" title="Zuletzt aktualisiert: <?= e(fmt_datetime($pushLastUpdate[(int) $row['id']] ?? null)) ?>">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-bell"/></svg>
|
||||
<?= $devices ?> Gerät<?= $devices === 1 ? '' : 'e' ?>
|
||||
</span>
|
||||
<?php elseif ($pushConfigured): ?>
|
||||
<span class="muted small">nicht aktiviert</span>
|
||||
<?php else: ?>
|
||||
<span class="muted small">–</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= e(fmt_datetime($row['last_login_at'])) ?></td>
|
||||
<td class="ta-right">
|
||||
<a class="btn small" href="<?= e(url('/admin/users/' . (int) $row['id'])) ?>"><svg class="ico" aria-hidden="true"><use href="#i-edit"/></svg> Bearbeiten</a>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
/** @var bool $isAdmin */
|
||||
/** @var string $today */
|
||||
/** @var bool $mailEnabled */
|
||||
/** @var bool $pushEnabled */
|
||||
$rangeUrl = static function (string $r) use ($employeeFilter, $showDone): string {
|
||||
$params = ['range' => $r];
|
||||
if ($employeeFilter > 0) {
|
||||
|
|
@ -33,10 +34,10 @@ foreach ($rows as $row) {
|
|||
<p class="page-head__lede">Automatisch aus Mietbeginn und Mietende berechnet – für den zuständigen Mitarbeiter.</p>
|
||||
</div>
|
||||
<div class="page-head__actions">
|
||||
<?php if ($isAdmin && $mailEnabled): ?>
|
||||
<form method="post" action="<?= e(url('/admin/reminders/send')) ?>" data-confirm="Fällige Erinnerungen jetzt per E-Mail an die Mitarbeiter senden?">
|
||||
<?php if ($isAdmin && ($mailEnabled || $pushEnabled)): ?>
|
||||
<form method="post" action="<?= e(url('/admin/reminders/send')) ?>" data-confirm="Fällige Erinnerungen jetzt per Push und E-Mail senden?">
|
||||
<?= csrf_field() ?>
|
||||
<button class="btn" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-mail"/></svg> E-Mail-Versand starten</button>
|
||||
<button class="btn" type="submit"><svg class="ico" aria-hidden="true"><use href="#i-bell"/></svg> Erinnerungen jetzt senden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<a class="btn primary" href="<?= e(url('/calendar')) ?>"><svg class="ico" aria-hidden="true"><use href="#i-calendar"/></svg> Kalender</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue