xref: /webtrees/resources/views/admin/site-logs.phtml (revision 36de22acf6348b1059dac63e3cd19589574906ac)
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<string,string> $tree_options
22 * @var string                    $type
23 * @var string                    $username
24 * @var Collection<string,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    <?= csrf_field() ?>
35
36    <div class="row">
37        <div class="form-group 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="form-group 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="form-group 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="form-group 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="form-group 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="form-group 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="form-group 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-confirm="<?= I18N::translate('Permanently delete these records?') ?>" data-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</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