Added flashes
This commit is contained in:
parent
5cf6ba2e76
commit
c98e1add62
|
@ -51,6 +51,10 @@ abstract class Controller
|
|||
*/
|
||||
public function render(string $template, array $vars = []): Response
|
||||
{
|
||||
if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
|
||||
$vars['flashes'] = $_SESSION['flashes'];
|
||||
$_SESSION['flashes'] = [];
|
||||
}
|
||||
$response = new Response($this->twig->render($template, $vars));
|
||||
return $response;
|
||||
}
|
||||
|
@ -59,4 +63,9 @@ abstract class Controller
|
|||
{
|
||||
return $this->kernel->getRouter()->getUrlForRoute($route);
|
||||
}
|
||||
|
||||
public function addFlash(string $category, string $content): void
|
||||
{
|
||||
$_SESSION['flashes'][] = ['category' => $category, 'content' => $content];
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ class Twig
|
|||
|
||||
public function addFunctions()
|
||||
{
|
||||
$path = new TwigFunction('path', function(string $route, array $params) {
|
||||
$path = new TwigFunction('path', function(string $route, array $params = []) {
|
||||
return $this->kernel->getRouter()->getUrlForRoute($route, $params);
|
||||
});
|
||||
$this->environment->addFunction($path);
|
||||
|
|
|
@ -27,6 +27,7 @@ class SecurityController extends Controller
|
|||
$_SESSION['isAuthenticated'] = true;
|
||||
return new RedirectResponse($this->generateRoute('default'));
|
||||
}
|
||||
$this->addFlash('danger', 'Username or password incorrect');
|
||||
return new RedirectResponse($this->generateRoute('login'));
|
||||
}
|
||||
}
|
|
@ -5,39 +5,35 @@
|
|||
|
||||
<title>Webcron management :: {% block title %}{% endblock %}</title>
|
||||
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css">
|
||||
<link rel="stylesheet" href="/public/css/site.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/css/site.css">
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js" type="text/javascript"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
|
||||
<script src="/public/js/site.js" type="text/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
|
||||
<script src="/js/site.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
<div class="page-header">
|
||||
<h1>Webcron management</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<ul class="nav nav-stacked">
|
||||
<li><a href="overview.php">Overview</a></li>
|
||||
<li><a href="addjob.php">Add a new cronjob</a></li>
|
||||
<li><a href="config.php">Configuration</a></li>
|
||||
</ul>
|
||||
<div class="container-fluid py-3">
|
||||
<div class="row py-3">
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
<div class="page-header">
|
||||
<h1>Webcron management</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-10">
|
||||
{% block content %}{% endblock %}
|
||||
<div class="row py-3">
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item"><a class="nav-link" href="{{ path('job_index') }}">Overview</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="addjob.php">Add a new cronjob</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="config.php">Configuration</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-10">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{% for flash in flashes %}
|
||||
<div class="alert alert-{{ flash.category }} alert-dismissible fade show" role="alert">
|
||||
{{ flash.content }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endfor %}
|
|
@ -22,11 +22,11 @@
|
|||
<td>{{ job.data.host }}</td>
|
||||
<td>{{ job.delay | interval }}</td>
|
||||
<td>{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
|
||||
<td>
|
||||
<a href="#" data-id="{{ job.id }}" class="runcron btn btn-default"><span class="glyphicon glyphicon-play"><span></a>
|
||||
<a href="{{ path('job_view', {'id': job.id}) }}" class="btn btn-default"><span class="glyphicon glyphicon-align-justify"></span></a>
|
||||
<a href="editjob.php?jobID={{ job.id }}" class="btn btn-default"><span class="glyphicon glyphicon-edit"><span></a>
|
||||
<a onclick="return confirm('Are you sure you want to delete this job?')" href="overview.php?id={{ job.id }}&action=delete" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span></a>
|
||||
<td class="text-end">
|
||||
<a href="#" data-id="{{ job.id }}" class="runcron btn btn-outline-primary"><i class="fa fa-play" aria-hidden="true"></i></a>
|
||||
<a href="{{ path('job_view', {'id': job.id}) }}" class="btn btn-outline-primary"><i class="fa fa-search" aria-hidden="true"></i></a>
|
||||
<a href="editjob.php?jobID={{ job.id }}" class="btn btn-outline-primary"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
|
||||
<a onclick="return confirm('Are you sure you want to delete this job?')" href="overview.php?id={{ job.id }}&action=delete" class="btn btn-outline-primary"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -5,40 +5,37 @@
|
|||
|
||||
<title>Webcron management :: Log in</title>
|
||||
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/public/css/site.css">
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
|
||||
<script src="/js/site.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="col-md-4 col-md-offset-4 col-xs-12">
|
||||
<h1>Webcron management</h1>
|
||||
<form class="form-horizontal" method="post" action="{{ path('login_check') }}">
|
||||
{% if not error == "" %}
|
||||
<div class="alert alert-danger fade in">
|
||||
<a href="#" class="close" data-dismiss="alert">×</a>
|
||||
<strong>Error!</strong> {{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="container-fluid py-3">
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col-md-4 col-xs-12">
|
||||
{{ include('flashes.html.twig') }}
|
||||
<h1>Webcron management</h1>
|
||||
<form class="form-horizontal" method="post" action="{{ path('login_check') }}">
|
||||
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Username</label>
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="username">
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="username">
|
||||
<label for="name">Username</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" name="passwd" class="form-control" id="passwd" placeholder="password">
|
||||
<label for="passwd">Password</label>
|
||||
</div>
|
||||
<div class="form-check mb-3">
|
||||
<input type="checkbox" name="autologin" id="autologin" value="autologin" class="form-check-input">
|
||||
<label class="from-check-label" for="autologin">Remember, remember</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="passwd">Password</label>
|
||||
<input type="password" name="passwd" class="form-control" id="url" placeholder="password">
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<input type="checkbox" name="autologin" id="autologin" value="autologin">
|
||||
<label for="autologin">Remember, remember</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue