Merge branch 'master' into feature/allow-to-extend-the-content-of-a-dashlet-on-the-right-6677
This commit is contained in:
commit
e6d507828c
|
@ -11,10 +11,16 @@
|
|||
<div class="content">
|
||||
<h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1>
|
||||
<p>
|
||||
<?= sprintf(
|
||||
<?php if (! $this->hasPermission('config/modules')) {
|
||||
echo $this->escape($this->translate(
|
||||
'Currently there is no dashlet available. Please contact the administrator.'
|
||||
));
|
||||
} else {
|
||||
printf(
|
||||
$this->escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')),
|
||||
$this->qlink($this->translate('modules'), 'config/modules')
|
||||
) ?>
|
||||
);
|
||||
} ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
|
|
@ -281,7 +281,10 @@ class Manager
|
|||
public function disableModule($name)
|
||||
{
|
||||
if (! $this->hasEnabled($name)) {
|
||||
return $this;
|
||||
throw new ConfigurationError(
|
||||
'Cannot disable module "%s". Module is not installed.',
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
if (! is_writable($this->enableDir)) {
|
||||
|
|
|
@ -9,6 +9,21 @@ use Icinga\Web\Controller;
|
|||
|
||||
class DocController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function moduleInit()
|
||||
{
|
||||
// Our UrlParams object does not take parameters from custom routes into account which is why we have to set
|
||||
// them explicitly
|
||||
if ($this->hasParam('chapter')) {
|
||||
$this->params->set('chapter', $this->getParam('chapter'));
|
||||
}
|
||||
if ($this->hasParam('moduleName')) {
|
||||
$this->params->set('moduleName', $this->getParam('moduleName'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a chapter
|
||||
*
|
||||
|
|
|
@ -167,6 +167,7 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Host Check Result'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -226,6 +226,7 @@ class Monitoring_HostsController extends Controller
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Host Check Results'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ class Monitoring_ServiceController extends MonitoredObjectController
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Service Check Result'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -242,6 +242,7 @@ class Monitoring_ServicesController extends Controller
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Service Check Results'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -52,11 +52,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
|
|||
'required' => true,
|
||||
'label' => $this->translate('Status'),
|
||||
'description' => $this->translate('The state this check result should report'),
|
||||
'multiOptions' => $object->getType() === $object::TYPE_HOST ? array(
|
||||
ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'),
|
||||
ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'),
|
||||
ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state')
|
||||
) : array(
|
||||
'multiOptions' => $object->getType() === $object::TYPE_HOST ? $this->getHostMultiOptions() : array(
|
||||
ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'),
|
||||
ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'),
|
||||
ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'),
|
||||
|
@ -115,4 +111,23 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the available host options based on the program version
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getHostMultiOptions()
|
||||
{
|
||||
$options = array(
|
||||
ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'),
|
||||
ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state')
|
||||
);
|
||||
|
||||
if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') {
|
||||
$options[ProcessCheckResultCommand::HOST_UNREACHABLE] = $this->translate('UNREACHABLE', 'icinga.state');
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,24 +52,46 @@ class RemoteInstanceForm extends Form
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether ssh identity resources exists or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasResources()
|
||||
{
|
||||
$resourceConfig = ResourceFactory::getResourceConfigs();
|
||||
|
||||
foreach ($resourceConfig as $name => $resource) {
|
||||
if ($resource->type === 'ssh') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see Form::createElements() For the method documentation.
|
||||
*/
|
||||
public function createElements(array $formData = array())
|
||||
{
|
||||
$useResource = isset($formData['use_resource']) ? $formData['use_resource'] : $this->getValue('use_resource');
|
||||
$useResource = false;
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'use_resource',
|
||||
array(
|
||||
'label' => $this->translate('Use SSH Identity'),
|
||||
'description' => $this->translate('Make use of the ssh identity resource'),
|
||||
'autosubmit' => true,
|
||||
'ignore' => true
|
||||
)
|
||||
);
|
||||
if ($this->hasResources()) {
|
||||
$useResource = isset($formData['use_resource'])
|
||||
? $formData['use_resource'] : $this->getValue('use_resource');
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'use_resource',
|
||||
array(
|
||||
'label' => $this->translate('Use SSH Identity'),
|
||||
'description' => $this->translate('Make use of the ssh identity resource'),
|
||||
'autosubmit' => true,
|
||||
'ignore' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($useResource) {
|
||||
|
||||
|
|
|
@ -331,4 +331,14 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
|||
array_push($parts, 'Query', ucfirst(strtolower($query)) . 'Query');
|
||||
return implode('\\', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and return the program version of the current instance
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProgramVersion()
|
||||
{
|
||||
return $this->select()->from('programstatus', array('program_version'))->fetchOne();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue