mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Basic data retrieval
This commit is contained in:
@@ -216,6 +216,37 @@
|
||||
|
||||
</ng-template>
|
||||
</li>
|
||||
|
||||
<li [ngbNavItem]="4">
|
||||
<a ngbNavLink i18n>Paperless Mail</a>
|
||||
<ng-template ngbNavContent>
|
||||
|
||||
<h4 i18n>Mail accounts</h4>
|
||||
<div formGroupName="mailAccounts">
|
||||
|
||||
<div *ngFor="let account of mailAccounts" [formGroupName]="account.id" class="row">
|
||||
<div class="mb-3 col">
|
||||
{{account.name}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="mailAccounts.length == 0" i18n>No mail accounts defined.</div>
|
||||
</div>
|
||||
|
||||
<h4 i18n>Mail rules</h4>
|
||||
<div formGroupName="mailRules">
|
||||
|
||||
<div *ngFor="let rule of mailRules" [formGroupName]="rule.id" class="row">
|
||||
<div class="mb-3 col">
|
||||
{{rule.name}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="mailRules.length == 0" i18n>No mail rules defined.</div>
|
||||
</div>
|
||||
|
||||
</ng-template>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div [ngbNavOutlet]="nav" class="border-start border-end border-bottom p-3 mb-3 shadow-sm"></div>
|
||||
|
@@ -29,6 +29,10 @@ import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { ViewportScroller } from '@angular/common'
|
||||
import { TourService } from 'ngx-ui-tour-ng-bootstrap'
|
||||
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account'
|
||||
import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule'
|
||||
import { MailAccountService as MailAccountService } from 'src/app/services/rest/mail-account.service'
|
||||
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@@ -40,6 +44,9 @@ export class SettingsComponent
|
||||
{
|
||||
savedViewGroup = new FormGroup({})
|
||||
|
||||
mailAccountGroup = new FormGroup({})
|
||||
mailRuleGroup = new FormGroup({})
|
||||
|
||||
settingsForm = new FormGroup({
|
||||
bulkEditConfirmationDialogs: new FormControl(null),
|
||||
bulkEditApplyOnClose: new FormControl(null),
|
||||
@@ -50,20 +57,28 @@ export class SettingsComponent
|
||||
darkModeInvertThumbs: new FormControl(null),
|
||||
themeColor: new FormControl(null),
|
||||
useNativePdfViewer: new FormControl(null),
|
||||
savedViews: this.savedViewGroup,
|
||||
displayLanguage: new FormControl(null),
|
||||
dateLocale: new FormControl(null),
|
||||
dateFormat: new FormControl(null),
|
||||
commentsEnabled: new FormControl(null),
|
||||
updateCheckingEnabled: new FormControl(null),
|
||||
|
||||
notificationsConsumerNewDocument: new FormControl(null),
|
||||
notificationsConsumerSuccess: new FormControl(null),
|
||||
notificationsConsumerFailed: new FormControl(null),
|
||||
notificationsConsumerSuppressOnDashboard: new FormControl(null),
|
||||
commentsEnabled: new FormControl(null),
|
||||
updateCheckingEnabled: new FormControl(null),
|
||||
|
||||
savedViews: this.savedViewGroup,
|
||||
|
||||
mailAccounts: this.mailAccountGroup,
|
||||
mailRules: this.mailRuleGroup,
|
||||
})
|
||||
|
||||
savedViews: PaperlessSavedView[]
|
||||
|
||||
mailAccounts: PaperlessMailAccount[]
|
||||
mailRules: PaperlessMailRule[]
|
||||
|
||||
store: BehaviorSubject<any>
|
||||
storeSub: Subscription
|
||||
isDirty$: Observable<boolean>
|
||||
@@ -81,6 +96,8 @@ export class SettingsComponent
|
||||
|
||||
constructor(
|
||||
public savedViewService: SavedViewService,
|
||||
public mailAccountService: MailAccountService,
|
||||
public mailRuleService: MailRuleService,
|
||||
private documentListViewService: DocumentListViewService,
|
||||
private toastService: ToastService,
|
||||
private settings: SettingsService,
|
||||
@@ -123,10 +140,13 @@ export class SettingsComponent
|
||||
useNativePdfViewer: this.settings.get(
|
||||
SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER
|
||||
),
|
||||
savedViews: {},
|
||||
displayLanguage: this.settings.getLanguage(),
|
||||
dateLocale: this.settings.get(SETTINGS_KEYS.DATE_LOCALE),
|
||||
dateFormat: this.settings.get(SETTINGS_KEYS.DATE_FORMAT),
|
||||
commentsEnabled: this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED),
|
||||
updateCheckingEnabled: this.settings.get(
|
||||
SETTINGS_KEYS.UPDATE_CHECKING_ENABLED
|
||||
),
|
||||
notificationsConsumerNewDocument: this.settings.get(
|
||||
SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT
|
||||
),
|
||||
@@ -139,17 +159,25 @@ export class SettingsComponent
|
||||
notificationsConsumerSuppressOnDashboard: this.settings.get(
|
||||
SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD
|
||||
),
|
||||
commentsEnabled: this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED),
|
||||
updateCheckingEnabled: this.settings.get(
|
||||
SETTINGS_KEYS.UPDATE_CHECKING_ENABLED
|
||||
),
|
||||
savedViews: {},
|
||||
mailAccounts: {},
|
||||
mailRules: {},
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.savedViewService.listAll().subscribe((r) => {
|
||||
this.savedViews = r.results
|
||||
this.initialize()
|
||||
|
||||
this.mailAccountService.listAll().subscribe((r) => {
|
||||
this.mailAccounts = r.results
|
||||
|
||||
this.mailRuleService.listAll().subscribe((r) => {
|
||||
this.mailRules = r.results
|
||||
|
||||
this.initialize()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,6 +204,76 @@ export class SettingsComponent
|
||||
)
|
||||
}
|
||||
|
||||
for (let account of this.mailAccounts) {
|
||||
storeData.mailAccounts[account.id.toString()] = {
|
||||
id: account.id,
|
||||
name: account.name,
|
||||
imap_server: account.imap_server,
|
||||
imap_port: account.imap_port,
|
||||
imap_security: account.imap_security,
|
||||
username: account.username,
|
||||
password: account.password,
|
||||
character_set: account.character_set,
|
||||
}
|
||||
this.mailAccountGroup.addControl(
|
||||
account.id.toString(),
|
||||
new FormGroup({
|
||||
id: new FormControl(null),
|
||||
name: new FormControl(null),
|
||||
imap_server: new FormControl(null),
|
||||
imap_port: new FormControl(null),
|
||||
imap_security: new FormControl(null),
|
||||
username: new FormControl(null),
|
||||
password: new FormControl(null),
|
||||
character_set: new FormControl(null),
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
for (let rule of this.mailRules) {
|
||||
storeData.mailRules[rule.id.toString()] = {
|
||||
name: rule.name,
|
||||
order: rule.order,
|
||||
account: rule.account,
|
||||
folder: rule.folder,
|
||||
filter_from: rule.filter_from,
|
||||
filter_subject: rule.filter_subject,
|
||||
filter_body: rule.filter_body,
|
||||
filter_attachment_filename: rule.filter_attachment_filename,
|
||||
maximum_age: rule.maximum_age,
|
||||
attachment_type: rule.attachment_type,
|
||||
action: rule.action,
|
||||
action_parameter: rule.action_parameter,
|
||||
assign_title_from: rule.assign_title_from,
|
||||
assign_tags: rule.assign_tags,
|
||||
assign_document_type: rule.assign_document_type,
|
||||
assign_correspondent_from: rule.assign_correspondent_from,
|
||||
assign_correspondent: rule.assign_correspondent,
|
||||
}
|
||||
this.mailRuleGroup.addControl(
|
||||
rule.id.toString(),
|
||||
new FormGroup({
|
||||
name: new FormControl(null),
|
||||
order: new FormControl(null),
|
||||
account: new FormControl(null),
|
||||
folder: new FormControl(null),
|
||||
filter_from: new FormControl(null),
|
||||
filter_subject: new FormControl(null),
|
||||
filter_body: new FormControl(null),
|
||||
filter_attachment_filename: new FormControl(null),
|
||||
maximum_age: new FormControl(null),
|
||||
attachment_type: new FormControl(null),
|
||||
action: new FormControl(null),
|
||||
action_parameter: new FormControl(null),
|
||||
assign_title_from: new FormControl(null),
|
||||
assign_tags: new FormControl(null),
|
||||
assign_document_type: new FormControl(null),
|
||||
assign_correspondent_from: new FormControl(null),
|
||||
assign_correspondent: new FormControl(null),
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
this.store = new BehaviorSubject(storeData)
|
||||
|
||||
this.storeSub = this.store.asObservable().subscribe((state) => {
|
||||
|
Reference in New Issue
Block a user