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

Integrated Akita store for Storage file service

Andreas Pfohl924d13fa1bd8
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 0c486a65538..fd1c4d67c30 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
@@ -35,6 +35,10 @@ import {
import { StorageFilesStore } from 'core-app/core/state/storage-files/storage-files.store';
import { Observable, of } from 'rxjs';
import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.model';
+import { IHalResourceLink } from 'core-app/core/state/hal-resource';
+import { insertCollectionIntoState } from 'core-app/core/state/collection-store';
+import { map } from 'rxjs/operators';
+import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
@Injectable()
export class StorageFilesResourceService extends ResourceCollectionService<IStorageFile> {
@@ -46,7 +50,20 @@ export class StorageFilesResourceService extends ResourceCollectionService<IStor
return new StorageFilesStore();
}
- public getMockData():Observable<IStorageFile[]> {
+ // fetch(link:IHalResourceLink):void {
+ fetch():void {
+ // this.http
+ // .get<[IStorageFile]>(link.href)
+ this.mockedFileList()
+ .pipe(map((fileList) => ({ _embedded: { elements: fileList } } as unknown as IHALCollection<IStorageFile>)))
+ .subscribe((fileList) => insertCollectionIntoState(this.store, fileList, 'root'));
+ }
+
+ files():Observable<IStorageFile[]> {
+ return this.collection('root');
+ }
+
+ private mockedFileList():Observable<IStorageFile[]> {
return of([
{
id: 1,
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 98f3d4a655d..aef85d05a0e 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
@@ -80,8 +80,9 @@ export class FilePickerModalComponent extends OpModalComponent implements OnInit
ngOnInit():void {
super.ngOnInit();
+ this.storageFilesResourceService.fetch();
- this.storageFiles$ = this.storageFilesResourceService.getMockData();
+ this.storageFiles$ = this.storageFilesResourceService.files();
this.storageFiles$.subscribe(() => {
this.loading$.next(false);