Merge branch 'feature/Show-Icinga-Web-2-s-version-in-the-frontend-9247'
resolves #9247
This commit is contained in:
commit
1bd18c5adb
|
@ -6,3 +6,6 @@ Vagrantfile export-ignore
|
|||
|
||||
# Normalize puppet manifests' line endings to LF on checkin and prevent conversion to CRLF when the files are checked out
|
||||
.puppet* eol=lf
|
||||
|
||||
# Include version information on `git archive'
|
||||
/application/VERSION export-subst
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$Format:%H%d %ci$
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
# namespace Icinga\Application\Controllers;
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Version;
|
||||
|
||||
class AboutController extends ActionController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->version = Version::get();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<div class="content">
|
||||
<h1>Icinga Web 2</h1>
|
||||
<?php
|
||||
$versionInfo = array();
|
||||
if ($version !== false) {
|
||||
foreach (array(
|
||||
'appVersion' => $this->translate('Version: %s'),
|
||||
'gitCommitID' => $this->translate('Git commit ID: %s'),
|
||||
'gitCommitDate' => $this->translate('Git commit date: %s')
|
||||
) as $key => $label) {
|
||||
if (array_key_exists($key, $version) && null !== ($value = $version[$key])) {
|
||||
$versionInfo[] = sprintf($label, htmlspecialchars($value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo (
|
||||
0 === count($versionInfo)
|
||||
? '<p class="message-error">' . $this->translate(
|
||||
'Can\'t determine Icinga Web 2\'s version'
|
||||
)
|
||||
: '<p>' . nl2br(implode("\n", $versionInfo), false)
|
||||
) . '</p>';
|
||||
?>
|
||||
</div>
|
|
@ -218,6 +218,7 @@ rm -rf %{buildroot}
|
|||
%{basedir}/application/forms
|
||||
%{basedir}/application/layouts
|
||||
%{basedir}/application/views
|
||||
%{basedir}/application/VERSION
|
||||
%{basedir}/doc
|
||||
%{basedir}/modules
|
||||
%{basedir}/public
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Application;
|
||||
|
||||
class Version
|
||||
{
|
||||
/**
|
||||
* Get the version of this instance of Icinga Web 2
|
||||
*
|
||||
* @return array|bool array on success, false otherwise
|
||||
*/
|
||||
public static function get()
|
||||
{
|
||||
if (false === ($appVersion = @file_get_contents(
|
||||
Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION'
|
||||
))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
if (false === ($res = preg_match(
|
||||
'/(?<!.)\s*(?P<gitCommitID>\w+)(?:\s*\(.*?(?:(?<=[\(,])\s*tag\s*:\s*v(?P<appVersion>.+?)\s*(?=[\),]).*?)?\))?\s*(?P<gitCommitDate>\S+)/ms',
|
||||
$appVersion,
|
||||
$matches
|
||||
)) || $res === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($matches as $key => $value) {
|
||||
if (is_int($key) || $value === '') {
|
||||
unset($matches[$key]);
|
||||
}
|
||||
}
|
||||
return $matches;
|
||||
}
|
||||
}
|
|
@ -279,6 +279,11 @@ class Menu implements RecursiveIterator
|
|||
'priority' => 990,
|
||||
'renderer' => 'ForeignMenuItemRenderer'
|
||||
));
|
||||
|
||||
$this->add(t('About'), array(
|
||||
'url' => 'about',
|
||||
'priority' => 1000
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,8 +331,7 @@ html {
|
|||
position: absolute;
|
||||
}
|
||||
|
||||
/* TODO: replace this with .error */
|
||||
.fileNotReadable {
|
||||
.message-error {
|
||||
padding: 0.5em;
|
||||
background-color: @colorCritical;
|
||||
font-weight: bold;
|
||||
|
|
Loading…
Reference in New Issue