mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
Fetch sitelog through Pg::all()
This commit is contained in:
@@ -47,21 +47,17 @@ class SiteLog extends \Gazelle\Base {
|
||||
|
||||
public function page(int $limit, int $offset, string $searchTerm): array {
|
||||
$conf = $this->configure($searchTerm);
|
||||
$st = $this->pg()->pdo()->prepare("
|
||||
select id_site_log,
|
||||
note,
|
||||
created
|
||||
from site_log {$conf['where']}
|
||||
order by id_site_log desc
|
||||
limit ? offset ?
|
||||
");
|
||||
array_push($conf['args'], $limit, $offset);
|
||||
|
||||
if ($st === false || !$st->execute($conf['args'])) {
|
||||
return [];
|
||||
}
|
||||
return $this->decorate(
|
||||
$st->fetchAll(\PDO::FETCH_NUM)
|
||||
$this->pg()->all("
|
||||
select id_site_log,
|
||||
note,
|
||||
created
|
||||
from site_log {$conf['where']}
|
||||
order by id_site_log desc
|
||||
limit ? offset ?
|
||||
", ...$conf['args']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,13 +85,13 @@ class SiteLog extends \Gazelle\Base {
|
||||
*/
|
||||
public function decorate(array $in): array {
|
||||
$out = [];
|
||||
foreach ($in as [$id, $message, $created]) {
|
||||
[$class, $message] = $this->colorize($message);
|
||||
foreach ($in as $entry) {
|
||||
[$class, $message] = $this->colorize($entry['note']);
|
||||
$out[] = [
|
||||
'id' => $id,
|
||||
'id' => $entry['id_site_log'],
|
||||
'class' => $class,
|
||||
'message' => $message,
|
||||
'created' => $created,
|
||||
'created' => $entry['created'],
|
||||
];
|
||||
}
|
||||
return $out;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<th>{{ paginator.total|number_format }} entries{% if search %} for “{{ search }}”{% endif %}</th>
|
||||
</tr>
|
||||
{% if sitelog.error %}
|
||||
<tr class="nobr"><td colspan="2">Search request failed ({{ siteLog.errorMessage }}).</td></tr>
|
||||
<tr class="nobr"><td colspan="3">Search request failed ({{ siteLog.errorMessage }}).</td></tr>
|
||||
{% else %}
|
||||
{% for event in page %}
|
||||
<tr class="row{{ cycle(['a', 'b'], loop.index0) }}" id="log_{{ event.id }}">
|
||||
@@ -42,7 +42,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr class="nobr"><td colspan="2">Nothing found!</td></tr>
|
||||
<tr class="nobr"><td colspan="3">Nothing found!</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{{ paginator.linkbox|raw }}
|
||||
|
||||
Reference in New Issue
Block a user