Skip to content

Commit

Permalink
EFRS-1173/BugFix displaying total number of examples that are valid a…
Browse files Browse the repository at this point in the history
…nd uploaded to the db
  • Loading branch information
smchedlidze826 committed Nov 29, 2021
1 parent 78885bc commit a7bd3be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ui/src/app/core/collection/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export class CollectionService {
.pipe(
map((resp: { faces: SubjectExampleResponseItem[] }) => {
const totalPages = resp['total_pages'];
return resp.faces.map(el => ({ ...el, page: page, totalPages: totalPages }));
const totalElements = resp['total_elements'];
return resp.faces.map(el => ({ ...el, page: page, totalPages: totalPages, totalElements: totalElements }));
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
<ng-container *ngSwitchCase="subjectModeEnum.BulkSelect"
>{{ 'manage_collection.right_side.selected_examples' | translate }} {{ selectedIds.length }}</ng-container
>
<ng-container *ngSwitchDefault
>{{ 'manage_collection.right_side.examples' | translate }} {{ uploadedExamples.length }}</ng-container
>
<ng-container *ngSwitchDefault>{{ 'manage_collection.right_side.examples' | translate }} {{ totalElements }}</ng-container>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class CollectionManagerSubjectRightComponent implements OnChanges {
prevItemCollection: CollectionItem[] = [];
subjectModeEnum = SubjectModeEnum;
uploadedExamples: CollectionItem[] = [];
totalElements: number = 0;

@Input() isPending: boolean;
@Input() isCollectionPending: boolean;
Expand Down Expand Up @@ -55,9 +56,15 @@ export class CollectionManagerSubjectRightComponent implements OnChanges {
const change = changes['collectionItems'];

if (change && change['currentValue'] !== change['previousValue']) {
const examples = this.collectionItems.filter(item => item.status === CircleLoadingProgressEnum.Uploaded);
const examples = this.collectionItems.filter(
item => item['totalElements'] === undefined && item.status === CircleLoadingProgressEnum.Uploaded
);

this.uploadedExamples = examples;
this.uploadedExamples = this.collectionItems.filter(item => item.status === CircleLoadingProgressEnum.Uploaded);

this.uploadedExamples.length && this.collectionItems[0]['totalElements']
? (this.totalElements = examples.length + this.collectionItems[0]['totalElements'])
: (this.totalElements = examples.length || 0);
}
}

Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/store/manage-collectiom/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const reducer: ActionReducer<CollectionEntityState> = createReducer(
subject: item.subject,
page: item['page'],
totalPages: item['totalPages'],
totalElements: item['totalElements'],
}));

return {
Expand All @@ -150,6 +151,7 @@ const reducer: ActionReducer<CollectionEntityState> = createReducer(
subject: item.subject,
page: item['page'],
totalPages: item['totalPages'],
totalElements: item['totalElements'],
}));

return {
Expand Down

0 comments on commit a7bd3be

Please sign in to comment.