]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fixhancement: display loading status for tags instead of 'Private' (#11140)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 23 Oct 2025 01:01:50 +0000 (18:01 -0700)
committerGitHub <noreply@github.com>
Thu, 23 Oct 2025 01:01:50 +0000 (18:01 -0700)
src-ui/src/app/components/common/tag/tag.component.html
src-ui/src/app/components/common/tag/tag.component.ts
src-ui/src/app/services/rest/abstract-paperless-service.ts
src-ui/src/app/services/rest/mail-account.service.ts
src-ui/src/app/services/rest/mail-rule.service.ts
src-ui/src/app/services/rest/saved-view.service.ts
src-ui/src/app/services/rest/workflow.service.ts

index ce2175eae52e423cdde25510b5f2a3e4dbb1abdc..ebf32d0b596f199c95a9a2d9c8d4e61073950f95 100644 (file)
@@ -9,6 +9,12 @@
   @if (clickable) {
     <a [title]="linkTitle" class="badge" [style.background]="tag.color" [style.color]="tag.text_color">{{tag.name}}</a>
   }
+} @else if (loading) {
+  <span class="placeholder-glow">
+    <span class="placeholder badge private">
+      <span class="text-dark">Loading...</span>
+    </span>
+  </span>
 } @else {
   @if (!clickable) {
     <span class="badge private" i18n>Private</span>
index c2f97f2a8f005850dd99ce062d2290938e1d1a38..35fd80a002f84e74f303cd2575f8c3b0173183a6 100644 (file)
@@ -53,4 +53,8 @@ export class TagComponent {
 
   @Input()
   showParents: boolean = false
+
+  public get loading(): boolean {
+    return this.tagService.loading
+  }
 }
index 34e2c8aeaddb86df9c5ff60f065041a709fb7801..60f91eb5faf6be6c051ddec070dff4f1a71bf127 100644 (file)
@@ -1,7 +1,7 @@
 import { HttpClient, HttpParams } from '@angular/common/http'
 import { inject, Injectable } from '@angular/core'
 import { Observable } from 'rxjs'
-import { map, publishReplay, refCount } from 'rxjs/operators'
+import { map, publishReplay, refCount, tap } from 'rxjs/operators'
 import { ObjectWithId } from 'src/app/data/object-with-id'
 import { Results } from 'src/app/data/results'
 import { environment } from 'src/environments/environment'
@@ -13,6 +13,11 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
   protected http: HttpClient
   protected resourceName: string
 
+  protected _loading: boolean = false
+  public get loading(): boolean {
+    return this._loading
+  }
+
   constructor() {
     this.http = inject(HttpClient)
   }
@@ -43,6 +48,7 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
     sortReverse?: boolean,
     extraParams?
   ): Observable<Results<T>> {
+    this._loading = true
     let httpParams = new HttpParams()
     if (page) {
       httpParams = httpParams.set('page', page.toString())
@@ -59,9 +65,15 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
         httpParams = httpParams.set(extraParamKey, extraParams[extraParamKey])
       }
     }
-    return this.http.get<Results<T>>(this.getResourceUrl(), {
-      params: httpParams,
-    })
+    return this.http
+      .get<Results<T>>(this.getResourceUrl(), {
+        params: httpParams,
+      })
+      .pipe(
+        tap(() => {
+          this._loading = false
+        })
+      )
   }
 
   private _listAll: Observable<Results<T>>
@@ -96,6 +108,7 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
   }
 
   getFew(ids: number[], extraParams?): Observable<Results<T>> {
+    this._loading = true
     let httpParams = new HttpParams()
     httpParams = httpParams.set('id__in', ids.join(','))
     httpParams = httpParams.set('ordering', '-id')
@@ -105,9 +118,15 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
         httpParams = httpParams.set(extraParamKey, extraParams[extraParamKey])
       }
     }
-    return this.http.get<Results<T>>(this.getResourceUrl(), {
-      params: httpParams,
-    })
+    return this.http
+      .get<Results<T>>(this.getResourceUrl(), {
+        params: httpParams,
+      })
+      .pipe(
+        tap(() => {
+          this._loading = false
+        })
+      )
   }
 
   clearCache() {
@@ -115,7 +134,12 @@ export abstract class AbstractPaperlessService<T extends ObjectWithId> {
   }
 
   get(id: number): Observable<T> {
-    return this.http.get<T>(this.getResourceUrl(id))
+    this._loading = true
+    return this.http.get<T>(this.getResourceUrl(id)).pipe(
+      tap(() => {
+        this._loading = false
+      })
+    )
   }
 
   create(o: T): Observable<T> {
index d4511e2d6cced20b82541b936108b3515fe599c1..54f6051e256b1b5280a456962c227eaec58518c0 100644 (file)
@@ -7,18 +7,16 @@ import { AbstractPaperlessService } from './abstract-paperless-service'
   providedIn: 'root',
 })
 export class MailAccountService extends AbstractPaperlessService<MailAccount> {
-  loading: boolean
-
   constructor() {
     super()
     this.resourceName = 'mail_accounts'
   }
 
   private reload() {
-    this.loading = true
+    this._loading = true
     this.listAll().subscribe((r) => {
       this.mailAccounts = r.results
-      this.loading = false
+      this._loading = false
     })
   }
 
index bb92107a9c38980808d9be89a30eb163083e40e1..e9923e57000128797c8a42258bdc01565eaedf94 100644 (file)
@@ -7,18 +7,16 @@ import { AbstractPaperlessService } from './abstract-paperless-service'
   providedIn: 'root',
 })
 export class MailRuleService extends AbstractPaperlessService<MailRule> {
-  loading: boolean
-
   constructor() {
     super()
     this.resourceName = 'mail_rules'
   }
 
   private reload() {
-    this.loading = true
+    this._loading = true
     this.listAll().subscribe((r) => {
       this.mailRules = r.results
-      this.loading = false
+      this._loading = false
     })
   }
 
index 4ea2cef65f3436e1731130ce48959da136a7a80d..7bdb890a0c3fc46236d3f0f98077ceef6c4232f2 100644 (file)
@@ -17,7 +17,6 @@ export class SavedViewService extends AbstractPaperlessService<SavedView> {
   private settingsService = inject(SettingsService)
   private documentService = inject(DocumentService)
 
-  public loading: boolean = true
   private savedViews: SavedView[] = []
   private savedViewDocumentCounts: Map<number, number> = new Map()
   private unsubscribeNotifier: Subject<void> = new Subject<void>()
@@ -38,12 +37,12 @@ export class SavedViewService extends AbstractPaperlessService<SavedView> {
       tap({
         next: (r) => {
           this.savedViews = r.results
-          this.loading = false
+          this._loading = false
           this.settingsService.dashboardIsEmpty =
             this.dashboardViews.length === 0
         },
         error: () => {
-          this.loading = false
+          this._loading = false
           this.settingsService.dashboardIsEmpty = true
         },
       })
index ecf564f064202b87cd539f23f5bdeb64af915a5d..5c037a8e372b0346052bc7889813758e337f54f9 100644 (file)
@@ -7,18 +7,16 @@ import { AbstractPaperlessService } from './abstract-paperless-service'
   providedIn: 'root',
 })
 export class WorkflowService extends AbstractPaperlessService<Workflow> {
-  loading: boolean
-
   constructor() {
     super()
     this.resourceName = 'workflows'
   }
 
   public reload() {
-    this.loading = true
+    this._loading = true
     this.listAll().subscribe((r) => {
       this.workflows = r.results
-      this.loading = false
+      this._loading = false
     })
   }