feat: add option to show manager in app navigation

fix #31
pull/67/head
sualko 2020-08-26 10:57:31 +02:00
parent d7a0bfce09
commit 557eb7029a
8 changed files with 74 additions and 2 deletions

View File

@ -36,7 +36,5 @@ Developer wanted! If you have time it would be awesome if you could help to enha
</dependencies>
<settings>
<admin>OCA\BigBlueButton\Settings\Admin</admin>
<personal>OCA\BigBlueButton\Settings\Personal</personal>
<personal-section>OCA\BigBlueButton\Settings\Section</personal-section>
</settings>
</info>

View File

@ -6,6 +6,7 @@ return [
'roomShare' => ['url' => '/roomShares'],
],
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'server#records', 'url' => '/server/{roomUid}/records', 'verb' => 'GET'],
['name' => 'server#check', 'url' => '/server/check', 'verb' => 'POST'],
['name' => 'server#version', 'url' => '/server/version', 'verb' => 'GET'],

View File

@ -2,6 +2,7 @@
namespace OCA\BigBlueButton\AppInfo;
use \OCP\IConfig;
use \OCP\AppFramework\App;
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
@ -16,5 +17,34 @@ class Application extends App {
$container = $this->getContainer();
$container->registerMiddleWare(JoinMiddleware::class);
$config = $container->query(IConfig::class);
if ($config->getAppValue('bbb', 'app.navigation') === 'true') {
$this->registerAsNavigationEntry();
} else {
$this->registerAsPersonalSetting();
}
}
private function registerAsPersonalSetting() {
$settingsManager = $this->getContainer()->getServer()->getSettingsManager();
$settingsManager->registerSection('personal', \OCA\BigBlueButton\Settings\Section::class);
$settingsManager->registerSetting('personal', \OCA\BigBlueButton\Settings\Personal::class);
}
private function registerAsNavigationEntry() {
$server = $this->getContainer()->getServer();
$server->getNavigationManager()->add(function () use ($server) {
return [
'id' => 'bbb',
'order' => 80,
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
'name' => 'BigBlueButton',
];
});
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace OCA\BigBlueButton\Controller;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;
class PageController extends Controller {
public function __construct(string $appName, IRequest $request) {
parent::__construct($appName, $request);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index() {
return new TemplateResponse($this->appName, 'manager');
}
}

View File

@ -27,6 +27,7 @@ class Admin implements ISettings {
$parameters = [
'api.url' => $this->config->getAppValue('bbb', 'api.url'),
'api.secret' => $this->config->getAppValue('bbb', 'api.secret'),
'app.navigation' => $this->config->getAppValue('bbb', 'app.navigation') === 'true' ? 'checked' : '',
];
return new TemplateResponse('bbb', 'admin', $parameters);

View File

@ -17,4 +17,9 @@ script('bbb', 'admin');
<div id="bbb-result"></div>
</form>
<p>
<input type="checkbox" name="app.navigation" id="bbb-app-navigation" class="checkbox" value="1" <?php p($_['app.navigation']); ?>>
<label for="bbb-app-navigation"><?php p($l->t('Show room manager in app navigation instead of settings page.')); ?></label>
</p>
</div>

View File

@ -19,6 +19,10 @@
border-radius: 50%;
}
#bbb-root {
width: 100%;
}
#bbb-warning {
padding: 1em;
background-color: rgb(255, 255, 123);
@ -53,6 +57,10 @@
p {
margin-bottom: 1em;
}
form {
margin-bottom: 2em;
}
}
#bbb-react-root {

View File

@ -71,4 +71,12 @@ $(() => {
$('#bbb-result').append(warningElement);
});
});
$<HTMLInputElement>('#bbb-settings [name="app.navigation"]').change((ev) => {
ev.preventDefault();
console.log('checkbox changed to', ev.target.checked);
OCP.AppConfig.setValue('bbb', 'app.navigation', ev.target.checked);
});
});