lib: Remove all traces of Icinga\Module\Businessprocess\Html

refs #130
This commit is contained in:
Johannes Meyer 2019-01-17 13:21:46 +01:00
parent 908dbd905f
commit 19ae300aca
22 changed files with 454 additions and 479 deletions

View file

@ -53,7 +53,7 @@ class NodeController extends Controller
)->setPath($path); )->setPath($path);
$bc = Breadcrumb::create($renderer); $bc = Breadcrumb::create($renderer);
$bc->attributes()->set('data-base-target', '_next'); $bc->getAttributes()->set('data-base-target', '_next');
$content->add($bc); $content->add($bc);
} }
} }

View file

@ -5,11 +5,6 @@ namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Date\DateFormatter; use Icinga\Date\DateFormatter;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\Html\Element;
use Icinga\Module\Businessprocess\Html\HtmlString;
use Icinga\Module\Businessprocess\Html\HtmlTag;
use Icinga\Module\Businessprocess\Html\Icon;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\Renderer\Breadcrumb; use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
use Icinga\Module\Businessprocess\Renderer\Renderer; use Icinga\Module\Businessprocess\Renderer\Renderer;
@ -23,11 +18,13 @@ use Icinga\Module\Businessprocess\Web\Component\ActionBar;
use Icinga\Module\Businessprocess\Web\Component\RenderedProcessActionBar; use Icinga\Module\Businessprocess\Web\Component\RenderedProcessActionBar;
use Icinga\Module\Businessprocess\Web\Component\Tabs; use Icinga\Module\Businessprocess\Web\Component\Tabs;
use Icinga\Module\Businessprocess\Web\Controller; use Icinga\Module\Businessprocess\Web\Controller;
use Icinga\Module\Businessprocess\Web\Url;
use Icinga\Util\Json; use Icinga\Util\Json;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\DashboardAction;
use Icinga\Web\Widget\Tabextension\OutputFormat; use Icinga\Web\Widget\Tabextension\OutputFormat;
use ipl\Html\Html;
use ipl\Html\HtmlString;
class ProcessController extends Controller class ProcessController extends Controller
{ {
@ -45,7 +42,7 @@ class ProcessController extends Controller
$this->setTitle($title); $this->setTitle($title);
$this->controls() $this->controls()
->add($this->tabsForCreate()->activate('create')) ->add($this->tabsForCreate()->activate('create'))
->add(HtmlTag::h1($title)); ->add(Html::tag('h1', null, $title));
$this->content()->add( $this->content()->add(
$this->loadForm('bpConfig') $this->loadForm('bpConfig')
@ -66,7 +63,7 @@ class ProcessController extends Controller
$this->setTitle($title); $this->setTitle($title);
$this->controls() $this->controls()
->add($this->tabsForCreate()->activate('upload')) ->add($this->tabsForCreate()->activate('upload'))
->add(HtmlTag::h1($title)); ->add(Html::tag('h1', null, $title));
$this->content()->add( $this->content()->add(
$this->loadForm('BpUpload') $this->loadForm('BpUpload')
@ -113,9 +110,9 @@ class ProcessController extends Controller
} }
$bp->addError(sprintf('There are %d missing nodes: %s', $count, implode(', ', $missing))); $bp->addError(sprintf('There are %d missing nodes: %s', $count, implode(', ', $missing)));
} }
$this->content()->addContent($this->showHints($bp)); $this->content()->add($this->showHints($bp));
$this->content()->addContent($this->showWarnings($bp)); $this->content()->add($this->showWarnings($bp));
$this->content()->addContent($this->showErrors($bp)); $this->content()->add($this->showErrors($bp));
$this->content()->add($renderer); $this->content()->add($renderer);
$this->loadActionForm($bp, $node); $this->loadActionForm($bp, $node);
$this->setDynamicAutorefresh(); $this->setDynamicAutorefresh();
@ -126,27 +123,23 @@ class ProcessController extends Controller
$controls = $this->controls(); $controls = $this->controls();
if ($this->showFullscreen) { if ($this->showFullscreen) {
$controls->attributes()->add('class', 'want-fullscreen'); $controls->getAttributes()->add('class', 'want-fullscreen');
$controls->add( $controls->add(Html::tag(
Link::create( 'a',
Icon::create('resize-small'), [
$this->url()->without('showFullscreen')->without('view'), 'href' => $this->url()->without('showFullscreen')->without('view'),
null, 'title' => $this->translate('Leave full screen and switch back to normal mode'),
array( 'style' => 'float: right'
'style' => 'float: right', ],
'title' => $this->translate( Html::tag('i', ['class' => 'icon icon-resize-small'])
'Leave full screen and switch back to normal mode' ));
)
)
)
);
} }
if (! ($this->showFullscreen || $this->view->compact)) { if (! ($this->showFullscreen || $this->view->compact)) {
$controls->add($this->getProcessTabs($bp, $renderer)); $controls->add($this->getProcessTabs($bp, $renderer));
} }
if (! $this->view->compact) { if (! $this->view->compact) {
$controls->add(Element::create('h1')->setContent($this->view->title)); $controls->add(Html::tag('h1')->setContent($this->view->title));
} }
$controls->add(Breadcrumb::create($renderer)); $controls->add(Breadcrumb::create($renderer));
if (! $this->showFullscreen && ! $this->view->compact) { if (! $this->showFullscreen && ! $this->view->compact) {
@ -259,7 +252,7 @@ class ProcessController extends Controller
} }
if ($form) { if ($form) {
$this->content()->prependContent(HtmlString::create((string) $form)); $this->content()->prepend(HtmlString::create((string) $form));
} }
} }
@ -283,9 +276,9 @@ class ProcessController extends Controller
protected function showWarnings(BpConfig $bp) protected function showWarnings(BpConfig $bp)
{ {
if ($bp->hasWarnings()) { if ($bp->hasWarnings()) {
$ul = Element::create('ul', array('class' => 'warning')); $ul = Html::tag('ul', array('class' => 'warning'));
foreach ($bp->getWarnings() as $warning) { foreach ($bp->getWarnings() as $warning) {
$ul->createElement('li')->addContent($warning); $ul->add(Html::tag('li')->setContent($warning));
} }
return $ul; return $ul;
@ -297,9 +290,9 @@ class ProcessController extends Controller
protected function showErrors(BpConfig $bp) protected function showErrors(BpConfig $bp)
{ {
if ($bp->hasWarnings()) { if ($bp->hasWarnings()) {
$ul = Element::create('ul', array('class' => 'error')); $ul = Html::tag('ul', array('class' => 'error'));
foreach ($bp->getErrors() as $msg) { foreach ($bp->getErrors() as $msg) {
$ul->createElement('li')->addContent($msg); $ul->add(Html::tag('li')->setContent($msg));
} }
return $ul; return $ul;
@ -310,40 +303,41 @@ class ProcessController extends Controller
protected function showHints(BpConfig $bp) protected function showHints(BpConfig $bp)
{ {
$ul = Element::create('ul', array('class' => 'error')); $ul = Html::tag('ul', ['class' => 'error']);
foreach ($bp->getErrors() as $error) { foreach ($bp->getErrors() as $error) {
$ul->createElement('li')->addContent($error); $ul->add(Html::tag('li')->setContent($error));
} }
if ($bp->hasChanges()) { if ($bp->hasChanges()) {
$ul->createElement('li')->setSeparator(' ')->addContent(sprintf( $li = Html::tag('li')->setSeparator(' ');
$li->add(sprintf(
$this->translate('This process has %d pending change(s).'), $this->translate('This process has %d pending change(s).'),
$bp->countChanges() $bp->countChanges()
))->addContent( ))->add(Html::tag(
Link::create( 'a',
$this->translate('Store'), ['href' => Url::fromPath('businessprocess/process/config', ['config' => $bp->getName()])],
'businessprocess/process/config', $this->translate('Store')
array('config' => $bp->getName()) ))->add(Html::tag(
) 'a',
)->addContent( ['href' => $this->url()->with('dismissChanges', true)],
Link::create( $this->translate('Dismiss')
$this->translate('Dismiss'), ));
$this->url()->with('dismissChanges', true), $ul->add($li);
null
)
);
} }
if ($bp->hasSimulations()) { if ($bp->hasSimulations()) {
$ul->createElement('li')->setSeparator(' ')->addContent(sprintf( $li = Html::tag('li')->setSeparator(' ');
$li->add(sprintf(
$this->translate('This process shows %d simulated state(s).'), $this->translate('This process shows %d simulated state(s).'),
$bp->countSimulations() $bp->countSimulations()
))->addContent(Link::create( ))->add(Html::tag(
$this->translate('Dismiss'), 'a',
$this->url()->with('dismissSimulations', true) ['href' => $this->url()->with('dismissSimulations', true)],
$this->translate('Dismiss')
)); ));
$ul->add($li);
} }
if ($ul->hasContent()) { if (! $ul->isEmpty()) {
return $ul; return $ul;
} else { } else {
return null; return null;
@ -380,7 +374,7 @@ class ProcessController extends Controller
$this->setTitle($title); $this->setTitle($title);
$this->controls() $this->controls()
->add($this->tabsForConfig($bp)->activate('source')) ->add($this->tabsForConfig($bp)->activate('source'))
->add(HtmlTag::h1($title)) ->add(Html::tag('h1', null, $title))
->add($this->createConfigActionBar($bp, $showDiff)); ->add($this->createConfigActionBar($bp, $showDiff));
$this->setViewScript('process/source'); $this->setViewScript('process/source');
@ -424,7 +418,7 @@ class ProcessController extends Controller
$this->setTitle($title); $this->setTitle($title);
$this->controls() $this->controls()
->add($this->tabsForConfig($bp)->activate('config')) ->add($this->tabsForConfig($bp)->activate('config'))
->add(HtmlTag::h1($title)) ->add(Html::tag('h1', null, $title))
->add($this->createConfigActionBar($bp)); ->add($this->createConfigActionBar($bp));
$url = Url::fromPath( $url = Url::fromPath(
@ -446,48 +440,42 @@ class ProcessController extends Controller
if ($showDiff) { if ($showDiff) {
$params = array('config' => $config->getName()); $params = array('config' => $config->getName());
$actionBar->add( $actionBar->add(Html::tag(
Link::create( 'a',
$this->translate('Source'), [
'businessprocess/process/source', 'href' => Url::fromPath('businessprocess/process/source', $params),
$params, 'class' => 'icon-doc-text',
array( 'title' => $this->translate('Show source code')
'class' => 'icon-doc-text', ],
'title' => $this->translate('Show source code'), $this->translate('Source')
) ));
)
);
} else { } else {
$params = array( $params = array(
'config' => $config->getName(), 'config' => $config->getName(),
'showDiff' => true 'showDiff' => true
); );
$actionBar->add( $actionBar->add(Html::tag(
Link::create( 'a',
$this->translate('Diff'), [
'businessprocess/process/source', 'href' => Url::fromPath('businessprocess/process/source', $params),
$params, 'class' => 'icon-flapping',
array( 'title' => $this->translate('Highlight changes')
'class' => 'icon-flapping', ],
'title' => $this->translate('Highlight changes'), $this->translate('Diff')
) ));
)
);
} }
$actionBar->add( $actionBar->add(Html::tag(
Link::create( 'a',
$this->translate('Download'), [
'businessprocess/process/download', 'href' => Url::fromPath('businessprocess/process/download', ['config' => $config->getName()]),
array('config' => $config->getName()), 'class' => 'icon-download',
array( 'target' => '_blank',
'target' => '_blank', 'title' => $this->translate('Download process configuration')
'class' => 'icon-download', ],
'title' => $this->translate('Download process configuration') $this->translate('Download')
) ));
)
);
return $actionBar; return $actionBar;
} }

View file

@ -2,8 +2,8 @@
namespace Icinga\Module\Businessprocess; namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Web\Url; use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\Html;
class HostNode extends MonitoredNode class HostNode extends MonitoredNode
{ {
@ -69,6 +69,6 @@ class HostNode extends MonitoredNode
public function getLink() public function getLink()
{ {
return Link::create($this->hostname, $this->getUrl()); return Html::tag('a', ['href' => $this->getUrl()], $this->hostname);
} }
} }

View file

@ -3,11 +3,11 @@
namespace Icinga\Module\Businessprocess; namespace Icinga\Module\Businessprocess;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\State\MonitoringState; use Icinga\Module\Businessprocess\State\MonitoringState;
use Icinga\Module\Businessprocess\Storage\LegacyStorage; use Icinga\Module\Businessprocess\Storage\LegacyStorage;
use Icinga\Module\Businessprocess\Web\Url;
use Exception; use Exception;
use Icinga\Web\Url;
use ipl\Html\Html;
class ImportedNode extends Node class ImportedNode extends Node
{ {
@ -226,13 +226,15 @@ class ImportedNode extends Node
*/ */
public function getLink() public function getLink()
{ {
return Link::create( return Html::tag(
$this->getAlias(), 'a',
'businessprocess/process/show', [
array( 'href' => Url::fromPath('businessprocess/process/show', [
'config' => $this->configName, 'config' => $this->configName,
'node' => $this->nodeName 'node' => $this->nodeName
) ])
],
$this->getAlias()
); );
} }
} }

View file

@ -2,7 +2,7 @@
namespace Icinga\Module\Businessprocess; namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\Html\Link; use ipl\Html\Html;
abstract class MonitoredNode extends Node abstract class MonitoredNode extends Node
{ {
@ -11,9 +11,9 @@ abstract class MonitoredNode extends Node
public function getLink() public function getLink()
{ {
if ($this->isMissing()) { if ($this->isMissing()) {
return Link::create($this->getAlias(), '#'); return Html::tag('a', ['href' => '#'], $this->getAlias());
} else { } else {
return Link::create($this->getAlias(), $this->getUrl()); return Html::tag('a', ['href' => $this->getUrl()], $this->getAlias());
} }
} }
} }

View file

@ -3,7 +3,7 @@
namespace Icinga\Module\Businessprocess; namespace Icinga\Module\Businessprocess;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Module\Businessprocess\Html\Link; use ipl\Html\Html;
abstract class Node abstract class Node
{ {
@ -368,12 +368,9 @@ abstract class Node
return $this->className; return $this->className;
} }
/**
* @return Link
*/
public function getLink() public function getLink()
{ {
return Link::create($this->getAlias(), '#'); return Html::tag('a', ['href' => '#'], $this->getAlias());
} }
public function operatorHtml() public function operatorHtml()

View file

@ -3,14 +3,12 @@
namespace Icinga\Module\Businessprocess\Renderer; namespace Icinga\Module\Businessprocess\Renderer;
use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\Html\BaseElement;
use Icinga\Module\Businessprocess\Html\Element;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Html\Icon;
use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile; use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile;
use Icinga\Module\Businessprocess\Web\Url; use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class Breadcrumb extends BaseElement class Breadcrumb extends BaseHtmlElement
{ {
protected $tag = 'ul'; protected $tag = 'ul';
@ -32,16 +30,18 @@ class Breadcrumb extends BaseElement
$bpUrl->remove('action'); $bpUrl->remove('action');
} }
$breadcrumb->add(Element::create('li')->add( $breadcrumb->add(Html::tag('li')->add(
Link::create( Html::tag(
Icon::create('dashboard'), 'a',
Url::fromPath('businessprocess'), [
null, 'href' => Url::fromPath('businessprocess'),
['title' => mt('businessprocess', 'Show Overview')] 'title' => mt('businessprocess', 'Show Overview')
],
Html::tag('i', ['class' => 'icon icon-dashboard'])
) )
)); ));
$breadcrumb->add(Element::create('li')->add( $breadcrumb->add(Html::tag('li')->add(
Link::create($bp->getTitle(), $bpUrl) Html::tag('a', ['href' => $bpUrl], $bp->getTitle())
)); ));
$path = $renderer->getCurrentPath(); $path = $renderer->getCurrentPath();
@ -52,7 +52,7 @@ class Breadcrumb extends BaseElement
static::renderNode($bp->getNode($node), $path, $renderer) static::renderNode($bp->getNode($node), $path, $renderer)
); );
} }
$breadcrumb->addContent($parts); $breadcrumb->add($parts);
return $breadcrumb; return $breadcrumb;
} }
@ -70,7 +70,7 @@ class Breadcrumb extends BaseElement
$renderer = clone($renderer); $renderer = clone($renderer);
$renderer->lock()->setIsBreadcrumb(); $renderer->lock()->setIsBreadcrumb();
$p = new NodeTile($renderer, (string) $node, $node, $path); $p = new NodeTile($renderer, (string) $node, $node, $path);
$p->attributes()->add('class', $renderer->getNodeClasses($node)); $p->getAttributes()->add('class', $renderer->getNodeClasses($node));
$p->setTag('li'); $p->setTag('li');
return $p; return $p;
} }

View file

@ -6,14 +6,14 @@ use Icinga\Date\DateFormatter;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Html\Container;
use Icinga\Module\Businessprocess\Html\Element;
use Icinga\Module\Businessprocess\Html\Html;
use Icinga\Module\Businessprocess\Html\HtmlString;
use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\Web\Url; use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlString;
abstract class Renderer extends Html abstract class Renderer extends HtmlDocument
{ {
/** @var BpConfig */ /** @var BpConfig */
protected $config; protected $config;
@ -122,7 +122,7 @@ abstract class Renderer extends Html
/** /**
* @param $summary * @param $summary
* @return Container * @return BaseHtmlElement
*/ */
public function renderStateBadges($summary) public function renderStateBadges($summary)
{ {
@ -136,26 +136,24 @@ abstract class Renderer extends Html
continue; continue;
} }
$elements[] = Element::create( $elements[] = Html::tag(
'span', 'span',
array( [
'class' => array( 'class' => [
'badge', 'badge',
'badge-' . strtolower($state) 'badge-' . strtolower($state)
), ],
// TODO: We should translate this in this module // TODO: We should translate this in this module
'title' => mt('monitoring', $state) 'title' => mt('monitoring', $state)
) ],
)->setContent($cnt); $cnt
);
} }
if (!empty($elements)) { if (!empty($elements)) {
$container = Container::create( $container = Html::tag('div', ['class' => 'badges']);
array('class' => 'badges')
)/* ->renderIfEmpty(false) */;
foreach ($elements as $element) { foreach ($elements as $element) {
$container->addContent($element); $container->add($element);
} }
return $container; return $container;
@ -306,13 +304,14 @@ abstract class Renderer extends Html
return HtmlString::create(''); return HtmlString::create('');
} }
return Element::create( return Html::tag(
'span', 'span',
array( [
'class' => array('relative-time', 'time-since'), 'class' => ['relative-time', 'time-since'],
'title' => DateFormatter::formatDateTime($time), 'title' => DateFormatter::formatDateTime($time)
) ],
)->setContent(DateFormatter::timeSince($time, $timeOnly)); DateFormatter::timeSince($time, $timeOnly)
);
} }
protected function createUnboundParent(BpConfig $bp) protected function createUnboundParent(BpConfig $bp)

View file

@ -2,10 +2,8 @@
namespace Icinga\Module\Businessprocess\Renderer; namespace Icinga\Module\Businessprocess\Renderer;
use Icinga\Module\Businessprocess\Html\Container;
use Icinga\Module\Businessprocess\Html\Icon;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile; use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile;
use ipl\Html\Html;
class TileRenderer extends Renderer class TileRenderer extends Renderer
{ {
@ -15,14 +13,12 @@ class TileRenderer extends Renderer
public function render() public function render()
{ {
$bp = $this->config; $bp = $this->config;
$nodesDiv = Container::create( $nodesDiv = Html::tag(
array( 'div',
'class' => array( [
'tiles', 'class' => ['tiles', $this->howMany()],
$this->howMany() 'data-base-target' => '_next'
), ]
'data-base-target' => '_next',
)
); );
$nodes = $this->getChildNodes(); $nodes = $this->getChildNodes();
@ -50,7 +46,7 @@ class TileRenderer extends Renderer
$this->add($this->addNewNode()); $this->add($this->addNewNode());
} }
$nodesDiv->addContent($this->getContent()); $nodesDiv->add($this->getContent());
$this->setContent($nodesDiv); $this->setContent($nodesDiv);
return parent::render(); return parent::render();
@ -80,30 +76,26 @@ class TileRenderer extends Renderer
protected function addNewNode() protected function addNewNode()
{ {
$div = Container::create( $div = Html::tag('div', ['class' => 'addnew', 'data-base-target' => '_self']);
array('class' => 'addnew', 'data-base-target' => '_self')
);
$actions = Container::create( $actions = Html::tag('div', ['class'=> 'actions']);
array('class'=> 'actions')
);
$link = Link::create( $link = Html::tag(
$this->translate('Add'), 'a',
$this->getUrl()->with('action', 'add'), [
null, 'href' => $this->getUrl()->with('action', 'add'),
array( 'title' => mt('businessprocess', 'Add a new business process node')
'title' => $this->translate('Add a new business process node') ],
) mt('businessprocess', 'Add')
); );
$actions->add( $actions->add(
Link::create( Html::tag(
Icon::create('plus'), 'a',
$this->getUrl()->with('action', 'add'), [
null, 'href' => $this->getUrl()->with('action', 'add'),
array( 'title' => mt('businessprocess', 'Add a new business process node')
'title' => $this->translate('Add a new business process node') ],
) Html::tag('i', ['class' => 'icon icon-plus'])
) )
); );

View file

@ -4,18 +4,15 @@ namespace Icinga\Module\Businessprocess\Renderer\TileRenderer;
use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\HostNode; use Icinga\Module\Businessprocess\HostNode;
use Icinga\Module\Businessprocess\Html\BaseElement;
use Icinga\Module\Businessprocess\Html\Container;
use Icinga\Module\Businessprocess\Html\HtmlString;
use Icinga\Module\Businessprocess\Html\Icon;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\ImportedNode; use Icinga\Module\Businessprocess\ImportedNode;
use Icinga\Module\Businessprocess\MonitoredNode; use Icinga\Module\Businessprocess\MonitoredNode;
use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\Renderer\Renderer; use Icinga\Module\Businessprocess\Renderer\Renderer;
use Icinga\Module\Businessprocess\ServiceNode; use Icinga\Module\Businessprocess\ServiceNode;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class NodeTile extends BaseElement class NodeTile extends BaseHtmlElement
{ {
protected $tag = 'div'; protected $tag = 'div';
@ -28,7 +25,7 @@ class NodeTile extends BaseElement
protected $path; protected $path;
/** /**
* @var Container * @var BaseHtmlElement
*/ */
private $actions; private $actions;
@ -57,11 +54,12 @@ class NodeTile extends BaseElement
protected function addActions() protected function addActions()
{ {
$this->actions = Container::create( $this->actions = Html::tag(
array( 'div',
[
'class' => 'actions', 'class' => 'actions',
'data-base-target' => '_self' 'data-base-target' => '_self'
) ]
); );
return $this->add($this->actions); return $this->add($this->actions);
@ -72,7 +70,7 @@ class NodeTile extends BaseElement
$renderer = $this->renderer; $renderer = $this->renderer;
$node = $this->node; $node = $this->node;
$attributes = $this->attributes(); $attributes = $this->getAttributes();
$attributes->add('class', $renderer->getNodeClasses($node)); $attributes->add('class', $renderer->getNodeClasses($node));
$attributes->add('id', 'bp-' . (string) $node); $attributes->add('id', 'bp-' . (string) $node);
@ -83,9 +81,9 @@ class NodeTile extends BaseElement
if ($node instanceof BpNode) { if ($node instanceof BpNode) {
if ($renderer->isBreadcrumb()) { if ($renderer->isBreadcrumb()) {
$link->addContent($renderer->renderStateBadges($node->getStateSummary())); $link->add($renderer->renderStateBadges($node->getStateSummary()));
} else { } else {
$this->addContent($renderer->renderStateBadges($node->getStateSummary())); $this->add($renderer->renderStateBadges($node->getStateSummary()));
} }
} }
@ -168,32 +166,22 @@ class NodeTile extends BaseElement
} }
/** /**
* @return Link * @return BaseHtmlElement
*/ */
protected function getMainNodeLink() protected function getMainNodeLink()
{ {
$node = $this->node; $node = $this->node;
$url = $this->getMainNodeUrl($node); $url = $this->getMainNodeUrl($node);
if ($node instanceof ServiceNode) { if ($node instanceof ServiceNode) {
$link = Link::create( $link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getAlias());
$node->getAlias(),
$url,
null,
array('data-base-target' => '_next')
);
} elseif ($node instanceof HostNode) { } elseif ($node instanceof HostNode) {
$link = Link::create( $link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getHostname());
$node->getHostname(),
$url,
null,
array('data-base-target' => '_next')
);
} else { } else {
$link = Link::create($node->getAlias(), $url); $link = Html::tag('a', ['href' => $url], $node->getAlias());
if ($node instanceof ImportedNode) { if ($node instanceof ImportedNode) {
$link->attributes()->add('data-base-target', '_next'); $link->getAttributes()->add('data-base-target', '_next');
} else { } else {
$link->attributes()->add('data-base-target', '_self'); $link->getAttributes()->add('data-base-target', '_self');
} }
} }
@ -206,56 +194,54 @@ class NodeTile extends BaseElement
$url = $this->getMainNodeUrl($node); $url = $this->getMainNodeUrl($node);
if ($node instanceof BpNode) { if ($node instanceof BpNode) {
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('dashboard'), 'a',
$url->with('mode', 'tile'), [
null, 'data-base-target' => '_self',
array( 'href' => $url->with('mode', 'tile'),
'title' => $this->translate('Show tiles for this subtree'), 'title' => mt('businessprocess', 'Show tiles for this subtree')
'data-base-target' => '_self' ],
) Html::tag('i', ['class' => 'icon icon-dashboard'])
))->add(Link::create( ))->add(Html::tag(
Icon::create('sitemap'), 'a',
$url->with('mode', 'tree'), [
null, 'data-base-target' => '_next',
array( 'href' => $url->with('mode', 'tree'),
'title' => $this->translate('Show this subtree as a tree'), 'title' => mt('businessprocess', 'Show this subtree as a tree')
'data-base-target' => '_next' ],
) Html::tag('i', ['class' => 'icon icon-sitemap'])
)); ));
$url = $node->getInfoUrl(); $url = $node->getInfoUrl();
if ($url !== null) { if ($url !== null) {
$link = Link::create( $link = Html::tag(
Icon::create('info-circled'), 'a',
$url, [
null, 'href' => $url,
array( 'class' => 'node-info',
'title' => sprintf('%s: %s', $this->translate('More information'), $url), 'title' => sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
'class' => 'node-info' ],
) Html::tag('i', ['class' => 'icon icon-circled'])
); );
if (preg_match('#^http(?:s)?://#', $url)) { if (preg_match('#^http(?:s)?://#', $url)) {
$link->addAttributes(array('target' => '_blank')); $link->addAttributes(['target' => '_blank']);
} }
$this->actions()->add($link); $this->actions()->add($link);
} }
} else { } else {
// $url = $this->makeMonitoredNodeUrl($node); // $url = $this->makeMonitoredNodeUrl($node);
if ($node instanceof ServiceNode) { if ($node instanceof ServiceNode) {
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('service'), 'a',
$node->getUrl(), ['href' => $node->getUrl(), 'data-base-target' => '_next'],
null, Html::tag('i', ['class' => 'icon icon-service'])
array('data-base-target' => '_next')
)); ));
} elseif ($node instanceof HostNode) { } elseif ($node instanceof HostNode) {
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('host'), 'a',
$node->getUrl(), ['href' => $node->getUrl(), 'data-base-target' => '_next'],
null, Html::tag('i', ['class' => 'icon icon-host'])
array('data-base-target' => '_next')
)); ));
} }
} }
@ -266,21 +252,29 @@ class NodeTile extends BaseElement
$node = $this->node; $node = $this->node;
$renderer = $this->renderer; $renderer = $this->renderer;
if ($node instanceof MonitoredNode) { if ($node instanceof MonitoredNode) {
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('magic'), 'a',
$renderer->getUrl()->with('action', 'simulation') [
->with('simulationnode', $this->name), 'href' => $renderer->getUrl()
null, ->with('action', 'simulation')
array('title' => $this->translate( ->with('simulationnode', $this->name),
'Show the business impact of this node by simulating a specific state' 'title' => mt(
)) 'businessprocess',
'Show the business impact of this node by simulating a specific state'
)
],
Html::tag('i', ['class' => 'icon icon-magic'])
)); ));
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('edit'), 'a',
$renderer->getUrl()->with('action', 'editmonitored')->with('editmonitorednode', $node->getName()), [
null, 'href' => $renderer->getUrl()
array('title' => $this->translate('Modify this monitored node')) ->with('action', 'editmonitored')
->with('editmonitorednode', $node->getName()),
'title' => mt('businessprocess', 'Modify this monitored node')
],
Html::tag('i', ['class' => 'icon icon-edit'])
)); ));
} }
@ -291,11 +285,15 @@ class NodeTile extends BaseElement
} }
if ($node instanceof BpNode) { if ($node instanceof BpNode) {
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('edit'), 'a',
$renderer->getUrl()->with('action', 'edit')->with('editnode', $node->getName()), [
null, 'href' => $renderer->getUrl()
array('title' => $this->translate('Modify this business process node')) ->with('action', 'edit')
->with('editnode', $node->getName()),
'title' => mt('businessprocess', 'Modify this business process node')
],
Html::tag('i', ['class' => 'icon icon-edit'])
)); ));
} }
@ -304,11 +302,13 @@ class NodeTile extends BaseElement
'deletenode' => $node->getName(), 'deletenode' => $node->getName(),
); );
$this->actions()->add(Link::create( $this->actions()->add(Html::tag(
Icon::create('cancel'), 'a',
$renderer->getUrl()->with($params), [
null, 'href' => $renderer->getUrl()->with($params),
array('title' => $this->translate('Delete this node')) 'title' => mt('businessprocess', 'Delete this node')
],
Html::tag('i', ['class' => 'icon icon-cancle'])
)); ));
} }
} }

View file

@ -4,12 +4,9 @@ namespace Icinga\Module\Businessprocess\Renderer;
use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
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\Node; use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\Web\Url; use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class TreeRenderer extends Renderer class TreeRenderer extends Renderer
{ {
@ -19,11 +16,12 @@ class TreeRenderer extends Renderer
public function render() public function render()
{ {
$bp = $this->config; $bp = $this->config;
$this->add(Container::create( $this->add(Html::tag(
array( 'div',
[
'id' => $bp->getHtmlId(), 'id' => $bp->getHtmlId(),
'class' => 'bp' 'class' => 'bp'
), ],
$this->renderBp($bp) $this->renderBp($bp)
)); ));
@ -79,16 +77,16 @@ class TreeRenderer extends Renderer
/** /**
* @param Node $node * @param Node $node
* @return Icon[] * @return BaseHtmlElement[]
*/ */
public function getNodeIcons(Node $node) public function getNodeIcons(Node $node)
{ {
$icons = array(); $icons = array();
if ($node->isInDowntime()) { if ($node->isInDowntime()) {
$icons[] = Icon::create('moon'); $icons[] = Html::tag('i', ['class' => 'icon icon-moon']);
} }
if ($node->isAcknowledged()) { if ($node->isAcknowledged()) {
$icons[] = Icon::create('ok'); $icons[] = Html::tag('i', ['class' => 'icon icon-ok']);
} }
return $icons; return $icons;
} }
@ -102,17 +100,17 @@ class TreeRenderer extends Renderer
*/ */
public function renderNode(BpConfig $bp, Node $node, $path = array()) public function renderNode(BpConfig $bp, Node $node, $path = array())
{ {
$table = Element::create( $table = Html::tag(
'table', 'table',
array( [
'id' => $this->getId($node, $path), 'id' => $this->getId($node, $path),
'class' => array( 'class' => array(
'bp', 'bp',
$node->getObjectClassName() $node->getObjectClassName()
) )
) ]
); );
$attributes = $table->attributes(); $attributes = $table->getAttributes();
$attributes->add('class', $this->getStateClassNames($node)); $attributes->add('class', $this->getStateClassNames($node));
if ($node->isHandled()) { if ($node->isHandled()) {
$attributes->add('class', 'handled'); $attributes->add('class', 'handled');
@ -123,57 +121,68 @@ class TreeRenderer extends Renderer
$attributes->add('class', 'node'); $attributes->add('class', 'node');
} }
$tbody = $table->createElement('tbody'); $tbody = Html::tag('tbody');
$tr = $tbody->createElement('tr'); $table->add($tbody);
$tr = Html::tag('tr');
$tbody->add($tr);
if ($node instanceof BpNode) { if ($node instanceof BpNode) {
$tr->createElement( $tr->add(Html::tag(
'th', 'th',
array( ['rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1)],
'rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1) Html::tag('span', ['class' => 'op'], $node->operatorHtml())
) ));
)->createElement(
'span',
array('class' => 'op')
)->setContent($node->operatorHtml());
} }
$td = $tr->createElement('td'); $td = Html::tag('td');
$tr->add($td);
if ($node instanceof BpNode && $node->hasInfoUrl()) { if ($node instanceof BpNode && $node->hasInfoUrl()) {
$td->add($this->createInfoAction($node)); $td->add($this->createInfoAction($node));
} }
if (! $this->isLocked()) { if (! $this->isLocked()) {
$td->addContent($this->getActionIcons($bp, $node)); $td->add($this->getActionIcons($bp, $node));
} }
$link = $node->getLink(); $link = $node->getLink();
$link->attributes()->set('data-base-target', '_next'); $link->getAttributes()->set('data-base-target', '_next');
$link->addContent($this->getNodeIcons($node)); $link->add($this->getNodeIcons($node));
if ($node->hasChildren()) { if ($node->hasChildren()) {
$link->addContent($this->renderStateBadges($node->getStateSummary())); $link->add($this->renderStateBadges($node->getStateSummary()));
} }
if ($time = $node->getLastStateChange()) { if ($time = $node->getLastStateChange()) {
$since = $this->timeSince($time)->prependContent( $since = $this->timeSince($time)->prepend(
sprintf(' (%s ', $node->getStateName()) sprintf(' (%s ', $node->getStateName())
)->addContent(')'); )->add(')');
$link->addContent($since); $link->add($since);
} }
$td->addContent($link); $td->add($link);
foreach ($node->getChildren() as $name => $child) { foreach ($node->getChildren() as $name => $child) {
$tbody->createElement('tr')->createElement('td')->setContent( $tbody->add(Html::tag(
$this->renderNode($bp, $child, $this->getCurrentPath()) 'tr',
); null,
Html::tag(
'td',
null,
$this->renderNode($bp, $child, $this->getCurrentPath())
)
));
} }
if (! $this->isLocked() && $node instanceof BpNode && $bp->getMetadata()->canModify()) { if (! $this->isLocked() && $node instanceof BpNode && $bp->getMetadata()->canModify()) {
$tbody->createElement('tr')->createElement('td')->setContent( $tbody->add(Html::tag(
$this->renderAddNewNode($node) 'tr',
); null,
Html::tag(
'td',
null,
$this->renderAddNewNode($node)
)
));
} }
return $table; return $table;
@ -200,7 +209,7 @@ class TreeRenderer extends Renderer
'action' => 'edit', 'action' => 'edit',
'editnode' => $node->getName() 'editnode' => $node->getName()
)), )),
$this->translate('Modify this node') mt('businessprocess', 'Modify this node')
); );
} }
@ -213,7 +222,7 @@ class TreeRenderer extends Renderer
'action' => 'simulation', 'action' => 'simulation',
'simulationnode' => $node->getName() 'simulationnode' => $node->getName()
)), )),
$this->translate('Simulate a specific state') mt('businessprocess', 'Simulate a specific state')
); );
} }
@ -223,33 +232,35 @@ class TreeRenderer extends Renderer
return $this->actionIcon( return $this->actionIcon(
'help', 'help',
$url, $url,
sprintf('%s: %s', $this->translate('More information'), $url) sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
); );
} }
protected function actionIcon($icon, $url, $title) protected function actionIcon($icon, $url, $title)
{ {
return Link::create( return Html::tag(
Icon::create($icon), 'a',
$url, [
null, 'href' => $url,
array(
'title' => $title, 'title' => $title,
'style' => 'float: right', 'style' => 'float: right'
) ],
Html::tag('i', ['class' => 'icon icon-' . $icon])
); );
} }
protected function renderAddNewNode($parent) protected function renderAddNewNode($parent)
{ {
return Link::create( return Html::tag(
$this->translate('Add'), 'a',
$this->getUrl()->with('action', 'add')->with('node', $parent->getName()), [
null, 'href' => $this->getUrl()
array( ->with('action', 'add')
'class' => 'addnew icon-plus', ->with('node', $parent->getName()),
'title' => $this->translate('Add a new business process node') 'title' => mt('businessprocess', 'Add a new business process node'),
) 'class' => 'addnew icon-plus'
],
mt('businessprocess', 'Add')
); );
} }
} }

View file

@ -7,9 +7,9 @@ use Diff_Renderer_Html_Inline;
use Diff_Renderer_Html_SideBySide; use Diff_Renderer_Html_SideBySide;
use Diff_Renderer_Text_Context; use Diff_Renderer_Text_Context;
use Diff_Renderer_Text_Unified; use Diff_Renderer_Text_Unified;
use Icinga\Module\Businessprocess\Html\Renderable; use ipl\Html\ValidHtml;
class ConfigDiff implements Renderable class ConfigDiff implements ValidHtml
{ {
protected $a; protected $a;

View file

@ -2,9 +2,9 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\Html\BaseElement; use ipl\Html\BaseHtmlElement;
class ActionBar extends BaseElement class ActionBar extends BaseHtmlElement
{ {
protected $contentSeparator = ' '; protected $contentSeparator = ' ';

View file

@ -3,15 +3,12 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Html\BaseElement; use Icinga\Web\Url;
use Icinga\Module\Businessprocess\Html\Container; use ipl\Html\BaseHtmlElement;
use Icinga\Module\Businessprocess\Html\Element; use ipl\Html\Html;
use Icinga\Module\Businessprocess\Html\Icon; use ipl\Html\Text;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Html\Text;
use Icinga\Module\Businessprocess\Web\Url;
class BpDashboardTile extends BaseElement class BpDashboardTile extends BaseHtmlElement
{ {
protected $tag = 'div'; protected $tag = 'div';
@ -19,33 +16,32 @@ class BpDashboardTile extends BaseElement
public function __construct(BpConfig $bp, $title, $description, $icon, $url, $urlParams = null, $attributes = null) public function __construct(BpConfig $bp, $title, $description, $icon, $url, $urlParams = null, $attributes = null)
{ {
$this->add( if (! isset($attributes['href'])) {
Container::create( $attributes['href'] = Url::fromPath($url, $urlParams ?: []);
['class' => 'bp-link', 'data-base-target' => '_main'], }
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']); $this->add(Html::tag(
'div',
['class' => 'bp-link', 'data-base-target' => '_main'],
Html::tag('a', $attributes, Html::tag('i', ['class' => 'icon icon-' . $icon]))
->add(Html::tag('span', ['class' => 'header'], $title))
->add($description)
));
$tiles = Html::tag('div', ['class' => 'bp-root-tiles']);
foreach ($bp->getChildren() as $node) { foreach ($bp->getChildren() as $node) {
$state = strtolower($node->getStateName()); $state = strtolower($node->getStateName());
$tiles->add( $tiles->add(Html::tag(
Link::create( 'a',
Text::create(' ')->setEscaped(), [
$url, 'href' => Url::fromPath($url, $urlParams ?: [])->with(['node' => $node->getName()]),
$urlParams + ['node' => $node->getName()], 'class' => "badge state-{$state}",
['class' => "badge state-{$state}", 'title' => $node->getAlias()] 'title' => $node->getAlias()
) ],
); Text::create(' ')->setEscaped()
));
} }
$this->add($tiles); $this->add($tiles);

View file

@ -2,10 +2,12 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\Html\Container; use ipl\Html\BaseHtmlElement;
class Content extends Container class Content extends BaseHtmlElement
{ {
protected $tag = 'div';
protected $contentSeparator = "\n"; protected $contentSeparator = "\n";
protected $defaultAttributes = array('class' => 'content'); protected $defaultAttributes = array('class' => 'content');

View file

@ -2,10 +2,12 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\Html\Container; use ipl\Html\BaseHtmlElement;
class Controls extends Container class Controls extends BaseHtmlElement
{ {
protected $tag = 'div';
protected $contentSeparator = "\n"; protected $contentSeparator = "\n";
protected $defaultAttributes = array('class' => 'controls'); protected $defaultAttributes = array('class' => 'controls');

View file

@ -3,13 +3,12 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Authentication\Auth; 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\State\MonitoringState;
use Icinga\Module\Businessprocess\Storage\Storage; use Icinga\Module\Businessprocess\Storage\Storage;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class Dashboard extends BaseElement class Dashboard extends BaseHtmlElement
{ {
/** @var string */ /** @var string */
protected $contentSeparator = "\n"; protected $contentSeparator = "\n";
@ -40,21 +39,22 @@ class Dashboard extends BaseElement
// TODO: Auth? // TODO: Auth?
$processes = $storage->listProcessNames(); $processes = $storage->listProcessNames();
$this->add( $this->add(
HtmlTag::h1($this->translate('Welcome to your Business Process Overview')) Html::tag('h1', null, mt('businessprocess', 'Welcome to your Business Process Overview'))
); );
$this->add( $this->add(Html::tag(
HtmlTag::p( 'p',
$this->translate( null,
'From here you can reach all your defined Business Process' mt(
. ' configurations, create new or modify existing ones' 'businessprocess',
) 'From here you can reach all your defined Business Process'
. ' configurations, create new or modify existing ones'
) )
); ));
if ($auth->hasPermission('businessprocess/create')) { if ($auth->hasPermission('businessprocess/create')) {
$this->add( $this->add(
new DashboardAction( new DashboardAction(
$this->translate('Create'), mt('businessprocess', 'Create'),
$this->translate('Create a new Business Process configuration'), mt('businessprocess', 'Create a new Business Process configuration'),
'plus', 'plus',
'businessprocess/process/create', 'businessprocess/process/create',
null, null,
@ -62,8 +62,8 @@ class Dashboard extends BaseElement
) )
)->add( )->add(
new DashboardAction( new DashboardAction(
$this->translate('Upload'), mt('businessprocess', 'Upload'),
$this->translate('Upload an existing Business Process configuration'), mt('businessprocess', 'Upload an existing Business Process configuration'),
'upload', 'upload',
'businessprocess/process/upload', 'businessprocess/process/upload',
null, null,
@ -71,10 +71,13 @@ class Dashboard extends BaseElement
) )
); );
} elseif (empty($processes)) { } elseif (empty($processes)) {
$this->addContent( $this->add(
Container::create() Html::tag('div')
->add(HtmlTag::h1($this->translate('Not available'))) ->add(Html::tag('h1', null, mt('businessprocess', 'Not available')))
->add(HtmlTag::p($this->translate('No Business Process has been defined for you'))) ->add(Html::tag('p', null, mt(
'businessprocess',
'No Business Process has been defined for you'
)))
); );
} }

View file

@ -2,12 +2,11 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\Html\BaseElement; use Icinga\Web\Url;
use Icinga\Module\Businessprocess\Html\Element; use ipl\Html\BaseHtmlElement;
use Icinga\Module\Businessprocess\Html\Icon; use ipl\Html\Html;
use Icinga\Module\Businessprocess\Html\Link;
class DashboardAction extends BaseElement class DashboardAction extends BaseHtmlElement
{ {
protected $tag = 'div'; protected $tag = 'div';
@ -15,15 +14,13 @@ class DashboardAction extends BaseElement
public function __construct($title, $description, $icon, $url, $urlParams = null, $attributes = null) public function __construct($title, $description, $icon, $url, $urlParams = null, $attributes = null)
{ {
$this->add( if (! isset($attributes['href'])) {
Link::create( $attributes['href'] = Url::fromPath($url, $urlParams ?: []);
Icon::create($icon), }
$url,
$urlParams, $this->add(Html::tag('a', $attributes)
$attributes ->add(Html::tag('i', ['class' => 'icon icon-' . $icon]))
)->add( ->add(Html::tag('span', ['class' => 'header'], $title))
Element::create('span', array('class' => 'header'))->addContent($title) ->add($description));
)->addContent($description)
);
} }
} }

View file

@ -4,10 +4,10 @@ namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Authentication\Auth; use Icinga\Authentication\Auth;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Module\Businessprocess\Renderer\Renderer; use Icinga\Module\Businessprocess\Renderer\Renderer;
use Icinga\Module\Businessprocess\Renderer\TreeRenderer; use Icinga\Module\Businessprocess\Renderer\TreeRenderer;
use Icinga\Module\Businessprocess\Web\Url; use Icinga\Web\Url;
use ipl\Html\Html;
class RenderedProcessActionBar extends ActionBar class RenderedProcessActionBar extends ActionBar
{ {
@ -16,87 +16,73 @@ class RenderedProcessActionBar extends ActionBar
$meta = $config->getMetadata(); $meta = $config->getMetadata();
if ($renderer instanceof TreeRenderer) { if ($renderer instanceof TreeRenderer) {
$this->add( $this->add(Html::tag(
Link::create( 'a',
$this->translate('Tiles'), [
$url->with('mode', 'tile'), 'href' => $url->with('mode', 'tile'),
null, 'title' => mt('businessprocess', 'Switch to Tile view'),
array( 'class' => 'icon-dashboard'
'class' => 'icon-dashboard', ],
'title' => $this->translate('Switch to Tile view'), mt('businessprocess', 'Tiles')
) ));
)
);
} else { } else {
$this->add( $this->add(Html::tag(
Link::create( 'a',
$this->translate('Tree'), [
$url->with('mode', 'tree'), 'href' => $url->with('mode', 'tree'),
null, 'title' => mt('businessprocess', 'Switch to Tree view'),
array( 'class' => 'icon-sitemap'
'class' => 'icon-sitemap', ],
'title' => $this->translate('Switch to Tree view'), mt('businessprocess', 'Tree')
) ));
)
);
} }
$this->add( $this->add(Html::tag(
Link::create( 'a',
$this->translate('Fullscreen'), [
$url->with('showFullscreen', true), 'data-base-target' => '_main',
null, 'href' => $url->with('showFullscreen', true),
array( 'title' => mt('businessprocess', 'Switch to fullscreen mode'),
'class' => 'icon-resize-full-alt', 'class' => 'icon-resize-full-alt'
'title' => $this->translate('Switch to fullscreen mode'), ],
'data-base-target' => '_main', mt('businessprocess', 'Fullscreen')
) ));
)
);
$hasChanges = $config->hasSimulations() || $config->hasBeenChanged(); $hasChanges = $config->hasSimulations() || $config->hasBeenChanged();
if ($renderer->isLocked()) { if ($renderer->isLocked()) {
$this->add( $this->add(Html::tag(
Link::create( 'a',
$this->translate('Editing locked'), [
$url->with('unlocked', true), 'href' => $url->with('unlocked', true),
null, 'title' => mt('businessprocess', 'Click to unlock editing for this process'),
array( 'class' => 'icon-lock'
'class' => 'icon-lock', ],
'title' => $this->translate('Click to unlock editing for this process'), mt('businessprocess', 'Editing locked')
) ));
)
);
} elseif (! $hasChanges) { } elseif (! $hasChanges) {
$this->add( $this->add(Html::tag(
Link::create( 'a',
$this->translate('Editing unlocked'), [
$url->without('unlocked')->without('action'), 'href' => $url->without('unlocked')->without('action'),
null, 'title' => mt('businessprocess', 'Click to lock editing for this process'),
array( 'class' => 'icon-lock-open'
'class' => 'icon-lock-open', ],
'title' => $this->translate('Click to lock editing for this process'), mt('businessprocess', 'Editing unlocked')
) ));
)
);
} }
if ($renderer->wantsRootNodes() && ( if ($renderer->wantsRootNodes() && (($hasChanges || (! $renderer->isLocked())) && $meta->canModify())) {
($hasChanges || (! $renderer->isLocked())) && $meta->canModify() $this->add(Html::tag(
)) { 'a',
$this->add( [
Link::create( 'data-base-target' => '_next',
$this->translate('Config'), 'href' => Url::fromPath('businessprocess/process/config', $this->currentProcessParams($url)),
'businessprocess/process/config', 'title' => mt('businessprocess', 'Modify this process'),
$this->currentProcessParams($url), 'class' => 'icon-wrench'
array( ],
'class' => 'icon-wrench', mt('businessprocess', 'Config')
'title' => $this->translate('Modify this process'), ));
'data-base-target' => '_next',
)
)
);
} }
} }

View file

@ -2,8 +2,8 @@
namespace Icinga\Module\Businessprocess\Web\Component; namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Module\Businessprocess\Html\Renderable; use ipl\Html\ValidHtml;
class Tabs extends WtfTabs implements Renderable class Tabs extends WtfTabs implements ValidHtml
{ {
} }

View file

@ -4,7 +4,6 @@ namespace Icinga\Module\Businessprocess\Web;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Html\HtmlTag;
use Icinga\Module\Businessprocess\Modification\ProcessChanges; use Icinga\Module\Businessprocess\Modification\ProcessChanges;
use Icinga\Module\Businessprocess\Storage\LegacyStorage; use Icinga\Module\Businessprocess\Storage\LegacyStorage;
use Icinga\Module\Businessprocess\Storage\Storage; use Icinga\Module\Businessprocess\Storage\Storage;
@ -16,6 +15,7 @@ use Icinga\Module\Businessprocess\Web\Form\FormLoader;
use Icinga\Web\Controller as ModuleController; use Icinga\Web\Controller as ModuleController;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Web\View; use Icinga\Web\View;
use ipl\Html\Html;
class Controller extends ModuleController class Controller extends ModuleController
{ {
@ -86,9 +86,9 @@ class Controller extends ModuleController
protected function controls() protected function controls()
{ {
if ($this->view->controls === null) { if ($this->view->controls === null) {
$controls = $this->view->controls = Controls::create(); $controls = $this->view->controls = new Controls();
if ($this->view->compact) { if ($this->view->compact) {
$controls->attributes()->add('class', 'compact'); $controls->getAttributes()->add('class', 'compact');
} }
} }
@ -101,9 +101,9 @@ class Controller extends ModuleController
protected function content() protected function content()
{ {
if ($this->view->content === null) { if ($this->view->content === null) {
$content = $this->view->content = Content::create(); $content = $this->view->content = new Content();
if ($this->view->compact) { if ($this->view->compact) {
$content->attributes()->add('class', 'compact'); $content->getAttributes()->add('class', 'compact');
} }
} }
@ -187,7 +187,7 @@ class Controller extends ModuleController
$args = func_get_args(); $args = func_get_args();
array_shift($args); array_shift($args);
$this->view->title = vsprintf($title, $args); $this->view->title = vsprintf($title, $args);
$this->controls()->add(HtmlTag::h1($this->view->title)); $this->controls()->add(Html::tag('h1', null, $this->view->title));
return $this; return $this;
} }

View file

@ -4,10 +4,10 @@ namespace Icinga\Module\Businessprocess\Web\Form;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Application\Modules\Module; use Icinga\Application\Modules\Module;
use Icinga\Module\Businessprocess\Html\Renderable; use ipl\Html\ValidHtml;
use Zend_Form; use Zend_Form;
abstract class QuickBaseForm extends Zend_Form implements Renderable abstract class QuickBaseForm extends Zend_Form implements ValidHtml
{ {
/** /**
* The Icinga module this form belongs to. Usually only set if the * The Icinga module this form belongs to. Usually only set if the