|
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\Check\CheckInterface; |
|
17
|
|
|
use Tvi\MonitorBundle\Runner\RunnerManager; |
|
18
|
|
|
|
|
19
|
|
|
class UIController extends Controller |
|
|
|
|
|
|
20
|
|
|
{ |
|
21
|
|
|
use TraitCommon; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
|
|
|
|
|
24
|
|
|
* @var RunnerManager |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $runnerManager; |
|
27
|
|
|
|
|
28
|
1 |
|
public function __construct(RunnerManager $runnerManager) |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
1 |
|
$this->runnerManager = $runnerManager; |
|
31
|
1 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
|
|
|
|
|
34
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function indexAction(Request $request) |
|
37
|
|
|
{ |
|
38
|
1 |
|
list($filterIds, $filterChecks, $filterGroups, $filterTags) = $this->getFilterParams($request); |
|
39
|
1 |
|
$filterChecks = $filterChecks ? $filterChecks : $filterIds; |
|
40
|
|
|
|
|
41
|
1 |
|
$groups = $this->runnerManager->findGroups(); |
|
42
|
1 |
|
$tags = $this->runnerManager->findTags(); |
|
43
|
1 |
|
$checks = $this->runnerManager->findChecks(); |
|
44
|
|
|
|
|
45
|
1 |
|
$selectedChecks = $this->runnerManager->findChecks($filterChecks, $filterGroups, $filterTags); |
|
46
|
|
|
|
|
47
|
1 |
|
uasort($checks, static function (CheckInterface $a, CheckInterface $b) { |
|
|
|
|
|
|
48
|
1 |
|
return ($a->getGroup() === $b->getGroup()) ? 0 : ($a->getGroup() < $b->getGroup() ? -1 : 1); |
|
49
|
1 |
|
}); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
1 |
|
return $this->render('@TviMonitor/ui/index.html.twig', [ |
|
|
|
|
|
|
52
|
1 |
|
'groups' => $groups, |
|
53
|
1 |
|
'tags' => $tags, |
|
54
|
1 |
|
'checks' => $checks, |
|
55
|
1 |
|
'filters' => ['checks' => $filterChecks, 'groups' => $filterGroups, 'tags' => $filterTags], |
|
56
|
1 |
|
'selectedChecks' => $selectedChecks, |
|
57
|
|
|
]); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|