1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
namespace Icinga\Module\Director\Web\Table;
use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
class ImportsourceTable extends ZfQueryBasedTable
{
protected $searchColumns = [
'source_name',
'description',
];
public function getColumnsToBeRendered()
{
return [
$this->translate('Source name'),
];
}
protected function assemble()
{
$this->getAttributes()->add('class', 'syncstate');
parent::assemble();
}
public function renderRow($row)
{
$caption = [Link::create(
$row->source_name,
'director/importsource',
['id' => $row->id]
)];
if ($row->description !== null) {
$caption[] = ': ' . $row->description;
}
if ($row->import_state === 'failing' && $row->last_error_message) {
$caption[] = ' (' . $row->last_error_message . ')';
}
$tr = $this::row([$caption]);
$tr->getAttributes()->add('class', $row->import_state);
return $tr;
}
public function prepareQuery()
{
return $this->db()->select()->from(
['s' => 'import_source'],
[
'id' => 's.id',
'source_name' => 's.source_name',
'provider_class' => 's.provider_class',
'import_state' => 's.import_state',
'last_error_message' => 's.last_error_message',
'description' => 's.description',
]
)->order('source_name ASC');
}
}
|