mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Fix: saved view permissions fixes (#7672)
This commit is contained in:
		@@ -57,7 +57,7 @@ describe(`Additional service tests for SavedViewService`, () => {
 | 
			
		||||
  let settingsService
 | 
			
		||||
 | 
			
		||||
  it('should retrieve saved views and sort them', () => {
 | 
			
		||||
    service.initialize()
 | 
			
		||||
    service.reload()
 | 
			
		||||
    const req = httpTestingController.expectOne(
 | 
			
		||||
      `${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
 | 
			
		||||
    )
 | 
			
		||||
@@ -70,7 +70,7 @@ describe(`Additional service tests for SavedViewService`, () => {
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('should gracefully handle errors', () => {
 | 
			
		||||
    service.initialize()
 | 
			
		||||
    service.reload()
 | 
			
		||||
    const req = httpTestingController.expectOne(
 | 
			
		||||
      `${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@ import { SavedView } from 'src/app/data/saved-view'
 | 
			
		||||
import { AbstractPaperlessService } from './abstract-paperless-service'
 | 
			
		||||
import { SettingsService } from '../settings.service'
 | 
			
		||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
 | 
			
		||||
import { Results } from 'src/app/data/results'
 | 
			
		||||
 | 
			
		||||
@Injectable({
 | 
			
		||||
  providedIn: 'root',
 | 
			
		||||
@@ -21,22 +22,31 @@ export class SavedViewService extends AbstractPaperlessService<SavedView> {
 | 
			
		||||
    super(http, 'saved_views')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public initialize() {
 | 
			
		||||
    this.reload()
 | 
			
		||||
  public list(
 | 
			
		||||
    page?: number,
 | 
			
		||||
    pageSize?: number,
 | 
			
		||||
    sortField?: string,
 | 
			
		||||
    sortReverse?: boolean,
 | 
			
		||||
    extraParams?: any
 | 
			
		||||
  ): Observable<Results<SavedView>> {
 | 
			
		||||
    return super.list(page, pageSize, sortField, sortReverse, extraParams).pipe(
 | 
			
		||||
      tap({
 | 
			
		||||
        next: (r) => {
 | 
			
		||||
          this.savedViews = r.results
 | 
			
		||||
          this.loading = false
 | 
			
		||||
          this.settingsService.dashboardIsEmpty =
 | 
			
		||||
            this.dashboardViews.length === 0
 | 
			
		||||
        },
 | 
			
		||||
        error: () => {
 | 
			
		||||
          this.loading = false
 | 
			
		||||
          this.settingsService.dashboardIsEmpty = true
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private reload() {
 | 
			
		||||
    this.listAll().subscribe({
 | 
			
		||||
      next: (r) => {
 | 
			
		||||
        this.savedViews = r.results
 | 
			
		||||
        this.loading = false
 | 
			
		||||
        this.settingsService.dashboardIsEmpty = this.dashboardViews.length === 0
 | 
			
		||||
      },
 | 
			
		||||
      error: () => {
 | 
			
		||||
        this.loading = false
 | 
			
		||||
        this.settingsService.dashboardIsEmpty = true
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
  public reload() {
 | 
			
		||||
    this.listAll().subscribe()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get allViews() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user