Skip to content

Commit

Permalink
Use fontawesome icons with ipl\Web\Widget\Icon class everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 authored and nilmerg committed Aug 8, 2023
1 parent 1360e1e commit af4b98f
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 69 deletions.
21 changes: 14 additions & 7 deletions application/controllers/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use ipl\Html\Text;
use ipl\Web\Control\SortControl;
use ipl\Web\Widget\Link;
use ipl\Web\Widget\Icon;

class ProcessController extends Controller
{
Expand Down Expand Up @@ -184,7 +185,7 @@ protected function prepareControls($bp, $renderer)
'href' => $this->url()->without('showFullscreen')->without('view'),
'title' => $this->translate('Leave full screen and switch back to normal mode')
],
Html::tag('i', ['class' => 'icon icon-resize-small'])
new Icon('down-left-and-up-right-to-center')
));
}

Expand Down Expand Up @@ -603,10 +604,12 @@ protected function createConfigActionBar(BpConfig $config, $showDiff = false)
'a',
[
'href' => Url::fromPath('businessprocess/process/source', $params),
'class' => 'icon-doc-text',
'title' => $this->translate('Show source code')
],
$this->translate('Source')
[
new Icon('file-lines'),
$this->translate('Source'),
]
));
} else {
$params = array(
Expand All @@ -618,22 +621,26 @@ protected function createConfigActionBar(BpConfig $config, $showDiff = false)
'a',
[
'href' => Url::fromPath('businessprocess/process/source', $params),
'class' => 'icon-flapping',
'title' => $this->translate('Highlight changes')
],
$this->translate('Diff')
[
new Icon('shuffle'),
$this->translate('Diff')
]
));
}

$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')
[
new Icon('download'),
$this->translate('Download')
]
));

return $actionBar;
Expand Down
3 changes: 2 additions & 1 deletion library/Businessprocess/BpNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Businessprocess\Exception\NestingError;
use ipl\Web\Widget\Icon;

class BpNode extends Node
{
Expand Down Expand Up @@ -639,7 +640,7 @@ public function operatorHtml()
}
}

public function getIcon()
public function getIcon(): Icon
{
$this->icon = $this->hasParents() ? 'cubes' : 'sitemap';
return parent::getIcon();
Expand Down
2 changes: 1 addition & 1 deletion library/Businessprocess/HostNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HostNode extends MonitoredNode

protected $className = 'host';

protected $icon = 'host';
protected $icon = 'laptop';

public function __construct($object)
{
Expand Down
9 changes: 4 additions & 5 deletions library/Businessprocess/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Icinga\Exception\ProgrammingError;
use ipl\Html\Html;
use ipl\Web\Widget\Icon;

abstract class Node
{
Expand Down Expand Up @@ -463,14 +464,12 @@ public function getObjectClassName()

public function getLink()
{
return Html::tag('a', ['href' => '#', 'class' => 'toggle'], Html::tag('i', [
'class' => 'icon icon-down-dir'
]));
return Html::tag('a', ['href' => '#', 'class' => 'toggle'], new Icon('caret-down'));
}

public function getIcon()
public function getIcon(): Icon
{
return Html::tag('i', ['class' => 'icon icon-' . ($this->icon ?: 'attention-circled')]);
return new Icon($this->icon ?? 'circle-exclamation');
}

public function operatorHtml()
Expand Down
3 changes: 2 additions & 1 deletion library/Businessprocess/Renderer/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Web\Widget\Icon;

class Breadcrumb extends BaseHtmlElement
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public static function create(Renderer $renderer)
'href' => Url::fromPath('businessprocess'),
'title' => mt('businessprocess', 'Show Overview')
],
Html::tag('i', ['class' => 'icon icon-home'])
new Icon('house')
)
));
$breadcrumb->add(Html::tag('li')->add(
Expand Down
39 changes: 14 additions & 25 deletions library/Businessprocess/Renderer/TileRenderer/NodeTile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

use Icinga\Date\DateFormatter;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\HostNode;
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 Icinga\Web\Url;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
Expand Down Expand Up @@ -202,14 +200,14 @@ protected function addDetailsActions()
'href' => $url->with('mode', 'tile'),
'title' => mt('businessprocess', 'Show tiles for this subtree')
],
Html::tag('i', ['class' => 'icon icon-dashboard'])
new Icon('grip')
))->add(Html::tag(
'a',
[
'href' => $url->with('mode', 'tree'),
'title' => mt('businessprocess', 'Show this subtree as a tree')
],
Html::tag('i', ['class' => 'icon icon-sitemap'])
new Icon('sitemap')
));
if ($node instanceof ImportedNode) {
if ($node->getBpConfig()->hasNode($node->getName())) {
Expand All @@ -223,7 +221,7 @@ protected function addDetailsActions()
'Show this process as part of its original configuration'
)
],
Html::tag('i', ['class' => 'icon icon-forward'])
new Icon('share')
));
}
}
Expand All @@ -238,28 +236,19 @@ protected function addDetailsActions()
'class' => 'node-info',
'title' => sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
],
Html::tag('i', ['class' => 'icon icon-info-circled'])
new Icon('info')
);
if (preg_match('#^http(?:s)?://#', $url)) {
$link->addAttributes(['target' => '_blank']);
}
$this->actions()->add($link);
}
} else {
// $url = $this->makeMonitoredNodeUrl($node);
if ($node instanceof ServiceNode) {
$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(Html::tag(
'a',
['href' => $node->getUrl(), 'data-base-target' => '_next'],
Html::tag('i', ['class' => 'icon icon-host'])
));
}
$this->actions()->add(Html::tag(
'a',
['href' => $node->getUrl(), 'data-base-target' => '_next'],
$node->getIcon()
));
}

if ($node->isAcknowledged()) {
Expand Down Expand Up @@ -299,7 +288,7 @@ protected function addActionLinks()
'Show the business impact of this node by simulating a specific state'
)
],
Html::tag('i', ['class' => 'icon icon-magic'])
new Icon('wand-magic-sparkles')
));

$this->actions()->add(Html::tag(
Expand All @@ -310,7 +299,7 @@ protected function addActionLinks()
->with('editmonitorednode', $this->node->getName()),
'title' => mt('businessprocess', 'Modify this monitored node')
],
Html::tag('i', ['class' => 'icon icon-edit'])
new Icon('edit')
));
}

Expand All @@ -327,7 +316,7 @@ protected function addActionLinks()
->with('editnode', $this->node->getName()),
'title' => mt('businessprocess', 'Modify this business process node')
],
Html::tag('i', ['class' => 'icon icon-edit'])
new Icon('edit')
));

$addUrl = $baseUrl->with([
Expand All @@ -341,7 +330,7 @@ protected function addActionLinks()
'href' => $addUrl,
'title' => mt('businessprocess', 'Add a new sub-node to this business process')
],
Html::tag('i', ['class' => 'icon icon-plus'])
new Icon('plus')
));
}
}
Expand All @@ -358,7 +347,7 @@ protected function addActionLinks()
'href' => $baseUrl->with($params),
'title' => mt('businessprocess', 'Delete this node')
],
Html::tag('i', ['class' => 'icon icon-cancel'])
new Icon('xmark')
));
}
}
Expand Down
15 changes: 8 additions & 7 deletions library/Businessprocess/Renderer/TreeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getNodeIcons(Node $node, array $path = null, BpNode $parent = nu
{
$icons = [];
if (empty($path) && $node instanceof BpNode) {
$icons[] = Html::tag('i', ['class' => 'icon icon-sitemap']);
$icons[] = new Icon('sitemap');
} else {
$icons[] = $node->getIcon();
}
Expand All @@ -137,7 +137,7 @@ public function getNodeIcons(Node $node, array $path = null, BpNode $parent = nu
]);

if ($node->isAcknowledged()) {
$icons[] = Html::tag('i', ['class' => 'icon icon-ok']);
$icons[] = new Icon('check');
} elseif ($node->isInDowntime()) {
$icons[] = new Icon('plug');
}
Expand All @@ -157,7 +157,8 @@ public function getOverriddenState($fakeState, Node $node)
)
])
);
$overriddenState->add(Html::tag('i', ['class' => 'icon icon-right-small']));

$overriddenState->add(new Icon('arrow-right'));
$overriddenState->add(
(new StateBall(strtolower($node->getStateName($fakeState)), StateBall::SIZE_MEDIUM))
->addAttributes([
Expand Down Expand Up @@ -232,7 +233,7 @@ public function renderNode(BpConfig $bp, Node $node, $path = array())
$summary->add($this->getActionIcons($bp, $node));
} elseif ($differentConfig) {
$summary->add($this->actionIcon(
'forward',
'share',
$this->getSourceUrl($node)->addParams(['mode' => 'tree'])->getAbsoluteUrl(),
mt('businessprocess', 'Show this process as part of its original configuration')
)->addAttributes(['data-base-target' => '_next']));
Expand Down Expand Up @@ -331,7 +332,7 @@ protected function createEditAction(BpConfig $bp, BpNode $node)
protected function createSimulationAction(BpConfig $bp, Node $node)
{
return $this->actionIcon(
'magic',
'wand-magic-sparkles',
$this->getUrl()->with(array(
//'config' => $bp->getName(),
'action' => 'simulation',
Expand All @@ -345,7 +346,7 @@ protected function createInfoAction(BpNode $node)
{
$url = $node->getInfoUrl();
return $this->actionIcon(
'help',
'question',
$url,
sprintf('%s: %s', mt('businessprocess', 'More information'), $url)
)->addAttributes(['target' => '_blank']);
Expand All @@ -360,7 +361,7 @@ protected function actionIcon($icon, $url, $title)
'title' => $title,
'class' => 'action-link'
],
Html::tag('i', ['class' => 'icon icon-' . $icon])
new Icon($icon)
);
}

Expand Down
2 changes: 1 addition & 1 deletion library/Businessprocess/ServiceNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ServiceNode extends MonitoredNode

protected $className = 'service';

protected $icon = 'service';
protected $icon = 'gear';

public function __construct($object)
{
Expand Down
Loading

0 comments on commit af4b98f

Please sign in to comment.