Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#43698] fixed loading indicator

Eric Schubert8658c80b1748
diff --git a/frontend/src/app/core/state/storage-files/storage-files.service.ts b/frontend/src/app/core/state/storage-files/storage-files.service.ts
index 10973655503..060d07339c9 100644
--- a/frontend/src/app/core/state/storage-files/storage-files.service.ts
+++ b/frontend/src/app/core/state/storage-files/storage-files.service.ts
@@ -27,7 +27,6 @@
//++
import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
@@ -43,7 +42,6 @@ import { insertCollectionIntoState } from 'core-app/core/state/collection-store'
@Injectable()
export class StorageFilesResourceService extends ResourceCollectionService<IStorageFile> {
-
protected createStore():CollectionStore<IStorageFile> {
return new StorageFilesStore();
}
diff --git a/frontend/src/app/shared/components/file-links/file-picker-modal/file-picker-modal.component.ts b/frontend/src/app/shared/components/file-links/file-picker-modal/file-picker-modal.component.ts
index e2e341ed12d..c866e4017db 100644
--- a/frontend/src/app/shared/components/file-links/file-picker-modal/file-picker-modal.component.ts
+++ b/frontend/src/app/shared/components/file-links/file-picker-modal/file-picker-modal.component.ts
@@ -35,8 +35,8 @@ import {
OnDestroy,
OnInit,
} from '@angular/core';
-import { BehaviorSubject } from 'rxjs';
-import { take } from 'rxjs/operators';
+import { BehaviorSubject, Observable } from 'rxjs';
+import { map, take } from 'rxjs/operators';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { IHalResourceLink } from 'core-app/core/state/hal-resource';
@@ -60,13 +60,13 @@ import getIconForStorageType from 'core-app/shared/components/file-links/storage
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FilePickerModalComponent extends OpModalComponent implements OnInit, OnDestroy {
- public loading$ = new BehaviorSubject<boolean>(true);
+ public breadcrumbs:BreadcrumbsContent;
- public listItems$ = new BehaviorSubject<StorageFileListItem[]>([]);
+ public listItems$:Observable<StorageFileListItem[]>;
- public breadcrumbs:BreadcrumbsContent;
+ public readonly loading$ = new BehaviorSubject<boolean>(true);
- public text = {
+ public readonly text = {
header: this.i18n.t('js.storages.file_links.select'),
buttons: {
openStorage: ():string => this.i18n.t('js.storages.open_storage', { storageType: this.locals.storageTypeName as string }),
@@ -89,7 +89,7 @@ export class FilePickerModalComponent extends OpModalComponent implements OnInit
private readonly fileMap:Record<string, IStorageFile> = {};
- private storageFiles$ = new BehaviorSubject<IStorageFile[]>([]);
+ private readonly storageFiles$ = new BehaviorSubject<IStorageFile[]>([]);
constructor(
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
@@ -112,18 +112,14 @@ export class FilePickerModalComponent extends OpModalComponent implements OnInit
navigate: () => this.changeLevel(null, this.breadcrumbs.crumbs.slice(0, 1)),
}]);
- this.storageFiles$
- .pipe(this.untilDestroyed())
- .subscribe((files) => {
- const fileListItems = files.map((file, index) => this.storageFileToListItem(file, index));
- this.listItems$.next(fileListItems);
- this.loading$.next(false);
- });
+ this.listItems$ = this.storageFiles$
+ .pipe(map((files) => files.map((file, index) => this.storageFileToListItem(file, index))));
this.storageFilesResourceService.files(this.makeFilesCollectionLink(null))
.pipe(take(1))
.subscribe((files) => {
this.storageFiles$.next(files);
+ this.loading$.next(false);
});
}
@@ -176,10 +172,13 @@ export class FilePickerModalComponent extends OpModalComponent implements OnInit
}
private changeLevel(parent:string|null, crumbs:Breadcrumb[]):void {
+ this.loading$.next(true);
+
this.storageFilesResourceService.files(this.makeFilesCollectionLink(parent))
.pipe(take(1))
.subscribe((files) => {
this.storageFiles$.next(files);
+ this.loading$.next(false);
this.breadcrumbs = new BreadcrumbsContent(crumbs);
});
}