Skip to content

Commit 29ab4b9

Browse files
committed
specify needed columns to extract for registation/preprint/project csv tsv downloading for /institutions/cos/dashboard/
1 parent 86f9043 commit 29ab4b9

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

src/app/features/admin-institutions/helpers/download-url.helper.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { DOWNLOAD_FORMATS } from '../constants';
22
import { DownloadType } from '../enums';
33

4-
export function downloadResults(downloadUrl: string | null, type: DownloadType) {
4+
export function downloadResults(
5+
downloadUrl: string | null,
6+
type: DownloadType,
7+
fields: string[],
8+
resourceType: string
9+
) {
510
if (!downloadUrl) {
611
return;
712
}
@@ -12,7 +17,11 @@ export function downloadResults(downloadUrl: string | null, type: DownloadType)
1217
cardSearchUrl.searchParams.set('page[size]', '10000');
1318
cardSearchUrl.searchParams.set('page[cursor]', '');
1419
cardSearchUrl.searchParams.set('acceptMediatype', format);
15-
cardSearchUrl.searchParams.set('withFileName', `projects-search-results`);
20+
cardSearchUrl.searchParams.set('withFileName', `${resourceType.toLowerCase()}s-search-results`);
21+
22+
if (type === DownloadType.CSV || type === DownloadType.TSV) {
23+
cardSearchUrl.searchParams.set(`fields[${resourceType}]`, fields.join(','));
24+
}
1625

1726
const downloadLink = cardSearchUrl.toString();
1827
window.open(downloadLink, '_blank');

src/app/features/admin-institutions/pages/institutions-preprints/institutions-preprints.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ export class InstitutionsPreprintsComponent implements OnInit, OnDestroy {
105105
}
106106

107107
download(type: DownloadType) {
108-
downloadResults(this.selfLink(), type);
108+
const fields = [
109+
'title',
110+
'dateCreated',
111+
'dateModified',
112+
'sameAs',
113+
'rights.name',
114+
'creator.name',
115+
'usage.viewCount',
116+
'usage.downloadCount',
117+
];
118+
const resourceType = 'Preprint';
119+
downloadResults(this.selfLink(), type, fields, resourceType);
109120
}
110121
}

src/app/features/admin-institutions/pages/institutions-projects/institutions-projects.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,22 @@ export class InstitutionsProjectsComponent implements OnInit, OnDestroy {
128128
}
129129

130130
download(type: DownloadType) {
131-
downloadResults(this.selfLink(), type);
131+
const fields = [
132+
'title',
133+
'dateCreated',
134+
'dateModified',
135+
'sameAs',
136+
'storageRegion.prefLabel',
137+
'storageByteCount',
138+
'creator.name',
139+
'usage.viewCount',
140+
'resourceNature.displayLabel',
141+
'rights.name',
142+
'hasOsfAddon.prefLabel',
143+
'funder.name',
144+
];
145+
const resourceType = 'Project';
146+
downloadResults(this.selfLink(), type, fields, resourceType);
132147
}
133148

134149
onIconClick(event: TableIconClickEvent): void {

src/app/features/admin-institutions/pages/institutions-registrations/institutions-registrations.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ export class InstitutionsRegistrationsComponent implements OnInit, OnDestroy {
106106
}
107107

108108
download(type: DownloadType) {
109-
downloadResults(this.selfLink(), type);
109+
const fields = [
110+
'title',
111+
'dateCreated',
112+
'dateModified',
113+
'sameAs',
114+
'storageRegion.prefLabel',
115+
'storageByteCount',
116+
'creator.name',
117+
'usage.viewCount',
118+
'resourceNature.displayLabel',
119+
'rights.name',
120+
'funder.name',
121+
'conformsTo.title',
122+
];
123+
const resourceType = 'Registration';
124+
downloadResults(this.selfLink(), type, fields, resourceType);
110125
}
111126
}

0 commit comments

Comments
 (0)