diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html index ac9d7c47e..af207c05c 100644 --- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html +++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.html @@ -1,5 +1,5 @@
- -
- + @if (aiEnabled) { +
+ -
-
- @if (!suggestions?.suggested_tags && !suggestions?.suggested_document_types && !suggestions?.suggested_correspondents) { -
- No novel suggestions -
- } - @if (suggestions?.suggested_tags?.length > 0) { - Tags - @for (tag of suggestions.suggested_tags; track tag) { - +
+
+ @if (!suggestions?.suggested_tags && !suggestions?.suggested_document_types && !suggestions?.suggested_correspondents) { +
+ No novel suggestions +
} - } - @if (suggestions?.suggested_document_types?.length > 0) { -
Document Types
- @for (type of suggestions.suggested_document_types; track type) { - + @if (suggestions?.suggested_tags.length > 0) { + Tags + @for (tag of suggestions.suggested_tags; track tag) { + + } } - } - @if (suggestions?.suggested_correspondents?.length > 0) { -
Correspondents
- @for (correspondent of suggestions.suggested_correspondents; track correspondent) { - + @if (suggestions?.suggested_document_types.length > 0) { +
Document Types
+ @for (type of suggestions.suggested_document_types; track type) { + + } } - } + @if (suggestions?.suggested_correspondents.length > 0) { +
Correspondents
+ @for (correspondent of suggestions.suggested_correspondents; track correspondent) { + + } + } +
-
+ }
diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts index 6d202a1b1..801a56af3 100644 --- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts +++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.spec.ts @@ -38,6 +38,8 @@ describe('SuggestionsDropdownComponent', () => { }) it('should toggle dropdown when clickSuggest is called and suggestions are not null', () => { + component.aiEnabled = true + fixture.detectChanges() component.suggestions = { suggested_correspondents: [], suggested_tags: [], diff --git a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts index 485c68627..b165f0a5e 100644 --- a/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts +++ b/src-ui/src/app/components/common/suggestions-dropdown/suggestions-dropdown.component.ts @@ -24,6 +24,9 @@ export class SuggestionsDropdownComponent { @Input() suggestions: DocumentSuggestions = null + @Input() + aiEnabled: boolean = false + @Input() loading: boolean = false @@ -47,7 +50,7 @@ export class SuggestionsDropdownComponent { if (!this.suggestions) { this.getSuggestions.emit(this) } else { - this.dropdown.toggle() + this.dropdown?.toggle() } } diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 88c12dff9..447b66c10 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -115,6 +115,7 @@ [disabled]="!userCanEdit || suggestionsLoading" [loading]="suggestionsLoading" [suggestions]="suggestions" + [aiEnabled]="aiEnabled" (getSuggestions)="getSuggestions()" (addTag)="createTag($event)" (addDocumentType)="createDocumentType($event)" diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 00698307d..612ccab19 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -299,6 +299,10 @@ export class DocumentDetailComponent return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER) } + get aiEnabled(): boolean { + return this.settings.get(SETTINGS_KEYS.AI_ENABLED) + } + get archiveContentRenderType(): ContentRenderType { return this.document?.archived_file_name ? this.getRenderType('application/pdf') diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts index c5164d6e1..386feb8f8 100644 --- a/src-ui/src/app/data/ui-settings.ts +++ b/src-ui/src/app/data/ui-settings.ts @@ -73,6 +73,7 @@ export const SETTINGS_KEYS = { GMAIL_OAUTH_URL: 'gmail_oauth_url', OUTLOOK_OAUTH_URL: 'outlook_oauth_url', EMAIL_ENABLED: 'email_enabled', + AI_ENABLED: 'ai_enabled', } export const SETTINGS: UiSetting[] = [ @@ -276,4 +277,9 @@ export const SETTINGS: UiSetting[] = [ type: 'string', default: 'page-width', // ZoomSetting from 'document-detail.component' }, + { + key: SETTINGS_KEYS.AI_ENABLED, + type: 'boolean', + default: false, + }, ] diff --git a/src/documents/tests/test_api_uisettings.py b/src/documents/tests/test_api_uisettings.py index e3b9d4999..2f16ccf7f 100644 --- a/src/documents/tests/test_api_uisettings.py +++ b/src/documents/tests/test_api_uisettings.py @@ -47,6 +47,7 @@ class TestApiUiSettings(DirectoriesMixin, APITestCase): "backend_setting": "default", }, "email_enabled": False, + "ai_enabled": False, }, ) diff --git a/src/documents/views.py b/src/documents/views.py index 8ddfaadf0..893381c87 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -2220,6 +2220,7 @@ class UiSettingsView(GenericAPIView): request.session["oauth_state"] = manager.state ui_settings["email_enabled"] = settings.EMAIL_ENABLED + ui_settings["ai_enabled"] = settings.AI_ENABLED user_resp = { "id": user.id,