1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the `tvi/monitor-bundle` project. |
5
|
|
|
* |
6
|
|
|
* (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Tvi\MonitorBundle\Controller; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Tvi\MonitorBundle\Runner\RunnerManager; |
17
|
|
|
|
18
|
|
|
class UIController extends Controller |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
use TraitCommon; |
21
|
|
|
|
22
|
|
|
/** |
|
|
|
|
23
|
|
|
* @var RunnerManager |
24
|
|
|
*/ |
25
|
|
|
protected $runnerManager; |
26
|
|
|
|
27
|
|
|
/** |
|
|
|
|
28
|
|
|
* @var ?string |
29
|
|
|
*/ |
30
|
|
|
protected $template; |
31
|
|
|
|
32
|
1 |
|
public function __construct(RunnerManager $runnerManager, string $template = null) |
|
|
|
|
33
|
|
|
{ |
34
|
1 |
|
$this->runnerManager = $runnerManager; |
35
|
1 |
|
$this->template = $template; |
36
|
1 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
|
|
|
|
39
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
40
|
|
|
*/ |
41
|
1 |
|
public function indexAction(Request $request) |
42
|
|
|
{ |
43
|
1 |
|
list($filterIds, $filterChecks, $filterGroups, $filterTags) = $this->getFilterParams($request); |
44
|
1 |
|
$filterChecks = $filterChecks ? $filterChecks : $filterIds; |
45
|
|
|
|
46
|
1 |
|
$groups = $this->runnerManager->findGroups(); |
47
|
1 |
|
$tags = $this->runnerManager->findTags(); |
48
|
1 |
|
$checks = $this->runnerManager->findChecks(); |
49
|
|
|
|
50
|
1 |
|
$selectedChecks = $this->runnerManager->findChecksSorted($filterChecks, $filterGroups, $filterTags); |
51
|
|
|
|
52
|
1 |
|
return $this->render($this->template ?? '@TviMonitor/UI/index.b4.html.twig', [ |
|
|
|
|
53
|
1 |
|
'groups' => $groups, |
54
|
1 |
|
'tags' => $tags, |
55
|
1 |
|
'checks' => $checks, |
56
|
1 |
|
'filters' => ['checks' => $filterChecks, 'groups' => $filterGroups, 'tags' => $filterTags], |
57
|
1 |
|
'selectedChecks' => $selectedChecks, |
58
|
|
|
]); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|