Add theme switcher, Help to navbar, form page exit confirmation.

This commit is contained in:
Buster Neece 2019-03-06 00:08:42 -06:00
parent ce6d35de04
commit b4e1581da1
8 changed files with 61 additions and 7 deletions

View File

@ -333,6 +333,9 @@ return function(App $app)
$this->map(['GET', 'POST'], '/profile/edit', Controller\Frontend\ProfileController::class.':editAction')
->setName('profile:edit');
$this->get('/profile/theme', Controller\Frontend\ProfileController::class.':themeAction')
->setName('profile:theme');
$this->get('/api_keys', Controller\Frontend\ApiKeysController::class.':indexAction')
->setName('api_keys:index');

View File

@ -98,4 +98,34 @@ class ProfileController
'title' => __('Edit Profile')
]);
}
public function themeAction(Request $request, Response $response): ResponseInterface
{
$user = $request->getUser();
$theme_field = $this->form_config['groups']['customization']['elements']['theme'][1];
$theme_options = array_keys($theme_field['choices']);
$current_theme = $user->getTheme();
if (empty($current_theme)) {
$current_theme = $theme_field['default'];
}
foreach($theme_options as $theme) {
if ($theme !== $current_theme) {
$user->setTheme($theme);
break;
}
}
$this->em->persist($user);
$this->em->flush($user);
$referer = $request->getHeaderLine('HTTP_REFERER');
if (!empty($referer)) {
return $response->withRedirect($referer);
}
return $response->withRedirect($request->getRouter()->named('dashboard'));
}
}

View File

@ -10,14 +10,14 @@ use Psr\Http\Message\UriInterface;
class Customization
{
const DEFAULT_TIMEZONE = 'UTC';
const DEFAULT_LOCALE = 'en_US.UTF-8';
public const DEFAULT_TIMEZONE = 'UTC';
public const DEFAULT_LOCALE = 'en_US.UTF-8';
/** @var Settings */
protected $app_settings;
/** @var Entity\User */
protected $user = null;
/** @var Entity\User|null */
protected $user;
/** @var Entity\Repository\SettingsRepository */
protected $settings_repo;

View File

@ -64,6 +64,7 @@ echo $assets->js();
<?=__('Dashboard') ?>
</a>
</li>
<li class="dropdown-divider">&nbsp;</li>
<?php if ($acl->userAllowed($user, 'view administration')): ?>
<li>
<a class="dropdown-item" href="<?=$router->named('admin:index:index') ?>">
@ -78,12 +79,24 @@ echo $assets->js();
<?=__('My Account') ?>
</a>
</li>
<li>
<a class="dropdown-item" href="<?=$router->named('profile:theme') ?>">
<i class="material-icons" aria-hidden="true">invert_colors</i>
<?=__('Switch Theme') ?>
</a>
</li>
<li>
<a class="dropdown-item" href="<?=$router->named('api_keys:index') ?>">
<i class="material-icons" aria-hidden="true">vpn_key</i>
<?=__('My API Keys') ?>
</a>
</li>
<li>
<a class="dropdown-item" href="https://www.azuracast.com/help.html" target="_blank">
<i class="material-icons" aria-hidden="true">help</i>
<?=__('Help') ?>
</a>
</li>
<li class="dropdown-divider">&nbsp;</li>
<?php if ($auth->isMasqueraded()): ?>
<li>

View File

@ -1,5 +1,5 @@
{
"dist/app.js": "dist/app-adaf66ef37.js",
"dist/app.js": "dist/app-b569c86b0e.js",
"dist/bootgrid.js": "dist/bootgrid-acbc545ec1.js",
"dist/dark.css": "dist/dark-4d4308fb20.css",
"dist/lib/autosize/autosize.min.js": "dist/lib/autosize/autosize-ad0656589d.min.js",

File diff suppressed because one or more lines are too long

2
web/static/dist/app-b569c86b0e.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,14 @@ function styleForm(form, translations) {
var $form = $(form);
$(window).on('beforeunload', function() {
return false;
});
$form.on('submit', function() {
$(window).off('beforeunload');
});
$form.find('fieldset').addClass('form-group');
$form.find('input:not(input[type=button],input[type=submit],input[type=reset],input[type=radio],input[type=checkbox]),textarea,select').addClass('form-control');