forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed all mistakes in the Item View page (#532)
* Redirect the user to the new browser page after click on featured service. * Show dropdown options in the featured services button - it was not working * Added the copy button into metadata field row. * Added missing Demo Uri metadata field * The referenced by is a hyperlink, the translations was added and fixed overlaying of big cz translation. * Replaced unwanted separator values in the Size metadata field. I've created a new pipe - dsReplaced * Updated messages for the full item page redirect * Updated metadata field translations * Show cursor on hover in the author preview component * Show handle and DOI identifier following the cfg. * Show different date messages in special occurrences * Show description with line breaks and redirection links. * Updated language and other metadata spacing with separator. * Added citation type to the bottom of the citation box. * Ref box should have full width * Fixed big spacing between metadata fields. It was because of d-inline-flex. * The full item view page looks almost the same as in the v5. * Make metadata values in the full item page clickable when there is a link and remove the separator `;` from the medata value. * Show language info only for admin * Added icons for every mimetype, that icon is showed up in the bitstream file box. * Collection component is aligned to other metadata values. * License info is different for CZ language and EN * Update button and form colors * Featured service dropdown options fixed. * fixed failing unit tests * Removed commented out and not used code.
- Loading branch information
1 parent
363c724
commit c48ef6c
Showing
515 changed files
with
886 additions
and
223 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/app/item-page/clarin-files-section/clarin-files-section.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<ng-container> | ||
<ds-clarin-license-info class="mt-3 d-block" [item]="item"></ds-clarin-license-info> | ||
<h6><i class="fa fa-paperclip"> </i>{{'item.page.files.head' | translate}}</h6> | ||
<div class="pb-3"> | ||
<span class="pr-1"> | ||
<a class="btn btn-download" (click)="setCommandline()" style="text-decoration: none" | ||
*ngIf="canShowCurlDownload"> | ||
<i class="fa fa-download fa-3x" style="display: block"> </i> | ||
{{'item.page.download.button.command.line' | translate}} | ||
</a> | ||
</span> | ||
<div id="command-div" *ngIf="isCommandLineVisible"> | ||
<button class="repo-copy-btn pull-right" data-clipboard-target="#command-div"></button> | ||
<pre style="background-color: #d9edf7; color: #3a87ad">{{ command }}</pre> | ||
</div> | ||
<span> | ||
<a *ngIf="canDownloadAllFiles" class="btn btn-download" id="download-all-button" (click)="downloadFiles()" | ||
style="visibility: visible"> | ||
<i style="display: block" class="fa fa-download fa-3x"> </i> | ||
{{'item.page.download.button.all.files.zip' | translate}} ({{ totalFileSizes }}) | ||
</a> | ||
</span> | ||
</div> | ||
<ds-preview-section [item]="item"></ds-preview-section> | ||
</ng-container> |
16 changes: 16 additions & 0 deletions
16
src/app/item-page/clarin-files-section/clarin-files-section.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
The styling file for the `clarin-files-section.component` | ||
*/ | ||
|
||
.btn-download{ | ||
color: #fff !important; | ||
background-color: #428bca; | ||
border-color: #357ebd; | ||
cursor: pointer; | ||
} | ||
|
||
.btn-download:hover { | ||
color: #fff; | ||
background-color: #3276b1; | ||
border-color: #285e8e; | ||
} |
69 changes: 69 additions & 0 deletions
69
src/app/item-page/clarin-files-section/clarin-files-section.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ClarinFilesSectionComponent } from './clarin-files-section.component'; | ||
import { RegistryService } from '../../core/registry/registry.service'; | ||
import { Router } from '@angular/router'; | ||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service'; | ||
import { RouterMock } from '../../shared/mocks/router.mock'; | ||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { MetadataBitstream } from '../../core/metadata/metadata-bitstream.model'; | ||
import { ResourceType } from '../../core/shared/resource-type'; | ||
import { HALLink } from '../../core/shared/hal-link.model'; | ||
import { BehaviorSubject , of} from 'rxjs'; | ||
|
||
describe('ClarinFilesSectionComponent', () => { | ||
let component: ClarinFilesSectionComponent; | ||
let fixture: ComponentFixture<ClarinFilesSectionComponent>; | ||
|
||
let mockRegistryService: any; | ||
let halService: HALEndpointService; | ||
// Set up the mock service's getMetadataBitstream method to return a simple stream | ||
const metadatabitstream = new MetadataBitstream(); | ||
metadatabitstream.id = 123; | ||
metadatabitstream.name = 'test'; | ||
metadatabitstream.description = 'test'; | ||
metadatabitstream.fileSize = '1MB'; | ||
metadatabitstream.checksum = 'abc'; | ||
metadatabitstream.type = new ResourceType('item'); | ||
metadatabitstream.fileInfo = []; | ||
metadatabitstream.format = 'text'; | ||
metadatabitstream.canPreview = false; | ||
metadatabitstream._links = { | ||
self: new HALLink(), | ||
schema: new HALLink(), | ||
}; | ||
|
||
metadatabitstream._links.self.href = ''; | ||
metadatabitstream._links.schema.href = ''; | ||
const metadataBitstreams: MetadataBitstream[] = [metadatabitstream]; | ||
const bitstreamStream = new BehaviorSubject(metadataBitstreams); | ||
|
||
beforeEach(async () => { | ||
mockRegistryService = jasmine.createSpyObj('RegistryService', { | ||
'getMetadataBitstream': of(bitstreamStream) | ||
} | ||
); | ||
halService = Object.assign(new HALEndpointServiceStub('some url')); | ||
|
||
await TestBed.configureTestingModule({ | ||
declarations: [ ClarinFilesSectionComponent ], | ||
imports: [ | ||
TranslateModule.forRoot() | ||
], | ||
providers: [ | ||
{ provide: RegistryService, useValue: mockRegistryService }, | ||
{ provide: Router, useValue: new RouterMock() }, | ||
{ provide: HALEndpointService, useValue: halService } | ||
], | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ClarinFilesSectionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
125 changes: 125 additions & 0 deletions
125
src/app/item-page/clarin-files-section/clarin-files-section.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Item } from '../../core/shared/item.model'; | ||
import { getAllSucceededRemoteListPayload } from '../../core/shared/operators'; | ||
import { getItemPageRoute } from '../item-page-routing-paths'; | ||
import { MetadataBitstream } from '../../core/metadata/metadata-bitstream.model'; | ||
import { RegistryService } from '../../core/registry/registry.service'; | ||
import { Router } from '@angular/router'; | ||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service'; | ||
|
||
@Component({ | ||
selector: 'ds-clarin-files-section', | ||
templateUrl: './clarin-files-section.component.html', | ||
styleUrls: ['./clarin-files-section.component.scss'] | ||
}) | ||
export class ClarinFilesSectionComponent implements OnInit { | ||
|
||
/** | ||
* The item to display files for | ||
*/ | ||
@Input() item: Item; | ||
|
||
/** | ||
* handle of the current item | ||
*/ | ||
@Input() itemHandle: string; | ||
|
||
canShowCurlDownload = false; | ||
|
||
/** | ||
* If download by command button is click, the command line will be shown | ||
*/ | ||
isCommandLineVisible = false; | ||
|
||
/** | ||
* command for the download command feature | ||
*/ | ||
command: string; | ||
|
||
/** | ||
* determine to show download all zip button or not | ||
*/ | ||
canDownloadAllFiles = false; | ||
|
||
/** | ||
* total size of list of files uploaded by users to this item | ||
*/ | ||
totalFileSizes: string; | ||
|
||
/** | ||
* list of files uploaded by users to this item | ||
*/ | ||
listOfFiles: MetadataBitstream[]; | ||
|
||
|
||
constructor(protected registryService: RegistryService, | ||
protected router: Router, | ||
protected halService: HALEndpointService) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.registryService | ||
.getMetadataBitstream(this.itemHandle, 'ORIGINAL,TEXT,THUMBNAIL') | ||
.pipe(getAllSucceededRemoteListPayload()) | ||
.subscribe((data: MetadataBitstream[]) => { | ||
this.listOfFiles = data; | ||
this.generateCurlCommand(); | ||
this.sumFileSizes(); | ||
}); | ||
} | ||
|
||
setCommandline() { | ||
this.isCommandLineVisible = !this.isCommandLineVisible; | ||
} | ||
|
||
downloadFiles() { | ||
void this.router.navigate([getItemPageRoute(this.item), 'download']); | ||
} | ||
|
||
generateCurlCommand() { | ||
const fileNames = this.listOfFiles.map((file: MetadataBitstream) => { | ||
// Show `Download All Files` only if there are more files. | ||
if (this.listOfFiles.length > 1) { | ||
this.canDownloadAllFiles = true; | ||
} | ||
|
||
if (file.canPreview) { | ||
this.canShowCurlDownload = true; | ||
} | ||
|
||
return file.name; | ||
}); | ||
|
||
this.command = `curl --remote-name-all ` + this.halService.getRootHref() + `/core/bitstreams/handle/${ | ||
this.itemHandle | ||
}/{${fileNames.join(',')}}`; | ||
} | ||
|
||
sumFileSizes() { | ||
const sizeUnits = { | ||
B: 1, | ||
KB: 1000, | ||
MB: 1000 * 1000, | ||
GB: 1000 * 1000 * 1000, | ||
TB: 1000 * 1000 * 1000 * 1000, | ||
}; | ||
|
||
let totalBytes = this.listOfFiles.reduce((total, file) => { | ||
const [valueStr, unit] = file.fileSize.split(' '); | ||
const value = parseFloat(valueStr); | ||
const bytes = value * sizeUnits[unit.toUpperCase()]; | ||
return total + bytes; | ||
}, 0); | ||
|
||
let finalUnit = 'B'; | ||
for (const unit of ['KB', 'MB', 'GB', 'TB']) { | ||
if (totalBytes < 1000) { | ||
break; | ||
} | ||
totalBytes /= 1000; | ||
finalUnit = unit; | ||
} | ||
|
||
this.totalFileSizes = totalBytes.toFixed(2) + ' ' + finalUnit; | ||
} | ||
} |
12 changes: 6 additions & 6 deletions
12
src/app/item-page/clarin-license-info/clarin-license-info.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div class="container pb-3"> | ||
<div class="container-fluid pb-3"> | ||
<ds-clarin-ref-citation [item]="item" class="row"></ds-clarin-ref-citation> | ||
<ds-clarin-ref-featured-services [item]="item" class="row"></ds-clarin-ref-featured-services> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.