From 32b57e7b4120043c1f21ba881914e61e24d8f2a5 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Sun, 8 Dec 2024 18:22:08 +0100 Subject: feat: save state in db Signed-off-by: Jana Peper --- apps/settings/lib/Controller/AISettingsController.php | 2 +- apps/settings/lib/Settings/Admin/ArtificialIntelligence.php | 4 ++++ apps/settings/src/components/AdminAI.vue | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/settings/lib/Controller/AISettingsController.php b/apps/settings/lib/Controller/AISettingsController.php index 0586c652702..e08ec616e80 100644 --- a/apps/settings/lib/Controller/AISettingsController.php +++ b/apps/settings/lib/Controller/AISettingsController.php @@ -38,7 +38,7 @@ class AISettingsController extends Controller { */ #[AuthorizedAdminSetting(settings: ArtificialIntelligence::class)] public function update($settings) { - $keys = ['ai.stt_provider', 'ai.textprocessing_provider_preferences', 'ai.taskprocessing_provider_preferences', 'ai.translation_provider_preferences', 'ai.text2image_provider']; + $keys = ['ai.stt_provider', 'ai.textprocessing_provider_preferences', 'ai.taskprocessing_provider_preferences','ai.taskprocessing_type_preferences', 'ai.translation_provider_preferences', 'ai.text2image_provider']; foreach ($keys as $key) { if (!isset($settings[$key])) { continue; diff --git a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php index 4092acecab8..197ea0de283 100644 --- a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php +++ b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php @@ -113,12 +113,14 @@ class ArtificialIntelligence implements IDelegatedSettings { } } $taskProcessingTaskTypes = []; + $taskProcessingTypeSettings = []; foreach ($this->taskProcessingManager->getAvailableTaskTypes() as $taskTypeId => $taskTypeDefinition) { $taskProcessingTaskTypes[] = [ 'id' => $taskTypeId, 'name' => $taskTypeDefinition['name'], 'description' => $taskTypeDefinition['description'], ]; + $taskProcessingTypeSettings[$taskTypeId] = true; } $this->initialState->provideInitialState('ai-stt-providers', $sttProviders); @@ -135,6 +137,7 @@ class ArtificialIntelligence implements IDelegatedSettings { 'ai.textprocessing_provider_preferences' => $textProcessingSettings, 'ai.text2image_provider' => count($text2imageProviders) > 0 ? $text2imageProviders[0]['id'] : null, 'ai.taskprocessing_provider_preferences' => $taskProcessingSettings, + 'ai.taskprocessing_type_preferences' => $taskProcessingTypeSettings, ]; foreach ($settings as $key => $defaultValue) { $value = $defaultValue; @@ -143,6 +146,7 @@ class ArtificialIntelligence implements IDelegatedSettings { $value = json_decode($json, true); switch ($key) { case 'ai.taskprocessing_provider_preferences': + case 'ai.taskprocessing_type_preferences': case 'ai.textprocessing_provider_preferences': // fill $value with $defaultValue values $value = array_merge($defaultValue, $value); diff --git a/apps/settings/src/components/AdminAI.vue b/apps/settings/src/components/AdminAI.vue index df53d88c85e..0d6f32a9aa9 100644 --- a/apps/settings/src/components/AdminAI.vue +++ b/apps/settings/src/components/AdminAI.vue @@ -11,13 +11,14 @@

{{ t('settings', 'Task:') }} {{ type.name }}

{{ type.description }}

+ v-model="settings['ai.taskprocessing_type_preferences'][type.id]" + @update:modelValue="saveChanges" > {{ t('settings', 'Enable') }}