Skip to content
Snippets Groups Projects
Commit f80abb9f authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

50452: Bitstream format registry

parent 70c36f7f
Branches
Tags
No related merge requests found
Showing
with 360 additions and 14 deletions
......@@ -138,7 +138,7 @@
}
},
"schema": {
"title": "DSpace Angular :: Metadata Schema",
"title": "DSpace Angular :: Metadata Schema Registry",
"head": "Metadata Schema",
"description": "This is the metadata schema for \"{{namespace}}\".",
"fields": {
......@@ -148,6 +148,24 @@
"scopenote": "Scope Note"
}
}
},
"bitstream-formats": {
"title": "DSpace Angular :: Bitstream Format Registry",
"head": "Bitstream Format Registry",
"description": "This list of bitstream formats provides information about known formats and their support level.",
"formats": {
"table": {
"name": "Name",
"mimetype": "MIME Type",
"supportLevel": {
"head": "Support Level",
"0": "Unknown",
"1": "Known",
"2": "Support"
},
"internal": "internal"
}
}
}
}
},
......
......@@ -2,12 +2,14 @@ import { MetadataRegistryComponent } from './metadata-registry/metadata-registry
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { MetadataSchemaComponent } from './metadata-schema/metadata-schema.component';
import { BitstreamFormatsComponent } from './bitstream-formats/bitstream-formats.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'metadata', component: MetadataRegistryComponent, data: { title: 'admin.registries.metadata.title' } },
{ path: 'metadata/:schemaName', component: MetadataSchemaComponent, data: { title: 'admin.registries.schema.title' } }
{ path: 'metadata/:schemaName', component: MetadataSchemaComponent, data: { title: 'admin.registries.schema.title' } },
{ path: 'bitstream-formats', component: BitstreamFormatsComponent, data: { title: 'admin.registries.bitstream-formats.title' } },
])
]
})
......
......@@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common';
import { MetadataSchemaComponent } from './metadata-schema/metadata-schema.component';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { BitstreamFormatsComponent } from './bitstream-formats/bitstream-formats.component';
@NgModule({
imports: [
......@@ -15,7 +16,8 @@ import { TranslateModule } from '@ngx-translate/core';
],
declarations: [
MetadataRegistryComponent,
MetadataSchemaComponent
MetadataSchemaComponent,
BitstreamFormatsComponent
]
})
export class AdminRegistriesModule {
......
<div class="container">
<div class="bitstream-formats row">
<div class="col-12">
<h2 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats.head' | translate}}</h2>
<p id="description" class="pb-2">{{'admin.registries.bitstream-formats.description' | translate}}</p>
<div class="table-responsive">
<table id="formats" class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.name' | translate}}</th>
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.mimetype' | translate}}</th>
<th scope="col">{{'admin.registries.bitstream-formats.formats.table.supportLevel.head' | translate}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let bitstreamFormat of (bitstreamFormats | async)?.payload?.page">
<td>{{bitstreamFormat.shortDescription}}</td>
<td>{{bitstreamFormat.mimetype}} <span *ngIf="bitstreamFormat.internal">({{'admin.registries.bitstream-formats.formats.table.internal' | translate}})</span></td>
<td>{{'admin.registries.bitstream-formats.formats.table.supportLevel.'+bitstreamFormat.supportLevel | translate}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
import { BitstreamFormatsComponent } from './bitstream-formats.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RegistryService } from '../../../core/registry/registry.service';
import { Observable } from 'rxjs/Observable';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser';
describe('BitstreamFormatsComponent', () => {
let comp: BitstreamFormatsComponent;
let fixture: ComponentFixture<BitstreamFormatsComponent>;
let registryService: RegistryService;
const mockFormatsList = [
{
shortDescription: 'Unknown',
description: 'Unknown data format',
mimetype: 'application/octet-stream',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'License',
description: 'Item-specific license agreed upon to submission',
mimetype: 'text/plain; charset=utf-8',
supportLevel: 1,
internal: true,
extensions: null
},
{
shortDescription: 'CC License',
description: 'Item-specific Creative Commons license agreed upon to submission',
mimetype: 'text/html; charset=utf-8',
supportLevel: 2,
internal: true,
extensions: null
},
{
shortDescription: 'Adobe PDF',
description: 'Adobe Portable Document Format',
mimetype: 'application/pdf',
supportLevel: 0,
internal: false,
extensions: null
}
];
const mockFormats = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList)));
const registryServiceStub = {
getBitstreamFormats: () => mockFormats
};
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot()],
declarations: [BitstreamFormatsComponent],
providers: [
{ provide: RegistryService, useValue: registryServiceStub }
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BitstreamFormatsComponent);
comp = fixture.componentInstance;
fixture.detectChanges();
registryService = (comp as any).service;
});
it('should contain four formats', () => {
const tbody: HTMLElement = fixture.debugElement.query(By.css('#formats>tbody')).nativeElement;
expect(tbody.children.length).toBe(4);
});
it('should contain the correct formats', () => {
const unknownName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(1) td:nth-child(1)')).nativeElement;
expect(unknownName.textContent).toBe('Unknown');
const licenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(2) td:nth-child(1)')).nativeElement;
expect(licenseName.textContent).toBe('License');
const ccLicenseName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(3) td:nth-child(1)')).nativeElement;
expect(ccLicenseName.textContent).toBe('CC License');
const adobeName: HTMLElement = fixture.debugElement.query(By.css('#formats tr:nth-child(4) td:nth-child(1)')).nativeElement;
expect(adobeName.textContent).toBe('Adobe PDF');
});
});
import { Component } from '@angular/core';
import { RegistryService } from '../../../core/registry/registry.service';
import { Observable } from 'rxjs/Observable';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { BitstreamFormat } from '../../../core/registry/mock-bitstream-format.model';
@Component({
selector: 'ds-bitstream-formats',
templateUrl: './bitstream-formats.component.html'
})
export class BitstreamFormatsComponent {
bitstreamFormats: Observable<RemoteData<PaginatedList<BitstreamFormat>>>;
constructor(registryService: RegistryService) {
this.bitstreamFormats = registryService.getBitstreamFormats();
}
}
......@@ -8,11 +8,12 @@ import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { RegistryService } from '../../../core/registry/registry.service';
describe('MetadataRegistryComponent', () => {
let comp: MetadataRegistryComponent;
let fixture: ComponentFixture<MetadataRegistryComponent>;
let metadataRegistryService: MetadataRegistryService;
let registryService: RegistryService;
const mockSchemasList = [
{
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1',
......@@ -26,7 +27,7 @@ describe('MetadataRegistryComponent', () => {
}
];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const metadataRegistryServiceStub = {
const registryServiceStub = {
getMetadataSchemas: () => mockSchemas
};
......@@ -35,16 +36,16 @@ describe('MetadataRegistryComponent', () => {
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot()],
declarations: [MetadataRegistryComponent],
providers: [
{ provide: MetadataRegistryService, useValue: metadataRegistryServiceStub }
{ provide: RegistryService, useValue: registryServiceStub }
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MetadataRegistryComponent);
comp = fixture.componentInstance; // SearchPageComponent test instance
comp = fixture.componentInstance;
fixture.detectChanges();
metadataRegistryService = (comp as any).service;
registryService = (comp as any).service;
});
it('should contain two schemas', () => {
......
......@@ -10,11 +10,12 @@ import { CommonModule } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import { By } from '@angular/platform-browser';
import { MockTranslateLoader } from '../../../shared/testing/mock-translate-loader';
import { RegistryService } from '../../../core/registry/registry.service';
describe('MetadataSchemaComponent', () => {
let comp: MetadataSchemaComponent;
let fixture: ComponentFixture<MetadataSchemaComponent>;
let metadataRegistryService: MetadataRegistryService;
let registryService: RegistryService;
const mockSchemasList = [
{
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1',
......@@ -58,7 +59,7 @@ describe('MetadataSchemaComponent', () => {
}
];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const metadataRegistryServiceStub = {
const registryServiceStub = {
getMetadataSchemas: () => mockSchemas,
getMetadataFieldsBySchema: (schema: MetadataSchema) => Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFieldsList.filter((value) => value.schema === schema)))),
getMetadataSchemaByName: (schemaName: string) => Observable.of(new RemoteData(false, false, true, undefined, mockSchemasList.filter((value) => value.prefix === schemaName)[0]))
......@@ -75,7 +76,7 @@ describe('MetadataSchemaComponent', () => {
imports: [CommonModule, TranslateModule.forRoot()],
declarations: [MetadataSchemaComponent],
providers: [
{ provide: MetadataRegistryService, useValue: metadataRegistryServiceStub },
{ provide: RegistryService, useValue: registryServiceStub },
{ provide: ActivatedRoute, useValue: activatedRouteStub }
]
}).compileComponents();
......@@ -83,9 +84,9 @@ describe('MetadataSchemaComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(MetadataSchemaComponent);
comp = fixture.componentInstance; // SearchPageComponent test instance
comp = fixture.componentInstance;
fixture.detectChanges();
metadataRegistryService = (comp as any).service;
registryService = (comp as any).service;
});
it('should contain the schema prefix in the header', () => {
......
export class BitstreamFormat {
shortDescription: string;
description: string;
mimetype: string;
supportLevel: number;
internal: boolean;
extensions: string;
}
......@@ -5,12 +5,14 @@ import { PaginatedList } from '../data/paginated-list';
import { PageInfo } from '../shared/page-info.model';
import { MetadataSchema } from '../metadata/metadataschema.model';
import { MetadataField } from '../metadata/metadatafield.model';
import { BitstreamFormat } from './mock-bitstream-format.model';
Injectable()
export class RegistryService {
metadataSchemas: MetadataSchema[];
metadataFields: MetadataField[];
bitstreamFormats: BitstreamFormat[];
public getMetadataSchemas(): Observable<RemoteData<PaginatedList<MetadataSchema>>> {
const pageInfo = new PageInfo();
......@@ -38,6 +40,16 @@ export class RegistryService {
return Observable.of(remoteData);
}
public getBitstreamFormats(): Observable<RemoteData<PaginatedList<BitstreamFormat>>> {
const pageInfo = new PageInfo();
pageInfo.elementsPerPage = 10;
pageInfo.currentPage = 1;
const payload = new PaginatedList(pageInfo, this.bitstreamFormats);
const remoteData = new RemoteData(false, false, true, undefined, payload);
return Observable.of(remoteData);
}
constructor() {
this.metadataSchemas = [
{
......@@ -1018,7 +1030,169 @@ export class RegistryService {
scopenote: null,
schema: this.metadataSchemas[1]
}
]
];
this.bitstreamFormats = [
{
shortDescription: 'Unknown',
description: 'Unknown data format',
mimetype: 'application/octet-stream',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'License',
description: 'Item-specific license agreed upon to submission',
mimetype: 'text/plain; charset=utf-8',
supportLevel: 1,
internal: true,
extensions: null
},
{
shortDescription: 'CC License',
description: 'Item-specific Creative Commons license agreed upon to submission',
mimetype: 'text/html; charset=utf-8',
supportLevel: 2,
internal: true,
extensions: null
},
{
shortDescription: 'Adobe PDF',
description: 'Adobe Portable Document Format',
mimetype: 'application/pdf',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'XML',
description: 'Extensible Markup Language',
mimetype: 'text/xml',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Text',
description: 'Plain Text',
mimetype: 'text/plain',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'HTML',
description: 'Hypertext Markup Language',
mimetype: 'text/html',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'CSS',
description: 'Cascading Style Sheets',
mimetype: 'text/css',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Word',
description: 'Microsoft Word',
mimetype: 'application/msword',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Word XML',
description: 'Microsoft Word XML',
mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Powerpoint',
description: 'Microsoft Powerpoint',
mimetype: 'application/vnd.ms-powerpoint',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Powerpoint XML',
description: 'Microsoft Powerpoint XML',
mimetype: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Excel',
description: 'Microsoft Excel',
mimetype: 'application/vnd.ms-excel',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'Microsoft Excel XML',
description: 'Microsoft Excel XML',
mimetype: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'MARC',
description: 'Machine-Readable Cataloging records',
mimetype: 'application/marc',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'JPEG',
description: 'Joint Photographic Experts Group/JPEG File Interchange Format (JFIF)',
mimetype: 'image/jpeg',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'GIF',
description: 'Graphics Interchange Format',
mimetype: 'image/gif',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'image/png',
description: 'Portable Network Graphics',
mimetype: 'image/png',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'TIFF',
description: 'Tag Image File Format',
mimetype: 'image/tiff',
supportLevel: 0,
internal: false,
extensions: null
},
{
shortDescription: 'AIFF',
description: 'Audio Interchange File Format',
mimetype: 'audio/x-aiff',
supportLevel: 0,
internal: false,
extensions: null
}
];
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment