ENHANCEMENT: Disabled running of running jobs

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

View File

@ -1,2 +1,9 @@
@import "~bootstrap/dist/css/bootstrap.css";
@import "~font-awesome";
@import "~font-awesome";
tr.norun td {
background-color: #ff8888;
}
tr.running td {
background-color: #88ff88;
}

View File

@ -23,6 +23,8 @@ class Job extends Repository
$job['host-displayname'] = $job['data']['host'];
$job['host'] = $job['data']['host'];
$job['service'] = $job['data']['service'] ?? '';
$job['norun'] = isset($job['lastrun']) && $job['nextrun'] > $job['lastrun'];
$job['running'] = $job['running'] != 0;
if(!empty($job['data']['containertype']) && $job['data']['containertype'] != 'none') {
$job['host-displayname'] = $job['data']['service'] . ' on ' . $job['data']['host'];
}

View File

@ -15,16 +15,16 @@
</thead>
<tbody>
{% for job in jobs %}
<tr{% if(job.norun == true) %} class="norun"{% endif %}>
<tr{% if job.norun == true %} class="norun"{% elseif job.running == true %} class="running"{% 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-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="{{ path('job_edit', {'id': job.id}) }}" class="btn btn-outline-primary"><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-primary"><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.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>
</td>
</tr>
{% endfor %}