mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-12 21:35:40 -05:00
@@ -1,22 +1,21 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service';
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { combineLatest, Observable } from 'rxjs'
|
||||
import { tap } from 'rxjs/operators'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SavedViewService extends AbstractPaperlessService<PaperlessSavedView> {
|
||||
|
||||
constructor(http: HttpClient) {
|
||||
super(http, 'saved_views')
|
||||
this.reload()
|
||||
}
|
||||
|
||||
private reload() {
|
||||
this.listAll().subscribe(r => this.savedViews = r.results)
|
||||
this.listAll().subscribe((r) => (this.savedViews = r.results))
|
||||
}
|
||||
|
||||
private savedViews: PaperlessSavedView[] = []
|
||||
@@ -26,34 +25,28 @@ export class SavedViewService extends AbstractPaperlessService<PaperlessSavedVie
|
||||
}
|
||||
|
||||
get sidebarViews() {
|
||||
return this.savedViews.filter(v => v.show_in_sidebar)
|
||||
return this.savedViews.filter((v) => v.show_in_sidebar)
|
||||
}
|
||||
|
||||
get dashboardViews() {
|
||||
return this.savedViews.filter(v => v.show_on_dashboard)
|
||||
return this.savedViews.filter((v) => v.show_on_dashboard)
|
||||
}
|
||||
|
||||
create(o: PaperlessSavedView) {
|
||||
return super.create(o).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
return super.create(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
update(o: PaperlessSavedView) {
|
||||
return super.update(o).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
return super.update(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
|
||||
patchMany(objects: PaperlessSavedView[]): Observable<PaperlessSavedView[]> {
|
||||
return combineLatest(objects.map(o => super.patch(o))).pipe(
|
||||
return combineLatest(objects.map((o) => super.patch(o))).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
}
|
||||
|
||||
delete(o: PaperlessSavedView) {
|
||||
return super.delete(o).pipe(
|
||||
tap(() => this.reload())
|
||||
)
|
||||
return super.delete(o).pipe(tap(() => this.reload()))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user