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