added admin settings service and api; made filesystem paths configurable; added babel config; added admin settings webpack config

This commit is contained in:
Jonathan Treffler 2024-04-23 19:51:41 +02:00 committed by root
parent 188ea3dfa9
commit b79f6cab6b
12 changed files with 10224 additions and 32 deletions

View file

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace OCA\GroupfolderFilesystemSnapshots\Service;
use OCA\GroupfolderFilesystemSnapshots\AppInfo\Application;
use OCP\IConfig;
class SettingsService {
private static array $VALID_APP_SETTINGS = ["filesystem_mountpoint_path", "filesystem_snapshots_path"];
public function __construct(private IConfig $config) {
}
public function getAppValues(): array {
$result = [];
foreach(self::$VALID_APP_SETTINGS as $key) {
$result[$key] = $this->config->getAppValue(Application::APP_ID, $key);
}
return $result;
}
public function getAppValue(string $key): string {
if(in_array($key, self::$VALID_APP_SETTINGS)) {
return $this->config->getAppValue(Application::APP_ID, $key);
}
}
public function setAppValue(string $key, string $value): string {
if(in_array($key, self::$VALID_APP_SETTINGS)) {
if($value !== '') {
$this->config->setAppValue(Application::APP_ID, $key, $value);
} else {
$this->config->deleteAppValue(Application::APP_ID, $key);
}
return $value;
}
}
}