diff --git a/package-lock.json b/package-lock.json
index ad2e386c13..b9e5f2e3c4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,6 +5,7 @@
"requires": true,
"packages": {
"": {
+ "name": "dsp-app",
"version": "7.0.1",
"dependencies": {
"@angular/animations": "^11.2.9",
@@ -4899,7 +4900,6 @@
"version": "9.0.0",
"dev": true,
"license": "MIT",
- "peer": true,
"peerDependencies": {
"tslib": "^1.10.0"
}
@@ -4908,7 +4908,6 @@
"version": "9.0.0",
"dev": true,
"license": "MIT",
- "peer": true,
"peerDependencies": {
"rxjs": "^6.5.3",
"tslib": "^1.10.0",
@@ -11156,7 +11155,6 @@
"node_modules/ng2-pdf-viewer/node_modules/pdfjs-dist": {
"version": "2.7.570",
"license": "Apache-2.0",
- "peer": true,
"peerDependencies": {
"worker-loader": "^3.0.7"
}
@@ -21763,6 +21761,8 @@
"version": "6.0.2",
"dev": true,
"requires": {
+ "@angular/compiler": "9.0.0",
+ "@angular/core": "9.0.0",
"app-root-path": "^3.0.0",
"aria-query": "^3.0.0",
"axobject-query": "2.0.2",
@@ -21780,13 +21780,11 @@
"@angular/compiler": {
"version": "9.0.0",
"dev": true,
- "peer": true,
"requires": {}
},
"@angular/core": {
"version": "9.0.0",
"dev": true,
- "peer": true,
"requires": {}
},
"source-map": {
@@ -26063,12 +26061,12 @@
"ng2-pdf-viewer": {
"version": "7.0.1",
"requires": {
+ "pdfjs-dist": "~2.7.570",
"tslib": "^2.0.0"
},
"dependencies": {
"pdfjs-dist": {
"version": "2.7.570",
- "peer": true,
"requires": {}
}
}
diff --git a/src/app/app-init.service.spec.ts b/src/app/app-init.service.spec.ts
index d2e81ae963..2321cefec6 100644
--- a/src/app/app-init.service.spec.ts
+++ b/src/app/app-init.service.spec.ts
@@ -19,6 +19,7 @@ describe('TestService', () => {
jsonWebToken: 'mytoken',
logErrors: true,
geonameToken: 'geoname_token',
+ iriBase: 'http://rdfh.ch',
instrumentation: {
environment: 'dev',
dataDog: {
@@ -84,6 +85,7 @@ describe('TestService', () => {
expect(service.dspApiConfig.jsonWebToken).toEqual('mytoken');
expect(service.dspApiConfig.logErrors).toEqual(true);
expect(service.dspAppConfig.geonameToken).toEqual('geoname_token');
+ expect(service.dspAppConfig.iriBase).toEqual('http://rdfh.ch');
expect(service.dspInstrumentationConfig.environment).toEqual('dev');
expect(service.dspInstrumentationConfig.dataDog.enabled).toEqual(true);
expect(service.dspInstrumentationConfig.dataDog.applicationId).toEqual('app_id');
diff --git a/src/app/app-init.service.ts b/src/app/app-init.service.ts
index a1c48baf95..b3b179309d 100644
--- a/src/app/app-init.service.ts
+++ b/src/app/app-init.service.ts
@@ -71,7 +71,8 @@ export class AppInitService {
// init dsp app extended configuration
this._dspAppConfig = new DspAppConfig(
- this._config.geonameToken
+ this._config.geonameToken,
+ this._config.iriBase
);
// init instrumentation configuration
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index a571ad2317..93165fc759 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -162,13 +162,17 @@ const routes: Routes = [
]
},
{
- path: 'resource/:id',
- component: ResourceComponent,
- runGuardsAndResolvers: 'always'
- },
- {
- path: 'resource/:id/:val',
- component: ResourceComponent,
+ path: 'resource',
+ children: [
+ {
+ path: ':project/:resource/:value',
+ component: ResourceComponent
+ },
+ {
+ path: ':project/:resource',
+ component: ResourceComponent,
+ }
+ ],
runGuardsAndResolvers: 'always'
},
{
diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts
index 8737f7696f..62de8b4612 100644
--- a/src/app/app.component.spec.ts
+++ b/src/app/app.component.spec.ts
@@ -1,5 +1,5 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { waitForAsync, TestBed } from '@angular/core/testing';
+import { TestBed, waitForAsync } from '@angular/core/testing';
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
@@ -12,8 +12,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { TestConfig } from 'test.config';
import { AppInitService } from './app-init.service';
import { AppComponent } from './app.component';
-import { DspApiConfigToken, DspApiConnectionToken, DspInstrumentationToken } from './main/declarations/dsp-api-tokens';
-import { DspDataDogConfig, DspInstrumentationConfig } from './main/declarations/dsp-instrumentation-config';
+import { DspApiConfigToken, DspApiConnectionToken } from './main/declarations/dsp-api-tokens';
import { HeaderComponent } from './main/header/header.component';
import { SelectLanguageComponent } from './main/select-language/select-language.component';
import { UserMenuComponent } from './user/user-menu/user-menu.component';
diff --git a/src/app/main/declarations/app-config.ts b/src/app/main/declarations/app-config.ts
index 3aeb082d91..e3ffa29bed 100644
--- a/src/app/main/declarations/app-config.ts
+++ b/src/app/main/declarations/app-config.ts
@@ -7,6 +7,7 @@ export interface IConfig {
iiifHost: string;
iiifPort: number;
iiifPath: string;
+ iriBase: string;
jsonWebToken: string;
geonameToken: string;
logErrors: boolean;
diff --git a/src/app/main/declarations/dsp-app-config.ts b/src/app/main/declarations/dsp-app-config.ts
index e75e27a775..4cd51cdc17 100644
--- a/src/app/main/declarations/dsp-app-config.ts
+++ b/src/app/main/declarations/dsp-app-config.ts
@@ -1,5 +1,6 @@
export class DspAppConfig {
constructor(
- public geonameToken: string
+ public geonameToken: string,
+ public iriBase: string
) { }
}
diff --git a/src/app/workspace/resource/properties/properties.component.html b/src/app/workspace/resource/properties/properties.component.html
index 79312cabba..d3d7f5f8cf 100644
--- a/src/app/workspace/resource/properties/properties.component.html
+++ b/src/app/workspace/resource/properties/properties.component.html
@@ -150,7 +150,7 @@
-
{{inRes.label}}
+
{{inRes.label}}
25"
[length]=numberOffAllIncomingLinkRes
[pageSize]="25"
diff --git a/src/app/workspace/resource/properties/properties.component.spec.ts b/src/app/workspace/resource/properties/properties.component.spec.ts
index 8326261d34..8fe0dde684 100644
--- a/src/app/workspace/resource/properties/properties.component.spec.ts
+++ b/src/app/workspace/resource/properties/properties.component.spec.ts
@@ -1,6 +1,7 @@
import { ClipboardModule } from '@angular/cdk/clipboard';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatSnackBarModule } from '@angular/material/snack-bar';
@@ -23,14 +24,15 @@ import {
SystemPropertyDefinition
} from '@dasch-swiss/dsp-js';
import { of, Subscription } from 'rxjs';
+import { AppInitService } from 'src/app/app-init.service';
+import { DspApiConnectionToken, DspAppConfigToken } from 'src/app/main/declarations/dsp-api-tokens';
+import { DspAppConfig } from 'src/app/main/declarations/dsp-app-config';
+import { TestConfig } from 'test.config';
import { DspResource } from '../dsp-resource';
-import { PropertiesComponent, PropertyInfoValues } from './properties.component';
-import { IncomingService } from '../incoming.service';
-import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
+import { IncomingService } from '../services/incoming.service';
import { UserService } from '../services/user.service';
-import { MatDialogModule } from '@angular/material/dialog';
-import { AppInitService } from 'src/app/app-init.service';
import { EmitEvent, Events, ValueOperationEventService } from '../services/value-operation-event.service';
+import { PropertiesComponent, PropertyInfoValues } from './properties.component';
/**
* test host component to simulate parent component.
@@ -147,6 +149,12 @@ describe('PropertiesComponent', () => {
const incomingServiceSpy = jasmine.createSpyObj('IncomingService', ['getIncomingLinks']);
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch'
+ }
+ };
+
TestBed.configureTestingModule({
imports: [
ClipboardModule,
@@ -178,6 +186,10 @@ describe('PropertiesComponent', () => {
provide: IncomingService,
useValue: incomingServiceSpy
},
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
+ }
]
})
.compileComponents();
diff --git a/src/app/workspace/resource/properties/properties.component.ts b/src/app/workspace/resource/properties/properties.component.ts
index 170716afa6..e993a5d006 100644
--- a/src/app/workspace/resource/properties/properties.component.ts
+++ b/src/app/workspace/resource/properties/properties.component.ts
@@ -32,8 +32,9 @@ import { ConfirmationWithComment, DialogComponent } from 'src/app/main/dialog/di
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { NotificationService } from 'src/app/main/services/notification.service';
import { DspResource } from '../dsp-resource';
-import { IncomingService } from '../incoming.service';
import { RepresentationConstants } from '../representation/file-representation';
+import { IncomingService } from '../services/incoming.service';
+import { ResourceService } from '../services/resource.service';
import { UserService } from '../services/user.service';
import {
AddedEventValue,
@@ -142,11 +143,12 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
@Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection,
private _dialog: MatDialog,
private _errorHandler: ErrorHandlerService,
+ private _incomingService: IncomingService,
private _notification: NotificationService,
+ private _resourceService: ResourceService,
private _userService: UserService,
private _valueOperationEventService: ValueOperationEventService,
private _valueService: ValueService,
- private _incomingService: IncomingService
) { }
ngOnInit(): void {
@@ -262,8 +264,9 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
* @param linkValue
*/
openResource(linkValue: ReadLinkValue | string) {
- const id = ((typeof linkValue == 'string') ? linkValue : linkValue.linkedResourceIri);
- window.open('/resource/' + encodeURIComponent(id), '_blank');
+ const iri = ((typeof linkValue == 'string') ? linkValue : linkValue.linkedResourceIri);
+ const path = this._resourceService.getResourcePath(iri);
+ window.open('/resource' + path, '_blank');
}
previewResource(linkValue: ReadLinkValue) {
diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.spec.ts b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.spec.ts
index 7d2ac31609..168a247e7d 100644
--- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.spec.ts
+++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.spec.ts
@@ -24,9 +24,7 @@ import {
MockResource,
MockUsers,
OntologiesEndpointV2,
- OntologiesMetadata,
- ReadOntology,
- ReadResource,
+ OntologiesMetadata, ReadResource,
ResourceClassAndPropertyDefinitions,
ResourceClassDefinition,
ResourcePropertyDefinition,
@@ -35,10 +33,10 @@ import {
UserResponse,
UsersEndpointAdmin
} from '@dasch-swiss/dsp-js';
-import { OntologyCache } from '@dasch-swiss/dsp-js/src/cache/ontology-cache/OntologyCache';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { AjaxResponse } from 'rxjs/ajax';
+import { AppInitService } from 'src/app/app-init.service';
import { CacheService } from 'src/app/main/cache/cache.service';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { BaseValueDirective } from 'src/app/main/directive/base-value.directive';
@@ -309,6 +307,11 @@ describe('ResourceInstanceFormComponent', () => {
const cacheServiceSpy = jasmine.createSpyObj('CacheService', ['get']);
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch'
+ }
+ };
// const routerSpy = jasmine.createSpyObj('Router', ['navigate', 'navigateByUrl']);
TestBed.configureTestingModule({
@@ -348,6 +351,10 @@ describe('ResourceInstanceFormComponent', () => {
provide: CacheService,
useValue: cacheServiceSpy
},
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
+ },
// {
// provide: Router,
// useValue: routerSpy
diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts
index d61a28362a..c057f24797 100644
--- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts
+++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Inject, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import {
ApiResponseError,
@@ -20,7 +20,8 @@ import { Subscription } from 'rxjs';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { DefaultClass, DefaultResourceClasses } from 'src/app/project/ontology/default-data/default-resource-classes';
-import { ProjectService } from '../project.service';
+import { ProjectService } from '../services/project.service';
+import { ResourceService } from '../services/resource.service';
import { SelectOntologyComponent } from './select-ontology/select-ontology.component';
import { SelectPropertiesComponent } from './select-properties/select-properties.component';
import { SelectResourceClassComponent } from './select-resource-class/select-resource-class.component';
@@ -87,6 +88,7 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
private _errorHandler: ErrorHandlerService,
private _fb: FormBuilder,
private _project: ProjectService,
+ private _resourceService: ResourceService,
private _router: Router
) { }
@@ -200,7 +202,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
(res: ReadResource) => {
this.resource = res;
- const goto = '/resource/' + encodeURIComponent(this.resource.id);
+ const path = this._resourceService.getResourcePath(this.resource.id);
+
+ const goto = '/resource' + path;
this._router.navigate([]).then(result => window.open(goto, '_blank'));
this.closeDialog.emit();
diff --git a/src/app/workspace/resource/resource-link-form/resource-link-form.component.spec.ts b/src/app/workspace/resource/resource-link-form/resource-link-form.component.spec.ts
index 5a384fdf56..0a4ba4732e 100644
--- a/src/app/workspace/resource/resource-link-form/resource-link-form.component.spec.ts
+++ b/src/app/workspace/resource/resource-link-form/resource-link-form.component.spec.ts
@@ -28,6 +28,7 @@ import {
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { AjaxResponse } from 'rxjs/ajax';
+import { AppInitService } from 'src/app/app-init.service';
import { CacheService } from 'src/app/main/cache/cache.service';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { Session, SessionService } from 'src/app/main/services/session.service';
@@ -122,6 +123,12 @@ describe('ResourceLinkFormComponent', () => {
const cacheServiceSpy = jasmine.createSpyObj('CacheService', ['get']);
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch'
+ }
+ };
+
TestBed.configureTestingModule({
declarations: [
ResourceLinkFormComponent,
@@ -143,6 +150,7 @@ describe('ResourceLinkFormComponent', () => {
TranslateModule.forRoot()
],
providers: [
+ AppInitService,
{
provide: DspApiConnectionToken,
useValue: dspConnSpy
@@ -154,6 +162,10 @@ describe('ResourceLinkFormComponent', () => {
{
provide: CacheService,
useValue: cacheServiceSpy
+ },
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
}
]
})
diff --git a/src/app/workspace/resource/resource-link-form/resource-link-form.component.ts b/src/app/workspace/resource/resource-link-form/resource-link-form.component.ts
index 270aeed9d6..d930ff8513 100644
--- a/src/app/workspace/resource/resource-link-form/resource-link-form.component.ts
+++ b/src/app/workspace/resource/resource-link-form/resource-link-form.component.ts
@@ -14,7 +14,8 @@ import {
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { FilteredResources } from '../../results/list-view/list-view.component';
-import { ProjectService } from '../project.service';
+import { ProjectService } from '../services/project.service';
+import { ResourceService } from '../services/resource.service';
@Component({
selector: 'app-resource-link-form',
@@ -54,6 +55,7 @@ export class ResourceLinkFormComponent implements OnInit {
private _errorHandler: ErrorHandlerService,
private _fb: FormBuilder,
private _project: ProjectService,
+ private _resourceService: ResourceService,
private _router: Router
) { }
@@ -148,8 +150,8 @@ export class ResourceLinkFormComponent implements OnInit {
this._dspApiConnection.v2.res.createResource(linkObj).subscribe(
(res: ReadResource) => {
- // --> TODO: do something with the successful response
- const goto = '/resource/' + encodeURIComponent(res.id);
+ const path = this._resourceService.getResourcePath(res.id);
+ const goto = '/resource' + path;
this._router.navigate([]).then(result => window.open(goto, '_blank'));
this.closeDialog.emit();
this.loading = false;
diff --git a/src/app/workspace/resource/resource.component.spec.ts b/src/app/workspace/resource/resource.component.spec.ts
index 984705700e..6e7ccc1def 100644
--- a/src/app/workspace/resource/resource.component.spec.ts
+++ b/src/app/workspace/resource/resource.component.spec.ts
@@ -13,6 +13,12 @@ describe('ResourceComponent', () => {
let component: ResourceComponent;
let fixture: ComponentFixture;
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch'
+ }
+ };
+
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ResourceComponent],
@@ -31,6 +37,10 @@ describe('ResourceComponent', () => {
{
provide: DspApiConnectionToken,
useValue: new KnoraApiConnection(TestConfig.ApiConfig)
+ },
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
}
]
}).compileComponents();
diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts
index a94bc2253d..0b694fe9e0 100644
--- a/src/app/workspace/resource/resource.component.ts
+++ b/src/app/workspace/resource/resource.component.ts
@@ -25,10 +25,11 @@ import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { NotificationService } from 'src/app/main/services/notification.service';
import { Session, SessionService } from 'src/app/main/services/session.service';
import { DspCompoundPosition, DspResource } from './dsp-resource';
-import { IncomingService } from './incoming.service';
import { PropertyInfoValues } from './properties/properties.component';
import { FileRepresentation, RepresentationConstants } from './representation/file-representation';
import { Region, StillImageComponent } from './representation/still-image/still-image.component';
+import { IncomingService } from './services/incoming.service';
+import { ResourceService } from './services/resource.service';
import { ValueOperationEventService } from './services/value-operation-event.service';
@Component({
@@ -43,6 +44,9 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
@Input() resourceIri: string;
+ projectCode: string;
+
+ resourceUuid: string;
// used to store the uuid of the value that is parsed from the url params
valueUuid: string;
@@ -90,15 +94,18 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
private _errorHandler: ErrorHandlerService,
private _incomingService: IncomingService,
private _notification: NotificationService,
+ private _resourceService: ResourceService,
private _route: ActivatedRoute,
private _router: Router,
private _session: SessionService,
- private _titleService: Title
+ private _titleService: Title,
) {
this._route.params.subscribe(params => {
- this.resourceIri = params['id'];
- this.valueUuid = params['val'];
+ this.projectCode = params['project'];
+ this.resourceUuid = params['resource'];
+ this.valueUuid = params['value'];
+ this.resourceIri = this._resourceService.getResourceIri(this.projectCode, this.resourceUuid);
this.getResource(this.resourceIri);
});
diff --git a/src/app/workspace/resource/services/geoname.service.spec.ts b/src/app/workspace/resource/services/geoname.service.spec.ts
index dda07123ad..652b5c2884 100644
--- a/src/app/workspace/resource/services/geoname.service.spec.ts
+++ b/src/app/workspace/resource/services/geoname.service.spec.ts
@@ -213,7 +213,6 @@ describe('GeonameService', () => {
dspAppConfig: {
geonameToken: 'token'
}
-
};
beforeEach(() => {
diff --git a/src/app/workspace/resource/incoming.service.spec.ts b/src/app/workspace/resource/services/incoming.service.spec.ts
similarity index 100%
rename from src/app/workspace/resource/incoming.service.spec.ts
rename to src/app/workspace/resource/services/incoming.service.spec.ts
diff --git a/src/app/workspace/resource/incoming.service.ts b/src/app/workspace/resource/services/incoming.service.ts
similarity index 100%
rename from src/app/workspace/resource/incoming.service.ts
rename to src/app/workspace/resource/services/incoming.service.ts
diff --git a/src/app/workspace/resource/project.service.spec.ts b/src/app/workspace/resource/services/project.service.spec.ts
similarity index 100%
rename from src/app/workspace/resource/project.service.spec.ts
rename to src/app/workspace/resource/services/project.service.spec.ts
diff --git a/src/app/workspace/resource/project.service.ts b/src/app/workspace/resource/services/project.service.ts
similarity index 93%
rename from src/app/workspace/resource/project.service.ts
rename to src/app/workspace/resource/services/project.service.ts
index adc491d68e..36c6d2ddf3 100644
--- a/src/app/workspace/resource/project.service.ts
+++ b/src/app/workspace/resource/services/project.service.ts
@@ -1,5 +1,13 @@
import { Inject, Injectable } from '@angular/core';
-import { ApiResponseData, ApiResponseError, Constants, KnoraApiConnection, ProjectsResponse, StoredProject, UserResponse } from '@dasch-swiss/dsp-js';
+import {
+ ApiResponseData,
+ ApiResponseError,
+ Constants,
+ KnoraApiConnection,
+ ProjectsResponse,
+ StoredProject,
+ UserResponse
+} from '@dasch-swiss/dsp-js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { CacheService } from 'src/app/main/cache/cache.service';
diff --git a/src/app/workspace/resource/services/resource.service.spec.ts b/src/app/workspace/resource/services/resource.service.spec.ts
new file mode 100644
index 0000000000..89e3eb605f
--- /dev/null
+++ b/src/app/workspace/resource/services/resource.service.spec.ts
@@ -0,0 +1,70 @@
+import { TestBed } from '@angular/core/testing';
+import { AppInitService } from 'src/app/app-init.service';
+import { ResourceService } from './resource.service';
+
+describe('ResourceService with iriBase = http://rdfh.ch', () => {
+ let service: ResourceService;
+
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch'
+ }
+ };
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
+ }
+ ]
+ });
+ service = TestBed.inject(ResourceService);
+ expect(service).toBeTruthy();
+ });
+
+ it('should return the resource iri from project code and resource uuid', () => {
+ const iri = service.getResourceIri('082B', 'SQkTPdHdTzq_gqbwj6QR-A');
+ expect(iri).toEqual('http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ });
+
+ it('should return the app\'s resource path from project iri', () => {
+ const path = service.getResourcePath('http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ expect(path).toEqual('/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ });
+});
+
+// if the iriBase has an slash at the end
+describe('ResourceService with iriBase = http://rdfh.ch/', () => {
+ let service: ResourceService;
+
+ const appInitSpy = {
+ dspAppConfig: {
+ iriBase: 'http://rdfh.ch/'
+ }
+ };
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [
+ {
+ provide: AppInitService,
+ useValue: appInitSpy
+ }
+ ]
+ });
+ service = TestBed.inject(ResourceService);
+ expect(service).toBeTruthy();
+ });
+
+ it('should return the resource iri from project code and resource uuid', () => {
+ const iri = service.getResourceIri('082B', 'SQkTPdHdTzq_gqbwj6QR-A');
+ expect(iri).toEqual('http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ });
+
+ it('should return the app\'s resource path from project iri', () => {
+ const path = service.getResourcePath('http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ expect(path).toEqual('/082B/SQkTPdHdTzq_gqbwj6QR-A');
+ });
+});
diff --git a/src/app/workspace/resource/services/resource.service.ts b/src/app/workspace/resource/services/resource.service.ts
new file mode 100644
index 0000000000..88a5261762
--- /dev/null
+++ b/src/app/workspace/resource/services/resource.service.ts
@@ -0,0 +1,43 @@
+import { Injectable } from '@angular/core';
+import { AppInitService } from 'src/app/app-init.service';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ResourceService {
+
+ iriBase: string;
+
+ constructor(
+ private _ais: AppInitService
+ ) {
+ this.iriBase = this._getIriBaseWithoutTrailingSlash(this._ais.dspAppConfig.iriBase);
+ }
+
+ /**
+ * gets resource path `[project-shortcode]/[resource-uuid]`
+ * @param iri e.g. http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A
+ * @returns resource path --> /082B/SQkTPdHdTzq_gqbwj6QR-A
+ */
+ getResourcePath(iri: string): string {
+ return iri.replace(this.iriBase, '');
+ }
+
+ /**
+ * gets resource iri
+ * @param shortcode e.g. 082B
+ * @param uuid e.g. SQkTPdHdTzq_gqbwj6QR-A
+ * @returns resource iri --> http://rdfh.ch/082B/SQkTPdHdTzq_gqbwj6QR-A
+ */
+ getResourceIri(shortcode: string, uuid: string): string {
+ return this.iriBase + '/' + shortcode + '/' + uuid;
+ }
+
+ /**
+ * returns iri base without trailing slash
+ * @returns iri base without trailing slash
+ */
+ private _getIriBaseWithoutTrailingSlash(base: string): string {
+ return base.replace(/\/$/, '');
+ }
+}
diff --git a/src/app/workspace/resource/values/geoname-value/geoname-value.component.spec.ts b/src/app/workspace/resource/values/geoname-value/geoname-value.component.spec.ts
index d1a5fcd976..c03a478b32 100644
--- a/src/app/workspace/resource/values/geoname-value/geoname-value.component.spec.ts
+++ b/src/app/workspace/resource/values/geoname-value/geoname-value.component.spec.ts
@@ -84,11 +84,13 @@ describe('GeonameValueComponent', () => {
MatIconModule,
MatAutocompleteModule
],
- providers: [{
- provide: GeonameService,
- useValue: mockGeonameService,
- AppInitService
- }]
+ providers: [
+ AppInitService,
+ {
+ provide: GeonameService,
+ useValue: mockGeonameService,
+ }
+ ]
})
.compileComponents();
}));
diff --git a/src/config/config.dev.json b/src/config/config.dev.json
index ea8626e284..26cd5f95a2 100644
--- a/src/config/config.dev.json
+++ b/src/config/config.dev.json
@@ -10,6 +10,7 @@
"geonameToken": "knora",
"jsonWebToken": "",
"logErrors": true,
+ "iriBase": "http://rdfh.ch",
"instrumentation": {
"environment": "dev",
"dataDog": {
diff --git a/src/config/config.prod.json b/src/config/config.prod.json
index c67af2f02f..321ca05b2e 100644
--- a/src/config/config.prod.json
+++ b/src/config/config.prod.json
@@ -10,6 +10,7 @@
"geonameToken": "knora",
"jsonWebToken": "",
"logErrors": false,
+ "iriBase": "http://rdfh.ch",
"instrumentation": {
"environment": "prod",
"dataDog": {
diff --git a/src/config/config.test-server.json b/src/config/config.test-server.json
index fb89476e3a..06d1a61cff 100644
--- a/src/config/config.test-server.json
+++ b/src/config/config.test-server.json
@@ -10,6 +10,7 @@
"geonameToken": "knora",
"jsonWebToken": "",
"logErrors": true,
+ "iriBase": "http://rdfh.ch",
"instrumentation": {
"environment": "test",
"dataDog": {
diff --git a/test.config.ts b/test.config.ts
index c3522443e1..b49993e454 100644
--- a/test.config.ts
+++ b/test.config.ts
@@ -4,7 +4,6 @@ import { Session } from 'src/app/main/services/session.service';
export class TestConfig {
public static ApiConfig = new KnoraApiConfig('http', '0.0.0.0', 3333);
- public static AppConfig = { name: 'DSP-APP', url: '0.0.0.0:4200' };
public static ProjectCode = '0001';