mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Limit perfdata label size
Add paratentheses when perfdata label size exceeds a certain limit. Display the full label as tooltip. refs #8334
This commit is contained in:
parent
ff01ee4f20
commit
1e8151bed3
@ -54,6 +54,26 @@ class String
|
|||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add ellipsis in the center of a string when a string is longer than max length
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param int $maxLength
|
||||||
|
* @param string $ellipsis
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function ellipsisCenter($string, $maxLength, $ellipsis = '...')
|
||||||
|
{
|
||||||
|
$start = ceil($maxLength / 2.0);
|
||||||
|
$end = floor($maxLength / 2.0);
|
||||||
|
if (strlen($string) > $maxLength) {
|
||||||
|
return substr($string, 0, $start - strlen($ellipsis)) . $ellipsis . substr($string, - $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find and return all similar strings in $possibilites matching $string with the given minimum $similarity
|
* Find and return all similar strings in $possibilites matching $string with the given minimum $similarity
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
use Icinga\Module\Monitoring\Plugin\Perfdata;
|
use Icinga\Module\Monitoring\Plugin\Perfdata;
|
||||||
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
|
||||||
|
use Icinga\Util\String;
|
||||||
|
|
||||||
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||||||
$columns[$column] = $labels[$column];
|
$columns[$column] = $labels[$column];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// restore original column array sorting sorting
|
// restore original column array sorting
|
||||||
$headers = array();
|
$headers = array();
|
||||||
foreach ($keys as $i => $column) {
|
foreach ($keys as $i => $column) {
|
||||||
if (isset($columns[$column])) {
|
if (isset($columns[$column])) {
|
||||||
@ -70,7 +71,12 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||||||
if (! isset($columns[$column])) {
|
if (! isset($columns[$column])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$data []= empty($value) ? '-' : (string) $value;
|
$text = $this->view->escape(empty($value) ? '-' : $value);
|
||||||
|
$data []= sprintf(
|
||||||
|
'<span title="%s">%s</span>',
|
||||||
|
$text,
|
||||||
|
String::ellipsisCenter($text, 24)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$table []= '<tr><td>' . implode('</td><td>', $data) . '</td></tr>';
|
$table []= '<tr><td>' . implode('</td><td>', $data) . '</td></tr>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user