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
|
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));
|
$response = new Response($this->twig->render($template, $vars));
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -59,4 +63,9 @@ abstract class Controller
|
||||||
{
|
{
|
||||||
return $this->kernel->getRouter()->getUrlForRoute($route);
|
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()
|
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);
|
return $this->kernel->getRouter()->getUrlForRoute($route, $params);
|
||||||
});
|
});
|
||||||
$this->environment->addFunction($path);
|
$this->environment->addFunction($path);
|
||||||
|
|
|
@ -27,6 +27,7 @@ class SecurityController extends Controller
|
||||||
$_SESSION['isAuthenticated'] = true;
|
$_SESSION['isAuthenticated'] = true;
|
||||||
return new RedirectResponse($this->generateRoute('default'));
|
return new RedirectResponse($this->generateRoute('default'));
|
||||||
}
|
}
|
||||||
|
$this->addFlash('danger', 'Username or password incorrect');
|
||||||
return new RedirectResponse($this->generateRoute('login'));
|
return new RedirectResponse($this->generateRoute('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,40 +4,36 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Webcron management :: {% block title %}{% endblock %}</title>
|
<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 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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" 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="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css">
|
<link rel="stylesheet" href="/css/site.css">
|
||||||
<link rel="stylesheet" href="/public/css/site.css">
|
|
||||||
|
<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="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="/js/site.js" type="text/javascript"></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>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="col-xs-12 col-sm-12">
|
<div class="container-fluid py-3">
|
||||||
<div class="page-header">
|
<div class="row py-3">
|
||||||
<h1>Webcron management</h1>
|
<div class="col-xs-12 col-sm-12">
|
||||||
</div>
|
<div class="page-header">
|
||||||
</div>
|
<h1>Webcron management</h1>
|
||||||
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row py-3">
|
||||||
<div class="col-xs-12 col-sm-10">
|
<div class="col-xs-12 col-sm-2">
|
||||||
{% block content %}{% endblock %}
|
<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>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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.data.host }}</td>
|
||||||
<td>{{ job.delay | interval }}</td>
|
<td>{{ job.delay | interval }}</td>
|
||||||
<td>{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
|
<td>{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
|
||||||
<td>
|
<td class="text-end">
|
||||||
<a href="#" data-id="{{ job.id }}" class="runcron btn btn-default"><span class="glyphicon glyphicon-play"><span></a>
|
<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-default"><span class="glyphicon glyphicon-align-justify"></span></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-default"><span class="glyphicon glyphicon-edit"><span></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-default"><span class="glyphicon glyphicon-remove"></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-outline-primary"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -4,41 +4,38 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Webcron management :: Log in</title>
|
<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 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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="/public/css/site.css">
|
<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://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
|
||||||
<script src="/js/site.js" type="text/javascript"></script>
|
<script src="/js/site.js" type="text/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="col-md-4 col-md-offset-4 col-xs-12">
|
<div class="container-fluid py-3">
|
||||||
<h1>Webcron management</h1>
|
<div class="row justify-content-md-center">
|
||||||
<form class="form-horizontal" method="post" action="{{ path('login_check') }}">
|
<div class="col-md-4 col-xs-12">
|
||||||
{% if not error == "" %}
|
{{ include('flashes.html.twig') }}
|
||||||
<div class="alert alert-danger fade in">
|
<h1>Webcron management</h1>
|
||||||
<a href="#" class="close" data-dismiss="alert">×</a>
|
<form class="form-horizontal" method="post" action="{{ path('login_check') }}">
|
||||||
<strong>Error!</strong> {{ error }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="form-group col-sm-12">
|
<div class="form-floating mb-3">
|
||||||
<label for="name">Username</label>
|
<input type="text" name="name" class="form-control" id="name" placeholder="username">
|
||||||
<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>
|
||||||
<div class="form-group col-sm-12">
|
</div>
|
||||||
<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>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue