Skip to content

Commit f2846eb

Browse files
Merge branch 'dspace-cris-2023_02_x' into DSC-983-counters-component-main
2 parents 48b8f4b + 9737ac9 commit f2846eb

6 files changed

Lines changed: 48 additions & 30 deletions

File tree

src/app/core/core.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ import {
237237
} from './metadata/schema-json-ld/schema-types/product/product-creative-work-schema-type';
238238
import { ProductDatasetSchemaType } from './metadata/schema-json-ld/schema-types/product/product-dataset-schema-type';
239239
import { PersonSchemaType } from './metadata/schema-json-ld/schema-types/Person/person-schema-type';
240+
import { InternalLinkService } from './services/internal-link.service';
240241

241242
/**
242243
* When not in production, endpoint responses can be mocked for testing purposes
@@ -270,6 +271,7 @@ const PROVIDERS = [
270271
{ provide: DspaceRestService, useFactory: restServiceFactory, deps: [MOCK_RESPONSE_MAP, HttpClient] },
271272
EPersonDataService,
272273
LinkHeadService,
274+
InternalLinkService,
273275
HALEndpointService,
274276
HostWindowService,
275277
ItemDataService,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h5 class="simple-view-element-header">{{"item.page.filesection.original.bundle"
3333
</ng-container>
3434
</dl>
3535
</div>
36-
<div class="col-2">
36+
<div *ngIf="!hasNoDownload(file)" class="col-2">
3737
<ds-themed-file-download-link [bitstream]="file" [item]="item">
3838
{{"item.page.filesection.download" | translate}}
3939
</ds-themed-file-download-link>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
108108
return hasValue(bundle) && !isEmpty(bundle.page);
109109
}
110110

111+
hasNoDownload(bitstream: Bitstream) {
112+
return bitstream?.allMetadataValues('bitstream.viewer.provider').includes('nodownload');
113+
}
114+
111115
ngOnDestroy(): void {
112116
this.paginationService.clearPagination(this.originalOptions.id);
113117
this.paginationService.clearPagination(this.licenseOptions.id);
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
<div>
2-
<div class="card">
3-
<div class = "row d-flex justify-content-center">
2+
<div class="card p-3">
3+
<div class="d-flex flex-wrap flex-row justify-content-around gap-4">
44
<div *ngIf="isLoading$ | async">
55
<ds-loading message="{{'loading.default' | translate}}"></ds-loading>
66
</div>
7-
<div *ngFor="let counter of (counterData$ | async)"
8-
class="px-4 py-1 d-flex flex-column" style="flex: 1 0 100px">
9-
<div (click)="goToLink(counter.link)"
10-
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
11-
class="col d-flex justify-content-center text-center align-items-center">
12-
<i [ngClass]="counter.icon"></i>
7+
<ng-container *ngFor="let counter of (counterData$ | async)">
8+
<ng-container *ngIf="counter.link; else countersSectionContent">
9+
<a class="text-decoration-none" *ngIf="internalLinkService.isLinkInternal(counter.link)" [routerLink]="internalLinkService.getRelativePath(counter.link)">
10+
<ng-container *ngTemplateOutlet="countersSectionContent"></ng-container>
11+
</a>
12+
<a class="text-decoration-none" *ngIf="!internalLinkService.isLinkInternal(counter.link)" [href]="counter.link" [target]="'_blank'">
13+
<ng-container *ngTemplateOutlet="countersSectionContent"></ng-container>
14+
</a>
15+
</ng-container>
16+
<ng-template #countersSectionContent>
17+
<div class="d-flex flex-wrap flex-column justify-content-between align-items-center gapy-1 counters-section">
18+
<i class="d-block mb-2" [ngClass]="counter.icon"></i>
19+
<div class="counters-label text-center">
20+
{{ 'explore.counters-section.' + counter.label | translate }}
21+
</div>
22+
<div class="text-center font-weight-bold">
23+
<b>{{ counter.count }}</b>
24+
</div>
1325
</div>
14-
<div (click)="goToLink(counter.link)"
15-
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
16-
class="col d-flex justify-content-center text-center align-items-center">
17-
{{'explore.counters-section.' + counter.label | translate}}
18-
</div>
19-
<div (click)="goToLink(counter.link)"
20-
[ngStyle]="{'cursor': counter.link? 'pointer' : 'inherit'}"
21-
class="col d-flex justify-content-center text-center align-items-center">
22-
<b>{{counter.count}}</b>
23-
</div>
24-
</div>
26+
</ng-template>
27+
</ng-container>
2528
</div>
2629
</div>
2730
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.counters-section {
2+
min-width: 120px;
3+
max-width: 140px;
4+
color: var(--bs-gray-800);
5+
6+
&:hover {
7+
color: #{darken($gray-800, 20%)};
8+
}
9+
}
10+
11+
.counters-label {
12+
line-height: 1.25;
13+
}

src/app/shared/explore/section-component/counters-section/counters-section.component.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import { isPlatformServer } from '@angular/common';
44
import { BehaviorSubject, forkJoin, Observable } from 'rxjs';
55
import { map } from 'rxjs/operators';
66

7-
import { NativeWindowRef, NativeWindowService } from '../../../../core/services/window.service';
87
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
98
import { SearchObjects } from '../../../search/models/search-objects.model';
109
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
1110
import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model';
1211
import { SectionComponent } from '../../../../core/layout/models/section.model';
1312
import { SearchService } from '../../../../core/shared/search/search.service';
1413
import { PaginatedSearchOptions } from '../../../search/models/paginated-search-options.model';
15-
import { hasValue } from '../../../empty.util';
1614
import { UUIDService } from '../../../../core/shared/uuid.service';
15+
import { InternalLinkService } from 'src/app/core/services/internal-link.service';
1716

1817
@Component({
1918
selector: 'ds-counters-section',
19+
styleUrls: ['./counters-section.component.scss'],
2020
templateUrl: './counters-section.component.html'
2121
})
2222
export class CountersSectionComponent implements OnInit {
@@ -38,10 +38,12 @@ export class CountersSectionComponent implements OnInit {
3838
});
3939

4040

41-
constructor(private searchService: SearchService,
41+
constructor(
42+
public internalLinkService: InternalLinkService,
43+
private searchService: SearchService,
4244
private uuidService: UUIDService,
4345
@Inject(PLATFORM_ID) private platformId: Object,
44-
@Inject(NativeWindowService) protected _window: NativeWindowRef,) {
46+
) {
4547

4648
}
4749

@@ -69,12 +71,6 @@ export class CountersSectionComponent implements OnInit {
6971
)));
7072
this.counterData$.subscribe(() => this.isLoading$.next(false));
7173
}
72-
73-
goToLink(link: string) {
74-
if (hasValue(link)) {
75-
this._window.nativeWindow.location.href = link;
76-
}
77-
}
7874
}
7975

8076

0 commit comments

Comments
 (0)