mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-05 21:29:33 -05:00
Merge pull request #182 from Icinga/feature/dashboard-display-root-nodes
Display root nodes in the dashboard
This commit is contained in:
commit
1975cab74d
5 changed files with 125 additions and 29 deletions
|
|
@ -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(
|
||||
|
|
|
|||
53
library/Businessprocess/Web/Component/BpDashboardTile.php
Normal file
53
library/Businessprocess/Web/Component/BpDashboardTile.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Businessprocess\Web\Component;
|
||||
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\Html\BaseElement;
|
||||
use Icinga\Module\Businessprocess\Html\Container;
|
||||
use Icinga\Module\Businessprocess\Html\Element;
|
||||
use Icinga\Module\Businessprocess\Html\Icon;
|
||||
use Icinga\Module\Businessprocess\Html\Link;
|
||||
use Icinga\Module\Businessprocess\Html\Text;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
|
||||
class BpDashboardTile extends BaseElement
|
||||
{
|
||||
protected $tag = 'div';
|
||||
|
||||
protected $defaultAttributes = ['class' => '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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue