From fa9cd9b1ea6b65afe65e4174d214e409a31373e3 Mon Sep 17 00:00:00 2001 From: Lotte Hofstede Date: Tue, 30 May 2017 11:21:17 +0200 Subject: [PATCH] 41650: finished full item page --- resources/i18n/en.json | 10 +++- .../models/normalized-bitstream.model.ts | 6 +++ src/app/core/shared/item.model.ts | 53 ++++++++----------- .../full-file-section.component.html | 32 ++++++++--- .../full-file-section.component.scss | 7 +++ .../full-file-section.component.ts | 28 +++++----- .../file-section/file-section.component.ts | 6 ++- src/backend/bitstreams.ts | 21 ++++++++ src/backend/bundles.ts | 18 +++++++ src/backend/items.ts | 9 ++-- 10 files changed, 132 insertions(+), 58 deletions(-) create mode 100644 src/app/item-page/full/field-components/file-section/full-file-section.component.scss diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 248c6a0744..a2418a35c6 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -12,8 +12,14 @@ "date": "Date", "uri": "URI", "files": "Files", - "downloads": "Downloads", - "collections": "Collections" + "collections": "Collections", + "filesection": { + "download": "Download", + "name": "Name:", + "format": "Format:", + "size": "Size:", + "description": "Description:" + } } }, diff --git a/src/app/core/cache/models/normalized-bitstream.model.ts b/src/app/core/cache/models/normalized-bitstream.model.ts index 57b4f63346..b6df211c2e 100644 --- a/src/app/core/cache/models/normalized-bitstream.model.ts +++ b/src/app/core/cache/models/normalized-bitstream.model.ts @@ -21,8 +21,14 @@ export class NormalizedBitstream extends NormalizedDSpaceObject { /** * The mime type of this Bitstream */ + @autoserialize mimetype: string; + /** + * The format of this Bitstream + */ + format: string; + /** * The description of this Bitstream */ diff --git a/src/app/core/shared/item.model.ts b/src/app/core/shared/item.model.ts index c663806f40..125f71881f 100644 --- a/src/app/core/shared/item.model.ts +++ b/src/app/core/shared/item.model.ts @@ -47,50 +47,40 @@ export class Item extends DSpaceObject { */ getThumbnail(): Observable { const bundle: Observable = this.getBundle("THUMBNAIL"); - return bundle.flatMap( - bundle => { - if (bundle != null) { - return bundle.primaryBitstream.payload; - } - else { - return Observable.of(undefined); - } - } - ); + return bundle + .filter(bundle => hasValue(bundle)) + .flatMap(bundle => bundle.primaryBitstream.payload) + .startWith(undefined); } /** * Retrieves the thumbnail for the given original of this item * @returns {Observable} the primaryBitstream of the "THUMBNAIL" bundle */ - getThumbnailForOriginal(original: Observable): Observable { //returns obs of obs of bitstream instead... + getThumbnailForOriginal(original: Bitstream): Observable { //returns obs of obs of bitstream instead... const bundle: Observable = this.getBundle("THUMBNAIL"); - return bundle.map( - bundle => { - if (bundle != null) { - return bundle.bitstreams.find( - file => { - return Observable.combineLatest( - original, - file.payload, - (original, thumbnail) => { - return (thumbnail.name.startsWith(original.name)); - }); - }); - } - } - ); + return bundle + .filter(bundle => hasValue(bundle)) + .flatMap(bundle => bundle + .bitstreams.payload.map(files => files + .find(thumbnail => thumbnail + .name.startsWith(original.name) + ) + ) + ) + .startWith(undefined);; } /** * Retrieves all files that should be displayed on the item page of this item * @returns {Observable>>} an array of all Bitstreams in the "ORIGINAL" bundle */ - getFiles(): Observable { - const bundle: Observable = this.getBundle("ORIGINAL"); + getFiles(name: String = "ORIGINAL"): Observable { + const bundle: Observable = this.getBundle(name); return bundle - .filter(bundle => hasValue(bundle)) - .flatMap(bundle => bundle.bitstreams.payload); + .filter(bundle => hasValue(bundle)) + .flatMap(bundle => bundle.bitstreams.payload) + .startWith([]); } /** @@ -105,7 +95,8 @@ export class Item extends DSpaceObject { return bundles.find((bundle: Bundle) => { return bundle.name === name }); - }); + }) + .startWith(undefined); } } diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.html b/src/app/item-page/full/field-components/file-section/full-file-section.component.html index 9e9903c913..d7e1712b7f 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.html +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.html @@ -1,11 +1,29 @@
- -
{{(file | async)?.name}}
-
{{(file | async)?.findMetadata("dc.description")}}
-
{{((file | async)?.size) | dsFileSize }}
- - {{"item.page.download" | translate}} - +
+ +
+
+
+
{{"item.page.filesection.name" | translate}}
+
{{file.name}}
+ +
{{"item.page.filesection.size" | translate}}
+
{{(file.size) | dsFileSize }}
+ + +
{{"item.page.filesection.format" | translate}}
+
{{(file.mimetype)}}
+ + +
{{"item.page.filesection.description" | translate}}
+
{{file.findMetadata("dc.description")}}
+
+
+
diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.scss b/src/app/item-page/full/field-components/file-section/full-file-section.component.scss new file mode 100644 index 0000000000..4597c711ff --- /dev/null +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.scss @@ -0,0 +1,7 @@ +@import '../../../../../styles/variables.scss'; +@import '../../../../../../node_modules/bootstrap/scss/_variables.scss'; +@media screen and (min-width: map-get($grid-breakpoints, md)) { + dt { + text-align: right; + } +} \ No newline at end of file diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts index 6ae2ad7649..3d2c85c801 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -3,6 +3,7 @@ import { Bitstream } from "../../../../core/shared/bitstream.model"; import { Item } from "../../../../core/shared/item.model"; import { Observable } from "rxjs"; import { FileSectionComponent } from "../../../simple/field-components/file-section/file-section.component"; +import { hasValue } from "../../../../shared/empty.util"; /** * This component renders the file section of the item @@ -11,13 +12,17 @@ import { FileSectionComponent } from "../../../simple/field-components/file-sect @Component({ selector: 'ds-item-page-full-file-section', + styleUrls: ['./full-file-section.component.css'], templateUrl: './full-file-section.component.html' }) -export class FullFileSectionComponent extends FileSectionComponent implements OnInit { +export class FullFileSectionComponent extends FileSectionComponent { @Input() item: Item; - files: Observable>>; + label : string; + + files: Observable; + thumbnails: Map> = new Map(); @@ -25,20 +30,17 @@ export class FullFileSectionComponent extends FileSectionComponent implements On universalInit() { } - ngOnInit(): void { - super.ngOnInit(); + initialize(): void { + const originals = this.item.getFiles("ORIGINAL"); + const licenses = this.item.getFiles("LICENSE"); + licenses.subscribe(licenses => console.log(licenses)); + this.files = Observable.combineLatest(originals, licenses, (originals, licenses) => [...originals, ...licenses]); this.files.subscribe( files => files.forEach( - file => { - file.subscribe( - original => { - const thumbnail : Observable = this.item.getThumbnailForOriginal(file); - thumbnail.subscribe(t => - console.log("TESTTTT" , t)); - this.thumbnails.set(original.id, thumbnail); - } - ); + original => { + const thumbnail: Observable = this.item.getThumbnailForOriginal(original); + this.thumbnails.set(original.id, thumbnail); } ) ) diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.ts index 37b6b7c98c..4cd1daf290 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.ts @@ -24,15 +24,17 @@ export class FileSectionComponent implements OnInit { constructor() { this.universalInit(); - } universalInit() { } ngOnInit(): void { + this.initialize(); + } + + initialize(): void { this.files = this.item.getFiles(); } - } diff --git a/src/backend/bitstreams.ts b/src/backend/bitstreams.ts index 6d10f87fbf..df10fae3e1 100644 --- a/src/backend/bitstreams.ts +++ b/src/backend/bitstreams.ts @@ -42,5 +42,26 @@ export const BITSTREAMS = [ ], "format": "JPEG", "mimetype": "image/jpeg" + }, + { + "_links": { + "self": { "href": "/bitstreams/8934" }, + "bundle": { "href": "/bundles/99f78e5e-3677-43b0-aaef-cddaa1a49092" }, + "retrieve": { "href": "/rest/bitstreams/ba7d24f2-8fc7-4b8e-b7b6-6c32be1c12a6/retrieve" } + }, + "id": "8934", + "uuid": "ba7d24f2-8fc7-4b8e-b7b6-6c32be1c12a6", + "name": "license.txt", + "size": 41183, + "checksum": { + "value": "8ad416e8a39e645020e13e06f1427814", + "algorithm": "MD5" + }, + "metadata": [ + { "key": "dc.title", "value": "license.txt", "language": null }, + { "key": "dc.description", "value": "License", "language": "en" } + ], + "format": "Text", + "mimetype": "text/plain" } ]; diff --git a/src/backend/bundles.ts b/src/backend/bundles.ts index 678b98007c..9656643375 100644 --- a/src/backend/bundles.ts +++ b/src/backend/bundles.ts @@ -36,5 +36,23 @@ export const BUNDLES = [ "metadata": [ { "key": "dc.title", "value": "THUMBNAIL", "language": "en" } ] + }, + { + "_links": { + "self": { "href": "/bundles/8475" }, + "items": [ + { "href": "/items/8871" } + ], + "bitstreams": [ + { "href": "/bitstreams/8934" }, + ], + "primaryBitstream": { "href": "/bitstreams/8934" } + }, + "id": "8475", + "uuid": "99f78e5e-3677-43b0-aaef-cddaa1a49092", + "name": "LICENSE", + "metadata": [ + { "key": "dc.title", "value": "LICENSE", "language": "en" } + ] } ]; diff --git a/src/backend/items.ts b/src/backend/items.ts index a60ac44033..3f2087afe6 100644 --- a/src/backend/items.ts +++ b/src/backend/items.ts @@ -18,6 +18,9 @@ export const ITEMS = [ }, { "href": "/bundles/5687" + }, + { + "href": "/bundles/8475" } ] }, @@ -109,9 +112,9 @@ export const ITEMS = [ { "href": "/bundles/2355" }, - // { - // "href": "/bundles/5687" - // } + { + "href": "/bundles/5687" + } ] }, "id": "9978",