Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/commands-6593
Browse files Browse the repository at this point in the history
Conflicts:
	application/forms/Preference/GeneralForm.php
	application/views/helpers/FormDateTime.php
	modules/monitoring/application/forms/Command/CommandForm.php
  • Loading branch information
lippserd committed Sep 8, 2014
2 parents a83ddb9 + e39dd64 commit 0e7ca59
Show file tree
Hide file tree
Showing 86 changed files with 1,739 additions and 511 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -11,6 +11,8 @@

build/

development/

# ./configure output
config.log
autom4te.cache
Expand Down
28 changes: 15 additions & 13 deletions application/controllers/ListController.php
Expand Up @@ -8,7 +8,8 @@
use Icinga\Data\ResourceFactory;
use Icinga\Logger\Logger;
use Icinga\Logger\Writer\FileWriter;
use Icinga\Protocol\File\Reader as FileReader;
use Icinga\Protocol\File\FileReader;
use \Zend_Controller_Action_Exception as ActionError;

/**
* Class ListController
Expand Down Expand Up @@ -38,20 +39,21 @@ protected function addTitleTab($action)
*/
public function applicationlogAction()
{
if (! Logger::writesToFile()) {
throw new ActionError('Site not found', 404);
}

$this->addTitleTab('application log');
$pattern = '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
. ' - (?<message>.*)$/'; // message

$loggerWriter = Logger::getInstance()->getWriter();
if ($loggerWriter instanceof FileWriter) {
$resource = new FileReader(new Zend_Config(array(
'filename' => $loggerWriter->getPath(),
'fields' => '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
. ' - (?<message>.*)$/' // message
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();
} else {
$this->view->logData = null;
}
$resource = new FileReader(new Zend_Config(array(
'filename' => $loggerWriter->getPath(),
'fields' => $pattern
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();
}
}
53 changes: 9 additions & 44 deletions application/controllers/SearchController.php
Expand Up @@ -3,9 +3,8 @@
// {{{ICINGA_LICENSE_HEADER}}}

use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;
use Icinga\Web\Widget;
use Icinga\Web\Url;
use Icinga\Web\Widget\SearchDashboard;

/**
* Search controller
Expand All @@ -14,47 +13,13 @@ class SearchController extends ActionController
{
public function indexAction()
{
$search = $this->_request->getParam('q');
if (! $search) {
$this->view->tabs = Widget::create('tabs')->add(
'search',
array(
'title' => $this->translate('Search'),
'url' => '/search',
)
)->activate('search');
$this->render('hint');
return;
}
$dashboard = Widget::create('dashboard')->createPane($this->translate('Search'));
$pane = $dashboard->getPane($this->translate('Search'));
$suffix = strlen($search) ? ': ' . rtrim($search, '*') . '*' : '';
$pane->addComponent(
$this->translate('Hosts') . $suffix,
Url::fromPath('monitoring/list/hosts', array(
'host_name' => $search . '*',
'sort' => 'host_severity',
'limit' => 10,
)
));
$pane->addComponent(
$this->translate('Services') . $suffix,
Url::fromPath('monitoring/list/services', array(
'service_description' => $search . '*',
'sort' => 'service_severity',
'limit' => 10,
)
));
$pane->addComponent('Hostgroups' . $suffix, Url::fromPath('monitoring/list/hostgroups', array(
'hostgroup' => $search . '*',
'limit' => 10,
)));
$pane->addComponent('Servicegroups' . $suffix, Url::fromPath('monitoring/list/servicegroups', array(
'servicegroup' => $search . '*',
'limit' => 10,
)));
$dashboard->activate($this->translate('Search'));
$this->view->dashboard = $dashboard;
$this->view->tabs = $dashboard->getTabs();
$this->view->dashboard = SearchDashboard::search($this->params->get('q'));

// NOTE: This renders the dashboard twice. Remove this once we can catch exceptions thrown in view scripts.
$this->view->dashboard->render();
}

public function hintAction()
{
}
}
2 changes: 1 addition & 1 deletion application/controllers/StaticController.php
Expand Up @@ -47,7 +47,7 @@ public function gravatarAction()
$cache->send($cacheFile);
return;
}
$img = file_get_contents('http://www.gravatar.com/avatar/' . $filename . '?s=200&d=mm');
$img = file_get_contents('http://www.gravatar.com/avatar/' . $filename . '?s=120&d=mm');
$cache->store($cacheFile, $img);
header('ETag: "' . $cache->etagForCachedFile($cacheFile) . '"');
echo $img;
Expand Down
8 changes: 4 additions & 4 deletions application/layouts/scripts/layout.phtml
Expand Up @@ -29,17 +29,17 @@ $iframeClass = $isIframe ? ' iframe' : '';
<title><?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?></title>
<!-- TODO: viewport and scale settings make no sense for us, fix this -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" />
<? if ($isIframe): ?>
<? if ($isIframe): ?>
<base target="_parent"/>
<?php else: ?>
<?php else: ?>
<script type="text/javascript">
(function() {
var html = document.getElementsByTagName('html')[0];
html.className = html.className.replace(/no-js/, 'js');
}());
</script>
<?php endif ?>
<?php endif ?>
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" />
<!-- Respond.js IE8 support of media queries -->
<!--[if lt IE 9]>
<script src="<?= $this->baseUrl('js/vendor/respond.min.js');?>"></script>
Expand Down
3 changes: 3 additions & 0 deletions application/layouts/scripts/parts/navigation.phtml
Expand Up @@ -3,6 +3,7 @@
use Icinga\Web\Url;
use Icinga\Web\Menu;
use Icinga\Web\MenuRenderer;
use Icinga\Web\Widget\SearchDashboard;

// Don't render a menu for unauthenticated users unless menu is auth aware
if (! $this->auth()->isAuthenticated()) {
Expand All @@ -11,8 +12,10 @@ if (! $this->auth()->isAuthenticated()) {

?>
<div id="menu" data-base-target="_main">
<? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
<form action="<?= $this->href('search') ?>" method="get" role="search">
<input type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
</form>
<? endif; ?>
<?= new MenuRenderer(Menu::load(), Url::fromRequest()->without('renderLayout')->getRelativeUrl()); ?>
</div>
13 changes: 4 additions & 9 deletions application/views/helpers/DateFormat.php
Expand Up @@ -3,7 +3,6 @@
// {{{ICINGA_LICENSE_HEADER}}}

use Icinga\Application\Icinga;
use Icinga\Application\Config;
use Icinga\Util\DateTimeFactory;

/**
Expand Down Expand Up @@ -108,10 +107,8 @@ public function formatDateTime($timestamp)
*/
public function getDateFormat()
{
return $this->request->getUser()->getPreferences()->get(
'app.dateFormat',
Config::app()->global !== null ? Config::app()->global->get('dateFormat', 'd/m/Y') : 'd/m/Y'
);
// TODO(mh): Missing localized format (#6077)
return 'd/m/Y';
}

/**
Expand All @@ -121,10 +118,8 @@ public function getDateFormat()
*/
public function getTimeFormat()
{
return $this->request->getUser()->getPreferences()->get(
'app.timeFormat',
Config::app()->global !== null ? Config::app()->global->get('timeFormat', 'g:i A') : 'g:i A'
);
// TODO(mh): Missing localized format (#6077)
return 'g:i A';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion application/views/helpers/FormTriStateCheckbox.php
Expand Up @@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}

use Zend_View_Helper_FormElement;
use \Zend_View_Helper_FormElement;

/**
* Helper to generate a "datetime" element
Expand Down
8 changes: 2 additions & 6 deletions application/views/scripts/search/hint.phtml
@@ -1,12 +1,8 @@
<div class="controls">
<?= $this->tabs ?>
</div>

<div class="content">
<h1><?= $this->translate("I'm ready to search, waiting for your input") ?></h1>
<p><strong><?= $this->translate('Hint') ?>: </strong><?= $this->translate(
'Please use the asterisk (*) as a placeholder for wildcard searches.'
. " For convenience I'll always add a wildcard after the last character"
. ' you typed.'
. " For convenience I'll always add a wildcard in front and after your"
. ' search string.'
) ?></p>
</div>
2 changes: 1 addition & 1 deletion application/views/scripts/search/index.phtml
@@ -1,5 +1,5 @@
<div class="controls">
<?= $this->tabs ?>
<?= $this->dashboard->getTabs() ?>
</div>

<div class="content dashboard">
Expand Down
2 changes: 0 additions & 2 deletions config/config.ini.in
@@ -1,7 +1,5 @@
[global]
timezone = "Europe/Berlin"
dateFormat = "d/m/Y"
timeFormat = "g:i A"

; Contains the directories that will be searched for available modules. Modules that
; don't exist in these directories can still be symlinked in the module folder, but
Expand Down
Empty file added doc/api/.gitkeep
Empty file.
25 changes: 25 additions & 0 deletions library/Icinga/Application/Modules/Module.php
Expand Up @@ -163,6 +163,31 @@ class Module
*/
protected $paneItems = array();

/**
* @var array
*/
protected $searchUrls = array();

/**
* @param string $title
* @param string $url
*/
public function provideSearchUrl($title, $url)
{
$searchUrl = (object) array(
'title' => $title,
'url' => $url
);

$this->searchUrls[] = $searchUrl;
}

public function getSearchUrls()
{
$this->launchConfigScript();
return $this->searchUrls;
}

/**
* Get all Menu Items
*
Expand Down
8 changes: 5 additions & 3 deletions library/Icinga/Application/Web.php
Expand Up @@ -10,6 +10,7 @@
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError;
use Icinga\Logger\Logger;
use Icinga\Util\TimezoneDetect;
use Icinga\Web\Request;
use Icinga\Web\Response;
use Icinga\Web\View;
Expand Down Expand Up @@ -273,10 +274,11 @@ private function setupPagination()
*/
protected function setupTimezone()
{
$userTimezone = null;

if ($this->user !== null && $this->user->getPreferences() !== null) {
$userTimezone = $this->user->getPreferences()->get('app.timezone');
} else {
$userTimezone = null;
$detect = new TimezoneDetect();
$userTimezone = $this->user->getPreferences()->get('app.timezone', $detect->getTimezoneName());
}

try {
Expand Down
2 changes: 1 addition & 1 deletion library/Icinga/Chart/Graph/BarGraph.php
Expand Up @@ -144,7 +144,7 @@ public function toSvg(RenderContext $ctx)
$this->tooltips[$x]->renderNoHtml($this->order, $data, $format)
);
$bar->setAttribute(
'title-rich',
'data-title-rich',
$this->tooltips[$x]->render($this->order, $data, $format)
);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Icinga/Data/ResourceFactory.php
Expand Up @@ -12,7 +12,7 @@
use Icinga\Protocol\Livestatus\Connection as LivestatusConnection;
use Icinga\Protocol\Statusdat\Reader as StatusdatReader;
use Icinga\Protocol\Ldap\Connection as LdapConnection;
use Icinga\Protocol\File\Reader as FileReader;
use Icinga\Protocol\File\FileReader;

/**
* Create resources from names or resource configuration
Expand Down
18 changes: 18 additions & 0 deletions library/Icinga/Logger/Logger.php
Expand Up @@ -28,6 +28,13 @@ class Logger
*/
protected $writer;

/**
* The configured type
*
* @string Type (syslog, file)
*/
protected $type = 'none';

/**
* The maximum severity to emit
*
Expand Down Expand Up @@ -85,6 +92,7 @@ protected function createWriter(Zend_Config $config)
$config->type
);
}
$this->type = $config->type;

return new $class($config);
}
Expand Down Expand Up @@ -212,6 +220,16 @@ public function getWriter()
return $this->writer;
}

public static function writesToSyslog()
{
return static::$instance && static::$instance->type === 'syslog';
}

public static function writesToFile()
{
return static::$instance && static::$instance->type === 'file';
}

/**
* Get this' instance
*
Expand Down

0 comments on commit 0e7ca59

Please sign in to comment.