fix showing community containers in the AIO interface and enabling or disabling them

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L. 2025-05-30 12:48:15 +02:00
parent 0fe4ea3238
commit 8a6772bc05
4 changed files with 18 additions and 21 deletions

View file

@ -1,12 +0,0 @@
<?php
namespace AIO\Container;
readonly class CommunityContainer {
public function __construct(
string $id,
string $name,
string $documentation,
) {
}
}

View file

@ -126,7 +126,17 @@ readonly class ConfigurationController {
}
if (isset($request->getParsedBody()['community-form'])) {
$this->configurationManager->SetEnabledCommunityContainers($request->getParsedBody()['enabled-community'] ?? []);
$cc = $this->configurationManager->listAvailableCommunityContainers();
$enabledCC = [];
/**
* @psalm-suppress PossiblyNullIterator
*/
foreach ($request->getParsedBody() as $item) {
if (array_key_exists($item , $cc)) {
$enabledCC[] = $item;
}
}
$this->configurationManager->SetEnabledCommunityContainers($enabledCC);
}
if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) {

View file

@ -3,7 +3,6 @@
namespace AIO\Data;
use AIO\Auth\PasswordGenerator;
use AIO\Container\CommunityContainer;
use AIO\Controller\DockerController;
class ConfigurationManager
@ -1018,7 +1017,6 @@ class ConfigurationManager
}
/** @return list<CommunityContainer> */
public function listAvailableCommunityContainers() : array {
$cc = [];
$dir = scandir(DataConst::GetCommunityContainersDirectory());
@ -1036,15 +1034,16 @@ class ConfigurationManager
apcu_add($filePath, $fileContents);
}
}
$json = is_string($fileContents) ? json_decode($fileContents) : false;
$json = is_string($fileContents) ? json_decode($fileContents, true) : false;
if(is_array($json) && is_array($json['aio_services_v1'])) {
foreach ($json['aio_services_v1'] as $service) {
$documentation = is_string($service['documentation']) ? $service['documentation'] : '';
if (is_string($service['display_name'])) {
$cc[] = new CommunityContainer(
$id,
$service['display_name'],
$documentation);
$cc[$id] = [
'id' => $id,
'name' => $service['display_name'],
'documentation' => $documentation
];
}
break;
}

View file

@ -16,7 +16,7 @@
<p>
<input
type="checkbox"
id="enabled-community[]"
id="{{ cc.id }}"
value="{{ cc.id }}"
name="{{ cc.id }}"
{% if cc.id in community_containers_enabled %}