From 852d2e4de16e1261e321ddee0c1ae755f29d7a2b Mon Sep 17 00:00:00 2001 From: "Buster \"Silver Eagle\" Neece" Date: Sun, 19 Jun 2022 17:28:31 -0500 Subject: [PATCH] Move log pages to Vue components. --- config/menus/station.php | 2 +- config/routes/admin.php | 14 +- config/routes/api_admin.php | 11 ++ config/routes/api_station.php | 11 ++ config/routes/stations.php | 13 +- frontend/vue/components/Admin/Logs.vue | 48 +++++++ .../vue/components/Admin/Logs/StationLogs.vue | 3 + frontend/vue/components/Common/LogList.vue | 43 ++++++ .../components/Common/StreamingLogModal.vue | 2 +- .../components/Common/StreamingLogView.vue | 22 ++- frontend/vue/components/Stations/Help.vue | 65 +++++++++ frontend/vue/pages/Admin/Logs.js | 7 + frontend/vue/pages/Stations/Help.js | 7 + frontend/webpack.config.js | 2 + src/Controller/Admin/LogsAction.php | 51 +++++++ .../Admin/LogsAction.php} | 79 +++++----- src/Controller/Api/Stations/LogsAction.php | 136 ++++++++++++++++++ src/Controller/Api/Traits/HasLogViewer.php | 25 +++- src/Controller/Stations/HelpAction.php | 30 ++++ src/Controller/Stations/LogsController.php | 67 --------- templates/admin/logs/index.phtml | 72 ---------- templates/partials/log_help_card.phtml | 24 ---- templates/partials/log_inline.js.phtml | 35 ----- templates/partials/log_inline.phtml | 15 -- templates/partials/log_viewer.js.phtml | 65 --------- templates/partials/log_viewer.phtml | 34 ----- templates/stations/logs/index.phtml | 29 ---- 27 files changed, 499 insertions(+), 413 deletions(-) create mode 100644 frontend/vue/components/Admin/Logs.vue create mode 100644 frontend/vue/components/Admin/Logs/StationLogs.vue create mode 100644 frontend/vue/components/Common/LogList.vue create mode 100644 frontend/vue/components/Stations/Help.vue create mode 100644 frontend/vue/pages/Admin/Logs.js create mode 100644 frontend/vue/pages/Stations/Help.js create mode 100644 src/Controller/Admin/LogsAction.php rename src/Controller/{Admin/LogsController.php => Api/Admin/LogsAction.php} (55%) create mode 100644 src/Controller/Api/Stations/LogsAction.php create mode 100644 src/Controller/Stations/HelpAction.php delete mode 100644 src/Controller/Stations/LogsController.php delete mode 100644 templates/admin/logs/index.phtml delete mode 100644 templates/partials/log_help_card.phtml delete mode 100644 templates/partials/log_inline.js.phtml delete mode 100644 templates/partials/log_inline.phtml delete mode 100644 templates/partials/log_viewer.js.phtml delete mode 100644 templates/partials/log_viewer.phtml delete mode 100644 templates/stations/logs/index.phtml diff --git a/config/menus/station.php b/config/menus/station.php index f40cc4aaf..6baebc34e 100644 --- a/config/menus/station.php +++ b/config/menus/station.php @@ -268,7 +268,7 @@ return function (App\Event\BuildStationMenu $e) { 'help' => [ 'label' => __('Help'), 'icon' => 'support', - 'url' => (string)$router->fromHere('stations:logs:index'), + 'url' => (string)$router->fromHere('stations:help'), 'permission' => StationPermissions::Logs, ], ] diff --git a/config/routes/admin.php b/config/routes/admin.php index 9cc25847d..6e310bcf7 100644 --- a/config/routes/admin.php +++ b/config/routes/admin.php @@ -91,17 +91,9 @@ return static function (RouteCollectorProxy $app) { ->setName('admin:custom_fields:index') ->add(new Middleware\Permissions(GlobalPermissions::CustomFields)); - $group->group( - '/logs', - function (RouteCollectorProxy $group) { - $group->get('', Controller\Admin\LogsController::class) - ->setName('admin:logs:index'); - - $group->get('/view/{station_id}/{log}', Controller\Admin\LogsController::class . ':viewAction') - ->setName('admin:logs:view') - ->add(Middleware\GetStation::class); - } - )->add(new Middleware\Permissions(GlobalPermissions::Logs)); + $group->get('/logs', Controller\Admin\LogsAction::class) + ->setName('admin:logs:index') + ->add(new Middleware\Permissions(GlobalPermissions::Logs)); $group->get('/permissions', Controller\Admin\PermissionsAction::class) ->setName('admin:permissions:index') diff --git a/config/routes/api_admin.php b/config/routes/api_admin.php index c6fe9471d..75a029482 100644 --- a/config/routes/api_admin.php +++ b/config/routes/api_admin.php @@ -188,6 +188,17 @@ return static function (RouteCollectorProxy $group) { Controller\Api\Admin\Stations\StorageLocationsAction::class )->setName('api:admin:stations:storage-locations') ->add(new Middleware\Permissions(GlobalPermissions::Stations)); + + $group->group( + '', + function (RouteCollectorProxy $group) { + $group->get('/logs', Controller\Api\Admin\LogsAction::class) + ->setName('api:admin:logs'); + + $group->get('/log/{log}', Controller\Api\Admin\LogsAction::class) + ->setName('api:admin:log'); + } + )->add(new Middleware\Permissions(GlobalPermissions::Logs)); } ); }; diff --git a/config/routes/api_station.php b/config/routes/api_station.php index 61d16a79b..a8ac5efa7 100644 --- a/config/routes/api_station.php +++ b/config/routes/api_station.php @@ -640,6 +640,17 @@ return static function (RouteCollectorProxy $group) { )->setName('api:stations:webhook:test-log'); } )->add(new Middleware\Permissions(StationPermissions::WebHooks, true)); + + $group->group( + '', + function (RouteCollectorProxy $group) { + $group->get('/logs', Controller\Api\Stations\LogsAction::class) + ->setName('api:stations:logs'); + + $group->get('/log/{log}', Controller\Api\Stations\LogsAction::class) + ->setName('api:stations:log'); + } + )->add(new Middleware\Permissions(StationPermissions::Logs, true)); } )->add(Middleware\RequireStation::class) ->add(Middleware\GetStation::class); diff --git a/config/routes/stations.php b/config/routes/stations.php index 89bc45a36..27a1f1a5d 100644 --- a/config/routes/stations.php +++ b/config/routes/stations.php @@ -44,16 +44,9 @@ return static function (RouteCollectorProxy $app) { ->setName('stations:stereo_tool_config') ->add(new Middleware\Permissions(StationPermissions::Broadcasting, true)); - $group->group( - '/logs', - function (RouteCollectorProxy $group) { - $group->get('', Controller\Stations\LogsController::class) - ->setName('stations:logs:index'); - - $group->get('/view/{log}', Controller\Stations\LogsController::class . ':viewAction') - ->setName('stations:logs:view'); - } - )->add(new Middleware\Permissions(StationPermissions::Logs, true)); + $group->get('/help', Controller\Stations\HelpAction::class) + ->setName('stations:help') + ->add(new Middleware\Permissions(StationPermissions::Logs, true)); $group->get('/playlists', Controller\Stations\PlaylistsAction::class) ->setName('stations:playlists:index') diff --git a/frontend/vue/components/Admin/Logs.vue b/frontend/vue/components/Admin/Logs.vue new file mode 100644 index 000000000..8a3508231 --- /dev/null +++ b/frontend/vue/components/Admin/Logs.vue @@ -0,0 +1,48 @@ + + + diff --git a/frontend/vue/components/Admin/Logs/StationLogs.vue b/frontend/vue/components/Admin/Logs/StationLogs.vue new file mode 100644 index 000000000..00d686027 --- /dev/null +++ b/frontend/vue/components/Admin/Logs/StationLogs.vue @@ -0,0 +1,3 @@ + diff --git a/frontend/vue/components/Common/LogList.vue b/frontend/vue/components/Common/LogList.vue new file mode 100644 index 000000000..7ba9c2cb2 --- /dev/null +++ b/frontend/vue/components/Common/LogList.vue @@ -0,0 +1,43 @@ + + + diff --git a/frontend/vue/components/Common/StreamingLogModal.vue b/frontend/vue/components/Common/StreamingLogModal.vue index f20f639be..0f170d092 100644 --- a/frontend/vue/components/Common/StreamingLogModal.vue +++ b/frontend/vue/components/Common/StreamingLogModal.vue @@ -22,7 +22,7 @@ export default { components: {StreamingLogView}, data() { return { - logUrl: null, + logUrl: null }; }, computed: { diff --git a/frontend/vue/components/Common/StreamingLogView.vue b/frontend/vue/components/Common/StreamingLogView.vue index c75989cf3..f51e9bbdc 100644 --- a/frontend/vue/components/Common/StreamingLogView.vue +++ b/frontend/vue/components/Common/StreamingLogView.vue @@ -1,14 +1,23 @@ diff --git a/frontend/vue/components/Stations/Help.vue b/frontend/vue/components/Stations/Help.vue new file mode 100644 index 000000000..90a65ec34 --- /dev/null +++ b/frontend/vue/components/Stations/Help.vue @@ -0,0 +1,65 @@ + + + diff --git a/frontend/vue/pages/Admin/Logs.js b/frontend/vue/pages/Admin/Logs.js new file mode 100644 index 000000000..517409d2f --- /dev/null +++ b/frontend/vue/pages/Admin/Logs.js @@ -0,0 +1,7 @@ +import initBase from '~/base.js'; + +import '~/vendor/bootstrapVue.js'; + +import AdminLogs from '~/components/Admin/Logs.vue'; + +export default initBase(AdminLogs); diff --git a/frontend/vue/pages/Stations/Help.js b/frontend/vue/pages/Stations/Help.js new file mode 100644 index 000000000..a12db18de --- /dev/null +++ b/frontend/vue/pages/Stations/Help.js @@ -0,0 +1,7 @@ +import initBase from '~/base.js'; + +import '~/vendor/bootstrapVue.js'; + +import Help from '~/components/Stations/Help.vue'; + +export default initBase(Help); diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index e87bcbb76..767d93e7c 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -15,6 +15,7 @@ module.exports = { AdminCustomFields: '~/pages/Admin/CustomFields.js', AdminGeoLite: '~/pages/Admin/GeoLite.js', AdminIndex: '~/pages/Admin/Index.js', + AdminLogs: '~/pages/Admin/Logs.js', AdminPermissions: '~/pages/Admin/Permissions.js', AdminSettings: '~/pages/Admin/Settings.js', AdminShoutcast: '~/pages/Admin/Shoutcast.js', @@ -35,6 +36,7 @@ module.exports = { SetupStation: '~/pages/Setup/Station.js', StationsBulkMedia: '~/pages/Stations/BulkMedia.js', StationsFallback: '~/pages/Stations/Fallback.js', + StationsHelp: '~/pages/Stations/Help.js', StationsHlsStreams: '~/pages/Stations/HlsStreams.js', StationsLiquidsoapConfig: '~/pages/Stations/LiquidsoapConfig.js', StationsMedia: '~/pages/Stations/Media.js', diff --git a/src/Controller/Admin/LogsAction.php b/src/Controller/Admin/LogsAction.php new file mode 100644 index 000000000..b9f028b32 --- /dev/null +++ b/src/Controller/Admin/LogsAction.php @@ -0,0 +1,51 @@ +getRouter(); + + $acl = $request->getAcl(); + $stationLogs = []; + foreach ($this->stationRepo->iterateEnabledStations() as $station) { + if ($acl->isAllowed(StationPermissions::Logs, $station)) { + $stationLogs[] = [ + 'id' => $station->getIdRequired(), + 'name' => $station->getName(), + 'url' => (string)$router->named('api:stations:logs', [ + 'station_id' => $station->getIdRequired(), + ]), + ]; + } + } + + return $request->getView()->renderVuePage( + response: $response, + component: 'Vue_AdminLogs', + id: 'admin-logs', + title: __('System Logs'), + props: [ + 'systemLogsUrl' => (string)$router->fromHere('api:admin:logs'), + 'stationLogs' => $stationLogs, + ], + ); + } +} diff --git a/src/Controller/Admin/LogsController.php b/src/Controller/Api/Admin/LogsAction.php similarity index 55% rename from src/Controller/Admin/LogsController.php rename to src/Controller/Api/Admin/LogsAction.php index a1b47e2c2..3f3e03fa9 100644 --- a/src/Controller/Admin/LogsController.php +++ b/src/Controller/Api/Admin/LogsAction.php @@ -2,47 +2,64 @@ declare(strict_types=1); -namespace App\Controller\Admin; +namespace App\Controller\Api\Admin; -use App\Controller\AbstractLogViewerController; -use App\Entity; +use App\Controller\Api\Traits\HasLogViewer; use App\Environment; use App\Exception; use App\Http\Response; use App\Http\ServerRequest; -use Doctrine\ORM\EntityManagerInterface; use Psr\Http\Message\ResponseInterface; -final class LogsController extends AbstractLogViewerController +final class LogsAction { + use HasLogViewer; + public function __construct( - private readonly EntityManagerInterface $em, private readonly Environment $environment ) { } public function __invoke( ServerRequest $request, - Response $response + Response $response, + ?string $log = null ): ResponseInterface { - $stations = $this->em->getRepository(Entity\Station::class)->findAll(); - $station_logs = []; + $logPaths = $this->getGlobalLogs(); - foreach ($stations as $station) { - /** @var Entity\Station $station */ - $station_logs[$station->getId()] = [ - 'name' => $station->getName(), - 'logs' => $this->getStationLogs($station), - ]; + if (null === $log) { + $router = $request->getRouter(); + return $response->withJson( + [ + 'logs' => array_map( + function (string $key, array $row) use ($router) { + $row['key'] = $key; + $row['links'] = [ + 'self' => (string)$router->named( + 'api:admin:log', + [ + 'log' => $key, + ] + ), + ]; + return $row; + }, + array_keys($logPaths), + array_values($logPaths) + ), + ] + ); } - return $request->getView()->renderToResponse( + if (!isset($logPaths[$log])) { + throw new Exception('Invalid log file specified.'); + } + + return $this->streamLogToResponse( + $request, $response, - 'admin/logs/index', - [ - 'global_logs' => $this->getGlobalLogs(), - 'station_logs' => $station_logs, - ] + $logPaths[$log]['path'], + $logPaths[$log]['tail'] ?? true ); } @@ -85,24 +102,4 @@ final class LogsController extends AbstractLogViewerController return $logPaths; } - - public function viewAction( - ServerRequest $request, - Response $response, - string $station_id, - string $log - ): ResponseInterface { - if ('global' === $station_id) { - $log_areas = $this->getGlobalLogs(); - } else { - $log_areas = $this->getStationLogs($request->getStation()); - } - - if (!isset($log_areas[$log])) { - throw new Exception('Invalid log file specified.'); - } - - $logArea = $log_areas[$log]; - return $this->streamLogToResponse($request, $response, $logArea['path'], $logArea['tail'] ?? true); - } } diff --git a/src/Controller/Api/Stations/LogsAction.php b/src/Controller/Api/Stations/LogsAction.php new file mode 100644 index 000000000..544c1dc5f --- /dev/null +++ b/src/Controller/Api/Stations/LogsAction.php @@ -0,0 +1,136 @@ +getStation(); + + $logPaths = $this->getStationLogs($station); + + if (null === $log) { + $router = $request->getRouter(); + return $response->withJson( + [ + 'logs' => array_map( + function (string $key, array $row) use ($router, $station_id) { + $row['key'] = $key; + $row['links'] = [ + 'self' => (string)$router->named( + 'api:stations:log', + [ + 'station_id' => $station_id, + 'log' => $key, + ] + ), + ]; + return $row; + }, + array_keys($logPaths), + array_values($logPaths) + ), + ] + ); + } + + if (!isset($logPaths[$log])) { + throw new Exception('Invalid log file specified.'); + } + + $frontendConfig = $station->getFrontendConfig(); + $filteredTerms = [ + $station->getAdapterApiKey(), + $frontendConfig->getAdminPassword(), + $frontendConfig->getRelayPassword(), + $frontendConfig->getSourcePassword(), + $frontendConfig->getStreamerPassword(), + ]; + + return $this->streamLogToResponse( + $request, + $response, + $logPaths[$log]['path'], + $logPaths[$log]['tail'] ?? true, + $filteredTerms + ); + } + + private function getStationLogs(Station $station): array + { + $logPaths = []; + $stationConfigDir = $station->getRadioConfigDir(); + + $logPaths['station_nginx'] = [ + 'name' => __('Station Nginx Configuration'), + 'path' => $stationConfigDir . '/nginx.conf', + 'tail' => false, + ]; + + if (BackendAdapters::Liquidsoap === $station->getBackendTypeEnum()) { + $logPaths['liquidsoap_log'] = [ + 'name' => __('Liquidsoap Log'), + 'path' => $stationConfigDir . '/liquidsoap.log', + 'tail' => true, + ]; + $logPaths['liquidsoap_liq'] = [ + 'name' => __('Liquidsoap Configuration'), + 'path' => $stationConfigDir . '/liquidsoap.liq', + 'tail' => false, + ]; + } + + switch ($station->getFrontendTypeEnum()) { + case FrontendAdapters::Icecast: + $logPaths['icecast_access_log'] = [ + 'name' => __('Icecast Access Log'), + 'path' => $stationConfigDir . '/icecast_access.log', + 'tail' => true, + ]; + $logPaths['icecast_error_log'] = [ + 'name' => __('Icecast Error Log'), + 'path' => $stationConfigDir . '/icecast.log', + 'tail' => true, + ]; + $logPaths['icecast_xml'] = [ + 'name' => __('Icecast Configuration'), + 'path' => $stationConfigDir . '/icecast.xml', + 'tail' => false, + ]; + break; + + case FrontendAdapters::Shoutcast: + $logPaths['shoutcast_log'] = [ + 'name' => __('SHOUTcast Log'), + 'path' => $stationConfigDir . '/shoutcast.log', + 'tail' => true, + ]; + $logPaths['shoutcast_conf'] = [ + 'name' => __('SHOUTcast Configuration'), + 'path' => $stationConfigDir . '/sc_serv.conf', + 'tail' => false, + ]; + break; + } + + return $logPaths; + } +} diff --git a/src/Controller/Api/Traits/HasLogViewer.php b/src/Controller/Api/Traits/HasLogViewer.php index 53aec63b3..16c38ed3a 100644 --- a/src/Controller/Api/Traits/HasLogViewer.php +++ b/src/Controller/Api/Traits/HasLogViewer.php @@ -18,7 +18,8 @@ trait HasLogViewer ServerRequest $request, Response $response, string $log_path, - bool $tail_file = true + bool $tail_file = true, + array $filteredTerms = [] ): ResponseInterface { clearstatcache(); @@ -28,7 +29,10 @@ trait HasLogViewer if (!$tail_file) { $log = file_get_contents($log_path) ?: ''; - $log_contents = $this->processLog($request, $log); + $log_contents = $this->processLog( + rawLog: $log, + filteredTerms: $filteredTerms + ); return $response->withJson( [ @@ -66,7 +70,12 @@ trait HasLogViewer $log_contents_raw = fread($fp, $log_visible_size) ?: ''; fclose($fp); - $log_contents = $this->processLog($request, $log_contents_raw, $cut_first_line, true); + $log_contents = $this->processLog( + rawLog: $log_contents_raw, + cutFirstLine: $cut_first_line, + cutEmptyLastLine: true, + filteredTerms: $filteredTerms + ); } return $response->withJson( @@ -78,11 +87,11 @@ trait HasLogViewer ); } - protected function processLog( - ServerRequest $request, + private function processLog( string $rawLog, bool $cutFirstLine = false, - bool $cutEmptyLastLine = false + bool $cutEmptyLastLine = false, + array $filteredTerms = [] ): string { $logParts = explode("\n", $rawLog); @@ -96,6 +105,8 @@ trait HasLogViewer $logParts = str_replace(['>', '<'], ['>', '<'], $logParts); $log = implode("\n", $logParts); - return mb_convert_encoding($log, 'UTF-8', 'UTF-8'); + $log = mb_convert_encoding($log, 'UTF-8', 'UTF-8'); + + return str_replace($filteredTerms, '(PASSWORD)', $log); } } diff --git a/src/Controller/Stations/HelpAction.php b/src/Controller/Stations/HelpAction.php new file mode 100644 index 000000000..43c38b1bd --- /dev/null +++ b/src/Controller/Stations/HelpAction.php @@ -0,0 +1,30 @@ +getRouter(); + + return $request->getView()->renderVuePage( + response: $response, + component: 'Vue_StationsHelp', + id: 'stations-help', + title: __('Help'), + props: [ + 'logsUrl' => (string)$router->fromHere('api:stations:logs'), + ], + ); + } +} diff --git a/src/Controller/Stations/LogsController.php b/src/Controller/Stations/LogsController.php deleted file mode 100644 index 5581bf2b2..000000000 --- a/src/Controller/Stations/LogsController.php +++ /dev/null @@ -1,67 +0,0 @@ -getStation(); - - return $request->getView()->renderToResponse($response, 'stations/logs/index', [ - 'logs' => $this->getStationLogs($station), - ]); - } - - public function viewAction( - ServerRequest $request, - Response $response, - string $station_id, - string $log, - ): ResponseInterface { - $station = $request->getStation(); - $log_areas = $this->getStationLogs($station); - - if (!isset($log_areas[$log])) { - throw new Exception('Invalid log file specified.'); - } - - $logArea = $log_areas[$log]; - return $this->streamLogToResponse($request, $response, $logArea['path'], $logArea['tail'] ?? true); - } - - protected function processLog( - ServerRequest $request, - string $rawLog, - bool $cutFirstLine = false, - bool $cutEmptyLastLine = false - ): string { - $log = parent::processLog($request, $rawLog, $cutFirstLine, $cutEmptyLastLine); - - // Filter out passwords, API keys, etc. - $station = $request->getStation(); - - $frontendConfig = $station->getFrontendConfig(); - - $passwords = [ - $station->getAdapterApiKey(), - $frontendConfig->getAdminPassword(), - $frontendConfig->getRelayPassword(), - $frontendConfig->getSourcePassword(), - $frontendConfig->getStreamerPassword(), - ]; - - return str_replace($passwords, '(PASSWORD)', $log); - } -} diff --git a/templates/admin/logs/index.phtml b/templates/admin/logs/index.phtml deleted file mode 100644 index 55f41132d..000000000 --- a/templates/admin/logs/index.phtml +++ /dev/null @@ -1,72 +0,0 @@ -layout('main', [ - 'title' => __('Log Viewer'), - 'manual' => true, -]); -?> - -
-
-
-
-

-
-
- isDocker()): ?> -

%s to access container logs from the terminal.' - ), - 'docker-compose logs -f (nginx|web|stations|...)' - ) ?>

- -
-
- $log_info): ?> - -
- -
- -
-
- -
-
-

-
-
- -
-
- $station_row): ?> -
- $log_info): ?> - -
- -
- -
- -
-
-
-
- fetch('partials/log_help_card')?> -
-
- -fetch('partials/log_viewer')?> diff --git a/templates/partials/log_help_card.phtml b/templates/partials/log_help_card.phtml deleted file mode 100644 index d4da78416..000000000 --- a/templates/partials/log_help_card.phtml +++ /dev/null @@ -1,24 +0,0 @@ -
-
-

-
-
-

support documents.'), - 'https://docs.azuracast.com/en/user-guide/troubleshooting' - )?>

- -

- -

%s. Be sure to include this when creating a new issue.'), - ($environment->isDocker() ? 'Docker' : 'Ansible') - )?>

-
- -
diff --git a/templates/partials/log_inline.js.phtml b/templates/partials/log_inline.js.phtml deleted file mode 100644 index abd91169b..000000000 --- a/templates/partials/log_inline.js.phtml +++ /dev/null @@ -1,35 +0,0 @@ -$(function () { - var logUrl = $('#log-view').data('url'); - var logContents = $('#log-view-contents'); - var currentLogPosition, timeoutUpdateLog; - - function updateLogView () { - $.getJSON(logUrl, { - position: currentLogPosition - }, function (logData) { - - if (currentLogPosition == 0) { - logContents.text(''); - } - - if (logData.contents != '') { - logContents.append(logData.contents + '\n'); - - // Timeout to allow height to adjust to appended contents. - setTimeout(function () { - logContents.animate({ scrollTop: logContents.prop('scrollHeight') }, 'fast'); - }, 500); - } - - currentLogPosition = logData.position; - - if (!logData.eof) { - timeoutUpdateLog = setTimeout(updateLogView, 15000); - } - }).fail(function (xhr) { - logContents.text('Error: ' + xhr.responseJSON.message); - }); - } - - timeoutUpdateLog = setTimeout(updateLogView, 1000); -}); diff --git a/templates/partials/log_inline.phtml b/templates/partials/log_inline.phtml deleted file mode 100644 index a8a9d6a45..000000000 --- a/templates/partials/log_inline.phtml +++ /dev/null @@ -1,15 +0,0 @@ -load('clipboard') - ->addInlineJs($this->fetch('partials/log_inline.js'), 99); -?> - -
- -
- -
-
diff --git a/templates/partials/log_viewer.js.phtml b/templates/partials/log_viewer.js.phtml deleted file mode 100644 index fb3d1de12..000000000 --- a/templates/partials/log_viewer.js.phtml +++ /dev/null @@ -1,65 +0,0 @@ -$(function() { - var log_modal = $('#modal-log-view'), - log_modal_contents = $('#modal-log-view-contents'); - - var current_log_url, - current_log_position, - timeout_update_log; - - log_modal.modal({ - focus: false, - show: false - }); - - function updateLogView() { - $.getJSON(current_log_url, { - position: current_log_position - }, function(log_data) { - - if (current_log_position == 0) { - log_modal_contents.text(''); - } - - if (log_data.contents != '') { - log_modal_contents.append(log_data.contents+"\n"); - - if (log_modal.find('#modal-log-autoscroll').is(':checked')) { - // Timeout to allow height to adjust to appended contents. - setTimeout(function() { - log_modal_contents.animate({scrollTop: log_modal_contents.prop("scrollHeight")}, "fast"); - }, 500); - } - } - - current_log_position = log_data.position; - - if (!log_data.eof) { - timeout_update_log = setTimeout(updateLogView, 15000); - } - }).fail(function(xhr) { - log_modal_contents.text('Error: '+xhr.responseJSON.message); - }); - } - - log_modal.on('hide.bs.modal', function (event) { - current_log_url = null; - current_log_position = 0; - - clearTimeout(timeout_update_log); - }); - - $('a.log-item').on('click', function(e) { - e.preventDefault(); - - current_log_url = $(this).attr('href'); - current_log_position = 0; - - log_modal.find('.modal-title').text($(this).find('.log-name').text()); - log_modal.find('#modal-log-view-contents').text('Loading...'); - - log_modal.modal('show'); - - updateLogView(); - return false; - }); -}); diff --git a/templates/partials/log_viewer.phtml b/templates/partials/log_viewer.phtml deleted file mode 100644 index a73988b05..000000000 --- a/templates/partials/log_viewer.phtml +++ /dev/null @@ -1,34 +0,0 @@ -load('clipboard') - ->addInlineJs($this->fetch('partials/log_viewer.js'), 99); -?> - - diff --git a/templates/stations/logs/index.phtml b/templates/stations/logs/index.phtml deleted file mode 100644 index c1b6d9d88..000000000 --- a/templates/stations/logs/index.phtml +++ /dev/null @@ -1,29 +0,0 @@ -layout('main', [ - 'title' => __('Log Viewer'), - 'manual' => true -]); -?> - -
-
-
-
-

-
-
- $log_info): ?> - -
- -
- -
-
-
-
- fetch('partials/log_help_card') ?> -
-
- -fetch('partials/log_viewer') ?>