mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-23 12:58:18 -05:00
Pass AI enabled to frontend
This commit is contained in:
parent
d1e5a647fa
commit
d2a40e5a0d
@ -1,5 +1,5 @@
|
|||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button type="button" class="btn btn-sm btn-outline-primary" (click)="clickSuggest()" [disabled]="loading">
|
<button type="button" class="btn btn-sm btn-outline-primary" (click)="clickSuggest()" [disabled]="loading || (suggestions && !aiEnabled)">
|
||||||
@if (loading) {
|
@if (loading) {
|
||||||
<div class="spinner-border spinner-border-sm" role="status"></div>
|
<div class="spinner-border spinner-border-sm" role="status"></div>
|
||||||
} @else {
|
} @else {
|
||||||
@ -10,8 +10,9 @@
|
|||||||
<span class="badge bg-primary ms-2">{{ totalSuggestions }}</span>
|
<span class="badge bg-primary ms-2">{{ totalSuggestions }}</span>
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
<div class="btn-group" ngbDropdown #dropdown="ngbDropdown" [popperOptions]="popperOptions">
|
|
||||||
|
|
||||||
|
@if (aiEnabled) {
|
||||||
|
<div class="btn-group" ngbDropdown #dropdown="ngbDropdown" [popperOptions]="popperOptions">
|
||||||
<button type="button" class="btn btn-sm btn-outline-primary" ngbDropdownToggle [disabled]="loading || !suggestions" aria-expanded="false" aria-controls="suggestionsDropdown" aria-label="Suggestions dropdown">
|
<button type="button" class="btn btn-sm btn-outline-primary" ngbDropdownToggle [disabled]="loading || !suggestions" aria-expanded="false" aria-controls="suggestionsDropdown" aria-label="Suggestions dropdown">
|
||||||
<span class="visually-hidden" i18n>Show suggestions</span>
|
<span class="visually-hidden" i18n>Show suggestions</span>
|
||||||
</button>
|
</button>
|
||||||
@ -23,19 +24,19 @@
|
|||||||
<small class="text-muted small fst-italic" i18n>No novel suggestions</small>
|
<small class="text-muted small fst-italic" i18n>No novel suggestions</small>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (suggestions?.suggested_tags?.length > 0) {
|
@if (suggestions?.suggested_tags.length > 0) {
|
||||||
<small class="list-group-item text-uppercase text-muted small">Tags</small>
|
<small class="list-group-item text-uppercase text-muted small">Tags</small>
|
||||||
@for (tag of suggestions.suggested_tags; track tag) {
|
@for (tag of suggestions.suggested_tags; track tag) {
|
||||||
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addTag.emit(tag)" i18n>{{ tag }}</button>
|
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addTag.emit(tag)" i18n>{{ tag }}</button>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if (suggestions?.suggested_document_types?.length > 0) {
|
@if (suggestions?.suggested_document_types.length > 0) {
|
||||||
<div class="list-group-item text-uppercase text-muted small">Document Types</div>
|
<div class="list-group-item text-uppercase text-muted small">Document Types</div>
|
||||||
@for (type of suggestions.suggested_document_types; track type) {
|
@for (type of suggestions.suggested_document_types; track type) {
|
||||||
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addDocumentType.emit(type)" i18n>{{ type }}</button>
|
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addDocumentType.emit(type)" i18n>{{ type }}</button>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if (suggestions?.suggested_correspondents?.length > 0) {
|
@if (suggestions?.suggested_correspondents.length > 0) {
|
||||||
<div class="list-group-item text-uppercase text-muted small">Correspondents</div>
|
<div class="list-group-item text-uppercase text-muted small">Correspondents</div>
|
||||||
@for (correspondent of suggestions.suggested_correspondents; track correspondent) {
|
@for (correspondent of suggestions.suggested_correspondents; track correspondent) {
|
||||||
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addCorrespondent.emit(correspondent)" i18n>{{ correspondent }}</button>
|
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addCorrespondent.emit(correspondent)" i18n>{{ correspondent }}</button>
|
||||||
@ -44,4 +45,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,6 +38,8 @@ describe('SuggestionsDropdownComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should toggle dropdown when clickSuggest is called and suggestions are not null', () => {
|
it('should toggle dropdown when clickSuggest is called and suggestions are not null', () => {
|
||||||
|
component.aiEnabled = true
|
||||||
|
fixture.detectChanges()
|
||||||
component.suggestions = {
|
component.suggestions = {
|
||||||
suggested_correspondents: [],
|
suggested_correspondents: [],
|
||||||
suggested_tags: [],
|
suggested_tags: [],
|
||||||
|
@ -24,6 +24,9 @@ export class SuggestionsDropdownComponent {
|
|||||||
@Input()
|
@Input()
|
||||||
suggestions: DocumentSuggestions = null
|
suggestions: DocumentSuggestions = null
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
aiEnabled: boolean = false
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
loading: boolean = false
|
loading: boolean = false
|
||||||
|
|
||||||
@ -47,7 +50,7 @@ export class SuggestionsDropdownComponent {
|
|||||||
if (!this.suggestions) {
|
if (!this.suggestions) {
|
||||||
this.getSuggestions.emit(this)
|
this.getSuggestions.emit(this)
|
||||||
} else {
|
} else {
|
||||||
this.dropdown.toggle()
|
this.dropdown?.toggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
[disabled]="!userCanEdit || suggestionsLoading"
|
[disabled]="!userCanEdit || suggestionsLoading"
|
||||||
[loading]="suggestionsLoading"
|
[loading]="suggestionsLoading"
|
||||||
[suggestions]="suggestions"
|
[suggestions]="suggestions"
|
||||||
|
[aiEnabled]="aiEnabled"
|
||||||
(getSuggestions)="getSuggestions()"
|
(getSuggestions)="getSuggestions()"
|
||||||
(addTag)="createTag($event)"
|
(addTag)="createTag($event)"
|
||||||
(addDocumentType)="createDocumentType($event)"
|
(addDocumentType)="createDocumentType($event)"
|
||||||
|
@ -299,6 +299,10 @@ export class DocumentDetailComponent
|
|||||||
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
|
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get aiEnabled(): boolean {
|
||||||
|
return this.settings.get(SETTINGS_KEYS.AI_ENABLED)
|
||||||
|
}
|
||||||
|
|
||||||
get archiveContentRenderType(): ContentRenderType {
|
get archiveContentRenderType(): ContentRenderType {
|
||||||
return this.document?.archived_file_name
|
return this.document?.archived_file_name
|
||||||
? this.getRenderType('application/pdf')
|
? this.getRenderType('application/pdf')
|
||||||
|
@ -73,6 +73,7 @@ export const SETTINGS_KEYS = {
|
|||||||
GMAIL_OAUTH_URL: 'gmail_oauth_url',
|
GMAIL_OAUTH_URL: 'gmail_oauth_url',
|
||||||
OUTLOOK_OAUTH_URL: 'outlook_oauth_url',
|
OUTLOOK_OAUTH_URL: 'outlook_oauth_url',
|
||||||
EMAIL_ENABLED: 'email_enabled',
|
EMAIL_ENABLED: 'email_enabled',
|
||||||
|
AI_ENABLED: 'ai_enabled',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SETTINGS: UiSetting[] = [
|
export const SETTINGS: UiSetting[] = [
|
||||||
@ -276,4 +277,9 @@ export const SETTINGS: UiSetting[] = [
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'page-width', // ZoomSetting from 'document-detail.component'
|
default: 'page-width', // ZoomSetting from 'document-detail.component'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: SETTINGS_KEYS.AI_ENABLED,
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
@ -47,6 +47,7 @@ class TestApiUiSettings(DirectoriesMixin, APITestCase):
|
|||||||
"backend_setting": "default",
|
"backend_setting": "default",
|
||||||
},
|
},
|
||||||
"email_enabled": False,
|
"email_enabled": False,
|
||||||
|
"ai_enabled": False,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2220,6 +2220,7 @@ class UiSettingsView(GenericAPIView):
|
|||||||
request.session["oauth_state"] = manager.state
|
request.session["oauth_state"] = manager.state
|
||||||
|
|
||||||
ui_settings["email_enabled"] = settings.EMAIL_ENABLED
|
ui_settings["email_enabled"] = settings.EMAIL_ENABLED
|
||||||
|
ui_settings["ai_enabled"] = settings.AI_ENABLED
|
||||||
|
|
||||||
user_resp = {
|
user_resp = {
|
||||||
"id": user.id,
|
"id": user.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user