diff --git a/library/Businessprocess/Renderer/TileRenderer.php b/library/Businessprocess/Renderer/TileRenderer.php index 1c6ca3b..5972a28 100644 --- a/library/Businessprocess/Renderer/TileRenderer.php +++ b/library/Businessprocess/Renderer/TileRenderer.php @@ -21,7 +21,7 @@ class TileRenderer extends Renderer 'tiles', $this->howMany() ), - 'data-base-target' => '_self', + 'data-base-target' => '_next', ) ); @@ -81,14 +81,11 @@ class TileRenderer extends Renderer protected function addNewNode() { $div = Container::create( - array('class' => 'addnew') + array('class' => 'addnew', 'data-base-target' => '_self') ); $actions = Container::create( - array( - 'class' => 'actions', - 'data-base-target' => '_self' - ) + array('class'=> 'actions') ); $link = Link::create( diff --git a/library/Businessprocess/Web/Component/BpDashboardTile.php b/library/Businessprocess/Web/Component/BpDashboardTile.php new file mode 100644 index 0000000..1d00681 --- /dev/null +++ b/library/Businessprocess/Web/Component/BpDashboardTile.php @@ -0,0 +1,53 @@ + 'dashboard-tile']; + + public function __construct(BpConfig $bp, $title, $description, $icon, $url, $urlParams = null, $attributes = null) + { + $this->add( + Container::create( + ['class' => 'bp-link'], + Link::create( + Icon::create($icon), + $url, + $urlParams, + $attributes + )->add( + Element::create('span', array('class' => 'header'))->addContent($title) + )->addContent($description) + ) + ); + + $tiles = Container::create(['class' => 'bp-root-tiles']); + + foreach ($bp->getChildren() as $node) { + $state = strtolower($node->getStateName()); + + $tiles->add( + Link::create( + Text::create(' ')->setEscaped(), + $url, + $urlParams + ['node' => $node->getName()], + ['class' => "badge state-{$state}", 'title' => $node->getAlias()] + ) + ); + } + + $this->add($tiles); + } +} diff --git a/library/Businessprocess/Web/Component/Dashboard.php b/library/Businessprocess/Web/Component/Dashboard.php index c33ec61..10eec7a 100644 --- a/library/Businessprocess/Web/Component/Dashboard.php +++ b/library/Businessprocess/Web/Component/Dashboard.php @@ -6,6 +6,7 @@ use Icinga\Authentication\Auth; use Icinga\Module\Businessprocess\Html\BaseElement; use Icinga\Module\Businessprocess\Html\Container; use Icinga\Module\Businessprocess\Html\HtmlTag; +use Icinga\Module\Businessprocess\State\MonitoringState; use Icinga\Module\Businessprocess\Storage\Storage; class Dashboard extends BaseElement @@ -85,7 +86,12 @@ class Dashboard extends BaseElement } else { $title = $name; } - $this->add(new DashboardAction( + + $bp = $storage->loadProcess($name); + MonitoringState::apply($bp); + + $this->add(new BpDashboardTile( + $bp, $title, $meta->get('Description'), 'sitemap', diff --git a/public/css/module.less b/public/css/module.less index 38f187c..95ca225 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -286,7 +286,7 @@ table.bp { } &.unreachable > tbody > tr > { th, td > a { background-color: @colorUnknown; } - } + } &.unreachable.handled > tbody > tr > { th, td > a { background-color: @colorUnreachableHandled; } } @@ -337,11 +337,65 @@ div.knightrider table.bp { /** BEGIN Dashboard **/ .overview-dashboard { - > div.action { + .header { + font-weight: bold; + display: block; + font-size: 1.25em; + } + + i { + float: left; + font-size: 2.5em; + margin-top: -0.1em; + margin-bottom: 2em; + color: inherit; + } + + .bp-root-tiles { + margin-left: 3em; + } + + .dashboard-tile { + cursor: pointer; + padding: 1em; + + &:hover { + background-color: @gray-lighter; + } + + .bp-link { + > a { + text-decoration: none; + color: inherit; + vertical-align: middle; + word-wrap: break-word; + width: 100%; + overflow: hidden; + } + } + + .badge { + margin-top: 0.25em; + text-decoration: none; + + &:last-child { + margin-right: 0; + } + + &:hover { + box-shadow: 0px 0px 5px #666; + } + } + } + + .dashboard-tile, + div.action { width: 20em; display: inline-block; vertical-align: top; + } + .action { > a { text-decoration: none; color: inherit; @@ -350,31 +404,12 @@ div.knightrider table.bp { padding: 1em; word-wrap: break-word; width: 100%; - height: 12em; overflow: hidden; box-sizing: border-box; - > span.header { - font-weight: bold; - display: block; - font-size: 1.25em; - } - - &:hover { - background-color: @text-color; - color: white; - } - &.addnew:hover { background-color: @icinga-blue; - } - - i { - float: left; - font-size: 2.5em; - margin-top: -0.1em; - margin-bottom: 2em; - color: inherit; + color: white; } } } diff --git a/public/js/module.js b/public/js/module.js index 0ea4169..b5617ee 100644 --- a/public/js/module.js +++ b/public/js/module.js @@ -34,6 +34,7 @@ this.module.on('mouseleave', 'div.bp', this.procMouseOut); this.module.on('click', 'div.tiles > div', this.tileClick); + this.module.on('click', '.dashboard-tile', this.dashboardTileClick); this.module.icinga.logger.debug('BP module initialized'); }, @@ -84,6 +85,10 @@ $(event.currentTarget).find('> a').first().trigger('click'); }, + dashboardTileClick: function(event) { + $(event.currentTarget).find('> .bp-link > a').first().trigger('click'); + }, + /** * Add 'hovered' class to hovered title elements *