xref: /webtrees/resources/views/admin/site-logs.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
6use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsData;
7use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsDelete;
8use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsDownload;
9use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsPage;
10use Fisharebest\Webtrees\I18N;
11use Fisharebest\Webtrees\View;
12use Illuminate\Support\Collection;
13
14/**
15 * @var string                       $earliest
16 * @var string                       $from
17 * @var string                       $ip
18 * @var string                       $latest
19 * @var string                       $title
20 * @var string                       $to
21 * @var string                       $text
22 * @var string                       $tree
23 * @var Collection<array-key,string> $tree_options
24 * @var string                       $type
25 * @var string                       $username
26 * @var Collection<array-key,string> $user_options
27 */
28
29?>
30
31<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
32
33<h1><?= $title ?></h1>
34
35<form method="post" class="form" name="logs">
36    <div class="row">
37        <div class="col-sm-6 col-sm-3">
38            <label for="from">
39                <?= I18N::translateContext('Start of date range', 'From') ?>
40            </label>
41            <input type="date" class="form-control" id="from" max="<?= e($latest) ?>" min="<?= e($earliest) ?>" name="from" value="<?= e($from) ?>" required="required">
42        </div>
43
44        <div class="col-sm-6 col-sm-3">
45            <label for="to">
46                <?= I18N::translateContext('End of date range', 'To') ?>
47            </label>
48            <input type="date" class="form-control" id="to" max="<?= e($latest) ?>" min="<?= e($earliest) ?>" name="to" value="<?= e($to) ?>" required="required">
49        </div>
50
51        <div class="col-sm-6 col-sm-2">
52            <label for="type">
53                <?= I18N::translate('Type') ?>
54            </label>
55            <?= view('components/select', ['name' => 'type', 'selected' => $type, 'options' => ['' => '', 'auth' => 'auth', 'config' => 'config', 'debug' => 'debug', 'edit' => 'edit', 'error' => 'error', 'media' => 'media', 'search' => 'search']]) ?>
56        </div>
57
58        <div class="col-sm-6 col-sm-4">
59            <label for="ip">
60                <?= I18N::translate('IP address') ?>
61            </label>
62            <input class="form-control" type="text" id="ip" name="ip" value="<?= e($ip) ?>">
63        </div>
64    </div>
65
66    <div class="row">
67        <div class="col-sm-4">
68            <label for="text">
69                <?= I18N::translate('Message') ?>
70            </label>
71            <input class="form-control" type="text" id="text" name="text" value="<?= e($text) ?>">
72        </div>
73
74        <div class="col-sm-4">
75            <label for="username">
76                <?= I18N::translate('User') ?>
77            </label>
78            <?= view('components/select', ['name' => 'username', 'selected' => $username, 'options' => $user_options]) ?>
79        </div>
80
81        <div class="col-sm-4">
82            <label for="tree">
83                <?= I18N::translate('Family tree') ?>
84            </label>
85            <?= view('components/select', ['name' => 'tree', 'selected' => $tree, 'options' => $tree_options]) ?>
86        </div>
87    </div>
88
89    <div class="text-center">
90        <button type="submit" class="btn btn-primary">
91        <?= view('icons/search') ?>
92            <?= /* I18N: A button label. */ I18N::translate('search') ?>
93        </button>
94
95        <a href="<?= e(route(SiteLogsPage::class)) ?>" type="submit" class="btn btn-secondary">
96            <?= view('icons/cancel') ?>
97            <?= /* I18N: A button label. */ I18N::translate('reset') ?>
98        </a>
99
100        <a href="<?= e(route(SiteLogsDownload::class, ['from' => $from, 'to' => $to, 'type' => $type, 'text' => $text, 'ip' => $ip, 'username' => $username, 'tree' => $tree])) ?>" class="btn btn-secondary">
101        <?= view('icons/download') ?>
102            <?= /* I18N: A button label. */ I18N::translate('download') ?>
103        </a>
104
105        <a href="#" class="btn btn-danger" data-wt-confirm="<?= I18N::translate('Permanently delete these records?') ?>" data-wt-post-url="<?= e(route(SiteLogsDelete::class, ['from' => $from, 'to' => $to, 'type' => $type, 'text' => $text, 'ip' => $ip, 'username' => $username, 'tree' => $tree])) ?>">
106        <?= view('icons/delete') ?>
107            <?= /* I18N: A button label. */ I18N::translate('delete') ?>
108        </a>
109    </div>
110
111    <?= csrf_field() ?>
112</form>
113
114<table
115    class="table table-bordered table-sm table-hover table-site-logs"
116    <?= view('lists/datatables-attributes') ?>
117    data-ajax="<?= e(route(SiteLogsData::class, ['from' => $from, 'to' => $to, 'type' => $type, 'text' => $text, 'ip' => $ip, 'username' => $username, 'tree' => $tree])) ?>"
118    data-server-side="true"
119    data-filter="false"
120>
121    <thead>
122        <tr>
123            <th></th>
124            <th><?= I18N::translate('Timestamp') ?></th>
125            <th><?= I18N::translate('Type') ?></th>
126            <th><?= I18N::translate('Message') ?></th>
127            <th><?= I18N::translate('IP address') ?></th>
128            <th><?= I18N::translate('User') ?></th>
129            <th><?= I18N::translate('Family tree') ?></th>
130        </tr>
131    </thead>
132</table>
133
134<?php View::push('javascript') ?>
135<script>
136  $(".table-site-logs").dataTable( {
137    processing: true,
138    sorting: [[ 0, "desc" ]],
139    columns: [
140      /* log_id      */ { visible: false },
141      /* Timestamp   */ { sort: 0 },
142      /* Type        */ { },
143      /* message     */ { },
144      /* IP address  */ { },
145      /* User        */ { },
146      /* Family tree */ { }
147    ]
148  });
149</script>
150<?php View::endpush() ?>
151