Skip to content
Permalink
Browse files
feat(DMP): own resource viewer (DSP-1586) (#434)
* chore(dependencies): update package.lock after npm i

* chore(deps): bump dsp-ui version

* chore(dmp): init own resource viewer

* style(resource): correct position of tab bar

* feat(resource): own resource toolbar (copied from ui-lib)

* chore(resource): copy property view from ui-lib to own component

* refactor(resource): fix compound viewer

* test(resource): bug fixes in tests

* refactor(resource): clean up code

* refactor(resource): clean up code

* chore(resource): copy still-image viewer from ui-lib

* test(resource): fix test

* style(resource): new still image viewer navigation

* fix(resource): get rid of console warning

* refactor(resource): fix typo

* refactor(resource): clean up code

* refactor(resource): clean up code

* refactor(resource): clean up code

* refactor(resource): turn valueOperationEventSubscription into an array

* chore(deps): reinstall node modules

* chore(deps): reinstall node modules

Co-authored-by: mdelez <60604010+mdelez@users.noreply.github.com>
  • Loading branch information
kilchenmann and mdelez committed May 7, 2021
1 parent c4726fe commit 35bd7b342424e1db6d6c788cf3dff0c4c4e5d446
Showing with 5,044 additions and 5,126 deletions.
  1. +1,849 −5,110 package-lock.json
  2. +6 −0 src/app/app.module.ts
  3. +47 −0 src/app/workspace/resource/dsp-resource.ts
  4. +162 −0 src/app/workspace/resource/incoming.service.spec.ts
  5. +217 −0 src/app/workspace/resource/incoming.service.ts
  6. +78 −0 src/app/workspace/resource/representation/still-image/still-image.component.html
  7. +139 −0 src/app/workspace/resource/representation/still-image/still-image.component.scss
  8. +300 −0 src/app/workspace/resource/representation/still-image/still-image.component.spec.ts
  9. +543 −0 src/app/workspace/resource/representation/still-image/still-image.component.ts
  10. +53 −0 src/app/workspace/resource/resource-properties/resource-properties.component.html
  11. +137 −0 src/app/workspace/resource/resource-properties/resource-properties.component.scss
  12. +382 −0 src/app/workspace/resource/resource-properties/resource-properties.component.spec.ts
  13. +304 −0 src/app/workspace/resource/resource-properties/resource-properties.component.ts
  14. +71 −0 src/app/workspace/resource/resource-toolbar/resource-toolbar.component.html
  15. +37 −0 src/app/workspace/resource/resource-toolbar/resource-toolbar.component.scss
  16. +182 −0 src/app/workspace/resource/resource-toolbar/resource-toolbar.component.spec.ts
  17. +86 −0 src/app/workspace/resource/resource-toolbar/resource-toolbar.component.ts
  18. +60 −1 src/app/workspace/resource/resource.component.html
  19. +380 −14 src/app/workspace/resource/resource.component.ts
  20. +11 −1 src/assets/style/_elements.scss

Large diffs are not rendered by default.

@@ -90,6 +90,9 @@ import { SwitchPropertiesComponent } from './workspace/resource/resource-instanc
import { SelectResourceClassComponent } from './workspace/resource/resource-instance-form/select-resource-class/select-resource-class.component';
import { ResourceComponent } from './workspace/resource/resource.component';
import { ResultsComponent } from './workspace/results/results.component';
import { ResourceToolbarComponent } from './workspace/resource/resource-toolbar/resource-toolbar.component';
import { ResourcePropertiesComponent } from './workspace/resource/resource-properties/resource-properties.component';
import { StillImageComponent } from './workspace/resource/representation/still-image/still-image.component';

// translate: AoT requires an exported function for factories
export function httpLoaderFactory(httpClient: HttpClient) {
@@ -167,6 +170,9 @@ export function httpLoaderFactory(httpClient: HttpClient) {
UsersComponent,
UsersListComponent,
VisualizerComponent,
ResourceToolbarComponent,
ResourcePropertiesComponent,
StillImageComponent,
],
imports: [
AppRoutingModule,
@@ -0,0 +1,47 @@
import {
ReadResource,
ReadValue,
SystemPropertyDefinition
} from '@dasch-swiss/dsp-js';
import { PropertyInfoValues } from '@dasch-swiss/dsp-ui';

export class DspResource {

res: ReadResource;

resProps: PropertyInfoValues[] = []; // array of resource properties

systemProps: SystemPropertyDefinition[] = []; // array of system properties

// regions or sequences
incomingAnnotations: ReadResource[] = [];

// incoming stillImages, movingImages, audio etc.
incomingRepresentations: ReadResource[] = [];

constructor(resource: ReadResource) {

this.res = resource;
}
}

export class DspCompoundPosition {
offset: number; // current offset of search requests
maxOffsets: number; // max offsets in relation to totalPages
position: number; // current item position in offset sequence
page: number; // current and real page number in compound object
totalPages: number; // total pages (part of) in compound object

constructor(totalPages: number) {
this.totalPages = totalPages;
this.maxOffsets = Math.ceil(totalPages / 25) - 1;
}
}

export interface PropIriToNameMapping {
[index: string]: string;
}

export interface PropertyValues {
[index: string]: ReadValue[];
}
@@ -0,0 +1,162 @@
import { TestBed } from '@angular/core/testing';
import { DspApiConnectionToken } from '@dasch-swiss/dsp-ui';
import { IncomingService } from './incoming.service';

describe('IncomingService', () => {
let service: IncomingService;

beforeEach(() => {
const dspConnSpyObj = {
v2: {
search: jasmine.createSpyObj('search', ['doExtendedSearch'])
}
};

TestBed.configureTestingModule({
providers: [
{
provide: DspApiConnectionToken,
useValue: dspConnSpyObj
},
]
});
service = TestBed.inject(IncomingService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should get incoming regions ', () => {

const dspSpy = TestBed.inject(DspApiConnectionToken);

const expectedQuery = `
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#>
CONSTRUCT {
?region knora-api:isMainResource true .
?region knora-api:hasGeometry ?geom .
?region knora-api:hasComment ?comment .
?region knora-api:hasColor ?color .
} WHERE {
?region a knora-api:Region .
?region a knora-api:Resource .
?region knora-api:isRegionOf <http://rdfh.ch/0801/letter> .
knora-api:isRegionOf knora-api:objectType knora-api:Resource .
<http://rdfh.ch/0801/letter> a knora-api:Resource .
?region knora-api:hasGeometry ?geom .
knora-api:hasGeometry knora-api:objectType knora-api:Geom .
?geom a knora-api:Geom .
?region knora-api:hasComment ?comment .
knora-api:hasComment knora-api:objectType xsd:string .
?comment a xsd:string .
?region knora-api:hasColor ?color .
knora-api:hasColor knora-api:objectType knora-api:Color .
?color a knora-api:Color .
} OFFSET 0
`;

service.getIncomingRegions('http://rdfh.ch/0801/letter', 0);

expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery);

});

it('should get incoming StillImageRepresentations ', () => {

const dspSpy = TestBed.inject(DspApiConnectionToken);

const expectedQuery = `
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#>
CONSTRUCT {
?page knora-api:isMainResource true .
?page knora-api:seqnum ?seqnum .
?page knora-api:hasStillImageFile ?file .
} WHERE {
?page a knora-api:StillImageRepresentation .
?page a knora-api:Resource .
?page knora-api:isPartOf <http://rdfh.ch/0801/letter> .
knora-api:isPartOf knora-api:objectType knora-api:Resource .
<http://rdfh.ch/0801/letter> a knora-api:Resource .
?page knora-api:seqnum ?seqnum .
knora-api:seqnum knora-api:objectType xsd:integer .
?seqnum a xsd:integer .
?page knora-api:hasStillImageFile ?file .
knora-api:hasStillImageFile knora-api:objectType knora-api:File .
?file a knora-api:File .
} ORDER BY ?seqnum
OFFSET 1
`;

service.getStillImageRepresentationsForCompoundResource('http://rdfh.ch/0801/letter', 1);

expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery);

});

it('should get incoming Links', () => {

const dspSpy = TestBed.inject(DspApiConnectionToken);

const expectedQuery = `
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#>
CONSTRUCT {
?incomingRes knora-api:isMainResource true .
?incomingRes ?incomingProp <http://rdfh.ch/0801/letter> .
} WHERE {
?incomingRes a knora-api:Resource .
?incomingRes ?incomingProp <http://rdfh.ch/0801/letter> .
<http://rdfh.ch/0801/letter> a knora-api:Resource .
?incomingProp knora-api:objectType knora-api:Resource .
knora-api:isRegionOf knora-api:objectType knora-api:Resource .
knora-api:isPartOf knora-api:objectType knora-api:Resource .
FILTER NOT EXISTS {
?incomingRes knora-api:isRegionOf <http://rdfh.ch/0801/letter> .
}
FILTER NOT EXISTS {
?incomingRes knora-api:isPartOf <http://rdfh.ch/0801/letter> .
}
} OFFSET 0
`;

service.getIncomingLinksForResource('http://rdfh.ch/0801/letter', 0);

expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery);

});

});
Loading

0 comments on commit 35bd7b3

Please sign in to comment.