1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2024-11-21 22:42:48 +01:00
Nextcloud-News/lib/Settings/AdminSettings.php
Benjamin Brahmer ea8002e2d9 add cron status badge to admin setting
Display  a info card in the settings, indicating when the last news update job ran.

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
2023-03-13 14:39:15 +01:00

62 lines
1.5 KiB
PHP

<?php
namespace OCA\News\Settings;
use OCA\News\AppInfo\Application;
use OCA\News\Service\StatusService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\AppFramework\Services\IInitialState;
class AdminSettings implements ISettings
{
/**
* @var IConfig
*/
private $config;
/** @var IInitialState */
private $initialState;
/** @var StatusService */
private $service;
public function __construct(IConfig $config, IInitialState $initialState, StatusService $service)
{
$this->config = $config;
$this->initialState = $initialState;
$this->service = $service;
}
public function getForm()
{
foreach (array_keys(Application::DEFAULT_SETTINGS) as $setting) {
$this->initialState->provideInitialState($setting, $this->config->getAppValue(
Application::NAME,
$setting,
(string)Application::DEFAULT_SETTINGS[$setting]
));
}
if ($this->service->isCronProperlyConfigured()) {
$lastUpdate = $this->service->getUpdateTime();
} else {
$lastUpdate = 0;
}
$this->initialState->provideInitialState("lastCron", $lastUpdate);
return new TemplateResponse(Application::NAME, 'admin', []);
}
public function getSection()
{
return 'news';
}
public function getPriority()
{
return 40;
}
}