mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
Merge branch 'feature/Show-Icinga-Web-2-s-version-in-the-frontend-9247'
resolves #9247
This commit is contained in:
commit
1bd18c5adb
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -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
|
# Normalize puppet manifests' line endings to LF on checkin and prevent conversion to CRLF when the files are checked out
|
||||||
.puppet* eol=lf
|
.puppet* eol=lf
|
||||||
|
|
||||||
|
# Include version information on `git archive'
|
||||||
|
/application/VERSION export-subst
|
||||||
|
1
application/VERSION
Normal file
1
application/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
$Format:%H%d %ci$
|
15
application/controllers/AboutController.php
Normal file
15
application/controllers/AboutController.php
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
25
application/views/scripts/about/index.phtml
Normal file
25
application/views/scripts/about/index.phtml
Normal file
@ -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/forms
|
||||||
%{basedir}/application/layouts
|
%{basedir}/application/layouts
|
||||||
%{basedir}/application/views
|
%{basedir}/application/views
|
||||||
|
%{basedir}/application/VERSION
|
||||||
%{basedir}/doc
|
%{basedir}/doc
|
||||||
%{basedir}/modules
|
%{basedir}/modules
|
||||||
%{basedir}/public
|
%{basedir}/public
|
||||||
|
37
library/Icinga/Application/Version.php
Normal file
37
library/Icinga/Application/Version.php
Normal file
@ -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,
|
'priority' => 990,
|
||||||
'renderer' => 'ForeignMenuItemRenderer'
|
'renderer' => 'ForeignMenuItemRenderer'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->add(t('About'), array(
|
||||||
|
'url' => 'about',
|
||||||
|
'priority' => 1000
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,8 +331,7 @@ html {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: replace this with .error */
|
.message-error {
|
||||||
.fileNotReadable {
|
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
background-color: @colorCritical;
|
background-color: @colorCritical;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user