Add "Get Next Song" debug command.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-03-12 00:49:50 -06:00
parent b0e7c35db8
commit ef4c438857
No known key found for this signature in database
GPG Key ID: 9FC8B9E008872109
3 changed files with 49 additions and 13 deletions

View File

@ -40,15 +40,19 @@ return static function (RouteCollectorProxy $app) {
['GET', 'POST'],
'/nowplaying',
Controller\Admin\DebugController::class . ':nowplayingAction'
)
->setName('admin:debug:nowplaying');
)->setName('admin:debug:nowplaying');
$group->map(
['GET', 'POST'],
'/nextsong',
Controller\Admin\DebugController::class . ':nextsongAction'
)
->setName('admin:debug:nextsong');
Controller\Admin\DebugController::class . ':nextSongAction'
)->setName('admin:debug:nextsong');
$group->map(
['GET', 'POST'],
'/clearqueue',
Controller\Admin\DebugController::class . ':clearStationQueueAction'
)->setName('admin:debug:clear-station-queue');
$group->post('/telnet', Controller\Admin\DebugController::class . ':telnetAction')
->setName('admin:debug:telnet');

View File

@ -139,14 +139,40 @@ class DebugController extends AbstractLogViewerController
$response,
'system/log_view',
[
'sidebar' => null,
'title' => __('Debug Output'),
'sidebar' => null,
'title' => __('Debug Output'),
'log_records' => $this->testHandler->getRecords(),
]
);
}
public function nextsongAction(
public function nextSongAction(
ServerRequest $request,
Response $response,
AutoDJ\Annotations $annotations,
): ResponseInterface {
$this->logger->pushHandler($this->testHandler);
$nextSongAnnotated = $annotations->annotateNextSong(
$request->getStation(),
false
);
$this->logger->info('Annotated next song: ' . $nextSongAnnotated);
$this->logger->popHandler();
return $request->getView()->renderToResponse(
$response,
'system/log_view',
[
'sidebar' => null,
'title' => __('Debug Output'),
'log_records' => $this->testHandler->getRecords(),
]
);
}
public function clearStationQueueAction(
ServerRequest $request,
Response $response,
EntityManagerInterface $em,

View File

@ -152,19 +152,25 @@ $assets
<h3><?= $station['name'] ?></h3>
<div class="row">
<div class="col-md-3">
<h5><?= __('Rebuild AutoDJ Queue') ?></h5>
<div class="col-md-4">
<h5><?= __('AutoDJ Queue') ?></h5>
<div class="buttons">
<a class="btn btn-sm btn-primary" role="button" href="<?= $router->named(
'admin:debug:clear-station-queue',
['station_id' => $station['id']]
) ?>">
<?= __('Clear Queue') ?>
</a>
<a class="btn btn-sm btn-primary" role="button" href="<?= $router->named(
'admin:debug:nextsong',
['station_id' => $station['id']]
) ?>">
<?= __('Run Task') ?>
<?= __('Get Next Song') ?>
</a>
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<h5><?= __('Get Now Playing') ?></h5>
<div class="buttons">
@ -178,7 +184,7 @@ $assets
</div>
<?php
if ($station['backend_type'] === \App\Radio\Enums\BackendAdapters::Liquidsoap->value): ?>
<div class="col-md-6">
<div class="col-md-4">
<h5><?= __('Send Liquidsoap Telnet Command') ?></h5>
<form class="form" method="POST" action="<?= $router->named(