enhance version-check and beautify displayed information
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -34,6 +34,7 @@ use Froxlor\Database\Database;
|
|||||||
use Froxlor\FileDir;
|
use Froxlor\FileDir;
|
||||||
use Froxlor\Froxlor;
|
use Froxlor\Froxlor;
|
||||||
use Froxlor\Http\HttpClient;
|
use Froxlor\Http\HttpClient;
|
||||||
|
use Froxlor\Install\Update;
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
use Froxlor\UI\Listing;
|
use Froxlor\UI\Listing;
|
||||||
use Froxlor\UI\Panel\UI;
|
use Froxlor\UI\Panel\UI;
|
||||||
@@ -193,8 +194,14 @@ class Ajax
|
|||||||
try {
|
try {
|
||||||
$json_result = \Froxlor\Api\Commands\Froxlor::getLocal($this->userinfo)->checkUpdate();
|
$json_result = \Froxlor\Api\Commands\Froxlor::getLocal($this->userinfo)->checkUpdate();
|
||||||
$result = json_decode($json_result, true)['data'];
|
$result = json_decode($json_result, true)['data'];
|
||||||
$result = UI::twig()->render($this->theme . '/misc/version_top.html.twig', $result);
|
$result['full_version'] = Froxlor::getFullVersion();
|
||||||
return $this->jsonResponse($result);
|
$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) {
|
} catch (Exception $e) {
|
||||||
// don't display anything if just not allowed due to permissions
|
// don't display anything if just not allowed due to permissions
|
||||||
if ($e->getCode() != 403) {
|
if ($e->getCode() != 403) {
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ class Froxlor extends ApiCommand
|
|||||||
'version' => $this->version,
|
'version' => $this->version,
|
||||||
'message' => $text,
|
'message' => $text,
|
||||||
'link' => AutoUpdate::getFromResult('url'),
|
'link' => AutoUpdate::getFromResult('url'),
|
||||||
'additional_info' => AutoUpdate::getFromResult('info')
|
'additional_info' => AutoUpdate::getFromResult('info'),
|
||||||
|
'aucheck' => $aucheck
|
||||||
];
|
];
|
||||||
} else if ($aucheck < 0 || $aucheck > 1) {
|
} else if ($aucheck < 0 || $aucheck > 1) {
|
||||||
// errors
|
// errors
|
||||||
@@ -105,7 +106,8 @@ class Froxlor extends ApiCommand
|
|||||||
'version' => $this->version,
|
'version' => $this->version,
|
||||||
'message' => '',
|
'message' => '',
|
||||||
'link' => '',
|
'link' => '',
|
||||||
'additional_info' => $errmsg
|
'additional_info' => $errmsg,
|
||||||
|
'aucheck' => $aucheck
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$response = [
|
$response = [
|
||||||
@@ -113,7 +115,8 @@ class Froxlor extends ApiCommand
|
|||||||
'version' => $this->version,
|
'version' => $this->version,
|
||||||
'message' => '',
|
'message' => '',
|
||||||
'link' => '',
|
'link' => '',
|
||||||
'additional_info' => lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')])
|
'additional_info' => AutoUpdate::getFromResult('info'),
|
||||||
|
'aucheck' => $aucheck
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ final class UpdateCommand extends CliCommand
|
|||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
// no new version
|
// no new version
|
||||||
$output->writeln('<info>' . lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')]) . '</>');
|
$output->writeln('<info>' . AutoUpdate::getFromResult('info') . '</>');
|
||||||
$result = self::SUCCESS;
|
$result = self::SUCCESS;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ class FroxlorTwig extends AbstractExtension
|
|||||||
$this,
|
$this,
|
||||||
'getSetting'
|
'getSetting'
|
||||||
]),
|
]),
|
||||||
|
new TwigFunction('get_config', [
|
||||||
|
$this,
|
||||||
|
'getConfig'
|
||||||
|
]),
|
||||||
new TwigFunction('lng', [
|
new TwigFunction('lng', [
|
||||||
$this,
|
$this,
|
||||||
'getLang'
|
'getLang'
|
||||||
@@ -125,6 +129,11 @@ class FroxlorTwig extends AbstractExtension
|
|||||||
return Settings::Get($setting);
|
return Settings::Get($setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfig($config = null)
|
||||||
|
{
|
||||||
|
return Settings::Config($config);
|
||||||
|
}
|
||||||
|
|
||||||
public function getLang($identifier = null, array $arguments = [])
|
public function getLang($identifier = null, array $arguments = [])
|
||||||
{
|
{
|
||||||
return lng($identifier, $arguments);
|
return lng($identifier, $arguments);
|
||||||
|
|||||||
26
templates/Froxlor/misc/version_popover.html.twig
Normal file
26
templates/Froxlor/misc/version_popover.html.twig
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% macro vpopover(isnewerversion, additional_info, full_version, dbversion, channel, last_update_check, message) %}
|
||||||
|
{% if isnewerversion == 0 %}
|
||||||
|
<p>{{ additional_info }}</p>
|
||||||
|
<div class='d-flex justify-content-between'>
|
||||||
|
<div class='fw-bold'>Version:</div>
|
||||||
|
<div>{{ full_version }}</div>
|
||||||
|
</div>
|
||||||
|
<div class='d-flex justify-content-between'>
|
||||||
|
<div class='fw-bold'>Database version:</div>
|
||||||
|
<div>{{ dbversion }}</div>
|
||||||
|
</div>
|
||||||
|
<div class='d-flex justify-content-between'>
|
||||||
|
<div class='fw-bold'>Channel:</div>
|
||||||
|
<div>{{ channel }}</div>
|
||||||
|
</div>
|
||||||
|
<div class='d-flex justify-content-between'>
|
||||||
|
<div class='fw-bold'>Last checked:</div>
|
||||||
|
<div>{{ last_update_check|date('d.m.Y H:i') }}</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p>{{ message }}</p>
|
||||||
|
{% if get_config('enable_webupdate') %}
|
||||||
|
<a class='btn d-block btn-outline-warning' href='admin_autoupdate.php?page=overview'>Open updater</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
<a class="nav-link {% if isnewerversion == 0 %}text-success{% else %}text-warning{% endif %}" {% if isnewerversion == 0 %} href="#" {% else %} href="admin_autoupdate.php?page=overview" {% endif %} title="{% if isnewerversion == 0 %}{{ additional_info }}{% else %}{{ message }}{% endif %}">
|
{% import "Froxlor/misc/version_popover.html.twig" as vc %}
|
||||||
{% if isnewerversion == 0 %}
|
<span id="ucheck" class="nav-link {% if isnewerversion == 0 and aucheck < 0 %}text-muted{% elseif isnewerversion == 0 %}text-success{% else %}text-warning{% endif %}"
|
||||||
|
data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-trigger="hover focus click" data-bs-html="true"
|
||||||
|
data-bs-content="{{ vc.vpopover(isnewerversion, additional_info, full_version, dbversion, channel, last_update_check, message) }}"
|
||||||
|
>
|
||||||
|
{% if isnewerversion == 0 and aucheck == 0 %}
|
||||||
<i class="fa-solid fa-circle-check me-1"></i>
|
<i class="fa-solid fa-circle-check me-1"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="fa-solid fa-circle-exclamation me-1"></i>
|
<i class="fa-solid fa-circle-exclamation me-1"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="d-md-none d-xl-inline">{{ version }}</span>
|
<span class="d-none d-xl-inline">{{ version }}</span>
|
||||||
</a>
|
</span>
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ $(function() {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$("#updatecheck").html(data);
|
$("#updatecheck").html(data);
|
||||||
|
new bootstrap.Popover(document.getElementById('ucheck'));
|
||||||
},
|
},
|
||||||
error: function (request, status, error) {
|
error: function (request, status, error) {
|
||||||
console.log(request, status, error)
|
console.log(request, status, error)
|
||||||
let message = 'Can\'t check version';
|
let message = 'Can\'t check version';
|
||||||
$("#updatecheck").html('<span class="text-decoration-none badge bg-warning mt-2 me-2" data-bs-toggle="tooltip" data-bs-placement="left" title="' + message + '"><i class="fa-solid fa-exclamation-triangle"></i> <span class="d-md-none d-xl-inline">' + message + '</span></span>');
|
$("#updatecheck").html('<span id="ucheck" class="text-decoration-none badge bg-warning mt-2 me-2" data-bs-toggle="tooltip" data-bs-placement="left" title="' + message + '"><i class="fa-solid fa-exclamation-triangle"></i> <span class="d-md-none d-xl-inline">' + message + '</span></span>');
|
||||||
|
new bootstrap.Tooltip(document.getElementById('ucheck'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user