mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
40416: normalized collection bug
This commit is contained in:
@@ -16,7 +16,8 @@
|
|||||||
"author": "Author",
|
"author": "Author",
|
||||||
"abstract": "Abstract",
|
"abstract": "Abstract",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"uri": "URI"
|
"uri": "URI",
|
||||||
|
"files": "Files"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ export class NormalizedBitstream extends NormalizedDSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* The size of this bitstream in bytes(?)
|
* The size of this bitstream in bytes(?)
|
||||||
*/
|
*/
|
||||||
|
@autoserialize
|
||||||
size: number;
|
size: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -42,6 +42,7 @@ export abstract class NormalizedDSpaceObject implements CacheableObject {
|
|||||||
/**
|
/**
|
||||||
* An array of DSpaceObjects that are direct parents of this DSpaceObject
|
* An array of DSpaceObjects that are direct parents of this DSpaceObject
|
||||||
*/
|
*/
|
||||||
|
@autoserialize
|
||||||
parents: Array<string>;
|
parents: Array<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,6 +3,7 @@ import { NormalizedDSpaceObject } from "./normalized-dspace-object.model";
|
|||||||
import { Item } from "../../shared/item.model";
|
import { Item } from "../../shared/item.model";
|
||||||
import { mapsTo, relationship } from "../builders/build-decorators";
|
import { mapsTo, relationship } from "../builders/build-decorators";
|
||||||
import { NormalizedBundle } from "./normalized-bundle.model";
|
import { NormalizedBundle } from "./normalized-bundle.model";
|
||||||
|
import { NormalizedCollection } from "./normalized-collection.model";
|
||||||
|
|
||||||
@mapsTo(Item)
|
@mapsTo(Item)
|
||||||
@inheritSerialization(NormalizedDSpaceObject)
|
@inheritSerialization(NormalizedDSpaceObject)
|
||||||
@@ -32,6 +33,8 @@ export class NormalizedItem extends NormalizedDSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* An array of Collections that are direct parents of this Item
|
* An array of Collections that are direct parents of this Item
|
||||||
*/
|
*/
|
||||||
|
@autoserialize
|
||||||
|
@relationship(NormalizedCollection)
|
||||||
parents: Array<string>;
|
parents: Array<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { DSpaceObject } from "./dspace-object.model";
|
import { DSpaceObject } from "./dspace-object.model";
|
||||||
import { Bundle } from "./bundle.model";
|
import { Bundle } from "./bundle.model";
|
||||||
|
import { RemoteData } from "../data/remote-data";
|
||||||
|
|
||||||
export class Bitstream extends DSpaceObject {
|
export class Bitstream extends DSpaceObject {
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ export class Bitstream extends DSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* An array of Bundles that are direct parents of this Bitstream
|
* An array of Bundles that are direct parents of this Bitstream
|
||||||
*/
|
*/
|
||||||
parents: Array<Bundle>;
|
parents: Array<RemoteData<Bundle>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Bundle that owns this Bitstream
|
* The Bundle that owns this Bitstream
|
||||||
|
@@ -14,7 +14,7 @@ export class Bundle extends DSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* An array of Items that are direct parents of this Bundle
|
* An array of Items that are direct parents of this Bundle
|
||||||
*/
|
*/
|
||||||
parents: Array<Item>;
|
parents: Array<RemoteData<Item>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Item that owns this Bundle
|
* The Item that owns this Bundle
|
||||||
|
@@ -58,7 +58,7 @@ export class Collection extends DSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* An array of Collections that are direct parents of this Collection
|
* An array of Collections that are direct parents of this Collection
|
||||||
*/
|
*/
|
||||||
parents: Array<Collection>;
|
parents: Array<RemoteData<Collection>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Collection that owns this Collection
|
* The Collection that owns this Collection
|
||||||
|
@@ -2,6 +2,7 @@ import { autoserialize, autoserializeAs } from "cerialize";
|
|||||||
import { Metadatum } from "./metadatum.model"
|
import { Metadatum } from "./metadatum.model"
|
||||||
import { isEmpty, isNotEmpty } from "../../shared/empty.util";
|
import { isEmpty, isNotEmpty } from "../../shared/empty.util";
|
||||||
import { CacheableObject } from "../cache/object-cache.reducer";
|
import { CacheableObject } from "../cache/object-cache.reducer";
|
||||||
|
import { RemoteData } from "../data/remote-data";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract model class for a DSpaceObject.
|
* An abstract model class for a DSpaceObject.
|
||||||
@@ -43,7 +44,7 @@ export abstract class DSpaceObject implements CacheableObject {
|
|||||||
/**
|
/**
|
||||||
* An array of DSpaceObjects that are direct parents of this DSpaceObject
|
* An array of DSpaceObjects that are direct parents of this DSpaceObject
|
||||||
*/
|
*/
|
||||||
parents: Array<DSpaceObject>;
|
parents: Array<RemoteData<DSpaceObject>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSpaceObject that owns this DSpaceObject
|
* The DSpaceObject that owns this DSpaceObject
|
||||||
|
@@ -33,8 +33,7 @@ export class Item extends DSpaceObject {
|
|||||||
/**
|
/**
|
||||||
* An array of Collections that are direct parents of this Item
|
* An array of Collections that are direct parents of this Item
|
||||||
*/
|
*/
|
||||||
@autoserializeAs(Collection)
|
parents: Array<RemoteData<Collection>>;
|
||||||
parents: Array<Collection>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Collection that owns this Item
|
* The Collection that owns this Item
|
||||||
@@ -50,14 +49,8 @@ export class Item extends DSpaceObject {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFiles(): Array<Observable<Bitstream>> {
|
getFiles(): Observable<Array<Observable<Bitstream>>> {
|
||||||
return this.getBundle("ORIGINAL").map(bundle => bundle.bitstreams.map(bitstream => bitstream.payload.flatMap(b => b))).;
|
return this.getBundle("ORIGINAL").map(bundle => bundle.bitstreams.map(bitstream => bitstream.payload));
|
||||||
// const bundle: Observable<Bundle> = this.getBundle("ORIGINAL");
|
|
||||||
// return bundle.map(
|
|
||||||
// bundle => bundle.bitstreams.flatMap(
|
|
||||||
// bitstream => bitstream.payload
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getBundle(name: String): Observable<Bundle> {
|
getBundle(name: String): Observable<Bundle> {
|
||||||
@@ -71,4 +64,8 @@ export class Item extends DSpaceObject {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCollections(): Array<Observable<Collection>> {
|
||||||
|
return this.parents.map(c => c.payload.map(p => p));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
7
src/app/item-page/collections/collections.component.html
Normal file
7
src/app/item-page/collections/collections.component.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<ds-metadata-field-wrapper [label]="label | translate">
|
||||||
|
<div class="collections">
|
||||||
|
<a *ngFor="let collection of collections" [href]="(collection)?.self">
|
||||||
|
<span>{{(collection)?.name}}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</ds-metadata-field-wrapper>
|
31
src/app/item-page/collections/collections.component.ts
Normal file
31
src/app/item-page/collections/collections.component.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { Collection } from "../../core/shared/collection.model";
|
||||||
|
import { Observable } from "rxjs";
|
||||||
|
import { Item } from "../../core/shared/item.model";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-page-collections',
|
||||||
|
templateUrl: './collections.component.html'
|
||||||
|
})
|
||||||
|
export class CollectionsComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() item: Item;
|
||||||
|
label : string = "item.page.collections";
|
||||||
|
collections: Array<Observable<Collection>>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.universalInit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
universalInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.collections = this.item.getCollections();
|
||||||
|
this.collections[0].subscribe(d => console.log("TEST TEST LOREM IPSUM LALALALAL"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -1,4 +1,8 @@
|
|||||||
<div class="item-page-specific-field">
|
<ds-metadata-field-wrapper [label]="label | translate">
|
||||||
<ds-metadata-uri-values [values]="item.getBundle("ORIGINAL")" [separator]="separator" [label]="label"></ds-metadata-uri-values>
|
<div class="file-section">
|
||||||
|
<a *ngFor="let file of (files | async)" [href]="(file | async)?.retrieve">
|
||||||
|
<span>{{(file | async)?.name}}</span>
|
||||||
|
<span>({{((file | async)?.size) | dsFileSize }})</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</ds-metadata-field-wrapper>
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Bitstream } from "../../core/shared/bitstream.model";
|
import { Bitstream } from "../../core/shared/bitstream.model";
|
||||||
import { Item } from "../../core/shared/item.model";
|
import { Item } from "../../core/shared/item.model";
|
||||||
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-metadata-field-wrapper',
|
selector: 'ds-item-page-file-section',
|
||||||
styleUrls: ['./metadata-field-wrapper.component.css'],
|
templateUrl: './file-section.component.html'
|
||||||
templateUrl: './metadata-field-wrapper.component.html'
|
|
||||||
})
|
})
|
||||||
export class MetadataFieldWrapperComponent {
|
export class FileSectionComponent implements OnInit {
|
||||||
|
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
files: Array<Bitstream>;
|
label : string = "item.page.files";
|
||||||
|
files: Observable<Array<Observable<Bitstream>>>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.universalInit();
|
this.universalInit();
|
||||||
@@ -18,7 +19,11 @@ export class MetadataFieldWrapperComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
universalInit() {
|
universalInit() {
|
||||||
this.files = this.item.getBundle("ORIGINAL").map(bundle => bundle.bitstreams.map(bitstream => bitstream.payload));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.files = this.item.getFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,17 @@
|
|||||||
<div class="item-page" *ngIf="item.hasSucceeded | async">
|
<div class="item-page" *ngIf="item.hasSucceeded | async">
|
||||||
Item page component
|
|
||||||
<ds-thumbnail [thumbnail]="thumbnail | async"></ds-thumbnail>
|
|
||||||
<ds-item-page-title-field [item]="item.payload | async"></ds-item-page-title-field>
|
<ds-item-page-title-field [item]="item.payload | async"></ds-item-page-title-field>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-4">
|
||||||
|
<ds-thumbnail [thumbnail]="thumbnail | async"></ds-thumbnail>
|
||||||
|
<ds-item-page-file-section [item]="item.payload | async"></ds-item-page-file-section>
|
||||||
<ds-item-page-date-field [item]="item.payload | async"></ds-item-page-date-field>
|
<ds-item-page-date-field [item]="item.payload | async"></ds-item-page-date-field>
|
||||||
<ds-item-page-author-field [item]="item.payload | async"></ds-item-page-author-field>
|
<ds-item-page-author-field [item]="item.payload | async"></ds-item-page-author-field>
|
||||||
<ds-item-page-abstract-field [item]="item.payload | async"></ds-item-page-abstract-field>
|
</div>
|
||||||
<ds-item-page-uri-field [item]="item.payload | async"></ds-item-page-uri-field>
|
<div class="col-xs-12 col-md-6">
|
||||||
<ds-item-page-file-section [item]="item.payload | async"></ds-item-page-file-section>
|
<ds-item-page-abstract-field
|
||||||
|
[item]="item.payload | async"></ds-item-page-abstract-field>
|
||||||
|
<ds-item-page-uri-field [item]="item.payload | async"></ds-item-page-uri-field>
|
||||||
|
<ds-item-page-collections [item]="item.payload | async"></ds-item-page-collections>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Item } from "../core/shared/item.model";
|
import { Item } from "../core/shared/item.model";
|
||||||
import { ItemDataService } from "../core/data/item-data.service";
|
import { ItemDataService } from "../core/data/item-data.service";
|
||||||
@@ -10,7 +10,6 @@ import { Bitstream } from "../core/shared/bitstream.model";
|
|||||||
selector: 'ds-item-page',
|
selector: 'ds-item-page',
|
||||||
styleUrls: ['./item-page.component.css'],
|
styleUrls: ['./item-page.component.css'],
|
||||||
templateUrl: './item-page.component.html',
|
templateUrl: './item-page.component.html',
|
||||||
// changeDetection: ChangeDetectionStrategy.OnPush
|
|
||||||
})
|
})
|
||||||
export class ItemPageComponent implements OnInit {
|
export class ItemPageComponent implements OnInit {
|
||||||
|
|
||||||
|
@@ -13,6 +13,8 @@ import { ItemPageTitleFieldComponent } from './specific-field/title/item-page-ti
|
|||||||
import { ItemPageSpecificFieldComponent } from './specific-field/item-page-specific-field.component';
|
import { ItemPageSpecificFieldComponent } from './specific-field/item-page-specific-field.component';
|
||||||
import { SharedModule } from './../shared/shared.module';
|
import { SharedModule } from './../shared/shared.module';
|
||||||
import { ThumbnailComponent } from "../thumbnail/thumbnail.component";
|
import { ThumbnailComponent } from "../thumbnail/thumbnail.component";
|
||||||
|
import { FileSectionComponent } from "./file-section/file-section.component";
|
||||||
|
import { CollectionsComponent } from "./collections/collections.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -27,6 +29,8 @@ import { ThumbnailComponent } from "../thumbnail/thumbnail.component";
|
|||||||
ItemPageTitleFieldComponent,
|
ItemPageTitleFieldComponent,
|
||||||
ItemPageSpecificFieldComponent,
|
ItemPageSpecificFieldComponent,
|
||||||
ThumbnailComponent,
|
ThumbnailComponent,
|
||||||
|
FileSectionComponent,
|
||||||
|
CollectionsComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
ItemPageRoutingModule,
|
ItemPageRoutingModule,
|
||||||
|
@@ -1 +1,6 @@
|
|||||||
@import '../../../styles/variables.scss';
|
@import '../../../styles/variables.scss';
|
||||||
|
:host {
|
||||||
|
.simple-view-element {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
@@ -9,6 +9,7 @@ import { ItemPageSpecificFieldComponent } from "../item-page-specific-field.comp
|
|||||||
export class ItemPageAbstractFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
export class ItemPageAbstractFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
||||||
|
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
|
separator : string;
|
||||||
|
|
||||||
fields : string[] = [
|
fields : string[] = [
|
||||||
"dc.description.abstract"
|
"dc.description.abstract"
|
||||||
|
@@ -9,6 +9,7 @@ import { ItemPageSpecificFieldComponent } from "../item-page-specific-field.comp
|
|||||||
export class ItemPageDateFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
export class ItemPageDateFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
||||||
|
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
|
separator : string;
|
||||||
|
|
||||||
fields : string[] = [
|
fields : string[] = [
|
||||||
"dc.date.issued"
|
"dc.date.issued"
|
||||||
|
@@ -9,6 +9,7 @@ import { ItemPageSpecificFieldComponent } from "../item-page-specific-field.comp
|
|||||||
export class ItemPageTitleFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
export class ItemPageTitleFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
||||||
|
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
|
separator : string;
|
||||||
|
|
||||||
fields : string[] = [
|
fields : string[] = [
|
||||||
"dc.title"
|
"dc.title"
|
||||||
|
@@ -9,6 +9,8 @@ import { ItemPageSpecificFieldComponent } from "../item-page-specific-field.comp
|
|||||||
export class ItemPageUriFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
export class ItemPageUriFieldComponent extends ItemPageSpecificFieldComponent implements OnInit {
|
||||||
|
|
||||||
@Input() item: Item;
|
@Input() item: Item;
|
||||||
|
separator : string;
|
||||||
|
|
||||||
|
|
||||||
fields : string[] = [
|
fields : string[] = [
|
||||||
"dc.identifier.uri"
|
"dc.identifier.uri"
|
||||||
|
@@ -7,6 +7,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
|||||||
import { TranslateModule } from 'ng2-translate/ng2-translate';
|
import { TranslateModule } from 'ng2-translate/ng2-translate';
|
||||||
|
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
|
import { FileSizePipe } from "./utils/file-size-pipe";
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
@@ -19,6 +20,7 @@ const MODULES = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const PIPES = [
|
const PIPES = [
|
||||||
|
FileSizePipe
|
||||||
// put pipes here
|
// put pipes here
|
||||||
];
|
];
|
||||||
|
|
||||||
|
36
src/app/shared/utils/file-size-pipe.ts
Normal file
36
src/app/shared/utils/file-size-pipe.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert bytes into largest possible unit.
|
||||||
|
* Takes an precision argument that defaults to 2.
|
||||||
|
* Usage:
|
||||||
|
* bytes | fileSize:precision
|
||||||
|
* Example:
|
||||||
|
* {{ 1024 | fileSize}}
|
||||||
|
* formats to: 1 KB
|
||||||
|
*/
|
||||||
|
@Pipe({name: 'dsFileSize'})
|
||||||
|
export class FileSizePipe implements PipeTransform {
|
||||||
|
|
||||||
|
private units = [
|
||||||
|
'bytes',
|
||||||
|
'KiB',
|
||||||
|
'MiB',
|
||||||
|
'GiB',
|
||||||
|
'TiB',
|
||||||
|
'PiB'
|
||||||
|
];
|
||||||
|
|
||||||
|
transform(bytes: number = 0, precision: number = 2 ) : string {
|
||||||
|
if ( isNaN( parseFloat( String(bytes) )) || ! isFinite( bytes ) ) return '?';
|
||||||
|
|
||||||
|
let unit = 0;
|
||||||
|
|
||||||
|
while ( bytes >= 1024 ) {
|
||||||
|
bytes /= 1024;
|
||||||
|
unit ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes.toFixed( + precision ) + ' ' + this.units[ unit ];
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,7 @@ export const ITEMS = [
|
|||||||
"self": {
|
"self": {
|
||||||
"href": "/items/8871"
|
"href": "/items/8871"
|
||||||
},
|
},
|
||||||
"collections": [
|
"parents": [
|
||||||
{
|
{
|
||||||
"href": "/collections/5179"
|
"href": "/collections/5179"
|
||||||
},
|
},
|
||||||
@@ -96,7 +96,7 @@ export const ITEMS = [
|
|||||||
"self": {
|
"self": {
|
||||||
"href": "/items/9978"
|
"href": "/items/9978"
|
||||||
},
|
},
|
||||||
"collections": [
|
"parents": [
|
||||||
{
|
{
|
||||||
"href": "/collections/5179"
|
"href": "/collections/5179"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user