mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
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
This commit is contained in:
parent
2d5060d1e3
commit
95b06309f3
1 changed files with 34 additions and 0 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue