Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] web interface #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace ColourStream\Bundle\CronBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
/**
* @Route(name="cron")
*/
public function indexAction()
{
$cronJobs = $this->getDoctrine()->getManager()->getRepository('ColourStreamCronBundle:CronJob')->findAll();
$parameters = [
'cronJobs' => $cronJobs,
];

return $this->render('ColourStreamCronBundle:default:index.html.twig', $parameters);
}
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ app/console cron:scan
app/console cron:run
```

5. Configure web interface (optional)
```
#app/config/routing.yml
cronbundle:
prefix: /admin/cron
resource: "@ColourStreamCronBundle/Resources/config/routing.yml"
```

## Running your cron jobs automatically

This bundle is designed around the idea that your tasks will be run with a minimum interval - the tasks will be run no more frequently than you schedule them, but they can only run when you trigger then (by running `app/console cron:run`, or the forthcoming web endpoint, for use with webcron services).
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cronbundle:
resource: @ColourStreamCronBundle/Controller/
type: annotation
7 changes: 7 additions & 0 deletions Resources/views/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body>
{% block body %}
{% endblock %}
</body>
</html>
19 changes: 19 additions & 0 deletions Resources/views/default/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "ColourStreamCronBundle::base.html.twig" %}

{% block body %}
<table>
{% for cronJob in cronJobs %}
<tr{% if cronJob.mostRecentRun and cronJob.mostRecentRun.result %} style="font-weight:bold;"{% endif %}>
<td>{{ cronJob.command }}</td>
<td>
{% if cronJob.mostRecentRun %}
{{ cronJob.mostRecentRun.runAt|date('Y-m-d H:i:s') }}
{% if cronJob.mostRecentRun.result %}
<br>{{ cronJob.mostRecentRun.output }}
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endblock %}