Skip to content

Commit

Permalink
Merge branch 'feature/improve-multi-select-view-8565'
Browse files Browse the repository at this point in the history
  • Loading branch information
majentsch committed May 18, 2015
2 parents ca37226 + 1f20ba1 commit 592d5ea
Show file tree
Hide file tree
Showing 29 changed files with 1,363 additions and 607 deletions.
1 change: 0 additions & 1 deletion library/Icinga/Authentication/Backend/LdapUserBackend.php
Expand Up @@ -286,7 +286,6 @@ public function listUsers()
$users[] = $row->{$this->userNameAttribute};
}
}

return $users;
}
}
3 changes: 2 additions & 1 deletion library/Icinga/Protocol/Ldap/Capability.php
Expand Up @@ -9,7 +9,8 @@
* Provides information about the available encryption mechanisms (StartTLS), the supported
* LDAP protocol (v2/v3), vendor-specific extensions or protocols controls and extensions.
*/
class Capability {
class Capability
{

const LDAP_SERVER_START_TLS_OID = '1.3.6.1.4.1.1466.20037';

Expand Down
3 changes: 2 additions & 1 deletion library/Icinga/Util/Color.php
Expand Up @@ -6,7 +6,8 @@
/**
* Provide functions to change and convert colors.
*/
class Color {
class Color
{
/**
* Convert a given color string to an rgb-array containing
* each color as a decimal value.
Expand Down
55 changes: 55 additions & 0 deletions library/Icinga/Util/String.php
Expand Up @@ -79,4 +79,59 @@ public static function findSimilar($string, array $possibilities, $similarity =

return $matches;
}

/**
* Check if a string ends with a different string
*
* @param $haystack The string to search for matches
* @param $needle The string to match at the start of the haystack
*
* @return bool Whether or not needle is at the beginning of haystack
*/
public static function endsWith($haystack, $needle)
{
return $needle === '' ||
(($temp = strlen($haystack) - strlen($needle)) >= 0 && false !== strpos($haystack, $needle, $temp));
}

/**
* Generates an array of strings that constitutes the cartesian product of all passed sets, with all
* string combinations concatenated using the passed join-operator.
*
* <pre>
* cartesianProduct(
* array(array('foo', 'bar'), array('mumble', 'grumble', null)),
* '_'
* );
* => array('foo_mumble', 'foo_grumble', 'bar_mumble', 'bar_grumble', 'foo', 'bar')
* </pre>
*
* @param array $sets An array of arrays containing all sets for which the cartesian
* product should be calculated.
* @param string $glue The glue used to join the strings, defaults to ''.
*
* @returns array The cartesian product in one array of strings.
*/
public static function cartesianProduct(array $sets, $glue = '')
{
$product = null;
foreach ($sets as $set) {
if (! isset($product)) {
$product = $set;
} else {
$newProduct = array();
foreach ($product as $strA) {
foreach ($set as $strB) {
if ($strB === null) {
$newProduct []= $strA;
} else {
$newProduct []= $strA . $glue . $strB;
}
}
}
$product = $newProduct;
}
}
return $product;
}
}
56 changes: 56 additions & 0 deletions library/Icinga/Web/Widget/Chart/InlinePie.php
Expand Up @@ -5,11 +5,13 @@

use Icinga\Chart\PieChart;
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Icinga\Util\String;
use Icinga\Web\Widget\AbstractWidget;
use Icinga\Web\Url;
use Icinga\Util\Format;
use Icinga\Application\Logger;
use Icinga\Exception\IcingaException;
use stdClass;

/**
* A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the
Expand All @@ -27,6 +29,45 @@ class InlinePie extends AbstractWidget
const NUMBER_FORMAT_BYTES = 'bytes';
const NUMBER_FORMAT_RATIO = 'ratio';

public static $colorsHostStates = array(
'#44bb77', // up
'#ff99aa', // down
'#cc77ff', // unreachable
'#77aaff' // pending
);

public static $colorsHostStatesHandledUnhandled = array(
'#44bb77', // up
'#44bb77',
'#ff99aa', // down
'#ff5566',
'#cc77ff', // unreachable
'#aa44ff',
'#77aaff', // pending
'#77aaff'
);

public static $colorsServiceStates = array(
'#44bb77', // Ok
'#ffaa44', // Warning
'#ff99aa', // Critical
'#aa44ff', // Unknown
'#77aaff' // Pending
);

public static $colorsServiceStatesHandleUnhandled = array(
'#44bb77', // Ok
'#44bb77',
'#ffaa44', // Warning
'#ffcc66',
'#ff99aa', // Critical
'#ff5566',
'#cc77ff', // Unknown
'#aa44ff',
'#77aaff', // Pending
'#77aaff'
);

/**
* The template string used for rendering this widget
*
Expand Down Expand Up @@ -231,4 +272,19 @@ public function render()
$template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template);
return $template;
}

public static function createFromStateSummary(stdClass $states, $title, array $colors)
{
$handledUnhandledStates = array();
foreach ($states as $key => $value) {
if (String::endsWith($key, '_handled') || String::endsWith($key, '_unhandled')) {
$handledUnhandledStates[$key] = $value;
}
}
$chart = new self(array_values($handledUnhandledStates), $title, $colors);
return $chart
->setSize(50)
->setTitle('')
->setSparklineClass('sparkline-multi');
}
}
10 changes: 5 additions & 5 deletions library/Icinga/Web/Widget/FilterEditor.php
Expand Up @@ -447,10 +447,10 @@ protected function renderFilterExpression(FilterExpression $filter)
if ($this->addTo && $this->addTo === $filter->getId()) {
return
preg_replace(
'/ class="autosubmit"/',
' class="autofocus"',
$this->selectOperator()
)
'/ class="autosubmit"/',
' class="autofocus"',
$this->selectOperator()
)
. '<ul><li>'
. $this->selectColumn($filter)
. $this->selectSign($filter)
Expand Down Expand Up @@ -697,7 +697,7 @@ public function renderSearch()
. t('Search...')
. '" /></form>';

if ($this->filter->isEmpty()) {
if ($this->filter->isEmpty()) {
$title = t('Filter this list');
} else {
$title = t('Modify this filter');
Expand Down

0 comments on commit 592d5ea

Please sign in to comment.