diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/table-item.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/table-item.component.html index 9bf026261..1954fb5ec 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/table-item.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/table-item.component.html @@ -11,7 +11,8 @@ - + +
@@ -58,11 +59,11 @@
; @Input() @Required() displayedAttributes!: IFileAttributeConfig[]; @Output() readonly calculateData = new EventEmitter(); } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.html index 072d80130..6148644a7 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.html @@ -5,7 +5,7 @@ {{ file.filename }} - +
diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.ts index ace8c60da..5fcbfd743 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/workflow-item/workflow-item.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, TemplateRef } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { File } from '@red/domain'; @Component({ @@ -9,6 +9,5 @@ import { File } from '@red/domain'; }) export class WorkflowItemComponent { @Input() file: File; - @Input() statsTemplate: TemplateRef; @Output() readonly actionPerformed = new EventEmitter(); } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html index 6bab6e9c4..767c52023 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.html @@ -90,10 +90,7 @@ - + @@ -129,18 +126,9 @@ (calculateData)="actionPerformed($event)" [displayedAttributes]="displayedAttributes" [file]="file" - [statsTemplate]="statsTemplate" > - - - - - + diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.ts index 7ca4a474a..4cde9f181 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/screen/dossier-overview-screen.component.ts @@ -1,6 +1,5 @@ import { ChangeDetectionStrategy, - ChangeDetectorRef, Component, ElementRef, forwardRef, @@ -20,7 +19,7 @@ import { StatusOverlayService } from '@upload-download/services/status-overlay.s import * as moment from 'moment'; import { UserService } from '@services/user.service'; import { Observable, timer } from 'rxjs'; -import { take, tap, withLatestFrom } from 'rxjs/operators'; +import { switchMap, take, tap, withLatestFrom } from 'rxjs/operators'; import { convertFiles, Files, handleFileDrop } from '@utils/index'; import { DossiersDialogService } from '../../../services/dossiers-dialog.service'; import { @@ -51,7 +50,6 @@ import { DossierTemplatesService } from '@services/entity-services/dossier-templ import { LongPressEvent } from '@shared/directives/long-press.directive'; import { UserPreferenceService } from '@services/user-preference.service'; import { saveAsCSV } from '@utils/csv-utils'; -import { FilesService } from '@services/entity-services/files.service'; import { FilesMapService } from '@services/entity-services/files-map.service'; import { ReanalysisService } from '@services/reanalysis.service'; import { DossierStatsService } from '@services/entity-services/dossier-stats.service'; @@ -99,7 +97,6 @@ export class DossierOverviewScreenComponent extends ListingComponent imple readonly routerHistoryService: RouterHistoryService, private readonly _appConfigService: AppConfigService, private readonly _dialogService: DossiersDialogService, - private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _fileUploadService: FileUploadService, private readonly _statusOverlayService: StatusOverlayService, private readonly _fileDropOverlayService: FileDropOverlayService, @@ -107,7 +104,6 @@ export class DossierOverviewScreenComponent extends ListingComponent imple private readonly _fileAttributesService: FileAttributesService, private readonly _configService: ConfigService, private readonly _userPreferenceService: UserPreferenceService, - private readonly _filesService: FilesService, private readonly _fileMapService: FilesMapService, private readonly _dossierStatsService: DossierStatsService, activatedRoute: ActivatedRoute, @@ -165,35 +161,35 @@ export class DossierOverviewScreenComponent extends ListingComponent imple .pipe(tap(files => this.entitiesService.setEntities(files))) .subscribe(); + this._fileDropOverlayService.initFileDropHandling(); + + await this.calculateData(); + + this.addSubscription = timer(0, 20 * 1000) + .pipe(switchMap(() => this.reloadFiles())) + .subscribe(); + + this.addSubscription = this.listingMode$.subscribe(() => { + this._computeAllFilters(); + }); + + this.addSubscription = this._dossierTemplatesService.entityChanged$.subscribe(() => { + this.fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig( + this.currentDossier.dossierTemplateId, + )?.fileAttributeConfigs; + }); + + this.addSubscription = this._tableComponent.scrollViewport.scrolledIndexChange + .pipe(tap(index => (this._lastScrolledIndex = index))) + .subscribe(); + try { - this._fileDropOverlayService.initFileDropHandling(); - - await this.calculateData(); - - this.addSubscription = timer(0, 20 * 1000).subscribe(async () => { - await this.reloadFiles(); - }); - - this.addSubscription = this.listingMode$.subscribe(() => { - this._computeAllFilters(); - }); - - this.addSubscription = this._dossierTemplatesService.entityChanged$.subscribe(() => { - this.fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig( - this.currentDossier.dossierTemplateId, - )?.fileAttributeConfigs; - }); - - this.addSubscription = this._tableComponent.scrollViewport.scrolledIndexChange - .pipe(tap(index => (this._lastScrolledIndex = index))) - .subscribe(); - this.dossierAttributes = await this._dossierAttributesService.getWithValues(this.currentDossier); } catch (e) { console.log('Error from dossier overview screen: ', e); - } finally { - this._loadingService.stop(); } + + this._loadingService.stop(); } ngOnDestroy(): void { @@ -202,8 +198,6 @@ export class DossierOverviewScreenComponent extends ListingComponent imple } async ngOnAttach() { - // await this._appStateService.reloadActiveDossierFiles(); - // await this._loadEntitiesFromState(); await this.ngOnInit(); this._tableComponent.scrollViewport.scrollToIndex(this._lastScrolledIndex, 'smooth'); } @@ -230,14 +224,12 @@ export class DossierOverviewScreenComponent extends ListingComponent imple const files = await this._appStateService.getFiles(this.currentDossier); await this._dossierStatsService.getFor([this.dossierId]).toPromise(); this.entitiesService.setEntities(files); - await this.calculateData(); + this._computeAllFilters(); } async calculateData(): Promise { await this._loadEntitiesFromState(); this._computeAllFilters(); - - this._changeDetectorRef.markForCheck(); } @HostListener('drop', ['$event']) @@ -286,13 +278,11 @@ export class DossierOverviewScreenComponent extends ListingComponent imple this._fileInput.nativeElement.value = null; } - async bulkActionPerformed(): Promise { - await this.reloadFiles(); - } - openAssignDossierMembersDialog(): void { const data = { dossierId: this.dossierId, section: 'members' }; - this._dialogService.openDialog('editDossier', null, data, async () => this.reloadFiles()); + this._dialogService.openDialog('editDossier', null, data, async () => { + await this.reloadFiles(); + }); } openDossierDictionaryDialog() { diff --git a/apps/red-ui/src/app/services/entity-services/dossier-stats.service.ts b/apps/red-ui/src/app/services/entity-services/dossier-stats.service.ts index 9e64ebf61..aeb845a64 100644 --- a/apps/red-ui/src/app/services/entity-services/dossier-stats.service.ts +++ b/apps/red-ui/src/app/services/entity-services/dossier-stats.service.ts @@ -33,7 +33,11 @@ export class DossierStatsService { set(stats: DossierStats): void { if (!this._map.has(stats.dossierId)) { this._map.set(stats.dossierId, new BehaviorSubject(stats)); - } else { + return; + } + + const old = this.get(stats.dossierId); + if (JSON.stringify(old) !== JSON.stringify(stats)) { this._map.get(stats.dossierId).next(stats); } }