ENHANCEMENT: changing status, if status changes

This commit is contained in:
Jeroen De Meerleer 2021-07-14 13:46:56 +02:00
parent 13608ce06b
commit c1782c26e2
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
3 changed files with 21 additions and 7 deletions

View File

@ -35,6 +35,20 @@ function initRunNowButtons() {
modal.find('.modal-title').html(data.title);
if (data.status == 'deferred') {
modal.find('.modal-body').html(data.message);
me.addClass('disabled');
let td = me.parents('td');
td.find('.btn').each(function() {
let btn = $(this);
btn.addClass('btn-outline-success');
btn.removeClass('btn-outline-primary');
btn.removeClass('btn-outline-danger');
})
let tr = me.parents('tr');
tr.addClass('running');
tr.removeClass('norun');
} else if (data.status == 'ran') {
let content = '<p>Cronjob ran in ' + data.runtime.toFixed(3) + ' seconds with exit code ' + data.exitcode +'</p>'
content += '<pre>' + data.output + '</pre>'

View File

@ -145,11 +145,11 @@ class Job extends Repository
private function runLocalCommand(string $command): array
{
pcntl_signal(SIGCHLD, SIG_DFL);
if(function_exists('pcntl_signal')) pcntl_signal(SIGCHLD, SIG_DFL);
$return['exitcode'] = NULL;
$return['output'] = NULL;
exec($command . ' 2>&1', $return['output'], $return['exitcode']);
pcntl_signal(SIGCHLD, SIG_IGN);
if(function_exists('pcntl_signal'))pcntl_signal(SIGCHLD, SIG_IGN);
$return['output'] = implode("\n", $return['output']);
return $return;
}

View File

@ -15,16 +15,16 @@
</thead>
<tbody>
{% for job in jobs %}
<tr{% if job.norun == true %} class="norun"{% elseif job.running == true %} class="running"{% endif %}>
<tr{% if job.running == true %} class="running"{% elseif job.norun == true %} class="norun"{% endif %}>
<td class="d-block d-md-table-cell">{{ job.name }}</td>
<td class="d-block d-md-table-cell">{{ attribute(job, 'host-displayname') }}</td>
<td class="d-block d-md-table-cell">{{ job.interval | interval }}</td>
<td class="d-block d-md-table-cell">{{ job.nextrun | date("d/m/Y H:i:s") }}</td>
<td class="text-md-right d-block d-md-table-cell">
<a href="#" data-href="{{ path('job_runnow', {'id': job.id}) }}" class="runnow btn btn-outline-{% if job.norun == true %}danger{% elseif job.running == true %}success{% else %}primary{% endif %}{% if job.running == true %} disabled{% endif %}"><i class="fa fa-play" aria-hidden="true"></i></a>
<a href="{{ path('job_view', {'id': job.id}) }}" class="btn btn-outline-{% if job.norun == true %}danger{% elseif job.running == true %}success{% else %}primary{% endif %}"><i class="fa fa-search" aria-hidden="true"></i></a>
<a href="{{ path('job_edit', {'id': job.id}) }}" class="btn btn-outline-{% if job.norun == true %}danger{% elseif job.running == true %}success{% else %}primary{% endif %}"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
<a href="#" data-confirmation="Are you sure you want to delete this job?" data-href="{{ path('job_delete', {'id': job.id}) }}" class="delete-btn btn btn-outline-{% if job.norun == true %}danger{% elseif job.running == true %}success{% else %}primary{% endif %}"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
<a href="#" data-href="{{ path('job_runnow', {'id': job.id}) }}" class="runnow btn btn-outline-{% if job.running == true %}success{% elseif job.norun == true %}danger{% else %}primary{% endif %}{% if job.running == true %} disabled{% endif %}"><i class="fa fa-play" aria-hidden="true"></i></a>
<a href="{{ path('job_view', {'id': job.id}) }}" class="btn btn-outline-{% if job.running == true %}success{% elseif job.norun == true %}danger{% else %}primary{% endif %}"><i class="fa fa-search" aria-hidden="true"></i></a>
<a href="{{ path('job_edit', {'id': job.id}) }}" class="btn btn-outline-{% if job.running == true %}success{% elseif job.norun == true %}danger{% else %}primary{% endif %}"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
<a href="#" data-confirmation="Are you sure you want to delete this job?" data-href="{{ path('job_delete', {'id': job.id}) }}" class="delete-btn btn btn-outline-{% if job.running == true %}success{% elseif job.norun == true %}danger{% else %}primary{% endif %}"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
</td>
</tr>
{% endfor %}