Skip to content
Snippets Groups Projects
Commit 5bd354b6 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Improve violation count badge in scheduler

Show total count of violations as number, but only mark in orange if there are any violations that are not manually resolved already
parent 51e7c8a3
No related branches found
No related tags found
1 merge request!146Improve scheduler
Pipeline #119809 passed
...@@ -196,16 +196,17 @@ ...@@ -196,16 +196,17 @@
const cv_callback_success = function(response) { const cv_callback_success = function(response) {
let table_html = ''; let table_html = '';
if(response.length > 0) { let unresolved_violations_count = 0;
// Update violation count badge
$('#violationCountBadge').html(response.length).removeClass('badge-success').addClass('badge-warning');
if(response.length > 0) {
// Update violations table // Update violations table
for(let i=0;i<response.length;i++) { for(let i=0;i<response.length;i++) {
if(response[i].manually_resolved) if(response[i].manually_resolved)
table_html += '<tr class="text-muted"><td class="nowrap">{% fa5_icon "check" "fas" %} '; table_html += '<tr class="text-muted"><td class="nowrap">{% fa5_icon "check" "fas" %} ';
else else {
table_html += '<tr><td>'; table_html += '<tr><td>';
unresolved_violations_count++;
}
if(response[i].level_display==='{% trans "Violation" %}') if(response[i].level_display==='{% trans "Violation" %}')
table_html += '{% fa5_icon "exclamation-triangle" "fas" %}'; table_html += '{% fa5_icon "exclamation-triangle" "fas" %}';
...@@ -217,13 +218,16 @@ ...@@ -217,13 +218,16 @@
} }
} }
else { else {
// Update violation count badge
$('#violationCountBadge').html(0).removeClass('badge-warning').addClass('badge-success');
// Update violations table // Update violations table
table_html ='<tr class="text-muted"><td colspan="2" class="text-center">{% trans "No violations" %}</td></tr>' table_html ='<tr class="text-muted"><td colspan="2" class="text-center">{% trans "No violations" %}</td></tr>'
} }
// Update violation count badge
if(unresolved_violations_count > 0)
$('#violationCountBadge').html(response.length).removeClass('badge-success').addClass('badge-warning');
else
$('#violationCountBadge').html(0).removeClass('badge-warning').addClass('badge-success');
// Show violation list (potentially empty) in violations table // Show violation list (potentially empty) in violations table
$('#violationsTableBody').html(table_html); $('#violationsTableBody').html(table_html);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment