add and display interrupt status

This commit is contained in:
aynsix
2020-08-06 15:17:06 +03:00
parent f6854caaba
commit b5b69343bd
13 changed files with 1932 additions and 1777 deletions

View File

@@ -73,16 +73,25 @@ class AdminConfigurationController extends Controller
/** @var WorkerRunningJobRepository $repoWorker */
$repoWorker = $app['repo.worker-running-job'];
$workerRunningJob = [];
$reload = ($request->query->get('reload')) == 1 ? true : false ;
if ($request->query->get('running') == 1 && $request->query->get('finished') == 1) {
$workerRunningJob = $repoWorker->findBy([], ['id' => 'DESC'], WorkerRunningJob::MAX_RESULT);
} elseif ($request->query->get('running') == 1) {
$workerRunningJob = $repoWorker->findBy(['status' => WorkerRunningJob::RUNNING], ['id' => 'DESC'], WorkerRunningJob::MAX_RESULT);
} elseif ($request->query->get('finished') == 1) {
$workerRunningJob = $repoWorker->findBy(['status' => WorkerRunningJob::FINISHED], ['id' => 'DESC'], WorkerRunningJob::MAX_RESULT);
$workerRunningJob = [];
$filterStatus = [];
if ($request->query->get('running') == 1) {
$filterStatus[] = WorkerRunningJob::RUNNING;
}
if ($request->query->get('finished') == 1) {
$filterStatus[] = WorkerRunningJob::FINISHED;
}
if ($request->query->get('error') == 1) {
$filterStatus[] = WorkerRunningJob::ERROR;
}
if ($request->query->get('interrupt') == 1) {
$filterStatus[] = WorkerRunningJob::INTERRUPT;
}
if (count($filterStatus) > 0) {
$workerRunningJob = $repoWorker->findByStatus($filterStatus);
}
return $this->render('admin/worker-manager/worker_info.html.twig', [
@@ -91,6 +100,31 @@ class AdminConfigurationController extends Controller
]);
}
/**
* @param Request $request
* @param integer $workerId
*/
public function changeStatusAction(Request $request, $workerId)
{
/** @var WorkerRunningJobRepository $repoWorker */
$repoWorker = $this->app['repo.worker-running-job'];
/** @var WorkerRunningJob $workerRunningJob */
$workerRunningJob = $repoWorker->find($workerId);
$workerRunningJob
->setStatus($request->request->get('status'))
->setFinished(new \DateTime('now'))
;
$em = $repoWorker->getEntityManager();
$em->persist($workerRunningJob);
$em->flush();
return $this->app->json(['success' => true]);
}
public function queueMonitorAction(PhraseaApplication $app, Request $request)
{
$reload = ($request->query->get('reload')) == 1 ? true : false ;