diff --git a/.devcontainer.json b/.devcontainer.json index f89a8023..02d23710 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,18 +1,18 @@ { - "image": "ghcr.io/shopwarelabs/devcontainer/symfony-flex:6.6.8-8.3", - "workspaceFolder": "/var/www/html", - "overrideCommand": false, - "updateRemoteUserUID": false, - "forwardPorts": [8000], - "portsAttributes": { - "8000": { - "label": "Shopware", - "onAutoForward": "notify" - }, - "8080": { - "label": "Administration Watcher", - "onAutoForward": "notify" - } - }, - "onCreateCommand": "install-activate-plugin" + "image": "ghcr.io/shopwarelabs/devcontainer/symfony-flex:6.6.8-8.3", + "workspaceFolder": "/var/www/html", + "overrideCommand": false, + "updateRemoteUserUID": false, + "forwardPorts": [8000], + "portsAttributes": { + "8000": { + "label": "Shopware", + "onAutoForward": "notify" + }, + "8080": { + "label": "Administration Watcher", + "onAutoForward": "notify" + } + }, + "onCreateCommand": "install-activate-plugin" } diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 21821327..3468d690 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -8,10 +8,29 @@ on: jobs: cs: - if: github.event_name != 'schedule' - uses: shopware/github-actions/.github/workflows/cs-fixer.yml@main - phpstan: - uses: shopware/github-actions/.github/workflows/phpstan.yml@main - with: - extensionName: FroshTools - shopwareVersion: v6.6.0.0-rc1 + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Pull verifier + run: docker pull ghcr.io/shopwarelabs/extension-verifier:latest + + - name: Run CS + run: docker run --rm -e GITHUB_STEP_SUMMARY -e GITHUB_ACTIONS -v $GITHUB_STEP_SUMMARY:$GITHUB_STEP_SUMMARY -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest format /ext --dry-run + + check: + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + version-selection: [ 'lowest', 'highest'] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Pull verifier + run: docker pull ghcr.io/shopwarelabs/extension-verifier:latest + + - name: Run Check + run: docker run --rm -e GITHUB_STEP_SUMMARY -e GITHUB_ACTIONS -v $GITHUB_STEP_SUMMARY:$GITHUB_STEP_SUMMARY -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest check /ext --check-against ${{ matrix.version-selection }} diff --git a/composer.json b/composer.json index c9a3dbd7..fa8b269f 100644 --- a/composer.json +++ b/composer.json @@ -1,49 +1,49 @@ { - "name": "frosh/tools", - "version": "2.6.0", - "description": "Provides some basic things for managing the Shopware Installation", - "type": "shopware-platform-plugin", - "license": "MIT", - "autoload": { - "psr-4": { - "Frosh\\Tools\\": "src/" - } - }, - "authors": [ - { - "name": "FriendsOfShopware", - "homepage": "https://friendsofshopware.com" - } - ], - "extra": { - "shopware-plugin-class": "Frosh\\Tools\\FroshTools", - "label": { - "de-DE": "Tools", - "en-GB": "Tools" - }, - "description": { - "de-DE": "Die kostenlose Shopware 6 App beinhaltet mehrere Werkzeuge um den Shop besser zu verwalten. Optimierter Cache Manager, Log Viewer um die Logeinträge zu sehen oder Tasks auszuführen.", - "en-GB": "The free Shopware 6 app include several tools to manage the store much better like a cache manager, log viewer to see the log entries, run the tasks or see the system status." - }, - "manufacturerLink": { - "de-DE": "https://github.com/FriendsOfShopware/FroshTools", - "en-GB": "https://github.com/FriendsOfShopware/FroshTools" - }, - "supportLink": { - "de-DE": "https://github.com/FriendsOfShopware/FroshTools/issues", - "en-GB": "https://github.com/FriendsOfShopware/FroshTools/issues" - } + "name": "frosh/tools", + "version": "2.6.0", + "description": "Provides some basic things for managing the Shopware Installation", + "type": "shopware-platform-plugin", + "license": "MIT", + "autoload": { + "psr-4": { + "Frosh\\Tools\\": "src/" + } + }, + "authors": [ + { + "name": "FriendsOfShopware", + "homepage": "https://friendsofshopware.com" + } + ], + "extra": { + "shopware-plugin-class": "Frosh\\Tools\\FroshTools", + "label": { + "de-DE": "Tools", + "en-GB": "Tools" }, - "require": { - "shopware/core": "~6.6.0" + "description": { + "de-DE": "Die kostenlose Shopware 6 App beinhaltet mehrere Werkzeuge um den Shop besser zu verwalten. Optimierter Cache Manager, Log Viewer um die Logeinträge zu sehen oder Tasks auszuführen.", + "en-GB": "The free Shopware 6 app include several tools to manage the store much better like a cache manager, log viewer to see the log entries, run the tasks or see the system status." }, - "config": { - "allow-plugins": { - "symfony/runtime": true - } + "manufacturerLink": { + "de-DE": "https://github.com/FriendsOfShopware/FroshTools", + "en-GB": "https://github.com/FriendsOfShopware/FroshTools" }, - "scripts": { - "cs-fix": "docker run --rm -v $(pwd):$(pwd) -w $(pwd) oskarstark/php-cs-fixer-ga --rules=@PER-CS2.0,no_unused_imports .", - "phpstan": "docker run --rm -v $(pwd):/app aragon999/phpstan-shopware:v6.6.0 analyse --level max ." + "supportLink": { + "de-DE": "https://github.com/FriendsOfShopware/FroshTools/issues", + "en-GB": "https://github.com/FriendsOfShopware/FroshTools/issues" + } + }, + "require": { + "shopware/core": "~6.6.0" + }, + "config": { + "allow-plugins": { + "symfony/runtime": true } + }, + "scripts": { + "format": "docker run --rm -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest format /ext", + "check": "docker run --rm -v $(pwd):/ext ghcr.io/shopwarelabs/extension-verifier:latest check /ext" + } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aafcb7b4..1ff472c7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,3 @@ parameters: level: 8 paths: - src - type_coverage: - return_type: 100 - param_type: 98 - property_type: 100 diff --git a/qodana.yaml b/qodana.yaml deleted file mode 100644 index ddff5ae7..00000000 --- a/qodana.yaml +++ /dev/null @@ -1,12 +0,0 @@ -version: "1.0" -linter: ghcr.io/shyim/qodana-php:8.2 -bootstrap: composer req shopware/elasticsearch:* -php: - version: "8.2" -include: - - name: VulnerableLibrariesGlobal -plugins: - - id: de.espend.idea.php.annotation - - id: fr.adrienbrault.idea.symfony2plugin - - id: com.kalessil.phpStorm.phpInspectionsEA - diff --git a/src/Command/EnvGetCommand.php b/src/Command/EnvGetCommand.php index 09c733d8..eb6e42dd 100644 --- a/src/Command/EnvGetCommand.php +++ b/src/Command/EnvGetCommand.php @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $var = $file->get($variable); if (!$var instanceof EnvironmentKeyValue) { - throw new \RuntimeException(sprintf('Cannot find variable with name: %s', $variable)); + throw new \RuntimeException(\sprintf('Cannot find variable with name: %s', $variable)); } if ($mode === 'json') { diff --git a/src/Command/EnvListCommand.php b/src/Command/EnvListCommand.php index dcb1b16d..dd0b412f 100644 --- a/src/Command/EnvListCommand.php +++ b/src/Command/EnvListCommand.php @@ -7,4 +7,6 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('frosh:env:list')] -class EnvListCommand extends EnvGetCommand {} +class EnvListCommand extends EnvGetCommand +{ +} diff --git a/src/Components/CacheAdapter.php b/src/Components/CacheAdapter.php index 202ab6d2..8f7cd4e6 100644 --- a/src/Components/CacheAdapter.php +++ b/src/Components/CacheAdapter.php @@ -114,14 +114,14 @@ private function getCacheAdapter(AdapterInterface $adapter): AdapterInterface { if ($adapter instanceof CacheDecorator) { // Do not declare function as static - $func = \Closure::bind(fn() => $adapter->decorated, $adapter, $adapter::class); + $func = \Closure::bind(fn () => $adapter->decorated, $adapter, $adapter::class); return $this->getCacheAdapter($func()); } if ($adapter instanceof TagAwareAdapter || $adapter instanceof TraceableAdapter) { // Do not declare function as static - $func = \Closure::bind(fn() => $adapter->pool, $adapter, $adapter::class); + $func = \Closure::bind(fn () => $adapter->pool, $adapter, $adapter::class); return $this->getCacheAdapter($func()); } @@ -132,10 +132,10 @@ private function getCacheAdapter(AdapterInterface $adapter): AdapterInterface private function getRedis(AdapterInterface $adapter): \Redis { if ($adapter instanceof RedisTagAwareAdapter) { - $redisProxyGetter = \Closure::bind(fn() => $adapter->redis, $adapter, RedisTagAwareAdapter::class); + $redisProxyGetter = \Closure::bind(fn () => $adapter->redis, $adapter, RedisTagAwareAdapter::class); } else { // @phpstan-ignore-next-line - $redisProxyGetter = \Closure::bind(fn() => $adapter->redis, $adapter, RedisAdapter::class); + $redisProxyGetter = \Closure::bind(fn () => $adapter->redis, $adapter, RedisAdapter::class); } return $redisProxyGetter(); @@ -143,14 +143,14 @@ private function getRedis(AdapterInterface $adapter): \Redis private function getPathFromFilesystemAdapter(FilesystemAdapter $adapter): string { - $getter = \Closure::bind(fn() => $adapter->directory, $adapter, $adapter::class); + $getter = \Closure::bind(fn () => $adapter->directory, $adapter, $adapter::class); return $getter(); } private function getPathOfFilesAdapter(PhpFilesAdapter $adapter): string { - $getter = \Closure::bind(fn() => $adapter->directory, $adapter, $adapter::class); + $getter = \Closure::bind(fn () => $adapter->directory, $adapter, $adapter::class); return $getter(); } diff --git a/src/Components/CacheHelper.php b/src/Components/CacheHelper.php index 2cd0133f..120a71b2 100644 --- a/src/Components/CacheHelper.php +++ b/src/Components/CacheHelper.php @@ -31,7 +31,7 @@ public static function removeDir(string $path): void $blankDir = sys_get_temp_dir() . '/' . uniqid() . '/'; if (!mkdir($blankDir, 0o755, true) && !is_dir($blankDir)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $blankDir)); + throw new \RuntimeException(\sprintf('Directory "%s" was not created', $blankDir)); } $process = new Process(['rsync', '-qa', '--delete', $blankDir, $path . '/']); diff --git a/src/Components/CacheRegistry.php b/src/Components/CacheRegistry.php index 5c67fc35..6ec0dd1e 100644 --- a/src/Components/CacheRegistry.php +++ b/src/Components/CacheRegistry.php @@ -27,7 +27,7 @@ public function all(): array public function get(string $name): CacheAdapter { if (!isset($this->adapters[$name])) { - throw new \OutOfBoundsException(sprintf('Cannot find adapter by name %s', $name)); + throw new \OutOfBoundsException(\sprintf('Cannot find adapter by name %s', $name)); } return $this->adapters[$name]; diff --git a/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php b/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php index de8b61da..eb9932c4 100644 --- a/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php +++ b/src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php @@ -14,7 +14,9 @@ public function __construct( #[Autowire(param: 'frosh_tools.elasticsearch.enabled')] private bool $elasticsearchEnabled, - ) {} + ) { + } + public function __invoke(ResponseEvent $event): void { if ($event->getRequest()->attributes->get('_route') !== 'api.info.config') { diff --git a/src/Components/Elasticsearch/DisabledElasticsearchManager.php b/src/Components/Elasticsearch/DisabledElasticsearchManager.php index 6b56ab4d..9d00d8ea 100644 --- a/src/Components/Elasticsearch/DisabledElasticsearchManager.php +++ b/src/Components/Elasticsearch/DisabledElasticsearchManager.php @@ -6,7 +6,9 @@ class DisabledElasticsearchManager extends ElasticsearchManager { - public function __construct() {} + public function __construct() + { + } public function isEnabled(): bool { diff --git a/src/Components/Elasticsearch/ElasticsearchManager.php b/src/Components/Elasticsearch/ElasticsearchManager.php index b0a3e765..9fe0789d 100644 --- a/src/Components/Elasticsearch/ElasticsearchManager.php +++ b/src/Components/Elasticsearch/ElasticsearchManager.php @@ -28,7 +28,8 @@ public function __construct( private readonly Connection $connection, #[Autowire(service: 'shopware.increment.gateway.registry')] private readonly IncrementGatewayRegistry $gatewayRegistry, - ) {} + ) { + } public function isEnabled(): bool { diff --git a/src/Components/Environment/EnvironmentFile.php b/src/Components/Environment/EnvironmentFile.php index 90ee898a..04e7a4f4 100644 --- a/src/Components/Environment/EnvironmentFile.php +++ b/src/Components/Environment/EnvironmentFile.php @@ -9,7 +9,9 @@ class EnvironmentFile implements \Stringable /** * @param list $items */ - public function __construct(private array $items) {} + public function __construct(private array $items) + { + } public function __toString(): string { diff --git a/src/Components/Environment/EnvironmentManager.php b/src/Components/Environment/EnvironmentManager.php index b10dc07c..8923125f 100644 --- a/src/Components/Environment/EnvironmentManager.php +++ b/src/Components/Environment/EnvironmentManager.php @@ -10,7 +10,7 @@ public function read(string $path): EnvironmentFile { $content = file_get_contents($path); if ($content === false) { - throw new \RuntimeException(sprintf('Cannot read file %s', $path)); + throw new \RuntimeException(\sprintf('Cannot read file %s', $path)); } /** @var array $lines */ diff --git a/src/Components/Health/Checker/HealthChecker/DebugChecker.php b/src/Components/Health/Checker/HealthChecker/DebugChecker.php index 49f39da7..fdbcbdd7 100644 --- a/src/Components/Health/Checker/HealthChecker/DebugChecker.php +++ b/src/Components/Health/Checker/HealthChecker/DebugChecker.php @@ -18,7 +18,8 @@ public function __construct( private readonly array $kernelBundles, #[Autowire(param: 'kernel.debug')] private readonly bool $kernelDebug, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/HealthChecker/HealthCheckerInterface.php b/src/Components/Health/Checker/HealthChecker/HealthCheckerInterface.php index 4198e70a..8c1670ec 100644 --- a/src/Components/Health/Checker/HealthChecker/HealthCheckerInterface.php +++ b/src/Components/Health/Checker/HealthChecker/HealthCheckerInterface.php @@ -7,4 +7,6 @@ use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; #[AutoconfigureTag('frosh_tools.health_checker')] -interface HealthCheckerInterface {} +interface HealthCheckerInterface +{ +} diff --git a/src/Components/Health/Checker/HealthChecker/MysqlChecker.php b/src/Components/Health/Checker/HealthChecker/MysqlChecker.php index 4ee105da..715a3e40 100644 --- a/src/Components/Health/Checker/HealthChecker/MysqlChecker.php +++ b/src/Components/Health/Checker/HealthChecker/MysqlChecker.php @@ -11,7 +11,9 @@ class MysqlChecker implements HealthCheckerInterface, CheckerInterface { - public function __construct(private readonly Connection $connection) {} + public function __construct(private readonly Connection $connection) + { + } public function collect(HealthCollection $collection): void { @@ -117,7 +119,7 @@ private static function getVersionNumber(string $versionString): string $versionString, $versionParts, )) { - throw new \RuntimeException(sprintf('Invalid version string: %s', $versionString)); + throw new \RuntimeException(\sprintf('Invalid version string: %s', $versionString)); } return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; diff --git a/src/Components/Health/Checker/HealthChecker/PhpChecker.php b/src/Components/Health/Checker/HealthChecker/PhpChecker.php index 842fe479..44403521 100644 --- a/src/Components/Health/Checker/HealthChecker/PhpChecker.php +++ b/src/Components/Health/Checker/HealthChecker/PhpChecker.php @@ -134,7 +134,7 @@ private function checkPcreJitActive(HealthCollection $collection): void private function parseQuantity(string $val): float { - //TODO: remove condition and own calculation when min php version is 8.2 + // TODO: remove condition and own calculation when min php version is 8.2 if (\function_exists('ini_parse_quantity')) { return (float) \ini_parse_quantity($val); } diff --git a/src/Components/Health/Checker/HealthChecker/ProductionChecker.php b/src/Components/Health/Checker/HealthChecker/ProductionChecker.php index ec53923c..c2118db5 100644 --- a/src/Components/Health/Checker/HealthChecker/ProductionChecker.php +++ b/src/Components/Health/Checker/HealthChecker/ProductionChecker.php @@ -14,7 +14,8 @@ class ProductionChecker implements HealthCheckerInterface, CheckerInterface public function __construct( #[Autowire(param: 'kernel.environment')] private readonly string $environment, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/HealthChecker/QueueChecker.php b/src/Components/Health/Checker/HealthChecker/QueueChecker.php index 93b22aa7..98db7f05 100644 --- a/src/Components/Health/Checker/HealthChecker/QueueChecker.php +++ b/src/Components/Health/Checker/HealthChecker/QueueChecker.php @@ -15,7 +15,8 @@ class QueueChecker implements HealthCheckerInterface, CheckerInterface public function __construct( private readonly Connection $connection, private readonly SystemConfigService $configService, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php b/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php index e502d7ce..af6a4c9f 100644 --- a/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SwagSecurityChecker.php @@ -9,11 +9,11 @@ use Frosh\Tools\Components\Health\HealthCollection; use Frosh\Tools\Components\Health\SettingsResult; use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Contracts\Cache\CacheInterface; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -27,7 +27,8 @@ public function __construct( private readonly CacheInterface $cacheObject, #[Autowire(lazy: true)] private readonly HttpClientInterface $httpClient, - ) {} + ) { + } public function collect(HealthCollection $collection): void { @@ -66,7 +67,7 @@ private function hasSecurityAdvisories(): bool throw new \RuntimeException('Could not fetch security.json'); } - $data = \json_decode(trim($securityJson), true, 512, JSON_THROW_ON_ERROR); + $data = \json_decode(trim($securityJson), true, 512, \JSON_THROW_ON_ERROR); if (!\is_array($data)) { throw new \RuntimeException('Could not read security.json'); @@ -123,7 +124,6 @@ private function determineSecurityIssue(HealthCollection $collection): void private function determineEolSupport(HealthCollection $collection): void { - $id = 'security-eol-shopware'; $snippet = 'Security updates'; @@ -222,7 +222,7 @@ private function getReleasesSupport(): array throw new \RuntimeException('Could not fetch releases.json'); } - $data = \json_decode(trim($releasesJson), true, 512, JSON_THROW_ON_ERROR); + $data = \json_decode(trim($releasesJson), true, 512, \JSON_THROW_ON_ERROR); if (!\is_array($data)) { throw new \RuntimeException('Could not read releases.json'); @@ -238,11 +238,11 @@ private function getReleasesSupport(): array } if (!empty($entry['extended_eol']) - && version_compare($entry['version'], ($result['extended_eol_version'] ?? ''), '>')) { + && version_compare($entry['version'], $result['extended_eol_version'] ?? '', '>')) { $result['extended_eol_version'] = $entry['version']; } - if (version_compare($entry['version'], ($result['version'] ?? ''), '>') + if (version_compare($entry['version'], $result['version'] ?? '', '>') && version_compare($entry['version'], $this->shopwareVersion, '<=')) { $result = [...$result, ...$entry]; } diff --git a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php index c7b6ff2b..befa0905 100644 --- a/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php +++ b/src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php @@ -15,7 +15,8 @@ class SystemInfoChecker implements HealthCheckerInterface, CheckerInterface public function __construct( #[Autowire(param: 'kernel.project_dir')] private readonly string $projectDir, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/HealthChecker/TaskChecker.php b/src/Components/Health/Checker/HealthChecker/TaskChecker.php index 115937ee..85dd0df3 100644 --- a/src/Components/Health/Checker/HealthChecker/TaskChecker.php +++ b/src/Components/Health/Checker/HealthChecker/TaskChecker.php @@ -18,7 +18,8 @@ public function __construct( private readonly Connection $connection, private readonly ParameterBagInterface $parameterBag, private readonly SystemConfigService $configService, - ) {} + ) { + } public function collect(HealthCollection $collection): void { @@ -45,7 +46,7 @@ public function collect(HealthCollection $collection): void $taskDateLimit = (new \DateTimeImmutable())->modify(\sprintf('-%d minutes', $maxDiff)); $recommended = \sprintf('max %d mins', $maxDiff); - $tasks = array_filter($tasks, fn(array $task) => new \DateTimeImmutable($task['next_execution_time']) < $taskDateLimit); + $tasks = array_filter($tasks, fn (array $task) => new \DateTimeImmutable($task['next_execution_time']) < $taskDateLimit); if ($tasks === []) { $collection->add(SettingsResult::ok('scheduled_task', 'Scheduled tasks overdue', '0 mins', $recommended)); diff --git a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php index 6c04201c..a1b43a5f 100644 --- a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php @@ -14,7 +14,8 @@ class AdminWorkerChecker implements PerformanceCheckerInterface, CheckerInterfac public function __construct( #[Autowire(param: 'shopware.admin_worker.enable_admin_worker')] private readonly bool $adminWorkerEnabled, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php index 7da6fb13..b9306913 100644 --- a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php @@ -1,4 +1,4 @@ -add( SettingsResult::error( strtolower($functionality) . '-compression-method-extension-zstd', diff --git a/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php b/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php index b3ccc0b4..422c03fe 100644 --- a/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php @@ -15,7 +15,8 @@ class DisableSymfonySecretsChecker implements PerformanceCheckerInterface, Check public function __construct( #[Autowire(service: 'secrets.vault')] private readonly ?AbstractVault $vault = null, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php b/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php index 85dd9a23..a6f86ce0 100644 --- a/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php @@ -11,7 +11,9 @@ class DisabledMailUpdatesChecker implements PerformanceCheckerInterface, CheckerInterface { - public function __construct(private readonly ParameterBagInterface $params) {} + public function __construct(private readonly ParameterBagInterface $params) + { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php b/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php index 3fb9976f..62d63731 100644 --- a/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php @@ -1,4 +1,4 @@ -connection->fetchOne('SELECT @@group_concat_max_len'); + $groupConcatMaxLen = $this->connection->fetchOne('SELECT @@group_concat_max_len'); if (!$groupConcatMaxLen || (int) $groupConcatMaxLen < self::MYSQL_GROUP_CONCAT_MAX_LEN) { $collection->add( SettingsResult::error( diff --git a/src/Components/Health/Checker/PerformanceChecker/PerformanceCheckerInterface.php b/src/Components/Health/Checker/PerformanceChecker/PerformanceCheckerInterface.php index 99eb8eb2..604d81ac 100644 --- a/src/Components/Health/Checker/PerformanceChecker/PerformanceCheckerInterface.php +++ b/src/Components/Health/Checker/PerformanceChecker/PerformanceCheckerInterface.php @@ -7,4 +7,6 @@ use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; #[AutoconfigureTag('frosh_tools.performance_checker')] -interface PerformanceCheckerInterface {} +interface PerformanceCheckerInterface +{ +} diff --git a/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php b/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php index 43788a46..12e02a87 100644 --- a/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php @@ -14,7 +14,8 @@ class ProductStreamIndexingChecker implements PerformanceCheckerInterface, Check public function __construct( #[Autowire(param: 'shopware.product_stream.indexing')] private readonly bool $productStreamIndexingEnabled, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php index a1414d6a..7482ba91 100644 --- a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php @@ -14,7 +14,8 @@ class QueueConnectionChecker implements PerformanceCheckerInterface, CheckerInte public function __construct( #[Autowire(param: 'frosh_tools.queue_connection')] protected string $connection, - ) {} + ) { + } public function collect(HealthCollection $collection): void { @@ -54,7 +55,7 @@ private function getSchema(): string { $urlSchema = \parse_url($this->connection, \PHP_URL_SCHEME); - if (!is_string($urlSchema)) { + if (!\is_string($urlSchema)) { $urlSchema = explode('://', $this->connection)[0] ?? 'unknown'; } diff --git a/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php b/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php index b76f7393..53208b94 100644 --- a/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php @@ -14,7 +14,8 @@ class RedisTagAwareChecker implements PerformanceCheckerInterface, CheckerInterf { public function __construct( private readonly CacheRegistry $cacheRegistry, - ) {} + ) { + } public function collect(HealthCollection $collection): void { diff --git a/src/Components/LineReader.php b/src/Components/LineReader.php index b0671137..366a5b83 100644 --- a/src/Components/LineReader.php +++ b/src/Components/LineReader.php @@ -13,12 +13,14 @@ final class LineReader /** * Prevent instantiation */ - private function __construct() {} + private function __construct() + { + } /** - * @return \Generator - * * @throws \InvalidArgumentException if $filePath is not readable + * + * @return \Generator */ public static function readLines(string $filePath): \Generator { @@ -30,9 +32,9 @@ public static function readLines(string $filePath): \Generator } /** - * @return \Generator - * * @throws \InvalidArgumentException if $filePath is not readable + * + * @return \Generator */ public static function readLinesBackwards(string $filePath): \Generator { diff --git a/src/Components/SystemConfig/ConfigSystemConfigLoader.php b/src/Components/SystemConfig/ConfigSystemConfigLoader.php index e1363af3..384b4d2a 100644 --- a/src/Components/SystemConfig/ConfigSystemConfigLoader.php +++ b/src/Components/SystemConfig/ConfigSystemConfigLoader.php @@ -1,9 +1,9 @@ -|bool|float|int|string|null>> $config */ - public function __construct(private readonly AbstractSystemConfigLoader $decorated, #[Autowire(param: 'frosh_tools.system_config')] private readonly array $config) {} + public function __construct(private readonly AbstractSystemConfigLoader $decorated, #[Autowire(param: 'frosh_tools.system_config')] private readonly array $config) + { + } public function getDecorated(): AbstractSystemConfigLoader { diff --git a/src/Controller/CacheController.php b/src/Controller/CacheController.php index 3fd0d314..3a740092 100644 --- a/src/Controller/CacheController.php +++ b/src/Controller/CacheController.php @@ -19,7 +19,8 @@ public function __construct( #[Autowire(param: 'kernel.cache_dir')] private readonly string $cacheDir, private readonly CacheRegistry $cacheRegistry, - ) {} + ) { + } #[Route(path: '/cache', name: 'api.frosh.tools.cache.get', methods: ['GET'])] public function cacheStatistics(): JsonResponse diff --git a/src/Controller/ElasticsearchController.php b/src/Controller/ElasticsearchController.php index 20a14e22..92b58d29 100644 --- a/src/Controller/ElasticsearchController.php +++ b/src/Controller/ElasticsearchController.php @@ -14,7 +14,9 @@ #[Route(path: '/api/_action/frosh-tools/elasticsearch', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] class ElasticsearchController extends AbstractController { - public function __construct(private readonly ElasticsearchManager $manager) {} + public function __construct(private readonly ElasticsearchManager $manager) + { + } #[Route(path: '/status', name: 'api.frosh.tools.elasticsearch.status', methods: ['GET'])] public function status(): Response diff --git a/src/Controller/HealthController.php b/src/Controller/HealthController.php index 6ac8c560..b3f641fb 100644 --- a/src/Controller/HealthController.php +++ b/src/Controller/HealthController.php @@ -27,7 +27,8 @@ public function __construct( #[AutowireIterator('frosh_tools.performance_checker')] private readonly iterable $performanceCheckers, private readonly CacheInterface $cacheObject, - ) {} + ) { + } #[Route(path: '/health/status', name: 'api.frosh.tools.health.status', methods: ['GET'])] public function status(): JsonResponse diff --git a/src/Controller/QueueController.php b/src/Controller/QueueController.php index 529b3ddf..18fa4189 100644 --- a/src/Controller/QueueController.php +++ b/src/Controller/QueueController.php @@ -27,7 +27,8 @@ public function __construct( private readonly IncrementGatewayRegistry $incrementer, #[Autowire(service: 'messenger.receiver_locator')] private readonly ServiceLocator $transportLocator, - ) {} + ) { + } #[Route(path: '/queue/list', name: 'api.frosh.tools.queue.list', methods: ['GET'])] public function list(): JsonResponse @@ -35,7 +36,7 @@ public function list(): JsonResponse $incrementer = $this->incrementer->get(IncrementGatewayRegistry::MESSAGE_QUEUE_POOL); $list = $incrementer->list('message_queue_stats', -1); - $queueData = array_map(static fn(array $entry) => [ + $queueData = array_map(static fn (array $entry) => [ 'name' => $entry['key'], 'size' => (int) $entry['count'], ], array_values($list)); @@ -78,7 +79,7 @@ private function getMessengerStats(array &$queueData): void ]; } - usort($queueData, static fn(array $a, array $b) => $b['size'] <=> $a['size']); + usort($queueData, static fn (array $a, array $b) => $b['size'] <=> $a['size']); } /** @@ -88,6 +89,6 @@ private function getTransportNames(): array { $transportNames = array_keys($this->transportLocator->getProvidedServices()); - return array_filter($transportNames, static fn(string $transportName) => str_starts_with($transportName, 'messenger.transport')); + return array_filter($transportNames, static fn (string $transportName) => str_starts_with($transportName, 'messenger.transport')); } } diff --git a/src/Controller/ScheduledTaskController.php b/src/Controller/ScheduledTaskController.php index 46630af0..dcc6d488 100644 --- a/src/Controller/ScheduledTaskController.php +++ b/src/Controller/ScheduledTaskController.php @@ -28,7 +28,8 @@ public function __construct( private readonly EntityRepository $scheduledTaskRepository, private readonly TaskRegistry $taskRegistry, private readonly TaskRunner $taskRunner, - ) {} + ) { + } #[Route(path: '/scheduled-task/{id}', name: 'api.frosh.tools.scheduled.task.run', methods: ['POST'])] public function runTask(string $id, Context $context): JsonResponse diff --git a/src/Controller/ShopwareFilesController.php b/src/Controller/ShopwareFilesController.php index 960cdb6a..48f7d787 100644 --- a/src/Controller/ShopwareFilesController.php +++ b/src/Controller/ShopwareFilesController.php @@ -60,7 +60,7 @@ public function listShopwareFiles(): JsonResponse return new JsonResponse(['error' => 'Git version is not supported']); } - $url = sprintf('https://swagger.docs.fos.gg/version/%s/Files.xxhsums', $this->shopwareVersion); + $url = \sprintf('https://swagger.docs.fos.gg/version/%s/Files.xxhsums', $this->shopwareVersion); $data = $this->httpClient->request('GET', $url)->getContent(false); $data = trim((string) $data); @@ -73,7 +73,7 @@ public function listShopwareFiles(): JsonResponse foreach (explode("\n", $data) as $row) { if ($this->isPlatform) { - $row = preg_replace_callback('/vendor\/shopware\/(.)/', fn($matches): string => 'src/' . strtoupper($matches[1]), $row); + $row = preg_replace_callback('/vendor\/shopware\/(.)/', fn ($matches): string => 'src/' . strtoupper($matches[1]), $row); } [$expectedMd5Sum, $file] = explode(' ', trim((string) $row)); @@ -171,7 +171,7 @@ public function restoreShopwareFile(Request $request, Context $context): JsonRes $userName = $this->getUserName($context) ?? 'unknown'; - $message = sprintf('File at "%s" has been restored by %s', $file, $userName); + $message = \sprintf('File at "%s" has been restored by %s', $file, $userName); $this->froshToolsLogger->info($message); @@ -234,7 +234,7 @@ private function getUserName(Context $context): ?string private function getUserNameByUserId(string $userId): ?string { - /** @var null|UserEntity $userEntity */ + /** @var UserEntity|null $userEntity */ $userEntity = $this->userRepository->search( new Criteria([$userId]), Context::createDefaultContext(), @@ -249,7 +249,7 @@ private function getUserNameByUserId(string $userId): ?string private function getNameByIntegrationId(string $integrationId): ?string { - /** @var null|IntegrationEntity $integrationEntity */ + /** @var IntegrationEntity|null $integrationEntity */ $integrationEntity = $this->integrationRepository->search( new Criteria([$integrationId]), Context::createDefaultContext(), diff --git a/src/Controller/StateMachineController.php b/src/Controller/StateMachineController.php index da907e37..d7b7ac2a 100644 --- a/src/Controller/StateMachineController.php +++ b/src/Controller/StateMachineController.php @@ -11,13 +11,13 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; +use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\System\StateMachine\StateMachineCollection; +use Shopware\Core\System\StateMachine\StateMachineEntity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; -use Shopware\Core\Framework\Uuid\Uuid; -use Shopware\Core\System\StateMachine\StateMachineEntity; #[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] final class StateMachineController extends AbstractController @@ -25,7 +25,9 @@ final class StateMachineController extends AbstractController /** * @param EntityRepository $stateMachineRepository */ - public function __construct(private readonly EntityRepository $stateMachineRepository) {} + public function __construct(private readonly EntityRepository $stateMachineRepository) + { + } #[Route(path: '/state-machines/load/{stateMachineId}', name: 'api.frosh.tools.state-machines.load', methods: ['GET'])] public function load(string $stateMachineId, Context $context): JsonResponse diff --git a/src/Resources/app/administration/src/api/elasticsearch.js b/src/Resources/app/administration/src/api/elasticsearch.js index b3839ee8..8bb0de5e 100644 --- a/src/Resources/app/administration/src/api/elasticsearch.js +++ b/src/Resources/app/administration/src/api/elasticsearch.js @@ -1,127 +1,138 @@ const { ApiService } = Shopware.Classes; class Elasticsearch extends ApiService { - constructor(httpClient, loginService, apiEndpoint = '_action/frosh-tools/elasticsearch') { - super(httpClient, loginService, apiEndpoint); - } + constructor( + httpClient, + loginService, + apiEndpoint = '_action/frosh-tools/elasticsearch', + ) { + super(httpClient, loginService, apiEndpoint); + } - status() { - const apiRoute = `${this.getApiBasePath()}/status`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + status() { + const apiRoute = `${this.getApiBasePath()}/status`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - indices() { - const apiRoute = `${this.getApiBasePath()}/indices`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + indices() { + const apiRoute = `${this.getApiBasePath()}/indices`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - deleteIndex(indexName) { - const apiRoute = `${this.getApiBasePath()}/index/` + indexName; - return this.httpClient.delete( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + deleteIndex(indexName) { + const apiRoute = `${this.getApiBasePath()}/index/` + indexName; + return this.httpClient + .delete(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - console(method, path, payload) { - const apiRoute = `${this.getApiBasePath()}/console` + path; - return this.httpClient.request( - { - url: apiRoute, - method: method, - headers: { - ...this.getBasicHeaders(), - 'content-type': 'application/json', - }, - data: payload, - }, - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + console(method, path, payload) { + const apiRoute = `${this.getApiBasePath()}/console` + path; + return this.httpClient + .request({ + url: apiRoute, + method: method, + headers: { + ...this.getBasicHeaders(), + 'content-type': 'application/json', + }, + data: payload, + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - flushAll() { - const apiRoute = `${this.getApiBasePath()}/flush_all`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + flushAll() { + const apiRoute = `${this.getApiBasePath()}/flush_all`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - reindex() { - const apiRoute = `${this.getApiBasePath()}/reindex`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + reindex() { + const apiRoute = `${this.getApiBasePath()}/reindex`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - switchAlias() { - const apiRoute = `${this.getApiBasePath()}/switch_alias`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + switchAlias() { + const apiRoute = `${this.getApiBasePath()}/switch_alias`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - cleanup() { - const apiRoute = `${this.getApiBasePath()}/cleanup`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + cleanup() { + const apiRoute = `${this.getApiBasePath()}/cleanup`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } - reset() { - const apiRoute = `${this.getApiBasePath()}/reset`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + reset() { + const apiRoute = `${this.getApiBasePath()}/reset`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } } export default Elasticsearch; diff --git a/src/Resources/app/administration/src/api/frosh-tools.js b/src/Resources/app/administration/src/api/frosh-tools.js index e81b7ccb..e0e2c491 100644 --- a/src/Resources/app/administration/src/api/frosh-tools.js +++ b/src/Resources/app/administration/src/api/frosh-tools.js @@ -1,214 +1,208 @@ const { ApiService } = Shopware.Classes; class FroshTools extends ApiService { - constructor(httpClient, loginService, apiEndpoint = '_action/frosh-tools') { - super(httpClient, loginService, apiEndpoint); - } - - getCacheInfo() { - const apiRoute = `${this.getApiBasePath()}/cache`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - clearCache(folder) { - const apiRoute = `${this.getApiBasePath()}/cache/${folder}`; - return this.httpClient.delete( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - getQueue() { - const apiRoute = `${this.getApiBasePath()}/queue/list`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - resetQueue() { - const apiRoute = `${this.getApiBasePath()}/queue`; - return this.httpClient.delete( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - runScheduledTask(id) { - const apiRoute = `${this.getApiBasePath()}/scheduled-task/${id}`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - scheduleScheduledTask(id, immediately = false) { - const apiRoute = `${this.getApiBasePath()}/scheduled-task/schedule/${id}`; - return this.httpClient.post( - apiRoute, - { - 'immediately': immediately - }, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - scheduledTasksRegister() { - const apiRoute = `${this.getApiBasePath()}/scheduled-tasks/register`; - return this.httpClient.post( - apiRoute, - {}, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - healthStatus(cached = false) { - if (!this.loginService.isLoggedIn()) { - return; - } - - let apiRoute = `${this.getApiBasePath()}/health/status`; - - if (cached) { - apiRoute = `${this.getApiBasePath()}/health-ping/status`; - } - - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - performanceStatus() { - const apiRoute = `${this.getApiBasePath()}/performance/status`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - getLogFiles() { - const apiRoute = `${this.getApiBasePath()}/logs/files`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } - - getLogFile(file, offset = 0, limit = 20) { - const apiRoute = `${this.getApiBasePath()}/logs/file`; - return this.httpClient.get( - apiRoute, - { - params: { - file, - offset, - limit - }, - headers: this.getBasicHeaders() - } - ).then((response) => { - return response; - }); - } - - getShopwareFiles() { - const apiRoute = `${this.getApiBasePath()}/shopware-files`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return response; - }); - } - - getFileContents(file) { - const apiRoute = `${this.getApiBasePath()}/file-contents`; - return this.httpClient.get( - apiRoute, - { - params: { - file, - }, - headers: this.getBasicHeaders() - } - ).then((response) => { - return response; - }); - } - - restoreShopwareFile(file) { - const apiRoute = `${this.getApiBasePath()}/shopware-file/restore`; - return this.httpClient.get( - apiRoute, - { - params: { - file, - }, - headers: this.getBasicHeaders() - } - ).then((response) => { - return response; - }); - } - - stateMachines(id) { - const apiRoute = `${this.getApiBasePath()}/state-machines/load/${id}`; - return this.httpClient.get( - apiRoute, - { - headers: this.getBasicHeaders() - } - ).then((response) => { - return ApiService.handleResponse(response); - }); - } + constructor(httpClient, loginService, apiEndpoint = '_action/frosh-tools') { + super(httpClient, loginService, apiEndpoint); + } + + getCacheInfo() { + const apiRoute = `${this.getApiBasePath()}/cache`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + clearCache(folder) { + const apiRoute = `${this.getApiBasePath()}/cache/${folder}`; + return this.httpClient + .delete(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + getQueue() { + const apiRoute = `${this.getApiBasePath()}/queue/list`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + resetQueue() { + const apiRoute = `${this.getApiBasePath()}/queue`; + return this.httpClient + .delete(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + runScheduledTask(id) { + const apiRoute = `${this.getApiBasePath()}/scheduled-task/${id}`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + scheduleScheduledTask(id, immediately = false) { + const apiRoute = `${this.getApiBasePath()}/scheduled-task/schedule/${id}`; + return this.httpClient + .post( + apiRoute, + { + immediately: immediately, + }, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + scheduledTasksRegister() { + const apiRoute = `${this.getApiBasePath()}/scheduled-tasks/register`; + return this.httpClient + .post( + apiRoute, + {}, + { + headers: this.getBasicHeaders(), + }, + ) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + healthStatus(cached = false) { + if (!this.loginService.isLoggedIn()) { + return; + } + + let apiRoute = `${this.getApiBasePath()}/health/status`; + + if (cached) { + apiRoute = `${this.getApiBasePath()}/health-ping/status`; + } + + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + performanceStatus() { + const apiRoute = `${this.getApiBasePath()}/performance/status`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + getLogFiles() { + const apiRoute = `${this.getApiBasePath()}/logs/files`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } + + getLogFile(file, offset = 0, limit = 20) { + const apiRoute = `${this.getApiBasePath()}/logs/file`; + return this.httpClient + .get(apiRoute, { + params: { + file, + offset, + limit, + }, + headers: this.getBasicHeaders(), + }) + .then((response) => { + return response; + }); + } + + getShopwareFiles() { + const apiRoute = `${this.getApiBasePath()}/shopware-files`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return response; + }); + } + + getFileContents(file) { + const apiRoute = `${this.getApiBasePath()}/file-contents`; + return this.httpClient + .get(apiRoute, { + params: { + file, + }, + headers: this.getBasicHeaders(), + }) + .then((response) => { + return response; + }); + } + + restoreShopwareFile(file) { + const apiRoute = `${this.getApiBasePath()}/shopware-file/restore`; + return this.httpClient + .get(apiRoute, { + params: { + file, + }, + headers: this.getBasicHeaders(), + }) + .then((response) => { + return response; + }); + } + + stateMachines(id) { + const apiRoute = `${this.getApiBasePath()}/state-machines/load/${id}`; + return this.httpClient + .get(apiRoute, { + headers: this.getBasicHeaders(), + }) + .then((response) => { + return ApiService.handleResponse(response); + }); + } } export default FroshTools; diff --git a/src/Resources/app/administration/src/api/index.js b/src/Resources/app/administration/src/api/index.js index b59e2812..579e8d11 100644 --- a/src/Resources/app/administration/src/api/index.js +++ b/src/Resources/app/administration/src/api/index.js @@ -1,16 +1,19 @@ -import FroshToolsService from "./frosh-tools"; -import Elasticsearch from "./elasticsearch"; +import FroshToolsService from './frosh-tools'; +import Elasticsearch from './elasticsearch'; const { Application } = Shopware; Application.addServiceProvider('froshToolsService', (container) => { - const initContainer = Application.getContainer('init'); + const initContainer = Application.getContainer('init'); - return new FroshToolsService(initContainer.httpClient, container.loginService); + return new FroshToolsService( + initContainer.httpClient, + container.loginService, + ); }); Application.addServiceProvider('froshElasticSearch', (container) => { - const initContainer = Application.getContainer('init'); + const initContainer = Application.getContainer('init'); - return new Elasticsearch(initContainer.httpClient, container.loginService); + return new Elasticsearch(initContainer.httpClient, container.loginService); }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/acl/index.js b/src/Resources/app/administration/src/module/frosh-tools/acl/index.js index db0cb7a2..330d2b37 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/acl/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/acl/index.js @@ -1,14 +1,11 @@ -Shopware.Service('privileges') - .addPrivilegeMappingEntry({ - category: 'additional_permissions', - parent: null, - key: 'frosh_tools', - roles: { - frosh_tools: { - privileges: [ - 'frosh_tools:read', - ], - dependencies: [], - }, - }, - }); +Shopware.Service('privileges').addPrivilegeMappingEntry({ + category: 'additional_permissions', + parent: null, + key: 'frosh_tools', + roles: { + frosh_tools: { + privileges: ['frosh_tools:read'], + dependencies: [], + }, + }, +}); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/index.js index 222b9ce9..db26a883 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/index.js @@ -5,104 +5,106 @@ const { Component, Mixin } = Shopware; const { Criteria } = Shopware.Data; Component.register('frosh-tools-tab-cache', { - template, - - inject: ['froshToolsService', 'repositoryFactory', 'themeService'], - mixins: [ - Mixin.getByName('notification') - ], - - data() { - return { - cacheInfo: null, - isLoading: true, - numberFormater: null - } - }, - - created() { - const language = Shopware.Application.getContainer('factory').locale.getLastKnownLocale(); - this.numberFormater = new Intl.NumberFormat( - language, - { minimumFractionDigits: 2, maximumFractionDigits: 2 } - ); - - this.createdComponent(); - }, - - computed: { - columns() { - return [ - { - property: 'name', - label: 'frosh-tools.name', - rawData: true - }, - { - property: 'size', - label: 'frosh-tools.used', - rawData: true, - align: 'right' - }, - { - property: 'freeSpace', - label: 'frosh-tools.free', - rawData: true, - align: 'right' - } - ]; + template, + + inject: ['froshToolsService', 'repositoryFactory', 'themeService'], + mixins: [Mixin.getByName('notification')], + + data() { + return { + cacheInfo: null, + isLoading: true, + numberFormater: null, + }; + }, + + created() { + const language = + Shopware.Application.getContainer('factory').locale.getLastKnownLocale(); + this.numberFormater = new Intl.NumberFormat(language, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }); + + this.createdComponent(); + }, + + computed: { + columns() { + return [ + { + property: 'name', + label: 'frosh-tools.name', + rawData: true, }, - cacheFolders() { - if (this.cacheInfo === null) { - return []; - } - - return this.cacheInfo; + { + property: 'size', + label: 'frosh-tools.used', + rawData: true, + align: 'right', + }, + { + property: 'freeSpace', + label: 'frosh-tools.free', + rawData: true, + align: 'right', }, + ]; + }, + cacheFolders() { + if (this.cacheInfo === null) { + return []; + } - salesChannelRepository() { - return this.repositoryFactory.create('sales_channel'); - } + return this.cacheInfo; }, - methods: { - async createdComponent() { - this.isLoading = true; - this.cacheInfo = await this.froshToolsService.getCacheInfo(); - this.isLoading = false; - }, + salesChannelRepository() { + return this.repositoryFactory.create('sales_channel'); + }, + }, - formatSize(bytes) { - const formatted = bytes / (1024 * 1024); + methods: { + async createdComponent() { + this.isLoading = true; + this.cacheInfo = await this.froshToolsService.getCacheInfo(); + this.isLoading = false; + }, - return this.numberFormater.format(formatted) + ' MiB'; - }, + formatSize(bytes) { + const formatted = bytes / (1024 * 1024); - async clearCache(item) { - this.isLoading = true; - await this.froshToolsService.clearCache(item.name); - await this.createdComponent(); - }, + return this.numberFormater.format(formatted) + ' MiB'; + }, - async compileTheme() { - const criteria = new Criteria(); - criteria.addAssociation('themes'); - this.isLoading = true; + async clearCache(item) { + this.isLoading = true; + await this.froshToolsService.clearCache(item.name); + await this.createdComponent(); + }, - let salesChannels = await this.salesChannelRepository.search(criteria, Shopware.Context.api); + async compileTheme() { + const criteria = new Criteria(); + criteria.addAssociation('themes'); + this.isLoading = true; - for (let salesChannel of salesChannels) { - const theme = salesChannel.extensions.themes.first(); + let salesChannels = await this.salesChannelRepository.search( + criteria, + Shopware.Context.api, + ); - if (theme) { - await this.themeService.assignTheme(theme.id, salesChannel.id); - this.createNotificationSuccess({ - message: `${salesChannel.translated.name}: ${this.$tc('frosh-tools.themeCompiled')}` - }) - } - } + for (let salesChannel of salesChannels) { + const theme = salesChannel.extensions.themes.first(); - this.isLoading = false; + if (theme) { + await this.themeService.assignTheme(theme.id, salesChannel.id); + this.createNotificationSuccess({ + message: `${salesChannel.translated.name}: ${this.$tc('frosh-tools.themeCompiled')}`, + }); } - } + } + + this.isLoading = false; + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-elasticsearch/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-elasticsearch/index.js index e5ffe43e..f4daa9af 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-elasticsearch/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-elasticsearch/index.js @@ -3,163 +3,165 @@ import template from './template.twig'; const { Mixin, Component } = Shopware; Component.register('frosh-tools-tab-elasticsearch', { - template, - - inject: ['froshElasticSearch'], - mixins: [ - Mixin.getByName('notification') - ], - - data() { - return { - isLoading: true, - isActive: true, - statusInfo: {}, - indices: [], - consoleInput: 'GET /_cat/indices', - consoleOutput: {}, - }; + template, + + inject: ['froshElasticSearch'], + mixins: [Mixin.getByName('notification')], + + data() { + return { + isLoading: true, + isActive: true, + statusInfo: {}, + indices: [], + consoleInput: 'GET /_cat/indices', + consoleOutput: {}, + }; + }, + + computed: { + columns() { + return [ + { + property: 'name', + label: 'frosh-tools.name', + rawData: true, + primary: true, + }, + { + property: 'indexSize', + label: 'frosh-tools.size', + rawData: true, + primary: true, + }, + { + property: 'docs', + label: 'frosh-tools.docs', + rawData: true, + primary: true, + }, + ]; }, + }, - computed: { - columns() { - return [ - { - property: 'name', - label: 'frosh-tools.name', - rawData: true, - primary: true - }, - { - property: 'indexSize', - label: 'frosh-tools.size', - rawData: true, - primary: true - }, - { - property: 'docs', - label: 'frosh-tools.docs', - rawData: true, - primary: true - } - ]; - } - }, + created() { + this.createdComponent(); + }, - created() { - this.createdComponent(); - }, + methods: { + async createdComponent() { + this.isLoading = true; - methods: { - async createdComponent() { - this.isLoading = true; + try { + this.statusInfo = await this.froshElasticSearch.status(); + } catch (err) { + this.isActive = false; + this.isLoading = false; - try { - this.statusInfo = await this.froshElasticSearch.status(); - } catch (err) { - this.isActive = false; - this.isLoading = false; + console.error(err); - return; - } finally { - this.isLoading = false; - } + return; + } finally { + this.isLoading = false; + } - this.indices = await this.froshElasticSearch.indices(); - }, + this.indices = await this.froshElasticSearch.indices(); + }, - formatSize(bytes) { - const thresh = 1024; - const dp = 1; - let formatted = bytes + formatSize(bytes) { + const thresh = 1024; + const dp = 1; + let formatted = bytes; - if (Math.abs(bytes) < thresh) { - return bytes + ' B'; - } + if (Math.abs(bytes) < thresh) { + return bytes + ' B'; + } - const units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; - let index = -1; - const reach = 10**dp; + const units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; + let index = -1; + const reach = 10 ** dp; - do { - formatted /= thresh; - ++index; - } while (Math.round(Math.abs(formatted) * reach) / reach >= thresh && index < units.length - 1); + do { + formatted /= thresh; + ++index; + } while ( + Math.round(Math.abs(formatted) * reach) / reach >= thresh && + index < units.length - 1 + ); - return formatted.toFixed(dp) + ' ' + units[index]; - }, + return formatted.toFixed(dp) + ' ' + units[index]; + }, - async deleteIndex(indexName) { - await this.froshElasticSearch.deleteIndex(indexName); - await this.createdComponent(); - }, + async deleteIndex(indexName) { + await this.froshElasticSearch.deleteIndex(indexName); + await this.createdComponent(); + }, - async onConsoleEnter() { - const lines = this.consoleInput.split("\n") - const requestLine = lines.shift(); - const payload = lines.join("\n").trim(); - const [method, uri] = requestLine.split(" "); - - try { - this.consoleOutput = await this.froshElasticSearch.console(method, uri, payload); - } catch (e) { - this.consoleOutput = e.response.data - } - }, + async onConsoleEnter() { + const lines = this.consoleInput.split('\n'); + const requestLine = lines.shift(); + const payload = lines.join('\n').trim(); + const [method, uri] = requestLine.split(' '); + + try { + this.consoleOutput = await this.froshElasticSearch.console( + method, + uri, + payload, + ); + } catch (e) { + this.consoleOutput = e.response.data; + } + }, - async reindex() { - await this.froshElasticSearch.reindex(); + async reindex() { + await this.froshElasticSearch.reindex(); - this.createNotificationSuccess({ - message: this.$tc('global.default.success') - } - ); + this.createNotificationSuccess({ + message: this.$tc('global.default.success'), + }); - await this.createdComponent() - }, + await this.createdComponent(); + }, - async switchAlias() { - await this.froshElasticSearch.switchAlias(); + async switchAlias() { + await this.froshElasticSearch.switchAlias(); - this.createNotificationSuccess({ - message: this.$tc('global.default.success') - } - ); + this.createNotificationSuccess({ + message: this.$tc('global.default.success'), + }); - await this.createdComponent() - }, + await this.createdComponent(); + }, - async flushAll() { - await this.froshElasticSearch.flushAll(); + async flushAll() { + await this.froshElasticSearch.flushAll(); - this.createNotificationSuccess({ - message: this.$tc('global.default.success') - } - ); + this.createNotificationSuccess({ + message: this.$tc('global.default.success'), + }); - await this.createdComponent() - }, + await this.createdComponent(); + }, - async resetElasticsearch() { - await this.froshElasticSearch.reset(); + async resetElasticsearch() { + await this.froshElasticSearch.reset(); - this.createNotificationSuccess({ - message: this.$tc('global.default.success') - } - ); + this.createNotificationSuccess({ + message: this.$tc('global.default.success'), + }); - await this.createdComponent() - }, + await this.createdComponent(); + }, - async cleanup() { - await this.froshElasticSearch.cleanup(); + async cleanup() { + await this.froshElasticSearch.cleanup(); - this.createNotificationSuccess({ - message: this.$tc('global.default.success') - } - ); + this.createNotificationSuccess({ + message: this.$tc('global.default.success'), + }); - await this.createdComponent() - } - } -}) + await this.createdComponent(); + }, + }, +}); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/index.js index c3260d5e..5e0c0f7c 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-files/index.js @@ -1,111 +1,118 @@ import template from './template.twig'; -import DiffMatchPatch from "diff-match-patch"; +import DiffMatchPatch from 'diff-match-patch'; const { Component, Mixin } = Shopware; Component.register('frosh-tools-tab-files', { - template, - inject: ['repositoryFactory', 'froshToolsService'], - mixins: [ - Mixin.getByName('notification') - ], - - data() { - return { - items: {}, - isLoading: true, - diffData: { - html: '', - file: '' - }, - showModal: false, - }; - }, - - created() { - this.createdComponent(); - }, - - computed: { - columns() { - return [ - { - property: 'name', - label: 'frosh-tools.name', - rawData: true, - primary: true - }, - { - property: 'expected', - label: 'frosh-tools.status', - rawData: true, - primary: true - } - ]; + template, + inject: ['repositoryFactory', 'froshToolsService'], + mixins: [Mixin.getByName('notification')], + + data() { + return { + items: {}, + isLoading: true, + diffData: { + html: '', + file: '', + }, + showModal: false, + }; + }, + + created() { + this.createdComponent(); + }, + + computed: { + columns() { + return [ + { + property: 'name', + label: 'frosh-tools.name', + rawData: true, + primary: true, }, - - isLoadingClass() { - return { - 'is-loading': this.isLoading - } + { + property: 'expected', + label: 'frosh-tools.status', + rawData: true, + primary: true, }, + ]; }, - methods: { - async refresh() { - this.isLoading = true; - await this.createdComponent(); - }, - - async createdComponent() { - this.items = (await this.froshToolsService.getShopwareFiles()).data; - this.isLoading = false; - }, + isLoadingClass() { + return { + 'is-loading': this.isLoading, + }; + }, + }, - openUrl(url) { - window.open(url, '_blank'); - }, + methods: { + async refresh() { + this.isLoading = true; + await this.createdComponent(); + }, - async diff(file) { - this.isLoading = true; - const fileContents = (await this.froshToolsService.getFileContents(file.name)).data; + async createdComponent() { + this.items = (await this.froshToolsService.getShopwareFiles()).data; + this.isLoading = false; + }, - const dmp = new DiffMatchPatch(); - const diff = dmp.diff_main(fileContents.originalContent, fileContents.content); - dmp.diff_cleanupSemantic(diff); - this.diffData.html = dmp.diff_prettyHtml(diff) - .replace(new RegExp('background:#e6ffe6;', 'g'), 'background:#ABF2BC;') - .replace(new RegExp('background:#ffe6e6;', 'g'), 'background:rgba(255,129,130,0.4);'); - this.diffData.file = file; + openUrl(url) { + window.open(url, '_blank'); + }, - this.openModal(); - this.isLoading = false; - }, + async diff(file) { + this.isLoading = true; + const fileContents = ( + await this.froshToolsService.getFileContents(file.name) + ).data; + + const dmp = new DiffMatchPatch(); + const diff = dmp.diff_main( + fileContents.originalContent, + fileContents.content, + ); + dmp.diff_cleanupSemantic(diff); + this.diffData.html = dmp + .diff_prettyHtml(diff) + .replace(new RegExp('background:#e6ffe6;', 'g'), 'background:#ABF2BC;') + .replace( + new RegExp('background:#ffe6e6;', 'g'), + 'background:rgba(255,129,130,0.4);', + ); + this.diffData.file = file; + + this.openModal(); + this.isLoading = false; + }, - async restoreFile(name) { - this.closeModal(); - this.isLoading = true; - const response = await this.froshToolsService.restoreShopwareFile(name); - - if (response.data.status) { - this.createNotificationSuccess({ - message: response.data.status - }) - } else { - this.createNotificationError({ - message: response.data.error - }) - } - - await this.refresh(); - }, + async restoreFile(name) { + this.closeModal(); + this.isLoading = true; + const response = await this.froshToolsService.restoreShopwareFile(name); + + if (response.data.status) { + this.createNotificationSuccess({ + message: response.data.status, + }); + } else { + this.createNotificationError({ + message: response.data.error, + }); + } + + await this.refresh(); + }, - openModal() { - this.showModal = true; - }, + openModal() { + this.showModal = true; + }, - closeModal() { - this.showModal = false; - }, - } + closeModal() { + this.showModal = false; + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js index 12555b97..13eec035 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js @@ -4,53 +4,53 @@ import './style.scss'; const { Component } = Shopware; Component.register('frosh-tools-tab-index', { - inject: ['froshToolsService'], - template, + inject: ['froshToolsService'], + template, - data() { - return { - isLoading: true, - health: null, - performanceStatus: null, - } - }, + data() { + return { + isLoading: true, + health: null, + performanceStatus: null, + }; + }, - created() { - this.createdComponent(); - }, + created() { + this.createdComponent(); + }, - computed: { - columns() { - return [ - { - property: 'name', - label: 'frosh-tools.name', - rawData: true - }, - { - property: 'current', - label: 'frosh-tools.current', - rawData: true - }, - { - property: 'recommended', - label: 'frosh-tools.recommended', - rawData: true - } - ]; + computed: { + columns() { + return [ + { + property: 'name', + label: 'frosh-tools.name', + rawData: true, + }, + { + property: 'current', + label: 'frosh-tools.current', + rawData: true, + }, + { + property: 'recommended', + label: 'frosh-tools.recommended', + rawData: true, }, + ]; }, + }, - methods: { - async refresh() { - this.isLoading = true; - await this.createdComponent(); - }, + methods: { + async refresh() { + this.isLoading = true; + await this.createdComponent(); + }, - async createdComponent() { - this.health = await this.froshToolsService.healthStatus(); - this.performanceStatus = await this.froshToolsService.performanceStatus(); - this.isLoading = false; - }, - } -}) + async createdComponent() { + this.health = await this.froshToolsService.healthStatus(); + this.performanceStatus = await this.froshToolsService.performanceStatus(); + this.isLoading = false; + }, + }, +}); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-logs/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-logs/index.js index 293acf77..cad28b0b 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-logs/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-logs/index.js @@ -4,99 +4,97 @@ import './style.scss'; const { Component, Mixin } = Shopware; Component.register('frosh-tools-tab-logs', { - template, - inject: ['froshToolsService'], - mixins: [ - Mixin.getByName('notification') - ], + template, + inject: ['froshToolsService'], + mixins: [Mixin.getByName('notification')], - data() { - return { - logFiles: [], - selectedLogFile: null, - logEntries: [], - totalLogEntries: 0, - limit: 25, - page: 1, - isLoading: true, - displayedLog: null - }; - }, + data() { + return { + logFiles: [], + selectedLogFile: null, + logEntries: [], + totalLogEntries: 0, + limit: 25, + page: 1, + isLoading: true, + displayedLog: null, + }; + }, - created() { - this.createdComponent(); - }, + created() { + this.createdComponent(); + }, - computed: { - columns() { - return [ - { - property: 'date', - label: 'frosh-tools.date', - rawData: true - }, - { - property: 'channel', - label: 'frosh-tools.channel', - rawData: true - }, - { - property: 'level', - label: 'frosh-tools.level', - rawData: true - }, - { - property: 'message', - label: 'frosh-tools.message', - rawData: true - } - ]; + computed: { + columns() { + return [ + { + property: 'date', + label: 'frosh-tools.date', + rawData: true, }, - - date() { - return Shopware.Filter.getByName('date'); + { + property: 'channel', + label: 'frosh-tools.channel', + rawData: true, + }, + { + property: 'level', + label: 'frosh-tools.level', + rawData: true, + }, + { + property: 'message', + label: 'frosh-tools.message', + rawData: true, }, + ]; }, - methods: { - async refresh() { - this.isLoading = true; - await this.createdComponent(); - await this.onFileSelected(); - }, + date() { + return Shopware.Filter.getByName('date'); + }, + }, - async createdComponent() { - this.logFiles = await this.froshToolsService.getLogFiles(); - this.isLoading = false; - }, + methods: { + async refresh() { + this.isLoading = true; + await this.createdComponent(); + await this.onFileSelected(); + }, - async onFileSelected() { - if (!this.selectedLogFile) { - return; - } + async createdComponent() { + this.logFiles = await this.froshToolsService.getLogFiles(); + this.isLoading = false; + }, - const logEntries = await this.froshToolsService.getLogFile( - this.selectedLogFile, - (this.page - 1) * this.limit, - this.limit - ); + async onFileSelected() { + if (!this.selectedLogFile) { + return; + } - this.logEntries = logEntries.data; - this.totalLogEntries = parseInt(logEntries.headers['file-size'], 10); - }, + const logEntries = await this.froshToolsService.getLogFile( + this.selectedLogFile, + (this.page - 1) * this.limit, + this.limit, + ); - async onPageChange(page) { - this.page = page.page; - this.limit = page.limit; - await this.onFileSelected(); - }, + this.logEntries = logEntries.data; + this.totalLogEntries = parseInt(logEntries.headers['file-size'], 10); + }, - showInfoModal(entryContents) { - this.displayedLog = entryContents; - }, + async onPageChange(page) { + this.page = page.page; + this.limit = page.limit; + await this.onFileSelected(); + }, - closeInfoModal() { - this.displayedLog = null; - }, - } + showInfoModal(entryContents) { + this.displayedLog = entryContents; + }, + + closeInfoModal() { + this.displayedLog = null; + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-queue/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-queue/index.js index ceb23902..0e60a184 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-queue/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-queue/index.js @@ -4,64 +4,62 @@ import './style.scss'; const { Component, Mixin } = Shopware; Component.register('frosh-tools-tab-queue', { - template, - inject: ['repositoryFactory', 'froshToolsService'], - mixins: [ - Mixin.getByName('notification') - ], + template, + inject: ['repositoryFactory', 'froshToolsService'], + mixins: [Mixin.getByName('notification')], - data() { - return { - queueEntries: [], - showResetModal: false, - isLoading: true - }; - }, + data() { + return { + queueEntries: [], + showResetModal: false, + isLoading: true, + }; + }, - created() { - this.createdComponent(); - }, + created() { + this.createdComponent(); + }, - computed: { - columns() { - return [ - { - property: 'name', - label: 'Name', - rawData: true - }, - { - property: 'size', - label: 'Size', - rawData: true - } - ]; - } + computed: { + columns() { + return [ + { + property: 'name', + label: 'Name', + rawData: true, + }, + { + property: 'size', + label: 'Size', + rawData: true, + }, + ]; }, + }, - methods: { - async refresh() { - this.isLoading = true; - await this.createdComponent(); - }, - async createdComponent() { - this.queueEntries = await this.froshToolsService.getQueue(); + methods: { + async refresh() { + this.isLoading = true; + await this.createdComponent(); + }, + async createdComponent() { + this.queueEntries = await this.froshToolsService.getQueue(); - for (const queue of this.queueEntries) { - const nameSplit = queue.name.split('\\') - queue.name = nameSplit[nameSplit.length - 1]; - } - this.isLoading = false; - }, - async resetQueue() { - this.isLoading = true; - await this.froshToolsService.resetQueue(); - this.showResetModal = false; - await this.createdComponent(); - this.createNotificationSuccess({ - message: this.$tc('frosh-tools.tabs.queue.reset.success') - }) - this.isLoading = false; - } - } + for (const queue of this.queueEntries) { + const nameSplit = queue.name.split('\\'); + queue.name = nameSplit[nameSplit.length - 1]; + } + this.isLoading = false; + }, + async resetQueue() { + this.isLoading = true; + await this.froshToolsService.resetQueue(); + this.showResetModal = false; + await this.createdComponent(); + this.createNotificationSuccess({ + message: this.$tc('frosh-tools.tabs.queue.reset.success'), + }); + this.isLoading = false; + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-scheduled/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-scheduled/index.js index cd75891f..f0d8f49d 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-scheduled/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-scheduled/index.js @@ -5,145 +5,163 @@ const { Component, Mixin } = Shopware; const { Criteria } = Shopware.Data; Component.register('frosh-tools-tab-scheduled', { - template, - inject: ['repositoryFactory', 'froshToolsService'], - mixins: [ - Mixin.getByName('notification') - ], - - data() { - return { - items: null, - showResetModal: false, - isLoading: true, - page: 1, - limit: 25, - taskError: null - }; + template, + inject: ['repositoryFactory', 'froshToolsService'], + mixins: [Mixin.getByName('notification')], + + data() { + return { + items: null, + showResetModal: false, + isLoading: true, + page: 1, + limit: 25, + taskError: null, + }; + }, + + created() { + this.createdComponent(); + }, + + computed: { + scheduledRepository() { + return this.repositoryFactory.create('scheduled_task'); }, - created() { - this.createdComponent(); - }, - - computed: { - scheduledRepository() { - return this.repositoryFactory.create('scheduled_task'); + columns() { + return [ + { + property: 'name', + label: 'frosh-tools.name', + rawData: true, + primary: true, }, - - columns() { - return [ - { - property: 'name', - label: 'frosh-tools.name', - rawData: true, - primary: true - }, - { - property: 'runInterval', - label: 'frosh-tools.interval', - rawData: true, - inlineEdit: 'number' - }, - { - property: 'lastExecutionTime', - label: 'frosh-tools.lastExecutionTime', - rawData: true - }, - { - property: 'nextExecutionTime', - label: 'frosh-tools.nextExecutionTime', - rawData: true, - inlineEdit: 'datetime' - }, - { - property: 'status', - label: 'frosh-tools.status', - rawData: true - } - ]; + { + property: 'runInterval', + label: 'frosh-tools.interval', + rawData: true, + inlineEdit: 'number', }, - - date() { - return Shopware.Filter.getByName('date'); + { + property: 'lastExecutionTime', + label: 'frosh-tools.lastExecutionTime', + rawData: true, + }, + { + property: 'nextExecutionTime', + label: 'frosh-tools.nextExecutionTime', + rawData: true, + inlineEdit: 'datetime', }, + { + property: 'status', + label: 'frosh-tools.status', + rawData: true, + }, + ]; }, - methods: { - async refresh() { - this.isLoading = true; - await this.createdComponent(); - }, + date() { + return Shopware.Filter.getByName('date'); + }, + }, - async createdComponent() { - const criteria = new Criteria(this.page, this.limit); - criteria.addSorting(Criteria.sort('nextExecutionTime', 'ASC')); - this.items = await this.scheduledRepository.search(criteria, Shopware.Context.api); - this.isLoading = false; - }, + methods: { + async refresh() { + this.isLoading = true; + await this.createdComponent(); + }, - async runTask(item) { - this.isLoading = true; - - try { - this.createNotificationInfo({ - message: this.$tc('frosh-tools.scheduledTaskStarted', 0, {'name': item.name}) - }) - await this.froshToolsService.runScheduledTask(item.id); - this.createNotificationSuccess({ - message: this.$tc('frosh-tools.scheduledTaskSucceed', 0, {'name': item.name}) - }) - } catch (e) { - this.createNotificationError({ - message: this.$tc('frosh-tools.scheduledTaskFailed', 0, {'name': item.name}) - }) - - this.taskError = e.response.data; - } - - this.createdComponent(); - }, + async createdComponent() { + const criteria = new Criteria(this.page, this.limit); + criteria.addSorting(Criteria.sort('nextExecutionTime', 'ASC')); + this.items = await this.scheduledRepository.search( + criteria, + Shopware.Context.api, + ); + this.isLoading = false; + }, - async scheduleTask(item, immediately = false) { - this.isLoading = true; - - try { - this.createNotificationInfo({ - message: this.$t('frosh-tools.scheduledTaskScheduleStarted', {'name': item.name}) - }) - await this.froshToolsService.scheduleScheduledTask(item.id, immediately); - this.createNotificationSuccess({ - message: this.$t('frosh-tools.scheduledTaskScheduleSucceed', {'name': item.name}) - }) - } catch (e) { - this.createNotificationError({ - message: this.$t('frosh-tools.scheduledTaskScheduleFailed', {'name': item.name}) - }) - - this.taskError = e.response.data; - } - - this.createdComponent(); - }, + async runTask(item) { + this.isLoading = true; + + try { + this.createNotificationInfo({ + message: this.$tc('frosh-tools.scheduledTaskStarted', 0, { + name: item.name, + }), + }); + await this.froshToolsService.runScheduledTask(item.id); + this.createNotificationSuccess({ + message: this.$tc('frosh-tools.scheduledTaskSucceed', 0, { + name: item.name, + }), + }); + } catch (e) { + this.createNotificationError({ + message: this.$tc('frosh-tools.scheduledTaskFailed', 0, { + name: item.name, + }), + }); + + this.taskError = e.response.data; + } + + this.createdComponent(); + }, - async registerScheduledTasks() { - this.isLoading = true; - - try { - this.createNotificationInfo({ - message: this.$tc('frosh-tools.scheduledTasksRegisterStarted') - }) - await this.froshToolsService.scheduledTasksRegister(); - this.createNotificationSuccess({ - message: this.$tc('frosh-tools.scheduledTasksRegisterSucceed') - }) - } catch (e) { - this.createNotificationError({ - message: this.$tc('frosh-tools.scheduledTasksRegisterFailed') - }) - } - - this.createdComponent(); - }, - } + async scheduleTask(item, immediately = false) { + this.isLoading = true; + + try { + this.createNotificationInfo({ + message: this.$t('frosh-tools.scheduledTaskScheduleStarted', { + name: item.name, + }), + }); + await this.froshToolsService.scheduleScheduledTask( + item.id, + immediately, + ); + this.createNotificationSuccess({ + message: this.$t('frosh-tools.scheduledTaskScheduleSucceed', { + name: item.name, + }), + }); + } catch (e) { + this.createNotificationError({ + message: this.$t('frosh-tools.scheduledTaskScheduleFailed', { + name: item.name, + }), + }); + + this.taskError = e.response.data; + } + + this.createdComponent(); + }, + + async registerScheduledTasks() { + this.isLoading = true; + + try { + this.createNotificationInfo({ + message: this.$tc('frosh-tools.scheduledTasksRegisterStarted'), + }); + await this.froshToolsService.scheduledTasksRegister(); + this.createNotificationSuccess({ + message: this.$tc('frosh-tools.scheduledTasksRegisterSucceed'), + }); + } catch (err) { + console.error(err); + + this.createNotificationError({ + message: this.$tc('frosh-tools.scheduledTasksRegisterFailed'), + }); + } + + this.createdComponent(); + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-state-machines/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-state-machines/index.js index 9e66427c..4a6acece 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-state-machines/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-state-machines/index.js @@ -1,53 +1,50 @@ -/*global Shopware*/ - import './style.scss'; import template from './template.html.twig'; const { Component, Mixin } = Shopware; Component.register('frosh-tools-tab-state-machines', { - template, + template, - inject: ['froshToolsService'], + inject: ['froshToolsService'], - mixins: [ - Mixin.getByName('notification') - ], + mixins: [Mixin.getByName('notification')], - data() { - return { - selectedStateMachine: null, - image: null, - isLoading: true, - } - }, + data() { + return { + selectedStateMachine: null, + image: null, + isLoading: true, + }; + }, - created() { - this.createdComponent(); + created() { + this.createdComponent(); + }, + + methods: { + createdComponent() { + this.isLoading = false; }, - methods: { - createdComponent() { - this.isLoading = false; - }, - - async onStateMachineChange(stateMachineChangeId) { - if (!stateMachineChangeId) { - return; - } - - const response = await this.froshToolsService.stateMachines(stateMachineChangeId); - - const elem = document.getElementById('state_machine'); - if ("svg" in response) { - this.image = response.svg; - elem.src = this.image; - elem.style.opacity = '1'; - elem.style.width = '100%'; - elem.style.height = 'auto'; - } else { - elem.style.opacity = '0'; - } - } - } + async onStateMachineChange(stateMachineChangeId) { + if (!stateMachineChangeId) { + return; + } + + const response = + await this.froshToolsService.stateMachines(stateMachineChangeId); + + const elem = document.getElementById('state_machine'); + if ('svg' in response) { + this.image = response.svg; + elem.src = this.image; + elem.style.opacity = '1'; + elem.style.width = '100%'; + elem.style.height = 'auto'; + } else { + elem.style.opacity = '0'; + } + }, + }, }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/index.js b/src/Resources/app/administration/src/module/frosh-tools/index.js index 846f65bc..3bd29612 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/index.js @@ -7,98 +7,98 @@ import './component/frosh-tools-tab-logs'; import './component/frosh-tools-tab-state-machines'; import './component/frosh-tools-tab-files'; import './page/index'; -import './acl' +import './acl'; Shopware.Module.register('frosh-tools', { - type: 'plugin', - name: 'frosh-tools.title', - title: 'frosh-tools.title', - description: '', - color: '#303A4F', + type: 'plugin', + name: 'frosh-tools.title', + title: 'frosh-tools.title', + description: '', + color: '#303A4F', - icon: 'regular-cog', + icon: 'regular-cog', - routes: { + routes: { + index: { + component: 'frosh-tools-index', + path: 'index', + children: { index: { - component: 'frosh-tools-index', - path: 'index', - children: { - index: { - component: 'frosh-tools-tab-index', - path: 'index', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - cache: { - component: 'frosh-tools-tab-cache', - path: 'cache', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - queue: { - component: 'frosh-tools-tab-queue', - path: 'queue', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - scheduled: { - component: 'frosh-tools-tab-scheduled', - path: 'scheduled', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - elasticsearch: { - component: 'frosh-tools-tab-elasticsearch', - path: 'elasticsearch', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - logs: { - component: 'frosh-tools-tab-logs', - path: 'logs', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - files: { - component: 'frosh-tools-tab-files', - path: 'files', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - statemachines: { - component: 'frosh-tools-tab-state-machines', - path: 'state-machines', - meta: { - privilege: 'frosh_tools:read', - parentPath: 'sw.settings.index.plugins' - } - }, - } + component: 'frosh-tools-tab-index', + path: 'index', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, }, + cache: { + component: 'frosh-tools-tab-cache', + path: 'cache', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + queue: { + component: 'frosh-tools-tab-queue', + path: 'queue', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + scheduled: { + component: 'frosh-tools-tab-scheduled', + path: 'scheduled', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + elasticsearch: { + component: 'frosh-tools-tab-elasticsearch', + path: 'elasticsearch', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + logs: { + component: 'frosh-tools-tab-logs', + path: 'logs', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + files: { + component: 'frosh-tools-tab-files', + path: 'files', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + statemachines: { + component: 'frosh-tools-tab-state-machines', + path: 'state-machines', + meta: { + privilege: 'frosh_tools:read', + parentPath: 'sw.settings.index.plugins', + }, + }, + }, }, + }, - settingsItem: [ - { - group: 'plugins', - to: 'frosh.tools.index.cache', - icon: 'regular-cog', - name: 'frosh-tools', - label: 'frosh-tools.title', - privilege: 'frosh_tools:read' - } - ] + settingsItem: [ + { + group: 'plugins', + to: 'frosh.tools.index.cache', + icon: 'regular-cog', + name: 'frosh-tools', + label: 'frosh-tools.title', + privilege: 'frosh_tools:read', + }, + ], }); diff --git a/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js b/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js index 84d97027..ac37a2e3 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/page/index/index.js @@ -4,11 +4,14 @@ import template from './template.twig'; const { Component } = Shopware; Component.register('frosh-tools-index', { - template, + template, - computed: { - elasticsearchAvailable() { - return Shopware.State.get('context').app.config.settings?.elasticsearchEnabled || false; - } - } + computed: { + elasticsearchAvailable() { + return ( + Shopware.State.get('context').app.config.settings + ?.elasticsearchEnabled || false + ); + }, + }, }); diff --git a/src/Resources/app/administration/src/overrides/sw-data-grid-inline-edit/index.js b/src/Resources/app/administration/src/overrides/sw-data-grid-inline-edit/index.js index e79343f4..d534b07d 100644 --- a/src/Resources/app/administration/src/overrides/sw-data-grid-inline-edit/index.js +++ b/src/Resources/app/administration/src/overrides/sw-data-grid-inline-edit/index.js @@ -3,5 +3,5 @@ import template from './template.twig'; const { Component } = Shopware; Component.override('sw-data-grid-inline-edit', { - template + template, }); diff --git a/src/Resources/app/administration/src/overrides/sw-version/index.js b/src/Resources/app/administration/src/overrides/sw-version/index.js index a3d4ee21..6b93cd71 100644 --- a/src/Resources/app/administration/src/overrides/sw-version/index.js +++ b/src/Resources/app/administration/src/overrides/sw-version/index.js @@ -3,82 +3,84 @@ import template from './template.twig'; const { Component } = Shopware; Component.override('sw-version', { - template, - inject: ['froshToolsService', 'acl', 'loginService'], + template, + inject: ['froshToolsService', 'acl', 'loginService'], - async created() { - if(!this.checkPermission()) { - return; - } - - await this.checkHealth(); - }, - - data() { - return { - health: null, - hasPermission: false - } - }, + async created() { + if (!this.checkPermission()) { + return; + } - computed: { - healthVariant() { - let variant = 'success'; + await this.checkHealth(); + }, - for (let health of this.health) { - if (health.state === 'STATE_ERROR') { - variant = 'error'; - continue; - } + data() { + return { + health: null, + hasPermission: false, + }; + }, - if (health.state === 'STATE_WARNING' && variant === 'success') { - variant = 'warning'; - } - } + computed: { + healthVariant() { + let variant = 'success'; - return variant; - }, + for (let health of this.health) { + if (health.state === 'STATE_ERROR') { + variant = 'error'; + continue; + } - healthPlaceholder() { - let msg = 'Shop Status: Ok'; + if (health.state === 'STATE_WARNING' && variant === 'success') { + variant = 'warning'; + } + } - if (this.health === null) { - return msg; - } + return variant; + }, - for (let health of this.health) { - if (health.state === 'STATE_ERROR') { - msg = 'Shop Status: May outage, Check System Status'; - continue; - } + healthPlaceholder() { + let msg = 'Shop Status: Ok'; - if (health.state === 'STATE_WARNING' && msg === 'Shop Status: Ok') { - msg = 'Shop Status: Issues, Check System Status'; - } - } + if (this.health === null) { + return msg; + } - return msg; + for (let health of this.health) { + if (health.state === 'STATE_ERROR') { + msg = 'Shop Status: May outage, Check System Status'; + continue; } - }, - methods: { - async checkHealth() { - this.health = await this.froshToolsService.healthStatus(true); + if (health.state === 'STATE_WARNING' && msg === 'Shop Status: Ok') { + msg = 'Shop Status: Issues, Check System Status'; + } + } - this.checkInterval = setInterval(async() => { - try { - this.health = await this.froshToolsService.healthStatus(true); - } catch (e) { - console.error(e); - clearInterval(this.checkInterval); - } - }, 60000); + return msg; + }, + }, + + methods: { + async checkHealth() { + this.health = await this.froshToolsService.healthStatus(true); + + this.checkInterval = setInterval(async () => { + try { + this.health = await this.froshToolsService.healthStatus(true); + } catch (e) { + console.error(e); + clearInterval(this.checkInterval); + } + }, 60000); - this.loginService.addOnLogoutListener(() => clearInterval(this.checkInterval)); - }, + this.loginService.addOnLogoutListener(() => + clearInterval(this.checkInterval), + ); + }, - checkPermission() { - return this.hasPermission = this.acl.can('frosh_tools:read'); - } - } -}) + checkPermission() { + return (this.hasPermission = this.acl.can('frosh_tools:read')); + }, + }, +});