mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-01 19:29:34 -05:00
ProcessController: unify view scripts for config...
...and diff
This commit is contained in:
parent
d4d46ac0c1
commit
7e11ead8a8
3 changed files with 65 additions and 43 deletions
|
|
@ -296,27 +296,71 @@ class ProcessController extends Controller
|
|||
*/
|
||||
public function sourceAction()
|
||||
{
|
||||
$this->tabsForConfig()->activate('source');
|
||||
$bp = $this->loadModifiedBpConfig();
|
||||
$this->view->showDiff = $showDiff = (bool) $this->params->get('showDiff', false);
|
||||
|
||||
$this->view->source = $this->storage()->render($bp);
|
||||
$this->view->showDiff = (bool) $this->params->get('showDiff', false);
|
||||
|
||||
if ($this->view->showDiff) {
|
||||
$this->view->diff = ConfigDiff::create(
|
||||
$this->storage()->getSource($this->view->configName),
|
||||
$this->view->source
|
||||
);
|
||||
$this->view->title = sprintf(
|
||||
$title = sprintf(
|
||||
$this->translate('%s: Source Code Differences'),
|
||||
$bp->getTitle()
|
||||
);
|
||||
} else {
|
||||
$this->view->title = sprintf(
|
||||
$title = sprintf(
|
||||
$this->translate('%s: Source Code'),
|
||||
$bp->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
$actionBar = new ActionBar();
|
||||
$this->setTitle($title);
|
||||
$this->controls()
|
||||
->add($this->tabsForConfig()->activate('source'))
|
||||
->add(HtmlTag::h1($title))
|
||||
->add($actionBar);
|
||||
|
||||
if ($showDiff) {
|
||||
$actionBar->add(
|
||||
Link::create(
|
||||
$this->translate('Source'),
|
||||
$this->url()->without('showDiff'),
|
||||
null,
|
||||
array(
|
||||
'class' => 'icon-doc-text',
|
||||
'title' => $this->translate('Show source code'),
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$actionBar->add(
|
||||
Link::create(
|
||||
$this->translate('Diff'),
|
||||
$this->url()->with('showDiff', true),
|
||||
null,
|
||||
array(
|
||||
'class' => 'icon-flapping',
|
||||
'title' => $this->translate('Highlight changes'),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$actionBar->add(
|
||||
Link::create(
|
||||
$this->translate('Download'),
|
||||
'businessprocess/process/download',
|
||||
array('config' => $bp->getName()),
|
||||
array(
|
||||
'target' => '_blank',
|
||||
'class' => 'icon-download',
|
||||
'title' => $this->translate('Download process configuration')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -345,24 +389,28 @@ class ProcessController extends Controller
|
|||
*/
|
||||
public function configAction()
|
||||
{
|
||||
$this->tabsForConfig()->activate('config');
|
||||
$bp = $this->loadModifiedBpConfig();
|
||||
|
||||
$this->setTitle(
|
||||
$title = sprintf(
|
||||
$this->translate('%s: Configuration'),
|
||||
$bp->getTitle()
|
||||
);
|
||||
$this->setTitle($title);
|
||||
$this->controls()
|
||||
->add($this->tabsForConfig()->activate('config'))
|
||||
->add(HtmlTag::h1($title));
|
||||
|
||||
$url = Url::fromPath(
|
||||
'businessprocess/process/show?unlocked',
|
||||
array('config' => $bp->getName())
|
||||
);
|
||||
|
||||
$this->view->form = $this->loadForm('bpConfig')
|
||||
->setProcessConfig($bp)
|
||||
->setStorage($this->storage())
|
||||
->setSuccessUrl($url)
|
||||
->handleRequest();
|
||||
$this->content()->add(
|
||||
$this->loadForm('bpConfig')
|
||||
->setProcessConfig($bp)
|
||||
->setStorage($this->storage())
|
||||
->setSuccessUrl($url)
|
||||
->handleRequest()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,16 +1,2 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?>
|
||||
<a href="<?= $this->url('businessprocess/process/source', array(
|
||||
'config' => $this->configName
|
||||
)) ?>" title="<?= $this->escape('Show configuration source') ?>"><?= $this->icon('doc-text') ?></a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->form ?>
|
||||
<div data-base-target="_main">
|
||||
<?= $this->deleteForm ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->controls->render() ?>
|
||||
<?= $this->content->render() ?>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?>
|
||||
<a href="<?= $this->url('businessprocess/process/download', array(
|
||||
'config' => $this->configName
|
||||
)) ?>" target="_self" title="<?= $this->escape($this->translate('Download process configuration')) ?>"><?= $this->icon('download') ?></a>
|
||||
<?php if ($this->showDiff): ?>
|
||||
<a href="<?= $this->url()->without('showDiff') ?>" title="<?= $this->escape($this->translate('Show source code')) ?>"><?= $this->icon('doc-text') ?></a>
|
||||
<?php else: ?>
|
||||
<a href="<?= $this->url()->with('showDiff', true) ?>" title="<?= $this->escape($this->translate('Highlight changes')) ?>"><?= $this->icon('flapping') ?></a>
|
||||
<?php endif ?>
|
||||
</h1>
|
||||
</div>
|
||||
<?= $this->controls->render() ?>
|
||||
|
||||
<div class="content">
|
||||
<?php if ($this->showDiff): ?>
|
||||
<div class="diff">
|
||||
<?= $this->diff->renderHtml() ?>
|
||||
<?= $this->diff->render() ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<table class="sourcecode">
|
||||
|
|
|
|||
Loading…
Reference in a new issue