Prevent service control links from appearing on fully remote stations.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-08-19 00:09:55 -05:00
parent c6a3d42089
commit 7f6df2aeab
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
3 changed files with 14 additions and 4 deletions

View File

@ -24,6 +24,8 @@ return function (App\Event\BuildStationMenu $e) {
$settings = $e->getSettings();
$hasLocalServices = $station->hasLocalServices();
$e->merge(
[
'start_station' => [
@ -33,7 +35,7 @@ return function (App\Event\BuildStationMenu $e) {
'url' => (string)$router->fromHere('api:stations:reload'),
'class' => 'api-call text-success',
'confirm' => $reloadMessage,
'visible' => !$station->getHasStarted(),
'visible' => $hasLocalServices && !$station->getHasStarted(),
'permission' => StationPermissions::Broadcasting,
],
'restart_station' => [
@ -44,7 +46,7 @@ return function (App\Event\BuildStationMenu $e) {
'class' => 'api-call text-warning btn-restart-station '
. (!$station->getNeedsRestart() ? 'd-none' : ''),
'confirm' => $reloadMessage,
'visible' => $station->getHasStarted(),
'visible' => $hasLocalServices && $station->getHasStarted(),
'permission' => StationPermissions::Broadcasting,
],
'profile' => [
@ -245,6 +247,7 @@ return function (App\Event\BuildStationMenu $e) {
'class' => 'text-muted',
'url' => (string)$router->fromHere('stations:queue:index'),
'permission' => StationPermissions::Broadcasting,
'visible' => $station->supportsAutoDjQueue(),
],
'reload' => [
'label' => __('Reload Configuration'),
@ -252,7 +255,7 @@ return function (App\Event\BuildStationMenu $e) {
'url' => (string)$router->fromHere('api:stations:reload'),
'confirm' => $willNotDisconnectMessage,
'permission' => StationPermissions::Broadcasting,
'visible' => $reloadSupported,
'visible' => $hasLocalServices && $reloadSupported,
],
'restart' => [
'label' => __('Restart Broadcasting'),
@ -260,6 +263,7 @@ return function (App\Event\BuildStationMenu $e) {
'url' => (string)$router->fromHere('api:stations:restart'),
'confirm' => $willDisconnectMessage,
'permission' => StationPermissions::Broadcasting,
'visible' => $hasLocalServices,
],
],
],

View File

@ -549,6 +549,12 @@ class Station implements Stringable, IdentifiableEntityInterface
return new StationBackendConfiguration((array)$this->backend_config);
}
public function hasLocalServices(): bool
{
return $this->getIsEnabled() &&
($this->getBackendTypeEnum()->isEnabled() || $this->getFrontendTypeEnum()->isEnabled());
}
/**
* @param array|StationBackendConfiguration $backend_config
* @param bool $force_overwrite

View File

@ -98,7 +98,7 @@ abstract class AbstractRemote
if (!str_starts_with($customPath, '/')) {
$customPath = '/' . $customPath;
}
return (string)$uri->withPath($customPath);
return (string)$uri->withPath($uri->getPath() . $customPath);
}
return (string)$uri;