Skip to content

Commit

Permalink
Merge pull request #134 from nextcloud/enh/personal-settings-configur…
Browse files Browse the repository at this point in the history
…ed-backends

enh(PersonalSettings): Add a section listing the configured backends
  • Loading branch information
marcelklehr authored Sep 30, 2024
2 parents cca40a3 + 781160c commit 3639f1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\TaskProcessing\Exception\Exception;
use OCP\TaskProcessing\IManager as ITaskProcessingManager;
use OCP\TaskProcessing\TaskTypes\AudioToText;
use OCP\TaskProcessing\TaskTypes\TextToImage;
Expand Down Expand Up @@ -57,6 +58,17 @@ public function getForm(): TemplateResponse {
'speech_to_text_picker_enabled' => $speechToTextPickerEnabled,
];
$this->initialStateService->provideInitialState('config', $userConfig);

$availableProviders = [];
foreach ($availableTaskTypes as $taskTypeId => $availableTaskType) {
try {
$provider = $this->taskProcessingManager->getPreferredProvider($taskTypeId);
$availableProviders[$availableTaskType['name']] = $provider->getName();
} catch (Exception $e) {
// pass
}
}
$this->initialStateService->provideInitialState('availableProviders', $availableProviders);
return new TemplateResponse(Application::APP_ID, 'personalSettings');
}

Expand Down
10 changes: 10 additions & 0 deletions src/components/PersonalSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
{{ t('assistant', 'No suitable providers are available. They must first be enabled by your administrator.') }}
</span>
</div>
<div v-else>
<h3>{{ t('assistant', 'Configured Backends') }}</h3>
<p>{{ t('assistant', 'The following services are used as backends for Nextcloud Assistant:') }}</p>
<ul>
<li v-for="(providerName, taskName) in providers" :key="taskName">
{{ t('assistant', '{providerName} for {taskName}', { providerName, taskName }, null, { escape: false }) }}
</li>
</ul>
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -68,6 +77,7 @@ export default {
data() {
return {
state: loadState('assistant', 'config'),
providers: loadState('assistant', 'availableProviders'),
}
},
Expand Down

0 comments on commit 3639f1f

Please sign in to comment.