1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dtc\QueueBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8
|
|
|
|
9
|
|
|
class QueueController extends Controller |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Summary stats. |
13
|
|
|
* |
14
|
|
|
* @Route("/") |
15
|
|
|
* @Route("/status/") |
16
|
|
|
* @Template() |
17
|
|
|
*/ |
18
|
|
|
public function statusAction() |
19
|
|
|
{ |
20
|
|
|
$params = array(); |
21
|
|
|
$jobManager = $this->get('dtc_queue.job_manager'); |
22
|
|
|
|
23
|
|
|
$params['status'] = $jobManager->getStatus(); |
24
|
|
|
|
25
|
|
|
return $params; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* List jobs in system by default. |
30
|
|
|
* |
31
|
|
|
* @Route("/jobs", name="dtc_queue_jobs") |
32
|
|
|
*/ |
33
|
|
|
public function jobsAction() |
34
|
|
|
{ |
35
|
|
|
$class1 = $this->container->getParameter('dtc_queue.class_job'); |
36
|
|
|
$class2 = $this->container->getParameter('dtc_queue.class_job_archive'); |
37
|
|
|
$label1 = 'Live Jobs'; |
38
|
|
|
$label2 = 'Archived Jobs'; |
39
|
|
|
|
40
|
|
|
return $this->renderDualGrid($class1, $class2, $label1, $label2); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $class1 |
45
|
|
|
* @param string $class2 |
46
|
|
|
* @param string $label1 |
47
|
|
|
* @param string $label2 |
48
|
|
|
* |
49
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
50
|
|
|
* |
51
|
|
|
* @throws \Exception |
52
|
|
|
*/ |
53
|
|
|
protected function renderDualGrid($class1, $class2, $label1, $label2) |
54
|
|
|
{ |
55
|
|
|
$managerType = $this->container->getParameter('dtc_queue.default_manager'); |
56
|
|
|
if ('mongodb' !== $managerType && 'orm' != $managerType) { |
57
|
|
|
throw new \Exception("Unsupported manager type: $managerType"); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$rendererFactory = $this->get('dtc_grid.renderer.factory'); |
61
|
|
|
$renderer = $rendererFactory->create('datatables'); |
62
|
|
|
$gridSource = $this->get('dtc_grid.manager.source')->get($class1); |
63
|
|
|
$renderer->bind($gridSource); |
64
|
|
|
$params = $renderer->getParams(); |
65
|
|
|
|
66
|
|
|
$renderer2 = $rendererFactory->create('datatables'); |
67
|
|
|
$gridSource = $this->get('dtc_grid.manager.source')->get($class2); |
68
|
|
|
$renderer2->bind($gridSource); |
69
|
|
|
$params2 = $renderer2->getParams(); |
70
|
|
|
|
71
|
|
|
$params['archive_grid'] = $params2['dtc_grid']; |
72
|
|
|
|
73
|
|
|
$params['dtc_queue_grid_label1'] = $label1; |
74
|
|
|
$params['dtc_queue_grid_label2'] = $label2; |
75
|
|
|
|
76
|
|
|
return $this->render('@DtcQueue/Queue/grid.html.twig', $params); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* List jobs in system by default. |
81
|
|
|
* |
82
|
|
|
* @Route("/runs", name="dtc_queue_runs") |
83
|
|
|
*/ |
84
|
|
|
public function runsAction() |
85
|
|
|
{ |
86
|
|
|
$class1 = $this->container->getParameter('dtc_queue.class_run'); |
87
|
|
|
$class2 = $this->container->getParameter('dtc_queue.class_run_archive'); |
88
|
|
|
$label1 = 'Live Runs'; |
89
|
|
|
$label2 = 'Archived Runs'; |
90
|
|
|
|
91
|
|
|
return $this->renderDualGrid($class1, $class2, $label1, $label2); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* List registered workers in the system. |
96
|
|
|
* |
97
|
|
|
* @Route("/workers/") |
98
|
|
|
* @Template() |
99
|
|
|
*/ |
100
|
|
|
public function workersAction() |
101
|
|
|
{ |
102
|
|
|
$params = array(); |
103
|
|
|
|
104
|
|
|
return $params; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Show a graph of job trends. |
109
|
|
|
* |
110
|
|
|
* @Route("/trends/") |
111
|
|
|
* @Template() |
112
|
|
|
*/ |
113
|
|
|
public function trendsAction() |
114
|
|
|
{ |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|