Skip to content

Commit 85512ca

Browse files
committed
Request-a-copy: Use wrapped ItemWithSupp.. and base item comps, except download link
1 parent 3f27d51 commit 85512ca

40 files changed

Lines changed: 148 additions & 2200 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Item } from './item.model';
2+
import { ItemRequest } from './item-request.model';
3+
4+
export class ItemWithSupplementaryData extends Item {
5+
itemRequest: ItemRequest;
6+
7+
constructor(itemRequest: ItemRequest) {
8+
super();
9+
this.itemRequest = itemRequest;
10+
}
11+
}

src/app/core/shared/media-viewer-item.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ export class MediaViewerItem {
2323
* Incoming Bitsream thumbnail
2424
*/
2525
thumbnail: string;
26+
27+
/**
28+
* Access token, if accessed via a Request-a-Copy link
29+
*/
30+
accessToken: string;
2631
}

src/app/item-page/access-by-token/field-components/file-download-link/item-secure-file-download-link.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<a [routerLink]="(bitstreamPath$| async)?.routerLink" class="dont-break-out" [queryParams]="(bitstreamPath$| async)?.queryParams" [target]="isBlank ? '_blank': '_self'" [ngClass]="cssClasses">
1+
<a [routerLink]="(bitstreamPath$| async)?.routerLink" class="dont-break-out"
2+
[queryParams]="(bitstreamPath$| async)?.queryParams"
3+
[target]="isBlank ? '_blank': '_self'"
4+
[ngClass]="cssClasses"
5+
[attr.aria-label]="('file-download-link.download' | translate) + dsoNameService.getName(bitstream)">
26
<!-- If the user cannot download the file by auth or token, show a lock icon -->
37
<span role="img" *ngIf="(canDownload$ | async) === false && (canDownloadWithToken$ | async) === false" [attr.aria-label]="'file-download-link.restricted' | translate" class="pr-1"><i class="fas fa-lock"></i></span>
48
<!-- If the user can download the file by token, and NOT normally show a lock open icon -->

src/app/item-page/access-by-token/field-components/file-download-link/item-secure-file-download-link.component.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import {
2323
getBitstreamDownloadWithAccessTokenRoute,
2424
getBitstreamRequestACopyRoute,
2525
} from '../../../../app-routing-paths';
26+
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
2627
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
2728
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
2829
import { Bitstream } from '../../../../core/shared/bitstream.model';
2930
import { Item } from '../../../../core/shared/item.model';
3031
import { ItemRequest } from '../../../../core/shared/item-request.model';
32+
import { ItemWithSupplementaryData } from '../../../../core/shared/item-with-supplementary-data.model';
3133
import {
3234
hasValue,
3335
isNotEmpty,
@@ -54,6 +56,9 @@ export class ItemSecureFileDownloadLinkComponent implements OnInit {
5456
*/
5557
@Input() bitstream: Bitstream;
5658

59+
/**
60+
* Item that owns the linked bitstream
61+
*/
5762
@Input() item: Item;
5863

5964
/**
@@ -66,15 +71,14 @@ export class ItemSecureFileDownloadLinkComponent implements OnInit {
6671
*/
6772
@Input() isBlank = false;
6873

69-
@Input() itemRequest: ItemRequest;
70-
7174
@Input() enableRequestACopy = true;
7275

7376
bitstreamPath$: Observable<{
7477
routerLink: string,
7578
queryParams: any,
7679
}>;
77-
80+
// ItemRequest object with access token, expiry, etc.
81+
itemRequest: ItemRequest;
7882
// authorized to download normally
7983
canDownload$: Observable<boolean>;
8084
// authorized to download with token
@@ -84,6 +88,7 @@ export class ItemSecureFileDownloadLinkComponent implements OnInit {
8488

8589
constructor(
8690
private authorizationService: AuthorizationDataService,
91+
protected dsoNameService: DSONameService,
8792
) {
8893
}
8994

@@ -92,6 +97,9 @@ export class ItemSecureFileDownloadLinkComponent implements OnInit {
9297
* (for a given bitstream), and ability to request a copy of a bitstream.
9398
*/
9499
ngOnInit() {
100+
if (this.item instanceof ItemWithSupplementaryData) {
101+
this.itemRequest = this.item.itemRequest;
102+
}
95103
this.canDownload$ = this.authorizationService.isAuthorized(FeatureID.CanDownload, isNotEmpty(this.bitstream) ? this.bitstream.self : undefined);
96104
this.canDownloadWithToken$ = observableOf(this.itemRequest ? (this.itemRequest.allfiles !== false || this.itemRequest.bitstreamId === this.bitstream.uuid) : false);
97105
this.canRequestACopy$ = this.authorizationService.isAuthorized(FeatureID.CanRequestACopy, isNotEmpty(this.bitstream) ? this.bitstream.self : undefined);

src/app/item-page/access-by-token/field-components/file-section/item-secure-file-section.component.html

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/app/item-page/access-by-token/field-components/file-section/item-secure-file-section.component.scss

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/app/item-page/access-by-token/field-components/file-section/item-secure-file-section.component.spec.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)