Skip to content

Commit

Permalink
Merged dspace-cris-2023_02_x into task/dspace-cris-2023_02_x/DSC-2028
Browse files Browse the repository at this point in the history
  • Loading branch information
atarix83 committed Nov 28, 2024
2 parents 114c523 + ddbd43a commit 2df6906
Show file tree
Hide file tree
Showing 33 changed files with 386 additions and 108 deletions.
4 changes: 0 additions & 4 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,6 @@ themes:
attributes:
rel: manifest
href: assets/dspace/images/favicons/manifest.webmanifest
- tagName: link
attributes:
rel: stylesheet
href: "https://fonts.googleapis.com/icon?family=Material+Icons"

# The default bundles that should always be displayed as suggestions when you upload a new bundle
bundle:
Expand Down
173 changes: 100 additions & 73 deletions src/app/core/metadata/metadata.service.spec.ts

Large diffs are not rendered by default.

86 changes: 76 additions & 10 deletions src/app/core/metadata/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { filter, map, mergeMap, switchMap, take } from 'rxjs/operators';

import { hasNoValue, hasValue, isNotEmpty } from '../../shared/empty.util';
import { DSONameService } from '../breadcrumbs/dso-name.service';
import { BitstreamDataService } from '../data/bitstream-data.service';
import { BitstreamFormatDataService } from '../data/bitstream-format-data.service';

import { RemoteData } from '../data/remote-data';
import { BitstreamFormat } from '../shared/bitstream-format.model';
Expand All @@ -46,6 +44,8 @@ import { ITEM } from '../shared/item.resource-type';
import { DOCUMENT, isPlatformBrowser, isPlatformServer } from '@angular/common';
import { Root } from '../data/root.model';
import { environment } from '../../../environments/environment';
import { Bundle } from '../shared/bundle.model';
import { followLink } from '../../shared/utils/follow-link-config.model';

/**
* The base selector function to select the metaTag section in the store
Expand Down Expand Up @@ -95,8 +95,6 @@ export class MetadataService {
private title: Title,
private dsoNameService: DSONameService,
private bundleDataService: BundleDataService,
private bitstreamDataService: BitstreamDataService,
private bitstreamFormatDataService: BitstreamFormatDataService,
private rootService: RootDataService,
private store: Store<CoreState>,
private hardRedirectService: HardRedirectService,
Expand Down Expand Up @@ -449,7 +447,7 @@ export class MetadataService {
* Add <meta name="og:image" ... > to the <head>
*/
private setOpenGraphImageTag(): void {
this.setPrimaryBitstreamInBundleTag('og:image');
this.setPrimaryImageInBundleTag('og:image');
}

/**
Expand All @@ -465,7 +463,7 @@ export class MetadataService {
* Add <meta name="twitter:image" ... > to the <head>
*/
private setTwitterImageTag(): void {
this.setPrimaryBitstreamInBundleTag('twitter:image');
this.setPrimaryImageInBundleTag('twitter:image');
}

/**
Expand Down Expand Up @@ -496,6 +494,74 @@ export class MetadataService {
}

private setPrimaryBitstreamInBundleTag(tag: string): void {
if (this.currentObject.value instanceof Item) {
const item = this.currentObject.value as Item;

// Retrieve the ORIGINAL bundle for the item
this.bundleDataService.findByItemAndName(
item,
'ORIGINAL',
true,
true,
followLink('primaryBitstream'),
followLink('bitstreams', {
findListOptions: {
// limit the number of bitstreams used to find the citation pdf url to the number
// shown by default on an item page
elementsPerPage: this.appConfig.item.bitstream.pageSize,
},
}, followLink('format')),
).pipe(
getFirstSucceededRemoteDataPayload(),
switchMap((bundle: Bundle) =>
// First try the primary bitstream
bundle.primaryBitstream.pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<Bitstream>) => {
if (hasValue(rd.payload)) {
return rd.payload;
} else {
return null;
}
}),
getDownloadableBitstream(this.authorizationService),
// return the bundle as well so we can use it again if there's no primary bitstream
map((bitstream: Bitstream) => [bundle, bitstream]),
),
),
switchMap(([bundle, primaryBitstream]: [Bundle, Bitstream]) => {
if (hasValue(primaryBitstream)) {
// If there was a downloadable primary bitstream, emit its link
return [getBitstreamDownloadRoute(primaryBitstream)];
} else {
// Otherwise consider the regular bitstreams in the bundle
return bundle.bitstreams.pipe(
getFirstCompletedRemoteData(),
switchMap((bitstreamRd: RemoteData<PaginatedList<Bitstream>>) => {
if (hasValue(bitstreamRd.payload) && bitstreamRd.payload.totalElements === 1) {
// If there's only one bitstream in the bundle, emit its link if its downloadable
return this.getBitLinkIfDownloadable(bitstreamRd.payload.page[0], bitstreamRd);
} else {
// Otherwise check all bitstreams to see if one matches the format whitelist
return this.getFirstAllowedFormatBitstreamLink(bitstreamRd);
}
}),
);
}
}),
take(1),
).subscribe((link: string) => {
// Use the found link to set the <meta> tag
this.addMetaTag(
tag,
new URLCombiner(this.hardRedirectService.getCurrentOrigin(), link).toString(),
true,
);
});
}
}

private setPrimaryImageInBundleTag(tag: string): void {
if (this.currentObject.value instanceof Item) {
const item = this.currentObject.value as Item;
this.getBitstreamFromThumbnail(item).pipe(
Expand All @@ -506,14 +572,14 @@ export class MetadataService {
return null;
}
}),
take(1)
take(1),
).subscribe((link) => {
if (hasValue(link)) {
// Use the found link to set the <meta> tag
this.addMetaTag(
tag,
new URLCombiner(this.getUrlOrigin(), link).toString(),
true
true,
);
} else {
this.addFallbackImageToTag(tag);
Expand Down Expand Up @@ -654,9 +720,9 @@ export class MetadataService {
return this.currentObject.value.allMetadataValues(keys);
}

private addMetaTag(name: string, content: string, isProperty = false): void {
protected addMetaTag(name: string, content: string, isProperty = false): void {
if (content) {
const tag = isProperty ? {property: name, content} as MetaDefinition
const tag = isProperty ? { name, property: name, content } as MetaDefinition
: { name, content } as MetaDefinition;
this.meta.updateTag(tag);
this.storeTag(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'
import { Item } from '../../../../../../../core/shared/item.model';
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
import { MetadataValue } from '../../../../../../../core/shared/metadata.models';
import { isEmpty } from '../../../../../../../shared/empty.util';

/**
* This component renders the links metadata fields.
Expand Down Expand Up @@ -56,8 +57,11 @@ export class LinkAuthorityComponent extends RenderingTypeValueModelComponent imp
}

getWebsiteIcon(): string {
const siteUrl = this.metadataValue.authority;
let iconStyle = '';
const siteUrl = this.metadataValue.authority;
if (isEmpty(siteUrl)) {
return iconStyle;
}

if (siteUrl.includes('linkedin')) {
iconStyle = 'fab fa-linkedin';
Expand Down
12 changes: 12 additions & 0 deletions src/app/shared/mocks/item.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,18 @@ export const ItemMock: Item = Object.assign(new Item(), {
language: 'en_US',
value: 'text'
}
],
'dc.relation.issn': [
{
language: 'en_US',
value: '123456789',
},
],
'dspace.entity.type': [
{
language: 'en',
value: 'Publication',
},
]
},
owningCollection: observableOf({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
</div>
<ds-truncatable [id]="item.id">
<h3 [innerHTML]="dsoTitle" [ngClass]="{'lead': true,'text-muted': !item.firstMetadataValue('dc.title')}"></h3>
<div *ngIf="item.hasMetadata('dspace.workflow.startDateTime') && item.hasMetadata('dc.date.accessioned')">
{{ 'mydspace.results.in-workflow-for' | translate }}
{{ getDateForArchivedItem(item.firstMetadataValue('dspace.workflow.startDateTime'), item.firstMetadataValue('dc.date.accessioned')) }}
</div>
<div>
<span class="text-muted">
<ds-truncatable-part [id]="item.id" [minLines]="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { WorkflowItem } from '../../../../core/submission/models/workflowitem.mo
import {
DuplicateMatchMetadataDetailConfig
} from '../../../../submission/sections/detect-duplicate/models/duplicate-detail-metadata.model';
import { parseISO, differenceInDays, differenceInMilliseconds } from 'date-fns';
import { environment } from '../../../../../environments/environment';

/**
Expand Down Expand Up @@ -83,6 +84,15 @@ export class ItemListPreviewComponent implements OnInit {
) {
}

getDateForArchivedItem(itemStartDate: string, dateAccessioned: string) {
const itemStartDateConverted: Date = parseISO(itemStartDate);
const dateAccessionedConverted: Date = parseISO(dateAccessioned);
const days: number = Math.floor(differenceInDays(dateAccessionedConverted, itemStartDateConverted));
const remainingMilliseconds: number = differenceInMilliseconds(dateAccessionedConverted, itemStartDateConverted) - days * 24 * 60 * 60 * 1000;
const hours: number = Math.floor(remainingMilliseconds / (60 * 60 * 1000));
return `${days} d ${hours} h`;
}

ngOnInit(): void {
this.showThumbnails = this.showThumbnails ?? this.appConfig.browseBy.showThumbnails;
this.dsoTitle = this.dsoNameService.getHitHighlights(this.object, this.item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
[innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span>
<div *ngIf="dso.hasMetadata('dspace.workflow.startDateTime')">
{{ 'mydspace.results.in-workflow-since' | translate }}
{{ getDateForItem(dso.firstMetadataValue('dspace.workflow.startDateTime')) }}
</div>
<span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1">
<ng-container *ngIf="dso.firstMetadataValue('dc.publisher') || dso.firstMetadataValue('dc.date.issued')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TruncatableService } from '../../../../../truncatable/truncatable.servi
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
import { APP_CONFIG, AppConfig } from '../../../../../../../config/app-config.interface';
import { getFirstSucceededRemoteListPayload } from '../../../../../../core/shared/operators';
import { differenceInDays, differenceInMilliseconds, parseISO} from 'date-fns';
import { filter, map } from 'rxjs/operators';
import { isNotEmpty } from '../../../../../empty.util';

Expand Down Expand Up @@ -89,6 +90,14 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
}
}

getDateForItem(itemStartDate: string) {
const itemStartDateConverted: Date = parseISO(itemStartDate);
const days: number = Math.floor(differenceInDays(Date.now(), itemStartDateConverted));
const remainingMilliseconds: number = differenceInMilliseconds(Date.now(), itemStartDateConverted) - days * 24 * 60 * 60 * 1000;
const hours: number = Math.floor(remainingMilliseconds / (60 * 60 * 1000));
return `${days} d ${hours} h`;
}

/**
* Prompt user for consents settings
*/
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added src/assets/fonts/nunito/static/Nunito-Black.ttf
Binary file not shown.
Binary file not shown.
Binary file added src/assets/fonts/nunito/static/Nunito-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/assets/fonts/nunito/static/Nunito-Italic.ttf
Binary file not shown.
Binary file added src/assets/fonts/nunito/static/Nunito-Light.ttf
Binary file not shown.
Binary file not shown.
Binary file added src/assets/fonts/nunito/static/Nunito-Medium.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,10 @@

"mydspace.results.is-correction": "Is a request of correction",

"mydspace.results.in-workflow-since": "In workflow since:",

"mydspace.results.in-workflow-for": "In workflow for:",

"mydspace.search-form.placeholder": "Search in MyDSpace...",

"mydspace.show.workflow": "Workflow tasks",
Expand Down
10 changes: 1 addition & 9 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,7 @@ export class DefaultAppConfig implements AppConfig {
'rel': 'manifest',
'href': 'assets/dspace/images/favicons/manifest.webmanifest',
}
},
{
// Insert <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> into the <head> of the page.
tagName: 'link',
attributes: {
'rel': 'stylesheet',
'href': 'https://fonts.googleapis.com/icon?family=Material+Icons',
}
},
}
]
},
];
Expand Down
20 changes: 10 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<meta http-equiv="cache-control" content="no-store">
<meta name="title" content="">
<meta name="description" content="">
<meta property="og:title" content="">
<meta property="og:description" content="">
<meta property="og:image" content="">
<meta property="og:url" content="">
<meta property="og:type" content="">
<meta property="twitter:title" content="">
<meta property="twitter:description" content="">
<meta property="twitter:image" content="">
<meta property="twitter:card" content="">
<meta name="og:title" property="og:title" content="">
<meta name="og:description" property="og:description" content="">
<meta name="og:image" property="og:image" content="">
<meta name="og:url" property="og:url" content="">
<meta name="og:type" property="og:type" content="">
<meta name="twitter:title" property="twitter:title" content="">
<meta name="twitter:description" property="twitter:description" content="">
<meta name="twitter:image" property="twitter:image" content="">
<meta name="twitter:card" property="twitter:card" content="">
</head>

<body>
<ds-app></ds-app>
<ds-app></ds-app>
</body>

<!-- do not include client bundle, it is injected with Zone already loaded -->
Expand Down
Loading

0 comments on commit 2df6906

Please sign in to comment.