Re-add benchmark helper

Enable benchmark via user preferences

resolves #5508
This commit is contained in:
Alexander Klimov 2014-01-24 12:20:13 +01:00
parent b9c86ac1f5
commit fc1fb60b01
4 changed files with 29 additions and 4 deletions

View File

@ -30,8 +30,8 @@
# namespace Icinga\Application\Controllers;
use \Icinga\Web\Controller\ActionController;
use \Icinga\Application\Icinga;
use Icinga\Web\Controller\ActionController;
use Icinga\Application\Benchmark;
/**
* Application wide index controller

View File

@ -214,6 +214,15 @@ class GeneralForm extends Form
$this->addDateFormatSettings($global);
$this->setSubmitLabel('{{SAVE_ICON}} Save Changes');
$this->addElement(
'checkbox',
'showBenchmark',
array(
'label' => 'Use benchmark',
'value' => $this->getUserPreferences()->get('app.showBenchmark')
)
);
}
/**
@ -227,7 +236,8 @@ class GeneralForm extends Form
return array(
'app.timezone' => $values['timezone'],
'app.dateFormat' => $values['date_format'],
'app.timeFormat' => $values['time_format']
'app.timeFormat' => $values['time_format'],
'app.showBenchmark' => $values['showBenchmark'] === '1' ? true : false
);
}
}

View File

@ -40,6 +40,6 @@
<?= $this->render('body.phtml') ?>
<script data-main="<?php echo $this->baseUrl('js/main.js')?>"
src="<?php echo $this->baseUrl('js/vendor/require.js') ?>"></script>
<?= $this->layout()->benchmark ?>
</body>
</html>

View File

@ -229,6 +229,21 @@ class ActionController extends Zend_Controller_Action
}
$this->_helper->layout()->setLayout($target);
}
$userPreferences = $this->getRequest()->getUser()->getPreferences();
if ($userPreferences->get('app.showBenchmark') === true) {
Benchmark::measure('Response ready');
$this->_helper->layout()->benchmark = $this->renderBenchmark();
}
}
/**
* Render the benchmark
*
* @return string Benchmark HTML
*/
protected function renderBenchmark()
{
return Benchmark::renderToHtml();
}
/**