В интерфейсе показываем только те действия, что разрешены правом
This commit is contained in:
1 parent
cb7d40aaff
commit
5552239161
15 files changed
+257
-104
No files matched your search
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use Rsgrinko\Proton\Access\AccessDenied;
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Access\Viewer;
|
||||
use Rsgrinko\Proton\Database\Model\Model;
|
||||
use Rsgrinko\Proton\Events\Events;
|
||||
@@ -25,7 +26,7 @@ final class TrashController extends Controller
|
||||
{
|
||||
public function index(Request $request, Viewer $viewer): Response
|
||||
{
|
||||
$kinds = $this->allowed($viewer);
|
||||
$kinds = $this->visible($viewer);
|
||||
|
||||
if ($kinds === []) {
|
||||
throw new AccessDenied('Корзина пуста для вашей роли');
|
||||
@@ -40,13 +41,16 @@ final class TrashController extends Controller
|
||||
->paginate($this->page($request), $this->perPage());
|
||||
|
||||
return $this->view('admin/trash', [
|
||||
'active' => 'trash',
|
||||
'kinds' => $kinds,
|
||||
'counts' => $this->counts($kinds),
|
||||
'kind' => $key,
|
||||
'label' => $kind['label'],
|
||||
'title' => $kind['title'],
|
||||
'page' => $page ?? ['items' => [], 'total' => 0, 'page' => 1, 'pages' => 1, 'per_page' => 0],
|
||||
'active' => 'trash',
|
||||
'kinds' => $kinds,
|
||||
'counts' => $this->counts($kinds),
|
||||
'kind' => $key,
|
||||
'label' => $kind['label'],
|
||||
'title' => $kind['title'],
|
||||
// Смотреть раздел корзины и возвращать/добивать из него — разные права:
|
||||
// trash.view даёт только первое
|
||||
'canAct' => $this->canAct($viewer, $kind),
|
||||
'page' => $page ?? ['items' => [], 'total' => 0, 'page' => 1, 'pages' => 1, 'per_page' => 0],
|
||||
], 'Корзина');
|
||||
}
|
||||
|
||||
@@ -103,7 +107,7 @@ final class TrashController extends Controller
|
||||
], ['action' => 'Действие']);
|
||||
|
||||
$key = (string) $request->input('kind', '');
|
||||
$kinds = $this->allowed($viewer);
|
||||
$kinds = $this->actionable($viewer);
|
||||
|
||||
if (!isset($kinds[$key])) {
|
||||
throw new AccessDenied('Этот раздел корзины вам не доступен');
|
||||
@@ -153,7 +157,7 @@ final class TrashController extends Controller
|
||||
public function clear(Request $request, Viewer $viewer): Response
|
||||
{
|
||||
$key = (string) $request->input('kind', '');
|
||||
$kinds = $this->allowed($viewer);
|
||||
$kinds = $this->actionable($viewer);
|
||||
|
||||
if (!isset($kinds[$key])) {
|
||||
throw new AccessDenied('Этот раздел корзины вам не доступен');
|
||||
@@ -181,7 +185,7 @@ final class TrashController extends Controller
|
||||
private function find(Request $request, Viewer $viewer): array
|
||||
{
|
||||
$key = (string) $request->input('kind', '');
|
||||
$kinds = $this->allowed($viewer);
|
||||
$kinds = $this->actionable($viewer);
|
||||
|
||||
if (!isset($kinds[$key])) {
|
||||
throw new AccessDenied('Этот раздел корзины вам не доступен');
|
||||
@@ -200,21 +204,50 @@ final class TrashController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Разделы, доступные этому человеку.
|
||||
* Разделы, которые этому человеку видно, — своё право раздела, а если
|
||||
* его нет, хватает и общего trash.view (или trash.manage — кто может
|
||||
* действовать, тот и видит).
|
||||
*
|
||||
* @return array<string, array{model: class-string<Model>, label: string, title: callable, permission: string}>
|
||||
*/
|
||||
private function allowed(Viewer $viewer): array
|
||||
private function visible(Viewer $viewer): array
|
||||
{
|
||||
$allowed = [];
|
||||
$visible = [];
|
||||
|
||||
foreach (Trash::kinds() as $key => $kind) {
|
||||
if ($kind['permission'] === '' || $viewer->can($kind['permission'])) {
|
||||
$allowed[$key] = $kind;
|
||||
if ($kind['permission'] === '' || $viewer->can($kind['permission']) || $viewer->canAny([Permission::TRASH_VIEW, Permission::TRASH_MANAGE])) {
|
||||
$visible[$key] = $kind;
|
||||
}
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
return $visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Разделы, в которых этому человеку можно возвращать и добивать записи —
|
||||
* trash.view сюда не пускает, только своё право раздела или trash.manage.
|
||||
*
|
||||
* @return array<string, array{model: class-string<Model>, label: string, title: callable, permission: string}>
|
||||
*/
|
||||
private function actionable(Viewer $viewer): array
|
||||
{
|
||||
$actionable = [];
|
||||
|
||||
foreach (Trash::kinds() as $key => $kind) {
|
||||
if ($kind['permission'] === '' || $viewer->can($kind['permission']) || $viewer->can(Permission::TRASH_MANAGE)) {
|
||||
$actionable[$key] = $kind;
|
||||
}
|
||||
}
|
||||
|
||||
return $actionable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{model: class-string<Model>, label: string, title: callable, permission: string} $kind
|
||||
*/
|
||||
private function canAct(Viewer $viewer, array $kind): bool
|
||||
{
|
||||
return $kind['permission'] === '' || $viewer->can($kind['permission']) || $viewer->can(Permission::TRASH_MANAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,11 @@ declare(strict_types=1);
|
||||
* @var bool $ftp задан ли FTP для отправки копий
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Backup\Backup;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$canManage = View::can(Permission::BACKUPS_MANAGE);
|
||||
?>
|
||||
<h1>Резервные копии</h1>
|
||||
|
||||
@@ -55,12 +58,14 @@ use Rsgrinko\Proton\View\View;
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="row" style="margin-top: 12px;">
|
||||
<form method="post" action="<?= View::e(View::route('admin.backups.store')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="primary">Сделать копию</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="row" style="margin-top: 12px;">
|
||||
<form method="post" action="<?= View::e(View::route('admin.backups.store')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="primary">Сделать копию</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<p class="muted small">
|
||||
Восстановление — только из консоли: <span class="mono">php bin/proton backup:restore <файл> --force</span>.
|
||||
@@ -80,7 +85,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<th>Файл</th>
|
||||
<th>Размер</th>
|
||||
<th class="hide-sm">Когда</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($files as $file) { ?>
|
||||
@@ -88,6 +93,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<td class="mono small break"><?= View::e($file['name']) ?></td>
|
||||
<td><?= View::e(Backup::size($file['size'])) ?></td>
|
||||
<td class="hide-sm muted small"><?= View::e(View::date($file['created'])) ?></td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<div class="row end">
|
||||
<form method="post" action="<?= View::e(View::route('admin.backups.download')) ?>">
|
||||
@@ -117,6 +123,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
@@ -10,11 +10,13 @@ declare(strict_types=1);
|
||||
* @var array<string, array{label: string, token: string, handler: callable}> $sources
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Models\IncomingHook;
|
||||
use Rsgrinko\Proton\Support\Config;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$base = rtrim((string) Config::get('app.url', ''), '/');
|
||||
$canManage = View::can(Permission::WEBHOOKS_MANAGE);
|
||||
$base = rtrim((string) Config::get('app.url', ''), '/');
|
||||
|
||||
/**
|
||||
* Тело посылки человеку: в базе оно лежит как есть, на экране — с отступами.
|
||||
@@ -148,11 +150,13 @@ $pretty = static function (mixed $payload): string {
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="right">
|
||||
<?php if ($canManage) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.incoming.test')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<input type="hidden" name="source" value="<?= View::e((string) $key) ?>">
|
||||
<button type="submit">Проверить</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
@@ -12,10 +12,12 @@ declare(strict_types=1);
|
||||
* @var array<int, array{name: string, interval: int, at: string, last: string, fromFinish: bool}> $schedule
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Queue\Queue;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$badges = [
|
||||
$canManage = View::can(Permission::QUEUE_MANAGE);
|
||||
$badges = [
|
||||
Queue::QUEUED => 'info',
|
||||
Queue::RUNNING => 'warn',
|
||||
Queue::DONE => 'ok',
|
||||
@@ -46,7 +48,7 @@ $badges = [
|
||||
<th>Задача</th>
|
||||
<th>Когда</th>
|
||||
<th>Последний раз</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($schedule as $task) { ?>
|
||||
@@ -59,6 +61,7 @@ $badges = [
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="muted small"><?= View::e($task['last'] === '' ? 'ни разу' : View::ago($task['last'])) ?></td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<form method="post" action="<?= View::e(View::route('admin.queue.run')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
@@ -66,6 +69,7 @@ $badges = [
|
||||
<button type="submit" data-confirm="Выполнить «<?= View::e($task['name']) ?>» прямо сейчас?">Выполнить</button>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
@@ -81,6 +85,7 @@ $badges = [
|
||||
<?php if ($page['items'] === []) { ?>
|
||||
<p class="muted">Ничего не нашлось.</p>
|
||||
<?php } else { ?>
|
||||
<?php if ($canManage) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.queue.retry')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
|
||||
@@ -99,11 +104,12 @@ $badges = [
|
||||
|
||||
<span class="muted small" data-check-count>ничего не отмечено</span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
<th>Задача</th>
|
||||
<th>Очередь</th>
|
||||
<th><?= View::partial('sort', ['filters' => $filters, 'route' => 'admin.queue', 'column' => 'priority', 'label' => 'Важность']) ?></th>
|
||||
@@ -117,7 +123,7 @@ $badges = [
|
||||
<?php foreach ($page['items'] as $job) { ?>
|
||||
<?php $status = (string) $job['status']; ?>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ids[]" value="<?= (int) $job['id'] ?>" data-check-item></td>
|
||||
<?php if ($canManage) { ?><td><input type="checkbox" name="ids[]" value="<?= (int) $job['id'] ?>" data-check-item></td><?php } ?>
|
||||
<td>
|
||||
<span class="mono small"><?= View::e((string) $job['job_class']) ?></span>
|
||||
|
||||
@@ -138,7 +144,7 @@ $badges = [
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php if ($canManage) { ?></form><?php } ?>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'admin.queue',
|
||||
|
||||
@@ -9,11 +9,16 @@ declare(strict_types=1);
|
||||
* @var array<string, array<string, string>> $groups права по разделам
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$isNew = !$role->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.roles.create') : View::route('admin.roles.show', ['id' => $role->id()]);
|
||||
$granted = $role->permissions();
|
||||
$isNew = !$role->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.roles.create') : View::route('admin.roles.show', ['id' => $role->id()]);
|
||||
$granted = $role->permissions();
|
||||
// Новая роль — только у тех, кто прошёл can:roles.manage в маршруте; карточку
|
||||
// существующей открывает и roles.view — тогда поля и галочки не трогать
|
||||
$canManage = View::can(Permission::ROLES_MANAGE);
|
||||
$readOnly = !$isNew && !$canManage;
|
||||
?>
|
||||
<h1><?= $isNew ? 'Новая роль' : View::e((string) $role->name) ?></h1>
|
||||
|
||||
@@ -23,12 +28,12 @@ $granted = $role->permissions();
|
||||
|
||||
<label>
|
||||
<span>Название</span>
|
||||
<input type="text" name="name" value="<?= View::e((string) $role->name) ?>" <?= $isNew ? 'autofocus' : '' ?> required>
|
||||
<input type="text" name="name" value="<?= View::e((string) $role->name) ?>" <?= $isNew ? 'autofocus' : '' ?> <?= $readOnly ? 'disabled' : '' ?> required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span>Описание</span>
|
||||
<input type="text" name="description" value="<?= View::e((string) $role->description) ?>">
|
||||
<input type="text" name="description" value="<?= View::e((string) $role->description) ?>" <?= $readOnly ? 'disabled' : '' ?>>
|
||||
</label>
|
||||
|
||||
<?php if ($role->isSystem()) { ?>
|
||||
@@ -46,7 +51,7 @@ $granted = $role->permissions();
|
||||
<?php foreach ($permissions as $code => $label) { ?>
|
||||
<label class="inline" style="margin-bottom: 6px;">
|
||||
<input type="checkbox" name="permissions[]" value="<?= View::e($code) ?>"
|
||||
<?= in_array($code, $granted, true) ? 'checked' : '' ?>>
|
||||
<?= in_array($code, $granted, true) ? 'checked' : '' ?> <?= $readOnly ? 'disabled' : '' ?>>
|
||||
<span><?= View::e($label) ?> <span class="muted mono"><?= View::e($code) ?></span></span>
|
||||
</label>
|
||||
<?php } ?>
|
||||
@@ -55,13 +60,13 @@ $granted = $role->permissions();
|
||||
<?php } ?>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit" class="primary">Сохранить</button>
|
||||
<?php if (!$readOnly) { ?><button type="submit" class="primary">Сохранить</button><?php } ?>
|
||||
<a class="btn" href="<?= View::e(View::route('admin.roles')) ?>">К списку</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php if (!$isNew && !$role->isSystem()) { ?>
|
||||
<?php if (!$isNew && !$role->isSystem() && $canManage) { ?>
|
||||
<div class="card">
|
||||
<h2>Удаление</h2>
|
||||
<p class="muted small">Роль удаляется, только если она никому не выдана.</p>
|
||||
|
||||
@@ -8,12 +8,15 @@ declare(strict_types=1);
|
||||
* @var array<int, \Rsgrinko\Proton\Models\Role> $roles
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
?>
|
||||
<div class="row">
|
||||
<h1 style="margin: 0;">Роли</h1>
|
||||
<span class="spacer"></span>
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.roles.create')) ?>">Новая роль</a>
|
||||
<?php if (View::can(Permission::ROLES_MANAGE)) { ?>
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.roles.create')) ?>">Новая роль</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 16px;">
|
||||
|
||||
@@ -12,12 +12,16 @@ declare(strict_types=1);
|
||||
* @var array<string, int> $top самые шумные адреса за сутки
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Models\SecurityEvent;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$canManage = View::can(Permission::SECURITY_MANAGE);
|
||||
?>
|
||||
<h1>Безопасность</h1>
|
||||
|
||||
<div class="grid cols-2">
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="card">
|
||||
<h2>Закрыть адрес</h2>
|
||||
|
||||
@@ -47,6 +51,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<h2>Кого подбирают</h2>
|
||||
@@ -75,6 +80,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<td class="mono small"><?= View::e((string) $ip) ?></td>
|
||||
<td class="right"><?= (int) $count ?></td>
|
||||
<td class="right">
|
||||
<?php if ($canManage) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.security.block')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<input type="hidden" name="ip" value="<?= View::e((string) $ip) ?>">
|
||||
@@ -82,6 +88,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<input type="hidden" name="minutes" value="60">
|
||||
<button type="submit">Закрыть на час</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@@ -104,7 +111,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<th>Адрес</th>
|
||||
<th>Причина</th>
|
||||
<th>До</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($blocks as $block) { ?>
|
||||
@@ -118,6 +125,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<?= View::e(View::date($block->until())) ?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<form method="post" action="<?= View::e(View::route('admin.security.unblock')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
@@ -125,6 +133,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<button type="submit">Открыть</button>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
@@ -153,7 +162,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<th>Адрес</th>
|
||||
<th>Логин</th>
|
||||
<th class="hide-sm">Страница</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $event) { ?>
|
||||
@@ -163,6 +172,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<td class="mono small"><?= View::e((string) $event->raw('ip')) ?></td>
|
||||
<td class="small"><?= View::e((string) $event->raw('login') ?: '—') ?></td>
|
||||
<td class="hide-sm muted small"><?= View::e((string) $event->raw('path') ?: '—') ?></td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<?php if ((string) $event->raw('ip') !== '') { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.security.block')) ?>">
|
||||
@@ -174,6 +184,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</form>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
@@ -9,8 +9,11 @@ declare(strict_types=1);
|
||||
* @var array<string, mixed> $values текущие значения
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Support\Settings;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$canManage = View::can(Permission::SETTINGS_MANAGE);
|
||||
?>
|
||||
<h1>Настройки</h1>
|
||||
|
||||
@@ -28,6 +31,7 @@ use Rsgrinko\Proton\View\View;
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('admin.settings')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<fieldset <?= $canManage ? '' : 'disabled' ?> style="border: 0; padding: 0; margin: 0;">
|
||||
|
||||
<?php foreach ($groups as $title => $items) { ?>
|
||||
<div class="card">
|
||||
@@ -79,11 +83,15 @@ use Rsgrinko\Proton\View\View;
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<button type="submit" class="primary">Сохранить</button>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<button type="submit" class="primary">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
@@ -101,20 +109,21 @@ foreach ($groups as $items) {
|
||||
<?php if ($overridden !== []) { ?>
|
||||
<div class="card">
|
||||
<h2>Изменённые настройки</h2>
|
||||
<p class="muted small">Эти значения взяты из базы. Сброс вернёт то, что задано в <span class="mono">.env</span>.</p>
|
||||
<p class="muted small">Эти значения взяты из базы<?= $canManage ? '. Сброс вернёт то, что задано в <span class="mono">.env</span>.' : '.' ?></p>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th>Настройка</th>
|
||||
<th>Ключ</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($overridden as $key => $label) { ?>
|
||||
<tr>
|
||||
<td><?= View::e($label) ?></td>
|
||||
<td class="mono small"><?= View::e($key) ?></td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<form method="post" action="<?= View::e(View::route('admin.settings.reset')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
@@ -122,6 +131,7 @@ foreach ($groups as $items) {
|
||||
<button type="submit">Сбросить</button>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
@@ -18,12 +18,14 @@ declare(strict_types=1);
|
||||
* @var string $php
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Support\Diagnostics;
|
||||
use Rsgrinko\Proton\Support\Str;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$badges = [Diagnostics::OK => 'ok', Diagnostics::WARN => 'warn', Diagnostics::ERROR => 'error'];
|
||||
$labels = [Diagnostics::OK => 'в порядке', Diagnostics::WARN => 'внимание', Diagnostics::ERROR => 'проблема'];
|
||||
$badges = [Diagnostics::OK => 'ok', Diagnostics::WARN => 'warn', Diagnostics::ERROR => 'error'];
|
||||
$labels = [Diagnostics::OK => 'в порядке', Diagnostics::WARN => 'внимание', Diagnostics::ERROR => 'проблема'];
|
||||
$canManage = View::can(Permission::SYSTEM_MANAGE);
|
||||
?>
|
||||
<h1>Состояние</h1>
|
||||
|
||||
@@ -92,7 +94,7 @@ $labels = [Diagnostics::OK => 'в порядке', Diagnostics::WARN => 'вни
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if (View::can('system.manage')) { ?>
|
||||
<?php if (View::can(Permission::SYSTEM_MANAGE)) { ?>
|
||||
<div class="row" style="margin-top: 12px;">
|
||||
<form method="post" action="<?= View::e(View::route('admin.system.action', ['action' => 'queue-retry'])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
@@ -138,7 +140,7 @@ $labels = [Diagnostics::OK => 'в порядке', Diagnostics::WARN => 'вни
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (View::can('system.manage')) { ?>
|
||||
<?php if (View::can(Permission::SYSTEM_MANAGE)) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.system.action', ['action' => 'schedule-run'])) ?>" style="margin-top: 12px;">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit">Выполнить, что пора</button>
|
||||
@@ -175,7 +177,7 @@ $labels = [Diagnostics::OK => 'в порядке', Diagnostics::WARN => 'вни
|
||||
он держит загруженные классы в памяти, и задачи продолжали бы выполняться старым кодом.
|
||||
</p>
|
||||
|
||||
<?php if (View::can('system.manage')) { ?>
|
||||
<?php if (View::can(Permission::SYSTEM_MANAGE)) { ?>
|
||||
<div class="row">
|
||||
<form method="post" action="<?= View::e(View::route('admin.system.action', ['action' => 'worker-restart'])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
|
||||
@@ -12,7 +12,10 @@ declare(strict_types=1);
|
||||
* @var string $issued только что выпущенный ключ — показывается один раз
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$canManage = View::can(Permission::TOKENS_MANAGE);
|
||||
?>
|
||||
<h1>Ключи API</h1>
|
||||
|
||||
@@ -25,6 +28,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="card">
|
||||
<h2>Выпустить ключ</h2>
|
||||
|
||||
@@ -67,6 +71,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?= View::partial('filters', ['filters' => $filters, 'route' => 'admin.tokens', 'total' => $page['total']]) ?>
|
||||
|
||||
@@ -87,7 +92,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<th>Состояние</th>
|
||||
<th class="hide-sm">Срок</th>
|
||||
<th class="hide-sm">Использован</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $token) { ?>
|
||||
@@ -117,6 +122,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="hide-sm muted small"><?= View::e(View::ago((string) $token->raw('last_used_at'))) ?></td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<div class="row end">
|
||||
<?php if ((int) $token->raw('active') === 1) { ?>
|
||||
@@ -132,6 +138,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
* @var string $label его подпись
|
||||
* @var callable $title как назвать запись
|
||||
* @var array{items: array<int, \Rsgrinko\Proton\Database\Model\Model>, total: int, page: int, pages: int, per_page: int} $page
|
||||
* @var bool $canAct смотреть раздел и возвращать/добивать из него — разные права
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Database\Model\Model;
|
||||
@@ -22,7 +23,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<div class="row">
|
||||
<?php foreach ($kinds as $key => $item) { ?>
|
||||
<?php if ($key === $kind) { ?>
|
||||
<span class="badge info"><?= View::e($item['label']) ?>: <?= (int) ($counts[$key] ?? 0) ?></span>
|
||||
<span class="btn small primary"><?= View::e($item['label']) ?> (<?= (int) ($counts[$key] ?? 0) ?>)</span>
|
||||
<?php } else { ?>
|
||||
<a class="btn small" href="<?= View::e(View::route('admin.trash', ['kind' => $key])) ?>">
|
||||
<?= View::e($item['label']) ?> (<?= (int) ($counts[$key] ?? 0) ?>)
|
||||
@@ -40,7 +41,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<h2 style="margin: 0;"><?= View::e($label) ?></h2>
|
||||
<span class="spacer"></span>
|
||||
|
||||
<?php if (($counts[$kind] ?? 0) > 0) { ?>
|
||||
<?php if ($canAct && ($counts[$kind] ?? 0) > 0) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.trash.clear')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<input type="hidden" name="kind" value="<?= View::e($kind) ?>">
|
||||
@@ -55,6 +56,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<?php if ($page['items'] === []) { ?>
|
||||
<p class="muted">Здесь пусто — ничего не удаляли или всё уже вернули.</p>
|
||||
<?php } else { ?>
|
||||
<?php if ($canAct) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.trash.bulk')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<input type="hidden" name="kind" value="<?= View::e($kind) ?>">
|
||||
@@ -66,21 +68,23 @@ use Rsgrinko\Proton\View\View;
|
||||
],
|
||||
'confirm' => 'Выполнить действие над отмеченными записями? Удаление совсем — без возврата.',
|
||||
]) ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th></th>
|
||||
<?php if ($canAct) { ?><th></th><?php } ?>
|
||||
<th>Запись</th>
|
||||
<th>Удалена</th>
|
||||
<th></th>
|
||||
<?php if ($canAct) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $record) { ?>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ids[]" value="<?= $record->id() ?>" data-check-item></td>
|
||||
<?php if ($canAct) { ?><td><input type="checkbox" name="ids[]" value="<?= $record->id() ?>" data-check-item></td><?php } ?>
|
||||
<td><?= View::e(($title)($record)) ?></td>
|
||||
<td class="muted small nowrap"><?= View::e(View::ago((string) $record->raw(Model::DELETED_AT))) ?></td>
|
||||
<?php if ($canAct) { ?>
|
||||
<td class="right">
|
||||
<div class="row end">
|
||||
<form method="post" action="<?= View::e(View::route('admin.trash.restore')) ?>">
|
||||
@@ -98,11 +102,12 @@ use Rsgrinko\Proton\View\View;
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<?php if ($canAct) { ?></form><?php } ?>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'admin.trash',
|
||||
|
||||
@@ -17,15 +17,28 @@ use Rsgrinko\Proton\Auth\Password;
|
||||
use Rsgrinko\Proton\Models\UserField;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$isNew = !$user->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.users.create') : View::route('admin.users.show', ['id' => $user->id()]);
|
||||
$hint = $isNew ? 'пусто — придумаем сами' : 'пусто — не менять';
|
||||
$isNew = !$user->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.users.create') : View::route('admin.users.show', ['id' => $user->id()]);
|
||||
$hint = $isNew ? 'пусто — придумаем сами' : 'пусто — не менять';
|
||||
// Новый — только у тех, кто прошёл can:users.manage в маршруте; карточку же
|
||||
// существующего человека открывает и users.view — форму правки там не покажем
|
||||
$canManage = View::can(Permission::USERS_MANAGE);
|
||||
|
||||
$roleName = '—';
|
||||
foreach ($roles as $role) {
|
||||
if ($role->id() === (int) $user->raw('role_id')) {
|
||||
$roleName = (string) $role->name;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<?php if (!$isNew) { ?><?= View::avatar($user) ?><?php } ?>
|
||||
<h1 style="margin: 0;"><?= $isNew ? 'Новый пользователь' : View::e((string) $user->login) ?></h1>
|
||||
</div>
|
||||
|
||||
<?php if ($isNew || $canManage) { ?>
|
||||
<div class="card">
|
||||
<form method="post" action="<?= View::e($action) ?>">
|
||||
<?= View::csrf() ?>
|
||||
@@ -74,6 +87,28 @@ $hint = $isNew ? 'пусто — придумаем сами' : 'пусто
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="card">
|
||||
<dl class="props">
|
||||
<dt>Логин</dt>
|
||||
<dd><?= View::e((string) $user->login) ?></dd>
|
||||
|
||||
<dt>Имя</dt>
|
||||
<dd><?= $user->name !== '' ? View::e((string) $user->name) : '<span class="muted">—</span>' ?></dd>
|
||||
|
||||
<dt>Почта</dt>
|
||||
<dd><?= $user->email !== '' ? View::e((string) $user->email) : '<span class="muted">—</span>' ?></dd>
|
||||
|
||||
<dt>Роль</dt>
|
||||
<dd><?= View::e($roleName) ?></dd>
|
||||
|
||||
<dt>Активен</dt>
|
||||
<dd><?= $user->isActive() ? 'да' : 'нет' ?></dd>
|
||||
</dl>
|
||||
|
||||
<p style="margin-top: 12px;"><a class="btn" href="<?= View::e(View::route('admin.users')) ?>">К списку</a></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (!$isNew) { ?>
|
||||
<div class="card">
|
||||
@@ -155,15 +190,17 @@ $hint = $isNew ? 'пусто — придумаем сами' : 'пусто
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<h2>Удаление</h2>
|
||||
<p class="muted small">Пользователь исчезнет вместе со своими сеансами. Его записи останутся.</p>
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="card">
|
||||
<h2>Удаление</h2>
|
||||
<p class="muted small">Пользователь исчезнет вместе со своими сеансами. Его записи останутся.</p>
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('admin.users.delete', ['id' => $user->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="danger">Удалить пользователя</button>
|
||||
</form>
|
||||
</div>
|
||||
<form method="post" action="<?= View::e(View::route('admin.users.delete', ['id' => $user->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="danger">Удалить пользователя</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($user->id() > 0) { ?>
|
||||
|
||||
@@ -10,12 +10,19 @@ declare(strict_types=1);
|
||||
* @var \Rsgrinko\Proton\Support\Filters $filters
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
// Список открыт и по users.view — правки и массовые действия показываем
|
||||
// только тому, у кого есть users.manage
|
||||
$canManage = View::can(Permission::USERS_MANAGE);
|
||||
?>
|
||||
<div class="row">
|
||||
<h1 style="margin: 0;">Пользователи</h1>
|
||||
<span class="spacer"></span>
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.users.create')) ?>">Новый пользователь</a>
|
||||
<?php if ($canManage) { ?>
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.users.create')) ?>">Новый пользователь</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 16px;">
|
||||
@@ -26,6 +33,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<?php if ($page['items'] === []) { ?>
|
||||
<p class="muted">Ничего не нашлось.</p>
|
||||
<?php } else { ?>
|
||||
<?php if ($canManage) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.users.bulk')) ?>">
|
||||
<?= View::csrf() ?>
|
||||
|
||||
@@ -37,11 +45,12 @@ use Rsgrinko\Proton\View\View;
|
||||
],
|
||||
'confirm' => 'Выполнить действие над отмеченными пользователями?',
|
||||
]) ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
<th></th>
|
||||
<th><?= View::partial('sort', ['filters' => $filters, 'route' => 'admin.users', 'column' => 'login', 'label' => 'Логин']) ?></th>
|
||||
<th class="hide-sm">Имя</th>
|
||||
@@ -53,7 +62,7 @@ use Rsgrinko\Proton\View\View;
|
||||
|
||||
<?php foreach ($page['items'] as $user) { ?>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ids[]" value="<?= $user->id() ?>" data-check-item></td>
|
||||
<?php if ($canManage) { ?><td><input type="checkbox" name="ids[]" value="<?= $user->id() ?>" data-check-item></td><?php } ?>
|
||||
<td><?= View::avatar($user) ?></td>
|
||||
<td><a href="<?= View::e(View::route('admin.users.show', ['id' => $user->id()])) ?>"><?= View::e((string) $user->login) ?></a></td>
|
||||
<td class="hide-sm"><?= View::e((string) $user->name) ?></td>
|
||||
@@ -72,7 +81,7 @@ use Rsgrinko\Proton\View\View;
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<?php if ($canManage) { ?></form><?php } ?>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'admin.users',
|
||||
|
||||
@@ -11,14 +11,18 @@ declare(strict_types=1);
|
||||
* @var string $fresh только что выданный секрет — показывается один раз
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Models\Webhook;
|
||||
use Rsgrinko\Proton\Models\WebhookDelivery;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$isNew = !$webhook->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.webhooks.create') : View::route('admin.webhooks.show', ['id' => $webhook->id()]);
|
||||
$selected = $webhook->events();
|
||||
$all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
$isNew = !$webhook->existsInDatabase();
|
||||
$action = $isNew ? View::route('admin.webhooks.create') : View::route('admin.webhooks.show', ['id' => $webhook->id()]);
|
||||
$selected = $webhook->events();
|
||||
$all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
$canManage = View::can(Permission::WEBHOOKS_MANAGE);
|
||||
$canDelete = View::can(Permission::WEBHOOKS_DELETE);
|
||||
$readOnly = !$isNew && !$canManage;
|
||||
?>
|
||||
<h1><?= $isNew ? 'Новый вебхук' : View::e((string) $webhook->name) ?></h1>
|
||||
|
||||
@@ -37,12 +41,12 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
|
||||
<label>
|
||||
<span>Название</span>
|
||||
<input type="text" name="name" value="<?= View::e((string) $webhook->name) ?>" placeholder="склад 1С" <?= $isNew ? 'autofocus' : '' ?>>
|
||||
<input type="text" name="name" value="<?= View::e((string) $webhook->name) ?>" placeholder="склад 1С" <?= $isNew ? 'autofocus' : '' ?> <?= $readOnly ? 'disabled' : '' ?>>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span>Адрес подписчика</span>
|
||||
<input type="url" name="url" value="<?= View::e((string) $webhook->url) ?>" placeholder="https://example.com/hooks/proton" required>
|
||||
<input type="url" name="url" value="<?= View::e((string) $webhook->url) ?>" placeholder="https://example.com/hooks/proton" <?= $readOnly ? 'disabled' : '' ?> required>
|
||||
</label>
|
||||
|
||||
<?php if ($isNew) { ?>
|
||||
@@ -55,7 +59,7 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
<h2 style="margin-top: 16px;">События</h2>
|
||||
|
||||
<label class="inline" style="margin-bottom: 6px;">
|
||||
<input type="checkbox" name="events[]" value="<?= View::e(Webhook::ALL_EVENTS) ?>" <?= $all ? 'checked' : '' ?>>
|
||||
<input type="checkbox" name="events[]" value="<?= View::e(Webhook::ALL_EVENTS) ?>" <?= $all ? 'checked' : '' ?> <?= $readOnly ? 'disabled' : '' ?>>
|
||||
<span>Все события — в том числе те, что появятся позже</span>
|
||||
</label>
|
||||
|
||||
@@ -66,7 +70,7 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
<?php foreach ($events as $code => $label) { ?>
|
||||
<label class="inline" style="margin-bottom: 6px;">
|
||||
<input type="checkbox" name="events[]" value="<?= View::e($code) ?>"
|
||||
<?= in_array($code, $selected, true) ? 'checked' : '' ?>>
|
||||
<?= in_array($code, $selected, true) ? 'checked' : '' ?> <?= $readOnly ? 'disabled' : '' ?>>
|
||||
<span><?= View::e($label) ?> <span class="muted mono"><?= View::e($code) ?></span></span>
|
||||
</label>
|
||||
<?php } ?>
|
||||
@@ -74,7 +78,7 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
<?php } ?>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit" class="primary">Сохранить</button>
|
||||
<?php if (!$readOnly) { ?><button type="submit" class="primary">Сохранить</button><?php } ?>
|
||||
<a class="btn" href="<?= View::e(View::route('admin.webhooks')) ?>">К списку</a>
|
||||
</div>
|
||||
</form>
|
||||
@@ -121,25 +125,29 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
|
||||
</table>
|
||||
|
||||
<div class="row" style="margin-top: 12px;">
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.test', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="primary">Отправить пробную посылку</button>
|
||||
</form>
|
||||
<?php if ($canManage) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.test', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="primary">Отправить пробную посылку</button>
|
||||
</form>
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.toggle', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit"><?= (bool) $webhook->active ? 'Отключить' : 'Включить' ?></button>
|
||||
</form>
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.toggle', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit"><?= (bool) $webhook->active ? 'Отключить' : 'Включить' ?></button>
|
||||
</form>
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.rotate', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit">Заменить секрет</button>
|
||||
</form>
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.rotate', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit">Заменить секрет</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.delete', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="danger">Удалить вебхук</button>
|
||||
</form>
|
||||
<?php if ($canDelete) { ?>
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.delete', ['id' => $webhook->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="danger">Удалить вебхук</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
* @var \Rsgrinko\Proton\Support\Filters $filters
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\Access\Permission;
|
||||
use Rsgrinko\Proton\Models\IncomingHook;
|
||||
use Rsgrinko\Proton\Models\Webhook;
|
||||
use Rsgrinko\Proton\Models\WebhookDelivery;
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$events = 0;
|
||||
$canManage = View::can(Permission::WEBHOOKS_MANAGE);
|
||||
$events = 0;
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$events += count($group);
|
||||
@@ -38,9 +40,11 @@ foreach ($groups as $group) {
|
||||
не доставлено <?= (int) ($stats[WebhookDelivery::FAILED] ?? 0) ?>.
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.webhooks.create')) ?>">Новый вебхук</a>
|
||||
</div>
|
||||
<?php if ($canManage) { ?>
|
||||
<div class="row">
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.webhooks.create')) ?>">Новый вебхук</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?= View::partial('filters', ['filters' => $filters, 'route' => 'admin.webhooks', 'total' => $page['total']]) ?>
|
||||
@@ -59,7 +63,7 @@ foreach ($groups as $group) {
|
||||
<th class="hide-sm">События</th>
|
||||
<th>Состояние</th>
|
||||
<th class="hide-sm">Последняя посылка</th>
|
||||
<th></th>
|
||||
<?php if ($canManage) { ?><th></th><?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $webhook) { ?>
|
||||
@@ -90,6 +94,7 @@ foreach ($groups as $group) {
|
||||
<span class="mono">(<?= (int) $webhook->raw('last_status') ?>)</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php if ($canManage) { ?>
|
||||
<td class="right">
|
||||
<div class="row end">
|
||||
<form method="post" action="<?= View::e(View::route('admin.webhooks.test', ['id' => $webhook->id()])) ?>">
|
||||
@@ -98,6 +103,7 @@ foreach ($groups as $group) {
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
Reference in new issue
Block a user