diff options
author | Andrey Borysenko <andrey18106x@gmail.com> | 2024-10-09 21:02:29 +0300 |
---|---|---|
committer | Andrey Borysenko <andrey18106x@gmail.com> | 2024-10-29 20:54:05 +0200 |
commit | 95b06309f3b55d0ac6412c8f07879d55bdfeb95e (patch) | |
tree | 6e992807888241927a2b5efc7af930b629c82830 /apps | |
parent | 2d5060d1e3161aadfafb11d3690bc337b9092d31 (diff) | |
download | nextcloud-server-95b06309f3b55d0ac6412c8f07879d55bdfeb95e.tar.gz nextcloud-server-95b06309f3b55d0ac6412c8f07879d55bdfeb95e.zip |
feat(app_api): add initial state data for AppAPI UI part
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
# Conflicts:
# apps/settings/lib/Controller/AppSettingsController.php
# Conflicts:
# apps/settings/lib/Controller/AppSettingsController.php
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Controller/AppSettingsController.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index a27de4e9673..e4b37a33c5d 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -43,6 +43,7 @@ use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use OCP\L10N\IFactory; +use OCP\Server; use OCP\Util; use Psr\Log\LoggerInterface; @@ -89,6 +90,8 @@ class AppSettingsController extends Controller { $this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual')); $this->initialState->provideInitialState('appstoreUpdateCount', count($this->getAppsWithUpdates())); + $this->provideAppApiState(); + $policy = new ContentSecurityPolicy(); $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); @@ -101,6 +104,37 @@ class AppSettingsController extends Controller { return $templateResponse; } + private function provideAppApiState(): void { + $appApiEnabled = $this->appManager->isInstalled('app_api'); + $this->initialState->provideInitialState('appApiEnabled', $appApiEnabled); + $daemonConfigAccessible = false; + $defaultDaemonConfig = null; + + if ($appApiEnabled) { + $exAppFetcher = Server::get(\OCA\AppAPI\Fetcher\ExAppFetcher::class); + $this->initialState->provideInitialState('appstoreExAppUpdateCount', count($exAppFetcher->getExAppsWithUpdates())); + + $defaultDaemonConfigName = $this->config->getAppValue('app_api', 'default_daemon_config'); + if ($defaultDaemonConfigName !== '') { + $daemonConfigService = Server::get(\OCA\AppAPI\Service\DaemonConfigService::class); + $daemonConfig = $daemonConfigService->getDaemonConfigByName($defaultDaemonConfigName); + if ($daemonConfig !== null) { + $defaultDaemonConfig = $daemonConfig->jsonSerialize(); + unset($defaultDaemonConfig['deploy_config']['haproxy_password']); + $dockerActions = Server::get(\OCA\AppAPI\DeployActions\DockerActions::class); + $dockerActions->initGuzzleClient($daemonConfig); + $daemonConfigAccessible = $dockerActions->ping($dockerActions->buildDockerUrl($daemonConfig)); + if (!$daemonConfigAccessible) { + $this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud. Please verify its configuration', $daemonConfig->getName())); + } + } + } + } + + $this->initialState->provideInitialState('defaultDaemonConfigAccessible', $daemonConfigAccessible); + $this->initialState->provideInitialState('defaultDaemonConfig', $defaultDaemonConfig); + } + /** * Get all active entries for the app discover section */ |