Skip to content

Commit adfbf68

Browse files
authored
Progress bar fixes (librenms#18616)
Fix undefined array key error Fix right background color not being applied (and update default)
1 parent 7aed25a commit adfbf68

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

LibreNMS/Util/Color.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,30 @@ public static function percentage($percentage, $component_perc_warn = null): arr
5858
if ($percentage > 75) {
5959
return [
6060
'left' => 'bf5d5b',
61-
'right' => 'd39392',
61+
'right' => 'eaeaea',
6262
'middle' => 'c97e7d',
6363
];
6464
}
6565

6666
if ($percentage > 50) {
6767
return [
6868
'left' => 'bf875b',
69-
'right' => 'd3ae92',
69+
'right' => 'eaeaea',
7070
'middle' => 'cca07e',
7171
];
7272
}
7373

7474
if ($percentage > 25) {
7575
return [
7676
'left' => '5b93bf',
77-
'right' => '92b7d3',
77+
'right' => 'eaeaea',
7878
'middle' => '7da8c9',
7979
];
8080
}
8181

8282
return [
8383
'left' => '9abf5b',
84-
'right' => 'bbd392',
84+
'right' => 'eaeaea',
8585
'middle' => 'afcc7c',
8686
];
8787
}

LibreNMS/Util/Html.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ public static function percentageBar($width, $height, $percent, $left_text = '',
145145
$colors = Color::percentage($percent, $warn ?: null);
146146
}
147147
$default = Color::percentage(0);
148-
$left_text_color = $colors['left_text'] ? '#' . $colors['left_text'] : 'inherit';
149-
$right_text_color = $colors['right_text'] ? '#' . $colors['right_text'] : 'inherit';
148+
$left_text_color = empty($colors['left_text']) ? 'inherit' : '#' . $colors['left_text'];
149+
$right_text_color = empty($colors['right_text']) ? 'inherit' : '#' . $colors['right_text'];
150150
$left_color = $colors['left'] ?? $default['left'];
151151
$right_color = $colors['right'] ?? $default['right'];
152152

153153
$output = [];
154154
$output[] = '<div style="width:' . $width . 'px">';
155-
$output[] = '<div class="progress" style="background-color:#eaeaea; height:' . $height . 'px; margin-bottom: 4px;">';
155+
$output[] = '<div class="progress" style="background-color:#' . $right_color . '; height:' . $height . 'px; margin-bottom: 4px;">';
156156

157157
$output[] = '<div class="progress-bar" role="progressbar" aria-valuenow="' . $percent . '" aria-valuemin="0" aria-valuemax="100" style="width:' . $percent . '%; background-color: #' . $left_color . '; height:' . $height . 'px;"></div>';
158158

0 commit comments

Comments
 (0)