diff --git a/lib/Froxlor/Ajax/Ajax.php b/lib/Froxlor/Ajax/Ajax.php index f6a1b217..1f6d1290 100644 --- a/lib/Froxlor/Ajax/Ajax.php +++ b/lib/Froxlor/Ajax/Ajax.php @@ -34,6 +34,7 @@ use Froxlor\Database\Database; use Froxlor\FileDir; use Froxlor\Froxlor; use Froxlor\Http\HttpClient; +use Froxlor\Install\Update; use Froxlor\Settings; use Froxlor\UI\Listing; use Froxlor\UI\Panel\UI; @@ -193,8 +194,14 @@ class Ajax try { $json_result = \Froxlor\Api\Commands\Froxlor::getLocal($this->userinfo)->checkUpdate(); $result = json_decode($json_result, true)['data']; - $result = UI::twig()->render($this->theme . '/misc/version_top.html.twig', $result); - return $this->jsonResponse($result); + $result['full_version'] = Froxlor::getFullVersion(); + $result['dbversion'] = Froxlor::DBVERSION; + $uc_data = Update::getUpdateCheckData(); + $result['last_update_check'] = $uc_data['ts']; + $result['channel'] = Settings::Get('system.update_channel'); + + $result_rendered = UI::twig()->render($this->theme . '/misc/version_top.html.twig', $result); + return $this->jsonResponse($result_rendered); } catch (Exception $e) { // don't display anything if just not allowed due to permissions if ($e->getCode() != 403) { diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 761b1c8e..690b5880 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -87,7 +87,8 @@ class Froxlor extends ApiCommand 'version' => $this->version, 'message' => $text, 'link' => AutoUpdate::getFromResult('url'), - 'additional_info' => AutoUpdate::getFromResult('info') + 'additional_info' => AutoUpdate::getFromResult('info'), + 'aucheck' => $aucheck ]; } else if ($aucheck < 0 || $aucheck > 1) { // errors @@ -105,7 +106,8 @@ class Froxlor extends ApiCommand 'version' => $this->version, 'message' => '', 'link' => '', - 'additional_info' => $errmsg + 'additional_info' => $errmsg, + 'aucheck' => $aucheck ]; } else { $response = [ @@ -113,7 +115,8 @@ class Froxlor extends ApiCommand 'version' => $this->version, 'message' => '', 'link' => '', - 'additional_info' => lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')]) + 'additional_info' => AutoUpdate::getFromResult('info'), + 'aucheck' => $aucheck ]; } diff --git a/lib/Froxlor/Cli/UpdateCommand.php b/lib/Froxlor/Cli/UpdateCommand.php index 23a50905..2f1fd27a 100644 --- a/lib/Froxlor/Cli/UpdateCommand.php +++ b/lib/Froxlor/Cli/UpdateCommand.php @@ -103,7 +103,7 @@ final class UpdateCommand extends CliCommand return self::SUCCESS; } // no new version - $output->writeln('' . lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')]) . ''); + $output->writeln('' . AutoUpdate::getFromResult('info') . ''); $result = self::SUCCESS; } } catch (Exception $e) { diff --git a/lib/Froxlor/UI/Panel/FroxlorTwig.php b/lib/Froxlor/UI/Panel/FroxlorTwig.php index 8b40a6ff..20c2d4e6 100644 --- a/lib/Froxlor/UI/Panel/FroxlorTwig.php +++ b/lib/Froxlor/UI/Panel/FroxlorTwig.php @@ -76,6 +76,10 @@ class FroxlorTwig extends AbstractExtension $this, 'getSetting' ]), + new TwigFunction('get_config', [ + $this, + 'getConfig' + ]), new TwigFunction('lng', [ $this, 'getLang' @@ -125,6 +129,11 @@ class FroxlorTwig extends AbstractExtension return Settings::Get($setting); } + public function getConfig($config = null) + { + return Settings::Config($config); + } + public function getLang($identifier = null, array $arguments = []) { return lng($identifier, $arguments); diff --git a/templates/Froxlor/misc/version_popover.html.twig b/templates/Froxlor/misc/version_popover.html.twig new file mode 100644 index 00000000..02916f45 --- /dev/null +++ b/templates/Froxlor/misc/version_popover.html.twig @@ -0,0 +1,26 @@ +{% macro vpopover(isnewerversion, additional_info, full_version, dbversion, channel, last_update_check, message) %} + {% if isnewerversion == 0 %} +

{{ additional_info }}

+
+
Version:
+
{{ full_version }}
+
+
+
Database version:
+
{{ dbversion }}
+
+
+
Channel:
+
{{ channel }}
+
+
+
Last checked:
+
{{ last_update_check|date('d.m.Y H:i') }}
+
+ {% else %} +

{{ message }}

+ {% if get_config('enable_webupdate') %} + Open updater + {% endif %} + {% endif %} +{% endmacro %} diff --git a/templates/Froxlor/misc/version_top.html.twig b/templates/Froxlor/misc/version_top.html.twig index 5c7de940..2531e2ce 100644 --- a/templates/Froxlor/misc/version_top.html.twig +++ b/templates/Froxlor/misc/version_top.html.twig @@ -1,8 +1,12 @@ - - {% if isnewerversion == 0 %} +{% import "Froxlor/misc/version_popover.html.twig" as vc %} + + {% if isnewerversion == 0 and aucheck == 0 %} {% else %} {% endif %} - {{ version }} - + {{ version }} + diff --git a/templates/Froxlor/src/js/components/updatecheck.js b/templates/Froxlor/src/js/components/updatecheck.js index c9316cc3..b992e80c 100644 --- a/templates/Froxlor/src/js/components/updatecheck.js +++ b/templates/Froxlor/src/js/components/updatecheck.js @@ -8,11 +8,13 @@ $(function() { type: "GET", success: function (data) { $("#updatecheck").html(data); + new bootstrap.Popover(document.getElementById('ucheck')); }, error: function (request, status, error) { console.log(request, status, error) let message = 'Can\'t check version'; - $("#updatecheck").html(' ' + message + ''); + $("#updatecheck").html(' ' + message + ''); + new bootstrap.Tooltip(document.getElementById('ucheck')); } }); }