Skip to content

Commit 4f72074

Browse files
[DURACOM-455] add advanced attachment
1 parent 64e866e commit 4f72074

34 files changed

Lines changed: 815 additions & 69 deletions

config/config.example.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,22 @@ identifierSubtypes:
730730
iconPosition: IdentifierSubtypesIconPositionEnum.LEFT
731731
link: https://ror.org
732732

733+
# Configuration for advanced attachment rendering. Controls how bitstream attachments and their metadata are displayed.
734+
advancedAttachmentRendering:
735+
# Pagination settings for attachment lists
736+
pagination:
737+
enabled: true
738+
elementsPerPage: 2
739+
# Metadata and attributes to display for each attachment. Use 'metadata' type for DSpace metadata fields, 'attribute' for bitstream properties (size, format, checksum).
740+
metadata:
741+
- name: dc.title
742+
type: metadata
743+
truncatable: false
744+
- name: dc.description
745+
type: metadata
746+
truncatable: true
747+
- name: size
748+
type: attribute
749+
- name: format
750+
type: attribute
751+

src/app/core/shared/bitstream.model.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const BITSTREAM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig<Bitstream>[] = [
3434
followLink('format'),
3535
];
3636

37+
export interface ChecksumInfo {
38+
checkSumAlgorithm: string;
39+
value: string;
40+
}
41+
3742
@typedObject
3843
@inheritSerialization(DSpaceObject)
3944
export class Bitstream extends DSpaceObject implements ChildHALResource {
@@ -51,6 +56,12 @@ export class Bitstream extends DSpaceObject implements ChildHALResource {
5156
@autoserialize
5257
description: string;
5358

59+
/**
60+
* The checksum information of this Bitstream
61+
*/
62+
@autoserialize
63+
checkSum: ChecksumInfo;
64+
5465
/**
5566
* The name of the Bundle this Bitstream is part of
5667
*/

src/app/item-page/full/field-components/file-section/full-file-section.component.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ <h3 class="h5 simple-view-element-header">
4040
</dl>
4141
</div>
4242
<div class="col-2">
43-
@if (showLinkAsButton) {
44-
<ds-file-download-button [bitstream]="file" [item]="item"></ds-file-download-button>
45-
} @else {
46-
<ds-file-download-link [showIcon]="true" [bitstream]="file" [item]="item" cssClasses="btn btn-outline-primary btn-download">
43+
<ds-file-download-link [showIcon]="true" [bitstream]="file" [item]="item" cssClasses="btn btn-outline-primary btn-download">
4744
<span class="d-none d-md-inline">
4845
{{ "item.page.filesection.download" | translate }}
4946
</span>
50-
</ds-file-download-link>
51-
}
52-
47+
</ds-file-download-link>
5348
</div>
5449
</div>
5550
}
@@ -97,15 +92,11 @@ <h3 class="h5 simple-view-element-header">
9792
</dl>
9893
</div>
9994
<div class="col-2">
100-
@if (showLinkAsButton) {
101-
<ds-file-download-button [bitstream]="file" [item]="item"></ds-file-download-button>
102-
} @else {
103-
<ds-file-download-link [showIcon]="true" [bitstream]="file" [item]="item" cssClasses="btn btn-outline-primary btn-download">
95+
<ds-file-download-link [showIcon]="true" [bitstream]="file" [item]="item" cssClasses="btn btn-outline-primary btn-download">
10496
<span class="d-none d-md-inline">
10597
{{ "item.page.filesection.download" | translate }}
10698
</span>
107-
</ds-file-download-link>
108-
}
99+
</ds-file-download-link>
109100
</div>
110101
</div>
111102
}

src/app/item-page/full/field-components/file-section/full-file-section.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
tap,
3535
} from 'rxjs/operators';
3636

37-
import { FileDownloadButtonComponent } from '../../../../shared/file-download-button/file-download-button.component';
3837
import { ThemedFileDownloadLinkComponent } from '../../../../shared/file-download-link/themed-file-download-link.component';
3938
import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field-wrapper/metadata-field-wrapper.component';
4039
import { PaginationComponent } from '../../../../shared/pagination/pagination.component';
@@ -54,7 +53,6 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
5453
templateUrl: './full-file-section.component.html',
5554
imports: [
5655
AsyncPipe,
57-
FileDownloadButtonComponent,
5856
FileSizePipe,
5957
MetadataFieldWrapperComponent,
6058
PaginationComponent,

src/app/item-page/simple/field-components/file-section/file-section.component.html

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,11 @@
1919
<span [innerHTML]="separator"></span>
2020
}
2121
</ng-template>
22-
23-
@if (showLinkAsButton) {
24-
<ds-file-download-button
25-
[bitstream]="file"
26-
[item]="item">
27-
<ng-container *ngTemplateOutlet="fileContent"></ng-container>
28-
</ds-file-download-button>
29-
} @else {
30-
<ds-file-download-link
31-
[bitstream]="file"
32-
[item]="item">
33-
<ng-container *ngTemplateOutlet="fileContent"></ng-container>
34-
</ds-file-download-link>
35-
}
36-
22+
<ds-file-download-link
23+
[bitstream]="file"
24+
[item]="item">
25+
<ng-container *ngTemplateOutlet="fileContent"></ng-container>
26+
</ds-file-download-link>
3727
}
3828
@if (isLoading) {
3929
<ds-loading message="{{'loading.default' | translate}}" [showMessage]="false"></ds-loading>

src/app/item-page/simple/field-components/file-section/file-section.component.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import { PaginatedList } from '@dspace/core/data/paginated-list.model';
1515
import { RemoteData } from '@dspace/core/data/remote-data';
1616
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
1717
import { Bitstream } from '@dspace/core/shared/bitstream.model';
18-
import { followLink } from '@dspace/core/shared/follow-link-config.model';
18+
import {
19+
followLink,
20+
FollowLinkConfig,
21+
} from '@dspace/core/shared/follow-link-config.model';
22+
import { HALResource } from '@dspace/core/shared/hal-resource.model';
1923
import { Item } from '@dspace/core/shared/item.model';
2024
import { getFirstCompletedRemoteData } from '@dspace/core/shared/operators';
2125
import { hasValue } from '@dspace/shared/utils/empty.util';
@@ -25,7 +29,6 @@ import {
2529
} from '@ngx-translate/core';
2630
import { BehaviorSubject } from 'rxjs';
2731

28-
import { FileDownloadButtonComponent } from '../../../../shared/file-download-button/file-download-button.component';
2932
import { ThemedFileDownloadLinkComponent } from '../../../../shared/file-download-link/themed-file-download-link.component';
3033
import { ThemedLoadingComponent } from '../../../../shared/loading/themed-loading.component';
3134
import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field-wrapper/metadata-field-wrapper.component';
@@ -41,7 +44,6 @@ import { VarDirective } from '../../../../shared/utils/var.directive';
4144
templateUrl: './file-section.component.html',
4245
imports: [
4346
CommonModule,
44-
FileDownloadButtonComponent,
4547
FileSizePipe,
4648
MetadataFieldWrapperComponent,
4749
ThemedFileDownloadLinkComponent,
@@ -70,7 +72,7 @@ export class FileSectionComponent implements OnInit {
7072

7173
primaryBitstreamId: string;
7274

73-
showLinkAsButton: boolean;
75+
showDownloadLinkAsAttachment: boolean;
7476

7577
constructor(
7678
protected bitstreamDataService: BitstreamDataService,
@@ -80,7 +82,7 @@ export class FileSectionComponent implements OnInit {
8082
@Inject(APP_CONFIG) protected appConfig: AppConfig,
8183
) {
8284
this.pageSize = this.appConfig.item.bitstream.pageSize;
83-
this.showLinkAsButton = this.appConfig.layout.showDownloadLinkAsButton;
85+
this.showDownloadLinkAsAttachment = this.appConfig.layout.showDownloadLinkAsAttachment;
8486
}
8587

8688
ngOnInit(): void {
@@ -111,10 +113,20 @@ export class FileSectionComponent implements OnInit {
111113
} else {
112114
this.currentPage++;
113115
}
116+
const followLinks: FollowLinkConfig<HALResource>[] = [
117+
followLink('accessStatus'),
118+
];
119+
120+
if (this.showDownloadLinkAsAttachment) {
121+
followLinks.push(
122+
...[followLink('thumbnail'), followLink('format')],
123+
);
124+
}
125+
114126
this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL', {
115127
currentPage: this.currentPage,
116128
elementsPerPage: this.pageSize,
117-
}, true, true, followLink('accessStatus')).pipe(
129+
}, true, true, ...followLinks).pipe(
118130
getFirstCompletedRemoteData(),
119131
).subscribe((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {
120132
if (bitstreamsRD.errorMessage) {

src/app/item-page/simple/item-types/publication/publication.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<ds-media-viewer [item]="object"></ds-media-viewer>
3030
</div>
3131
}
32-
<ds-item-page-file-section [item]="object"></ds-item-page-file-section>
32+
@if (showDownloadLinkAsAttachment !== true) {
33+
<ds-item-page-file-section [item]="object"></ds-item-page-file-section>
34+
}
3335
<ds-item-page-date-field [item]="object"></ds-item-page-date-field>
3436
<ds-metadata-representation-list class="ds-item-page-mixed-author-field"
3537
[parentItem]="object"
@@ -55,6 +57,9 @@
5557
</ds-generic-item-page-field>
5658
</div>
5759
<div class="col-12 col-md-7">
60+
@if (showDownloadLinkAsAttachment) {
61+
<ds-item-page-attachment-section [item]="object"></ds-item-page-attachment-section>
62+
}
5863
<ds-related-items
5964
[parentItem]="object"
6065
[relationType]="'isProjectOfPublication'"

src/app/item-page/simple/item-types/publication/publication.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RouterLink } from '@angular/router';
77
import { ViewMode } from '@dspace/core/shared/view-mode.model';
88
import { TranslateModule } from '@ngx-translate/core';
99

10+
import { AttachmentSectionComponent } from '../../../../shared/bitstream-attachment/section/attachment-section.component';
1011
import { DsoEditMenuComponent } from '../../../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
1112
import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field-wrapper/metadata-field-wrapper.component';
1213
import { listableObjectComponent } from '../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
@@ -38,6 +39,7 @@ import { ItemComponent } from '../shared/item.component';
3839
changeDetection: ChangeDetectionStrategy.OnPush,
3940
imports: [
4041
AsyncPipe,
42+
AttachmentSectionComponent,
4143
CollectionsComponent,
4244
DsoEditMenuComponent,
4345
GenericItemPageFieldComponent,

src/app/item-page/simple/item-types/shared/item.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ export class ItemComponent implements OnInit {
7979
*/
8080
geospatialItemPageFieldsEnabled = false;
8181

82+
showDownloadLinkAsAttachment: boolean;
83+
8284
constructor(protected routeService: RouteService,
8385
protected router: Router) {
8486
this.mediaViewer = environment.mediaViewer;
8587
this.geospatialItemPageFieldsEnabled = environment.geospatialMapViewer.enableItemPageFields;
88+
this.showDownloadLinkAsAttachment = environment.layout.showDownloadLinkAsAttachment;
8689
}
8790

8891
/**

src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
<ds-media-viewer [item]="object"></ds-media-viewer>
3131
</div>
3232
}
33-
<ds-item-page-file-section [item]="object"></ds-item-page-file-section>
33+
@if (showDownloadLinkAsAttachment) {
34+
<ds-item-page-file-section [item]="object"></ds-item-page-file-section>
35+
}
3436
<ds-item-page-date-field [item]="object"></ds-item-page-date-field>
3537
<ds-metadata-representation-list class="ds-item-page-mixed-author-field"
3638
[parentItem]="object"
@@ -56,6 +58,9 @@
5658
</ds-generic-item-page-field>
5759
</div>
5860
<div class="col-12 col-md-6">
61+
@if (showDownloadLinkAsAttachment) {
62+
<ds-item-page-attachment-section [item]="object"></ds-item-page-attachment-section>
63+
}
5964
<ds-item-page-abstract-field [item]="object"></ds-item-page-abstract-field>
6065
<ds-generic-item-page-field [item]="object"
6166
[fields]="['dc.description']"

0 commit comments

Comments
 (0)