fix: always show missing conf message

pull/129/head
sualko 2021-02-24 14:59:56 +01:00
parent b28469ada4
commit cc566608b2
5 changed files with 62 additions and 35 deletions

View File

@ -2,19 +2,18 @@
namespace OCA\BigBlueButton\Controller;
use OCA\BigBlueButton\TemplateProvider;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IRequest;
class PageController extends Controller {
/** @var IConfig */
private $config;
/** @var TemplateProvider */
private $templateProvider;
public function __construct(string $appName, IRequest $request, IConfig $config) {
public function __construct(string $appName, IRequest $request, TemplateProvider $templateProvider) {
parent::__construct($appName, $request);
$this->config = $config;
$this->templateProvider = $templateProvider;
}
/**
@ -22,8 +21,6 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function index() {
return new TemplateResponse($this->appName, 'manager', [
'shortener' => $this->config->getAppValue('bbb', 'app.shortener', ''),
]);
return $this->templateProvider->getManager();
}
}

View File

@ -2,42 +2,29 @@
namespace OCA\BigBlueButton\Settings;
use \OCP\IL10N;
use OCA\BigBlueButton\TemplateProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
class Personal implements ISettings {
/** @var IConfig */
private $config;
/** @var IL10N */
private $l;
/** @var TemplateProvider */
private $templateProvider;
/**
* Admin constructor.
*
* @param IConfig $config
*/
public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
public function __construct(TemplateProvider $templateProvider) {
$this->templateProvider = $templateProvider;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$warning = '';
if (empty($this->config->getAppValue('bbb', 'api.url')) || empty($this->config->getAppValue('bbb', 'api.secret'))) {
$warning = $this->l->t('API URL or secret not configured. Please contact your administrator.');
}
return new TemplateResponse('bbb', 'manager', [
'warning' => $warning,
'shortener' => $this->config->getAppValue('bbb', 'app.shortener', ''),
]);
return $this->templateProvider->getManager();
}
/**

41
lib/TemplateProvider.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace OCA\BigBlueButton;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
class TemplateProvider {
/** @var IConfig */
private $config;
/** @var IL10N */
private $l;
/**
* Admin constructor.
*
* @param IConfig $config
*/
public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
}
/**
* @return TemplateResponse
*/
public function getManager(): TemplateResponse {
$warning = '';
if (empty($this->config->getAppValue('bbb', 'api.url')) || empty($this->config->getAppValue('bbb', 'api.secret'))) {
$warning = $this->l->t('API URL or secret not configured. Please contact your administrator.');
}
return new TemplateResponse('bbb', 'manager', [
'warning' => $warning,
'shortener' => $this->config->getAppValue('bbb', 'app.shortener', ''),
]);
}
}

View File

@ -2,6 +2,7 @@
script('bbb', 'manager');
?>
<div id="bbb-app">
<div id="bbb-root" data-shortener="<?php p($_['shortener']); ?>"></div>
<?php if (!empty($_['warning'])): ?>
@ -9,3 +10,4 @@ script('bbb', 'manager');
<span class="icon icon-error-color icon-visible"></span> <?php p($_['warning']); ?>
</div>
<?php endif; ?>
</div>

View File

@ -35,7 +35,7 @@
opacity: 0.6;
}
#bbb-root {
#bbb-root, #bbb-app {
width: 100%;
}