Added add route
This commit is contained in:
parent
70ba6473e9
commit
2a5f1bd30c
|
@ -28,3 +28,10 @@ job_view:
|
|||
path: '/job/{id}'
|
||||
defaults:
|
||||
_controller: JeroenED\Webcron\Controller\JobController::viewAction
|
||||
requirements:
|
||||
id: \d+
|
||||
|
||||
job_add:
|
||||
path: '/job/add'
|
||||
defaults:
|
||||
_controller: JeroenED\Webcron\Controller\JobController::addAction
|
||||
|
|
|
@ -2,8 +2,8 @@ $(document).ready(function() {
|
|||
$("body").on("click", "#patternDropdown li", function() {
|
||||
if(this.value != "custom") { $("input#delay").val($(this).data("val")); }
|
||||
});
|
||||
$('#nextrunselector').datetimepicker( { format: 'DD/MM/YYYY HH:mm:ss' } );
|
||||
$('#lastrunselector').datetimepicker( { format: 'DD/MM/YYYY HH:mm:ss' } );
|
||||
$('#nextrunselector').datetimepicker({format: 'L LTS'});
|
||||
$('#lastrunselector').datetimepicker({format: 'L LTS'});
|
||||
|
||||
$("body").on("click", ".runcron", function() {
|
||||
$("#ajax_loader").show();
|
||||
|
|
|
@ -24,4 +24,9 @@ class JobController extends Controller
|
|||
{
|
||||
return new Response('Not implemented yet', Response::HTTP_TOO_EARLY);
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
return $this->render('job/add.html.twig');
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
{% extends "base.html.twig" %}
|
||||
{% block title %}Add job{% endblock %}
|
||||
{% block content %}
|
||||
<form method="post" action="/webcron.old/addjob.php">
|
||||
{% if not error == "" %}
|
||||
<div class="alert alert-danger fade in">
|
||||
<a href="#" class="close" data-dismiss="alert">×</a>
|
||||
<strong>Error!</strong> {{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not message == "" %}
|
||||
<div class="alert alert-success fade in">
|
||||
<a href="#" class="close" data-dismiss="alert">×</a>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="System update">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="url">url</label>
|
||||
<input type="text" name="url" class="form-control" id="url" placeholder="http://example.com/ or 'sudo yum update -y'">
|
||||
<p class="url-description"></p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="host">host</label>
|
||||
<input type="text" name="host" class="form-control" id="host" placeholder="localhost">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Delay (in seconds)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Pattern <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu" id="patternDropdown">
|
||||
<li data-val="60"><a href="#">Every minute</a></li>
|
||||
<li data-val="3600"><a href="#">Every hour</a></li>
|
||||
<li data-val="86400"><a href="#">Every day</a></li>
|
||||
<li data-val="604800"><a href="#">Every week</a></li>
|
||||
<li data-val="2419200"><a href="#">Every 4 weeks</a></li>
|
||||
<li data-val="custom"><a href="#">Custom</a></li>
|
||||
</ul>
|
||||
</div><!-- /btn-group -->
|
||||
<input type="number" class="form-control" id="delay" name="delay">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="nextrun">Next run</label>
|
||||
<div class="input-group date" id="nextrunselector">
|
||||
<span class="input-group-addon">
|
||||
<span class="glyphicon glyphicon-calendar"></span>
|
||||
</span>
|
||||
<input type="text" class="form-control" name="nextrun">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="lastrun">Last run</label>
|
||||
<div class="input-group date" id="lastrunselector">
|
||||
<span class="input-group-addon">
|
||||
<span class="glyphicon glyphicon-calendar"></span>
|
||||
</span>
|
||||
<input type="text" class="form-control" name="lastrun">
|
||||
<span class="input-group-addon">
|
||||
<input type="checkbox" name="eternal" value="true"> Eternal
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="expected">Expected exit code</label>
|
||||
<input type="text" name="expected" class="form-control" id="host" placeholder="200">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -5,12 +5,16 @@
|
|||
|
||||
<title>Webcron management :: {% block title %}{% endblock %}</title>
|
||||
|
||||
<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://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" 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">
|
||||
{% block extrastyles %}{% endblock %}
|
||||
|
||||
<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://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
|
||||
<script src="/js/site.js" type="text/javascript"></script>
|
||||
{% block extrascripts %}{% endblock %}
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -26,7 +30,7 @@
|
|||
<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="{{ path('job_add') }}">Add a new cronjob</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="config.php">Configuration</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ path('logout') }}">Logout</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
{% 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>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
49
templates/job/add.html.twig
Normal file
49
templates/job/add.html.twig
Normal file
|
@ -0,0 +1,49 @@
|
|||
{% extends "base.html.twig" %}
|
||||
{% block title %}Add job{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Add a cronjob</h2>
|
||||
<form method="post" class="form-horizontal" action="{{ path('job_add') }}">
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="System update">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="url">url</label>
|
||||
<input type="text" name="url" class="form-control" id="url" placeholder="http://example.com/ or 'sudo yum update -y'">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="host">host</label>
|
||||
<input type="text" name="host" class="form-control" id="host" placeholder="localhost">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name">Delay (in seconds)</label>
|
||||
<input type="number" class="form-control" id="delay" name="delay">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="nextrun">Next run</label>
|
||||
<input type="text" id="nextrunselector" class="form-control datetimepicker-input" data-target="#nextrunselector" data-toggle="datetimepicker" name="nextrun">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="lastrun">Last run</label>
|
||||
<input type="datetime-local" id="nextrunselector" class="form-control" name="nextrun">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="expected">Expected exit code</label>
|
||||
<input type="text" name="expected" class="form-control" id="host" placeholder="200">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extrastyles %}
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.39.0/css/tempusdominus-bootstrap-4.min.css" integrity="sha512-3JRrEUwaCkFUBLK1N8HehwQgu8e23jTH4np5NHOmQOobuC4ROQxFwFgBLTnhcnQRMs84muMh0PnnwXlPq5MGjg==" crossorigin="anonymous" />
|
||||
{% endblock %}
|
||||
|
||||
{% block extrascripts %}
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.0/moment.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.39.0/js/tempusdominus-bootstrap-4.min.js" integrity="sha512-k6/Bkb8Fxf/c1Tkyl39yJwcOZ1P4cRrJu77p83zJjN2Z55prbFHxPs9vN7q3l3+tSMGPDdoH51AEU8Vgo1cgAA==" crossorigin="anonymous"></script>
|
||||
{% endblock %}
|
|
@ -2,13 +2,8 @@
|
|||
{% block title %}Overview{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Overview of your cronjobs</h2>
|
||||
{% if not message == "" %}
|
||||
<div class="alert alert-success fade in">
|
||||
<a href="#" class="close" data-dismiss="alert">×</a>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table">
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Host</th>
|
||||
|
@ -16,7 +11,7 @@
|
|||
<th>Next run</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
{% for job in jobs %}
|
||||
{% for job in jobs %}
|
||||
<tr{% if(job.norun == true) %} class="norun"{% endif %}>
|
||||
<td>{{ job.name }}</td>
|
||||
<td>{{ job.data.host }}</td>
|
||||
|
@ -29,7 +24,7 @@
|
|||
<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 %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div id="resultmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
<title>Webcron management :: Log in</title>
|
||||
|
||||
<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">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/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://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
|
||||
<script src="/js/site.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
@ -20,13 +21,13 @@
|
|||
<h1>Webcron management</h1>
|
||||
<form class="form-horizontal" method="post" action="{{ path('login_check') }}">
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="username">
|
||||
<div class="mb-3">
|
||||
<label for="name">Username</label>
|
||||
<input type="text" name="name" class="form-control" id="name" placeholder="username">
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" name="passwd" class="form-control" id="passwd" placeholder="password">
|
||||
<div class="mb-3">
|
||||
<label for="passwd">Password</label>
|
||||
<input type="password" name="passwd" class="form-control" id="passwd" placeholder="password">
|
||||
</div>
|
||||
<div class="form-check mb-3">
|
||||
<input type="checkbox" name="autologin" id="autologin" value="autologin" class="form-check-input">
|
||||
|
|
|
@ -26,7 +26,7 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") {
|
|||
}
|
||||
}
|
||||
|
||||
echo $twig->render('addjob.html.twig', array("message" => $message, "error" => $error));
|
||||
echo $twig->render('add.html.twig', array("message" => $message, "error" => $error));
|
||||
}
|
||||
elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user