Renamed delay to interval

This commit is contained in:
Jeroen De Meerleer 2021-05-06 15:53:21 +02:00
parent 35f73d9d6e
commit 8d3cc06410
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
5 changed files with 18 additions and 18 deletions

View File

@ -2,7 +2,7 @@ $(function() {
initDatePickers(); initDatePickers();
initCronType(); initCronType();
initVarInputs(); initVarInputs();
initDelayPattern(); initIntervalPattern();
bsCustomFileInput.init() bsCustomFileInput.init()
}); });
@ -44,10 +44,10 @@ function initVarInputs()
} }
function initDelayPattern() function initIntervalPattern()
{ {
$('.delaypattern-item').on('click', function() { $('.intervalpattern-item').on('click', function() {
let time = $(this).data('time'); let time = $(this).data('time');
$('#delay').val(time); $('#interval').val(time);
}) })
} }

View File

@ -32,7 +32,7 @@ class Job
{ {
if(empty($values['type']) || if(empty($values['type']) ||
empty($values['name']) || empty($values['name']) ||
empty($values['delay']) || empty($values['interval']) ||
empty($values['nextrun']) empty($values['nextrun'])
) { ) {
return ['success' => false, 'message' => 'Some fields are empty']; return ['success' => false, 'message' => 'Some fields are empty'];
@ -118,10 +118,10 @@ class Job
} }
$data = json_encode($data); $data = json_encode($data);
$addJobSql = "INSERT INTO job(name, data, delay, nextrun, lastrun) VALUES (:name, :data, :delay, :nextrun, :lastrun)"; $addJobSql = "INSERT INTO job(name, data, interval, nextrun, lastrun) VALUES (:name, :data, :interval, :nextrun, :lastrun)";
$addJobStmt = $this->dbcon->prepare($addJobSql); $addJobStmt = $this->dbcon->prepare($addJobSql);
$addJobStmt->execute([':name' => $values['name'], ':data' => $data, ':delay' => $values['delay'], ':nextrun' => $values['nextrun'], ':lastrun' => $values['lastrun'], ]); $addJobStmt->execute([':name' => $values['name'], ':data' => $data, ':interval' => $values['interval'], ':nextrun' => $values['nextrun'], ':lastrun' => $values['lastrun'], ]);
return ['success' => true, 'message' => 'Cronjob succesfully added']; return ['success' => true, 'message' => 'Cronjob succesfully added'];
} }

View File

@ -3,7 +3,7 @@ CREATE TABLE job (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name TEXT(25) NOT NULL, name TEXT(25) NOT NULL,
"data" TEXT NOT NULL, "data" TEXT NOT NULL,
delay INTEGER, interval INTEGER,
nextrun INTEGER, nextrun INTEGER,
lastrun INTEGER lastrun INTEGER
); );

View File

@ -10,21 +10,21 @@
<input type="text" name="name" class="form-control" id="name" placeholder="System update"> <input type="text" name="name" class="form-control" id="name" placeholder="System update">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="name">Delay (in seconds)</label> <label for="name">Interval (in seconds)</label>
<div class="input-group"> <div class="input-group">
<div class="dropdown input-group-prepend"> <div class="dropdown input-group-prepend">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="delayButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button class="btn btn-outline-primary dropdown-toggle" type="button" id="intervalButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Patterns Patterns
</button> </button>
<div class="dropdown-menu" aria-labelledby="delayButton"> <div class="dropdown-menu" aria-labelledby="intervalButton">
<a class="dropdown-item delaypattern-item" href="#" data-time="60">Every minute</a> <a class="dropdown-item intervalpattern-item" href="#" data-time="60">Every minute</a>
<a class="dropdown-item delaypattern-item" href="#" data-time="3600">Every hour</a> <a class="dropdown-item intervalpattern-item" href="#" data-time="3600">Every hour</a>
<a class="dropdown-item delaypattern-item" href="#" data-time="86400">Every day</a> <a class="dropdown-item intervalpattern-item" href="#" data-time="86400">Every day</a>
<a class="dropdown-item delaypattern-item" href="#" data-time="604800">Every week</a> <a class="dropdown-item intervalpattern-item" href="#" data-time="604800">Every week</a>
<a class="dropdown-item delaypattern-item" href="#" data-time="2419200">Every 4 weeks</a> <a class="dropdown-item intervalpattern-item" href="#" data-time="2419200">Every 4 weeks</a>
</div> </div>
</div> </div>
<input type="number" class="form-control" id="delay" name="delay"> <input type="number" class="form-control" id="interval" name="interval">
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-3">

View File

@ -15,7 +15,7 @@
<tr{% if(job.norun == true) %} class="norun"{% endif %}> <tr{% if(job.norun == true) %} class="norun"{% endif %}>
<td>{{ job.name }}</td> <td>{{ job.name }}</td>
<td>{{ job.data.host }}</td> <td>{{ job.data.host }}</td>
<td>{{ job.delay | interval }}</td> <td>{{ job.interval | 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 class="text-end"> <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="#" data-id="{{ job.id }}" class="runcron btn btn-outline-primary"><i class="fa fa-play" aria-hidden="true"></i></a>