Fixes #5514 -- Hide links for HLS/streamers when disabled.
This commit is contained in:
parent
5b46d13d0d
commit
43d9624c76
|
@ -139,7 +139,7 @@ return function (App\Event\BuildStationMenu $e) {
|
|||
'label' => __('Streamer/DJ Accounts'),
|
||||
'icon' => 'mic',
|
||||
'url' => (string)$router->fromHere('stations:streamers:index'),
|
||||
'visible' => $backend->supportsStreamers(),
|
||||
'visible' => $backend->supportsStreamers() && $station->getEnableStreamers(),
|
||||
'permission' => StationPermissions::Streamers,
|
||||
],
|
||||
|
||||
|
@ -209,7 +209,7 @@ return function (App\Event\BuildStationMenu $e) {
|
|||
'hls_streams' => [
|
||||
'label' => __('HLS Streams'),
|
||||
'url' => (string)$router->fromHere('stations:hls_streams:index'),
|
||||
'visible' => $backend->supportsHls(),
|
||||
'visible' => $backend->supportsHls() && $station->getEnableHls(),
|
||||
'permission' => StationPermissions::MountPoints,
|
||||
],
|
||||
'remotes' => [
|
||||
|
|
|
@ -4,20 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\StationRepository;
|
||||
use App\Exception\StationUnsupportedException;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Session\Flash;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class HlsStreamsAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly StationRepository $stationRepo
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
|
@ -26,36 +19,11 @@ final class HlsStreamsAction
|
|||
$station = $request->getStation();
|
||||
$backend = $request->getStationBackend();
|
||||
|
||||
if (!$backend->supportsHls()) {
|
||||
if (!$backend->supportsHls() || !$station->getEnableHls()) {
|
||||
throw new StationUnsupportedException();
|
||||
}
|
||||
|
||||
$view = $request->getView();
|
||||
|
||||
if (!$station->getEnableHls()) {
|
||||
$params = $request->getQueryParams();
|
||||
if (isset($params['enable'])) {
|
||||
$station->setEnableHls(true);
|
||||
|
||||
$em = $this->stationRepo->getEntityManager();
|
||||
$em->persist($station);
|
||||
$em->flush();
|
||||
|
||||
$this->stationRepo->resetHls($station, $request->getStationBackend());
|
||||
|
||||
$request->getFlash()->addMessage(
|
||||
'<b>' . __('HLS enabled!') . '</b>',
|
||||
Flash::SUCCESS
|
||||
);
|
||||
|
||||
return $response->withRedirect((string)$request->getRouter()->fromHere('stations:hls:index'));
|
||||
}
|
||||
|
||||
return $view->renderToResponse($response, 'stations/hls_disabled');
|
||||
}
|
||||
|
||||
$router = $request->getRouter();
|
||||
|
||||
return $request->getView()->renderVuePage(
|
||||
response: $response,
|
||||
component: 'Vue_StationsHlsStreams',
|
||||
|
|
|
@ -9,14 +9,11 @@ use App\Exception\StationUnsupportedException;
|
|||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use App\Session\Flash;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class StreamersAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly AzuraCastCentral $acCentral,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
|
@ -30,30 +27,10 @@ final class StreamersAction
|
|||
$station = $request->getStation();
|
||||
$backend = $request->getStationBackend();
|
||||
|
||||
if (!$backend->supportsStreamers()) {
|
||||
if (!$backend->supportsStreamers() && !$station->getEnableStreamers()) {
|
||||
throw new StationUnsupportedException();
|
||||
}
|
||||
|
||||
$view = $request->getView();
|
||||
|
||||
if (!$station->getEnableStreamers()) {
|
||||
$params = $request->getQueryParams();
|
||||
if (isset($params['enable'])) {
|
||||
$station->setEnableStreamers(true);
|
||||
$this->em->persist($station);
|
||||
$this->em->flush();
|
||||
|
||||
$request->getFlash()->addMessage(
|
||||
'<b>' . __('Streamers enabled!') . '</b><br>' . __('You can now set up streamer (DJ) accounts.'),
|
||||
Flash::SUCCESS
|
||||
);
|
||||
|
||||
return $response->withRedirect((string)$request->getRouter()->fromHere('stations:streamers:index'));
|
||||
}
|
||||
|
||||
return $view->renderToResponse($response, 'stations/streamers_disabled');
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$backendConfig = $station->getBackendConfig();
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
$this->layout('main', ['title' => __('HLS Streams')]) ?>
|
||||
|
||||
<p><?= __('HLS is currently disabled for this station. To enable HLS, click the button below.') ?></p>
|
||||
|
||||
<a class="btn btn-lg btn-success" role="button" href="<?= $router->fromHere(null, [], ['enable' => true]) ?>">
|
||||
<?= __('Enable HLS') ?>
|
||||
</a>
|
|
@ -1,5 +0,0 @@
|
|||
<?php $this->layout('main', ['title' => __('Streamer/DJ Accounts')]) ?>
|
||||
|
||||
<p><?=__('Streamer accounts are currently disabled for this station. To enable streamer accounts, click the button below.') ?></p>
|
||||
|
||||
<a class="btn btn-lg btn-success" role="button" href="<?=$router->fromHere(null, [], ['enable' => true]) ?>"><?=__('Enable Streaming') ?></a>
|
Loading…
Reference in New Issue