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:
52
src-ui/src/app/services/rest/mail-account.service.ts
Normal file
52
src-ui/src/app/services/rest/mail-account.service.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { combineLatest, Observable } from 'rxjs'
|
||||
import { tap } from 'rxjs/operators'
|
||||
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MailAccountService extends AbstractPaperlessService<PaperlessMailAccount> {
|
||||
loading: boolean
|
||||
|
||||
constructor(http: HttpClient) {
|
||||
super(http, 'mail_accounts')
|
||||
this.reload()
|
||||
}
|
||||
|
||||
private reload() {
|
||||
this.loading = true
|
||||
this.listAll().subscribe((r) => {
|
||||
this.mailAccounts = r.results
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
private mailAccounts: PaperlessMailAccount[] = []
|
||||
|
||||
get allAccounts() {
|
||||
return this.mailAccounts
|
||||
}
|
||||
|
||||
create(o: PaperlessMailAccount) {
|
||||
return super.create(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
update(o: PaperlessMailAccount) {
|
||||
return super.update(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
patchMany(
|
||||
objects: PaperlessMailAccount[]
|
||||
): Observable<PaperlessMailAccount[]> {
|
||||
return combineLatest(objects.map((o) => super.patch(o))).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
}
|
||||
|
||||
delete(o: PaperlessMailAccount) {
|
||||
return super.delete(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
}
|
50
src-ui/src/app/services/rest/mail-rule.service.ts
Normal file
50
src-ui/src/app/services/rest/mail-rule.service.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { combineLatest, Observable } from 'rxjs'
|
||||
import { tap } from 'rxjs/operators'
|
||||
import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MailRuleService extends AbstractPaperlessService<PaperlessMailRule> {
|
||||
loading: boolean
|
||||
|
||||
constructor(http: HttpClient) {
|
||||
super(http, 'mail_rules')
|
||||
this.reload()
|
||||
}
|
||||
|
||||
private reload() {
|
||||
this.loading = true
|
||||
this.listAll().subscribe((r) => {
|
||||
this.mailRules = r.results
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
private mailRules: PaperlessMailRule[] = []
|
||||
|
||||
get allRules() {
|
||||
return this.mailRules
|
||||
}
|
||||
|
||||
create(o: PaperlessMailRule) {
|
||||
return super.create(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
update(o: PaperlessMailRule) {
|
||||
return super.update(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
patchMany(objects: PaperlessMailRule[]): Observable<PaperlessMailRule[]> {
|
||||
return combineLatest(objects.map((o) => super.patch(o))).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
}
|
||||
|
||||
delete(o: PaperlessMailRule) {
|
||||
return super.delete(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user