Merge branch 'master' into feature/allow-to-extend-the-content-of-a-dashlet-on-the-right-6677

This commit is contained in:
Johannes Meyer 2015-08-04 15:29:48 +02:00
commit e6d507828c
10 changed files with 94 additions and 19 deletions

View File

@ -11,10 +11,16 @@
<div class="content"> <div class="content">
<h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1> <h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1>
<p> <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->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') $this->qlink($this->translate('modules'), 'config/modules')
) ?> );
} ?>
</p> </p>
</div> </div>
<?php endif ?> <?php endif ?>

View File

@ -281,7 +281,10 @@ class Manager
public function disableModule($name) public function disableModule($name)
{ {
if (! $this->hasEnabled($name)) { if (! $this->hasEnabled($name)) {
return $this; throw new ConfigurationError(
'Cannot disable module "%s". Module is not installed.',
$name
);
} }
if (! is_writable($this->enableDir)) { if (! is_writable($this->enableDir)) {

View File

@ -9,6 +9,21 @@ use Icinga\Web\Controller;
class DocController extends 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 * Render a chapter
* *

View File

@ -167,6 +167,7 @@ class Monitoring_HostController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Result')); $form->setTitle($this->translate('Submit Passive Host Check Result'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -226,6 +226,7 @@ class Monitoring_HostsController extends Controller
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Results')); $form->setTitle($this->translate('Submit Passive Host Check Results'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -122,6 +122,7 @@ class Monitoring_ServiceController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Result')); $form->setTitle($this->translate('Submit Passive Service Check Result'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -242,6 +242,7 @@ class Monitoring_ServicesController extends Controller
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Results')); $form->setTitle($this->translate('Submit Passive Service Check Results'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -52,11 +52,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
'required' => true, 'required' => true,
'label' => $this->translate('Status'), 'label' => $this->translate('Status'),
'description' => $this->translate('The state this check result should report'), 'description' => $this->translate('The state this check result should report'),
'multiOptions' => $object->getType() === $object::TYPE_HOST ? array( 'multiOptions' => $object->getType() === $object::TYPE_HOST ? $this->getHostMultiOptions() : 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(
ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'), ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'),
ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'), ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'),
ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'), ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'),
@ -115,4 +111,23 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
return true; 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;
}
} }

View File

@ -52,13 +52,34 @@ class RemoteInstanceForm extends Form
return $this; 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) * (non-PHPDoc)
* @see Form::createElements() For the method documentation. * @see Form::createElements() For the method documentation.
*/ */
public function createElements(array $formData = array()) public function createElements(array $formData = array())
{ {
$useResource = isset($formData['use_resource']) ? $formData['use_resource'] : $this->getValue('use_resource'); $useResource = false;
if ($this->hasResources()) {
$useResource = isset($formData['use_resource'])
? $formData['use_resource'] : $this->getValue('use_resource');
$this->addElement( $this->addElement(
'checkbox', 'checkbox',
@ -70,6 +91,7 @@ class RemoteInstanceForm extends Form
'ignore' => true 'ignore' => true
) )
); );
}
if ($useResource) { if ($useResource) {

View File

@ -331,4 +331,14 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
array_push($parts, 'Query', ucfirst(strtolower($query)) . 'Query'); array_push($parts, 'Query', ucfirst(strtolower($query)) . 'Query');
return implode('\\', $parts); 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();
}
} }