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\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) {
|
||||
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ final class UpdateCommand extends CliCommand
|
||||
return self::SUCCESS;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user