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);
$bc = Breadcrumb::create($renderer);
$bc->attributes()->set('data-base-target', '_next');
$bc->getAttributes()->set('data-base-target', '_next');
$content->add($bc);
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,10 +2,8 @@
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 ipl\Html\Html;
class TileRenderer extends Renderer
{
@ -15,14 +13,12 @@ class TileRenderer extends Renderer
public function render()
{
$bp = $this->config;
$nodesDiv = Container::create(
array(
'class' => array(
'tiles',
$this->howMany()
),
'data-base-target' => '_next',
)
$nodesDiv = Html::tag(
'div',
[
'class' => ['tiles', $this->howMany()],
'data-base-target' => '_next'
]
);
$nodes = $this->getChildNodes();
@ -50,7 +46,7 @@ class TileRenderer extends Renderer
$this->add($this->addNewNode());
}
$nodesDiv->addContent($this->getContent());
$nodesDiv->add($this->getContent());
$this->setContent($nodesDiv);
return parent::render();
@ -80,30 +76,26 @@ class TileRenderer extends Renderer
protected function addNewNode()
{
$div = Container::create(
array('class' => 'addnew', 'data-base-target' => '_self')
);
$div = Html::tag('div', ['class' => 'addnew', 'data-base-target' => '_self']);
$actions = Container::create(
array('class'=> 'actions')
);
$actions = Html::tag('div', ['class'=> 'actions']);
$link = Link::create(
$this->translate('Add'),
$this->getUrl()->with('action', 'add'),
null,
array(
'title' => $this->translate('Add a new business process node')
)
$link = Html::tag(
'a',
[
'href' => $this->getUrl()->with('action', 'add'),
'title' => mt('businessprocess', 'Add a new business process node')
],
mt('businessprocess', 'Add')
);
$actions->add(
Link::create(
Icon::create('plus'),
$this->getUrl()->with('action', 'add'),
null,
array(
'title' => $this->translate('Add a new business process node')
)
Html::tag(
'a',
[
'href' => $this->getUrl()->with('action', 'add'),
'title' => mt('businessprocess', '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\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\MonitoredNode;
use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\Renderer\Renderer;
use Icinga\Module\Businessprocess\ServiceNode;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class NodeTile extends BaseElement
class NodeTile extends BaseHtmlElement
{
protected $tag = 'div';
@ -28,7 +25,7 @@ class NodeTile extends BaseElement
protected $path;
/**
* @var Container
* @var BaseHtmlElement
*/
private $actions;
@ -57,11 +54,12 @@ class NodeTile extends BaseElement
protected function addActions()
{
$this->actions = Container::create(
array(
$this->actions = Html::tag(
'div',
[
'class' => 'actions',
'data-base-target' => '_self'
)
]
);
return $this->add($this->actions);
@ -72,7 +70,7 @@ class NodeTile extends BaseElement
$renderer = $this->renderer;
$node = $this->node;
$attributes = $this->attributes();
$attributes = $this->getAttributes();
$attributes->add('class', $renderer->getNodeClasses($node));
$attributes->add('id', 'bp-' . (string) $node);
@ -83,9 +81,9 @@ class NodeTile extends BaseElement
if ($node instanceof BpNode) {
if ($renderer->isBreadcrumb()) {
$link->addContent($renderer->renderStateBadges($node->getStateSummary()));
$link->add($renderer->renderStateBadges($node->getStateSummary()));
} 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()
{
$node = $this->node;
$url = $this->getMainNodeUrl($node);
if ($node instanceof ServiceNode) {
$link = Link::create(
$node->getAlias(),
$url,
null,
array('data-base-target' => '_next')
);
$link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getAlias());
} elseif ($node instanceof HostNode) {
$link = Link::create(
$node->getHostname(),
$url,
null,
array('data-base-target' => '_next')
);
$link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getHostname());
} else {
$link = Link::create($node->getAlias(), $url);
$link = Html::tag('a', ['href' => $url], $node->getAlias());
if ($node instanceof ImportedNode) {
$link->attributes()->add('data-base-target', '_next');
$link->getAttributes()->add('data-base-target', '_next');
} 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);
if ($node instanceof BpNode) {
$this->actions()->add(Link::create(
Icon::create('dashboard'),
$url->with('mode', 'tile'),
null,
array(
'title' => $this->translate('Show tiles for this subtree'),
'data-base-target' => '_self'
)
))->add(Link::create(
Icon::create('sitemap'),
$url->with('mode', 'tree'),
null,
array(
'title' => $this->translate('Show this subtree as a tree'),
'data-base-target' => '_next'
)
$this->actions()->add(Html::tag(
'a',
[
'data-base-target' => '_self',
'href' => $url->with('mode', 'tile'),
'title' => mt('businessprocess', 'Show tiles for this subtree')
],
Html::tag('i', ['class' => 'icon icon-dashboard'])
))->add(Html::tag(
'a',
[
'data-base-target' => '_next',
'href' => $url->with('mode', 'tree'),
'title' => mt('businessprocess', 'Show this subtree as a tree')
],
Html::tag('i', ['class' => 'icon icon-sitemap'])
));
$url = $node->getInfoUrl();
if ($url !== null) {
$link = Link::create(
Icon::create('info-circled'),
$url,
null,
array(
'title' => sprintf('%s: %s', $this->translate('More information'), $url),
'class' => 'node-info'
)
$link = Html::tag(
'a',
[
'href' => $url,
'class' => 'node-info',
'title' => sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
],
Html::tag('i', ['class' => 'icon icon-circled'])
);
if (preg_match('#^http(?:s)?://#', $url)) {
$link->addAttributes(array('target' => '_blank'));
$link->addAttributes(['target' => '_blank']);
}
$this->actions()->add($link);
}
} else {
// $url = $this->makeMonitoredNodeUrl($node);
if ($node instanceof ServiceNode) {
$this->actions()->add(Link::create(
Icon::create('service'),
$node->getUrl(),
null,
array('data-base-target' => '_next')
$this->actions()->add(Html::tag(
'a',
['href' => $node->getUrl(), 'data-base-target' => '_next'],
Html::tag('i', ['class' => 'icon icon-service'])
));
} elseif ($node instanceof HostNode) {
$this->actions()->add(Link::create(
Icon::create('host'),
$node->getUrl(),
null,
array('data-base-target' => '_next')
$this->actions()->add(Html::tag(
'a',
['href' => $node->getUrl(), 'data-base-target' => '_next'],
Html::tag('i', ['class' => 'icon icon-host'])
));
}
}
@ -266,21 +252,29 @@ class NodeTile extends BaseElement
$node = $this->node;
$renderer = $this->renderer;
if ($node instanceof MonitoredNode) {
$this->actions()->add(Link::create(
Icon::create('magic'),
$renderer->getUrl()->with('action', 'simulation')
->with('simulationnode', $this->name),
null,
array('title' => $this->translate(
'Show the business impact of this node by simulating a specific state'
))
$this->actions()->add(Html::tag(
'a',
[
'href' => $renderer->getUrl()
->with('action', 'simulation')
->with('simulationnode', $this->name),
'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(
Icon::create('edit'),
$renderer->getUrl()->with('action', 'editmonitored')->with('editmonitorednode', $node->getName()),
null,
array('title' => $this->translate('Modify this monitored node'))
$this->actions()->add(Html::tag(
'a',
[
'href' => $renderer->getUrl()
->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) {
$this->actions()->add(Link::create(
Icon::create('edit'),
$renderer->getUrl()->with('action', 'edit')->with('editnode', $node->getName()),
null,
array('title' => $this->translate('Modify this business process node'))
$this->actions()->add(Html::tag(
'a',
[
'href' => $renderer->getUrl()
->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(),
);
$this->actions()->add(Link::create(
Icon::create('cancel'),
$renderer->getUrl()->with($params),
null,
array('title' => $this->translate('Delete this node'))
$this->actions()->add(Html::tag(
'a',
[
'href' => $renderer->getUrl()->with($params),
'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\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\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class TreeRenderer extends Renderer
{
@ -19,11 +16,12 @@ class TreeRenderer extends Renderer
public function render()
{
$bp = $this->config;
$this->add(Container::create(
array(
$this->add(Html::tag(
'div',
[
'id' => $bp->getHtmlId(),
'class' => 'bp'
),
],
$this->renderBp($bp)
));
@ -79,16 +77,16 @@ class TreeRenderer extends Renderer
/**
* @param Node $node
* @return Icon[]
* @return BaseHtmlElement[]
*/
public function getNodeIcons(Node $node)
{
$icons = array();
if ($node->isInDowntime()) {
$icons[] = Icon::create('moon');
$icons[] = Html::tag('i', ['class' => 'icon icon-moon']);
}
if ($node->isAcknowledged()) {
$icons[] = Icon::create('ok');
$icons[] = Html::tag('i', ['class' => 'icon icon-ok']);
}
return $icons;
}
@ -102,17 +100,17 @@ class TreeRenderer extends Renderer
*/
public function renderNode(BpConfig $bp, Node $node, $path = array())
{
$table = Element::create(
$table = Html::tag(
'table',
array(
[
'id' => $this->getId($node, $path),
'class' => array(
'bp',
$node->getObjectClassName()
)
)
]
);
$attributes = $table->attributes();
$attributes = $table->getAttributes();
$attributes->add('class', $this->getStateClassNames($node));
if ($node->isHandled()) {
$attributes->add('class', 'handled');
@ -123,57 +121,68 @@ class TreeRenderer extends Renderer
$attributes->add('class', 'node');
}
$tbody = $table->createElement('tbody');
$tr = $tbody->createElement('tr');
$tbody = Html::tag('tbody');
$table->add($tbody);
$tr = Html::tag('tr');
$tbody->add($tr);
if ($node instanceof BpNode) {
$tr->createElement(
$tr->add(Html::tag(
'th',
array(
'rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1)
)
)->createElement(
'span',
array('class' => 'op')
)->setContent($node->operatorHtml());
['rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1)],
Html::tag('span', ['class' => 'op'], $node->operatorHtml())
));
}
$td = $tr->createElement('td');
$td = Html::tag('td');
$tr->add($td);
if ($node instanceof BpNode && $node->hasInfoUrl()) {
$td->add($this->createInfoAction($node));
}
if (! $this->isLocked()) {
$td->addContent($this->getActionIcons($bp, $node));
$td->add($this->getActionIcons($bp, $node));
}
$link = $node->getLink();
$link->attributes()->set('data-base-target', '_next');
$link->addContent($this->getNodeIcons($node));
$link->getAttributes()->set('data-base-target', '_next');
$link->add($this->getNodeIcons($node));
if ($node->hasChildren()) {
$link->addContent($this->renderStateBadges($node->getStateSummary()));
$link->add($this->renderStateBadges($node->getStateSummary()));
}
if ($time = $node->getLastStateChange()) {
$since = $this->timeSince($time)->prependContent(
$since = $this->timeSince($time)->prepend(
sprintf(' (%s ', $node->getStateName())
)->addContent(')');
$link->addContent($since);
)->add(')');
$link->add($since);
}
$td->addContent($link);
$td->add($link);
foreach ($node->getChildren() as $name => $child) {
$tbody->createElement('tr')->createElement('td')->setContent(
$this->renderNode($bp, $child, $this->getCurrentPath())
);
$tbody->add(Html::tag(
'tr',
null,
Html::tag(
'td',
null,
$this->renderNode($bp, $child, $this->getCurrentPath())
)
));
}
if (! $this->isLocked() && $node instanceof BpNode && $bp->getMetadata()->canModify()) {
$tbody->createElement('tr')->createElement('td')->setContent(
$this->renderAddNewNode($node)
);
$tbody->add(Html::tag(
'tr',
null,
Html::tag(
'td',
null,
$this->renderAddNewNode($node)
)
));
}
return $table;
@ -200,7 +209,7 @@ class TreeRenderer extends Renderer
'action' => 'edit',
'editnode' => $node->getName()
)),
$this->translate('Modify this node')
mt('businessprocess', 'Modify this node')
);
}
@ -213,7 +222,7 @@ class TreeRenderer extends Renderer
'action' => 'simulation',
'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(
'help',
$url,
sprintf('%s: %s', $this->translate('More information'), $url)
sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
);
}
protected function actionIcon($icon, $url, $title)
{
return Link::create(
Icon::create($icon),
$url,
null,
array(
return Html::tag(
'a',
[
'href' => $url,
'title' => $title,
'style' => 'float: right',
)
'style' => 'float: right'
],
Html::tag('i', ['class' => 'icon icon-' . $icon])
);
}
protected function renderAddNewNode($parent)
{
return Link::create(
$this->translate('Add'),
$this->getUrl()->with('action', 'add')->with('node', $parent->getName()),
null,
array(
'class' => 'addnew icon-plus',
'title' => $this->translate('Add a new business process node')
)
return Html::tag(
'a',
[
'href' => $this->getUrl()
->with('action', 'add')
->with('node', $parent->getName()),
'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_Text_Context;
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;

View file

@ -2,9 +2,9 @@
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 = ' ';

View file

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

View file

@ -2,10 +2,12 @@
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 $defaultAttributes = array('class' => 'content');

View file

@ -2,10 +2,12 @@
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 $defaultAttributes = array('class' => 'controls');

View file

@ -3,13 +3,12 @@
namespace Icinga\Module\Businessprocess\Web\Component;
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;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class Dashboard extends BaseElement
class Dashboard extends BaseHtmlElement
{
/** @var string */
protected $contentSeparator = "\n";
@ -40,21 +39,22 @@ class Dashboard extends BaseElement
// TODO: Auth?
$processes = $storage->listProcessNames();
$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(
HtmlTag::p(
$this->translate(
'From here you can reach all your defined Business Process'
. ' configurations, create new or modify existing ones'
)
$this->add(Html::tag(
'p',
null,
mt(
'businessprocess',
'From here you can reach all your defined Business Process'
. ' configurations, create new or modify existing ones'
)
);
));
if ($auth->hasPermission('businessprocess/create')) {
$this->add(
new DashboardAction(
$this->translate('Create'),
$this->translate('Create a new Business Process configuration'),
mt('businessprocess', 'Create'),
mt('businessprocess', 'Create a new Business Process configuration'),
'plus',
'businessprocess/process/create',
null,
@ -62,8 +62,8 @@ class Dashboard extends BaseElement
)
)->add(
new DashboardAction(
$this->translate('Upload'),
$this->translate('Upload an existing Business Process configuration'),
mt('businessprocess', 'Upload'),
mt('businessprocess', 'Upload an existing Business Process configuration'),
'upload',
'businessprocess/process/upload',
null,
@ -71,10 +71,13 @@ class Dashboard extends BaseElement
)
);
} elseif (empty($processes)) {
$this->addContent(
Container::create()
->add(HtmlTag::h1($this->translate('Not available')))
->add(HtmlTag::p($this->translate('No Business Process has been defined for you')))
$this->add(
Html::tag('div')
->add(Html::tag('h1', null, mt('businessprocess', 'Not available')))
->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;
use Icinga\Module\Businessprocess\Html\BaseElement;
use Icinga\Module\Businessprocess\Html\Element;
use Icinga\Module\Businessprocess\Html\Icon;
use Icinga\Module\Businessprocess\Html\Link;
use Icinga\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
class DashboardAction extends BaseElement
class DashboardAction extends BaseHtmlElement
{
protected $tag = 'div';
@ -15,15 +14,13 @@ class DashboardAction extends BaseElement
public function __construct($title, $description, $icon, $url, $urlParams = null, $attributes = null)
{
$this->add(
Link::create(
Icon::create($icon),
$url,
$urlParams,
$attributes
)->add(
Element::create('span', array('class' => 'header'))->addContent($title)
)->addContent($description)
);
if (! isset($attributes['href'])) {
$attributes['href'] = Url::fromPath($url, $urlParams ?: []);
}
$this->add(Html::tag('a', $attributes)
->add(Html::tag('i', ['class' => 'icon icon-' . $icon]))
->add(Html::tag('span', ['class' => 'header'], $title))
->add($description));
}
}

View file

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

View file

@ -2,8 +2,8 @@
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\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Html\HtmlTag;
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
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\Notification;
use Icinga\Web\View;
use ipl\Html\Html;
class Controller extends ModuleController
{
@ -86,9 +86,9 @@ class Controller extends ModuleController
protected function controls()
{
if ($this->view->controls === null) {
$controls = $this->view->controls = Controls::create();
$controls = $this->view->controls = new Controls();
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()
{
if ($this->view->content === null) {
$content = $this->view->content = Content::create();
$content = $this->view->content = new Content();
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();
array_shift($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;
}

View file

@ -4,10 +4,10 @@ namespace Icinga\Module\Businessprocess\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Application\Modules\Module;
use Icinga\Module\Businessprocess\Html\Renderable;
use ipl\Html\ValidHtml;
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