Skip to content

Commit 08c564c

Browse files
committed
Minor improvements in study page
1 parent df9155d commit 08c564c

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/app/metadata/features/study-details/study-details.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1>Study Details</h1>
2121
</div>
2222
} @else if (studyDetails.isLoading() || datasetsLoading()) {
2323
<mat-spinner class="float-left" [diameter]="24"> </mat-spinner>
24-
} @else if (studyDetails.hasValue() && datasetsRequest.hasValue()) {
24+
} @else if (studyDetails.hasValue()) {
2525
@let study = studyDetails.value();
2626
<div class="min-w-72">
2727
<div
@@ -69,9 +69,7 @@ <h3 class="flex items-center text-2xl sm:inline-flex">Datasets</h3>
6969
>
7070
<caption class="cdk-visually-hidden">
7171
Datasets belonging to study
72-
{{
73-
study.accession
74-
}}
72+
{{ study.accession }}
7573
</caption>
7674
<ng-container matColumnDef="accession">
7775
<th mat-header-cell *matHeaderCellDef class="min-w-64">

src/app/metadata/features/study-details/study-details.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { MetadataService } from '@app/metadata/services/metadata';
1818
import { ConfigService } from '@app/shared/services/config';
1919
import { NavigationTrackingService } from '@app/shared/services/navigation';
2020

21+
const MAX_DATASETS = 100;
22+
2123
/**
2224
* Component for the study page
2325
*/
@@ -41,6 +43,7 @@ export class StudyDetailsComponent implements OnInit {
4143
#location = inject(NavigationTrackingService);
4244
#study = this.#metadataService.study;
4345
#config = inject(ConfigService);
46+
#massUrl = this.#config.massUrl;
4447
#rtsUrl = this.#config.rtsUrl;
4548

4649
id = input.required<string>();
@@ -52,25 +55,22 @@ export class StudyDetailsComponent implements OnInit {
5255
/**
5356
* The list of datasets queried via mass.
5457
*/
55-
datasetsRequest = httpResource<SearchResults>(() => {
58+
#datasetsResource = httpResource<SearchResults>(() => {
5659
return (
57-
'/api/mass/search?class_name=EmbeddedDataset&filter_by=study.accession&value=' +
58-
this.id() +
59-
'&limit=100'
60+
`${this.#massUrl}/search?class_name=EmbeddedDataset` +
61+
`&filter_by=study.accession&value=${this.id()}&limit=${MAX_DATASETS}`
6062
);
6163
}).asReadonly();
6264

63-
datasets = computed(() => {
64-
if (this.datasetsRequest.hasValue()) {
65-
return this.datasetsRequest.value();
66-
} else {
67-
return { hits: [], total: 0 };
68-
}
69-
});
70-
datasetsLoading = computed(() => this.datasetsRequest.isLoading());
71-
datasetsError = computed(() => this.datasetsRequest.error());
65+
datasets = computed(() =>
66+
this.#datasetsResource.hasValue()
67+
? this.#datasetsResource.value()
68+
: { hits: [], total: 0 },
69+
);
70+
datasetsLoading = computed(() => this.#datasetsResource.isLoading());
71+
datasetsError = computed(() => this.#datasetsResource.error());
7272

73-
#updateSourceEffect = effect(() => (this.source.data = this.datasets()?.hits || []));
73+
#updateSourceEffect = effect(() => (this.source.data = this.datasets().hits));
7474

7575
/**
7676
* Called on component initialization

0 commit comments

Comments
 (0)