diff --git a/.gitignore b/.gitignore
index 492ce54460..88635cf051 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,3 +48,6 @@ docs/bin
.DS_Store
Thumbs.db
*.code-workspace
+
+# Generated docs
+/site
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 513d783b15..f3e4ed6b91 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -153,6 +153,7 @@ import { SearchSelectOntologyComponent } from './workspace/search/advanced-searc
import { ExpertSearchComponent } from './workspace/search/expert-search/expert-search.component';
import { FulltextSearchComponent } from './workspace/search/fulltext-search/fulltext-search.component';
import { SearchPanelComponent } from './workspace/search/search-panel/search-panel.component';
+import { ReplaceFileFormComponent } from './workspace/resource/representation/replace-file-form/replace-file-form.component';
// translate: AoT requires an exported function for factories
export function httpLoaderFactory(httpClient: HttpClient) {
@@ -294,6 +295,7 @@ export function httpLoaderFactory(httpClient: HttpClient) {
UserMenuComponent,
UsersComponent,
UsersListComponent,
+ ReplaceFileFormComponent,
],
imports: [
AngularSplitModule.forRoot(),
diff --git a/src/app/main/dialog/dialog.component.html b/src/app/main/dialog/dialog.component.html
index ec28359b5f..d403b2c59c 100644
--- a/src/app/main/dialog/dialog.component.html
+++ b/src/app/main/dialog/dialog.component.html
@@ -392,6 +392,13 @@
+
No valid file url found for this resource.
diff --git a/src/app/workspace/resource/representation/archive/archive.component.ts b/src/app/workspace/resource/representation/archive/archive.component.ts
index b06e3b11cf..7dabe1647e 100644
--- a/src/app/workspace/resource/representation/archive/archive.component.ts
+++ b/src/app/workspace/resource/representation/archive/archive.component.ts
@@ -1,6 +1,12 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, Inject, Input, OnInit } from '@angular/core';
+import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
+import { Constants, UpdateFileValue, UpdateResource, UpdateValue, WriteValueResponse, ReadResource, ApiResponseError, KnoraApiConnection, ReadArchiveFileValue } from '@dasch-swiss/dsp-js';
+import { mergeMap } from 'rxjs/operators';
+import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
+import { DialogComponent } from 'src/app/main/dialog/dialog.component';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
+import { EmitEvent, Events, UpdatedFileEventValue, ValueOperationEventService } from '../../services/value-operation-event.service';
import { FileRepresentation } from '../file-representation';
@Component({
@@ -11,27 +17,21 @@ import { FileRepresentation } from '../file-representation';
export class ArchiveComponent implements OnInit {
@Input() src: FileRepresentation;
+ @Input() parentResource: ReadResource;
+
originalFilename: string;
temp: string;
constructor(
+ @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection,
private readonly _http: HttpClient,
- private _errorHandler: ErrorHandlerService
+ private _dialog: MatDialog,
+ private _errorHandler: ErrorHandlerService,
+ private _valueOperationEventService: ValueOperationEventService
) { }
ngOnInit(): void {
- const requestOptions = {
- headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
- withCredentials: true
- };
-
- const pathToJson = this.src.fileValue.fileUrl.substring(0, this.src.fileValue.fileUrl.lastIndexOf('/')) + '/knora.json';
-
- this._http.get(pathToJson, requestOptions).subscribe(
- res => {
- this.originalFilename = res['originalFilename'];
- }
- );
+ this._getOriginalFilename();
}
// https://stackoverflow.com/questions/66986983/angular-10-download-file-from-firebase-link-without-opening-into-new-tab
@@ -60,4 +60,68 @@ export class ArchiveComponent implements OnInit {
e.click();
document.body.removeChild(e);
}
+
+ openReplaceFileDialog(){
+ const propId = this.parentResource.properties[Constants.HasArchiveFileValue][0].id;
+
+ const dialogConfig: MatDialogConfig = {
+ width: '800px',
+ maxHeight: '80vh',
+ position: {
+ top: '112px'
+ },
+ data: { mode: 'replaceFile', title: 'Archive (zip, x-tar, gzip)', subtitle: 'Update the archive file of this resource' , representation: 'archive', id: propId },
+ disableClose: true
+ };
+ const dialogRef = this._dialog.open(
+ DialogComponent,
+ dialogConfig
+ );
+
+ dialogRef.afterClosed().subscribe((data) => {
+ this._replaceFile(data);
+ });
+ }
+
+ private _getOriginalFilename() {
+ const requestOptions = {
+ headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
+ withCredentials: true
+ };
+
+ const pathToJson = this.src.fileValue.fileUrl.substring(0, this.src.fileValue.fileUrl.lastIndexOf('/')) + '/knora.json';
+
+ this._http.get(pathToJson, requestOptions).subscribe(
+ res => {
+ this.originalFilename = res['originalFilename'];
+ }
+ );
+ }
+
+ private _replaceFile(file: UpdateFileValue) {
+ const updateRes = new UpdateResource();
+ updateRes.id = this.parentResource.id;
+ updateRes.type = this.parentResource.type;
+ updateRes.property = Constants.HasArchiveFileValue;
+ updateRes.value = file;
+
+ this._dspApiConnection.v2.values.updateValue(updateRes as UpdateResource
).pipe(
+ mergeMap((res: WriteValueResponse) => this._dspApiConnection.v2.values.getValue(this.parentResource.id, res.uuid))
+ ).subscribe(
+ (res2: ReadResource) => {
+ this.src.fileValue.fileUrl = (res2.properties[Constants.HasArchiveFileValue][0] as ReadArchiveFileValue).fileUrl;
+ this.src.fileValue.filename = (res2.properties[Constants.HasArchiveFileValue][0] as ReadArchiveFileValue).filename;
+ this.src.fileValue.strval = (res2.properties[Constants.HasArchiveFileValue][0] as ReadArchiveFileValue).strval;
+
+ this._getOriginalFilename();
+
+ this._valueOperationEventService.emit(
+ new EmitEvent(Events.FileValueUpdated, new UpdatedFileEventValue(
+ res2.properties[Constants.HasArchiveFileValue][0])));
+ },
+ (error: ApiResponseError) => {
+ this._errorHandler.showMessage(error);
+ }
+ );
+ }
}
diff --git a/src/app/workspace/resource/representation/audio/audio.component.html b/src/app/workspace/resource/representation/audio/audio.component.html
index 7e4bf049ca..62c4d5846b 100644
--- a/src/app/workspace/resource/representation/audio/audio.component.html
+++ b/src/app/workspace/resource/representation/audio/audio.component.html
@@ -1,4 +1,13 @@
-
+
+
+
+
+
+
+
+
diff --git a/src/app/workspace/resource/representation/audio/audio.component.scss b/src/app/workspace/resource/representation/audio/audio.component.scss
index a1acb2ba8e..48609f7c45 100644
--- a/src/app/workspace/resource/representation/audio/audio.component.scss
+++ b/src/app/workspace/resource/representation/audio/audio.component.scss
@@ -1,3 +1,18 @@
-audio {
+.controls {
width: 100%;
+
+ .audio-player,
+ .upload-button {
+ display: inline-block;
+ vertical-align: middle;
+ }
+
+ .audio-player {
+ width: 80%;
+
+ audio {
+ width: 100%;
+ }
+ }
}
+
diff --git a/src/app/workspace/resource/representation/audio/audio.component.ts b/src/app/workspace/resource/representation/audio/audio.component.ts
index bd30950664..6ab4a594aa 100644
--- a/src/app/workspace/resource/representation/audio/audio.component.ts
+++ b/src/app/workspace/resource/representation/audio/audio.component.ts
@@ -1,5 +1,12 @@
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, Inject, Input, OnInit } from '@angular/core';
+import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
+import { UpdateFileValue, UpdateResource, Constants, UpdateValue, WriteValueResponse, ReadResource, ApiResponseError, KnoraApiConnection, ReadAudioFileValue } from '@dasch-swiss/dsp-js';
+import { mergeMap } from 'rxjs/operators';
+import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
+import { DialogComponent } from 'src/app/main/dialog/dialog.component';
+import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
+import { EmitEvent, Events, UpdatedFileEventValue, ValueOperationEventService } from '../../services/value-operation-event.service';
import { FileRepresentation } from '../file-representation';
@@ -11,15 +18,75 @@ import { FileRepresentation } from '../file-representation';
export class AudioComponent implements OnInit {
@Input() src: FileRepresentation;
+ @Input() parentResource: ReadResource;
audio: SafeUrl;
constructor(
- private _sanitizer: DomSanitizer
+ @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection,
+ private _sanitizer: DomSanitizer,
+ private _dialog: MatDialog,
+ private _errorHandler: ErrorHandlerService,
+ private _valueOperationEventService: ValueOperationEventService
) { }
ngOnInit(): void {
this.audio = this._sanitizer.bypassSecurityTrustUrl(this.src.fileValue.fileUrl);
}
+ openReplaceFileDialog(){
+ const propId = this.parentResource.properties[Constants.HasAudioFileValue][0].id;
+
+ const dialogConfig: MatDialogConfig = {
+ width: '800px',
+ maxHeight: '80vh',
+ position: {
+ top: '112px'
+ },
+ data: { mode: 'replaceFile', title: 'Audio', subtitle: 'Update the audio file of this resource' , representation: 'audio', id: propId },
+ disableClose: true
+ };
+ const dialogRef = this._dialog.open(
+ DialogComponent,
+ dialogConfig
+ );
+
+ dialogRef.afterClosed().subscribe((data) => {
+ this._replaceFile(data);
+ });
+ }
+
+ private _replaceFile(file: UpdateFileValue) {
+ const updateRes = new UpdateResource();
+ updateRes.id = this.parentResource.id;
+ updateRes.type = this.parentResource.type;
+ updateRes.property = Constants.HasAudioFileValue;
+ updateRes.value = file;
+
+ this._dspApiConnection.v2.values.updateValue(updateRes as UpdateResource).pipe(
+ mergeMap((res: WriteValueResponse) => this._dspApiConnection.v2.values.getValue(this.parentResource.id, res.uuid))
+ ).subscribe(
+ (res2: ReadResource) => {
+
+ this.src.fileValue.fileUrl = (res2.properties[Constants.HasAudioFileValue][0] as ReadAudioFileValue).fileUrl;
+ this.src.fileValue.filename = (res2.properties[Constants.HasAudioFileValue][0] as ReadAudioFileValue).filename;
+ this.src.fileValue.strval = (res2.properties[Constants.HasAudioFileValue][0] as ReadAudioFileValue).strval;
+ this.src.fileValue.valueCreationDate = (res2.properties[Constants.HasAudioFileValue][0] as ReadAudioFileValue).valueCreationDate;
+
+ this.audio = this._sanitizer.bypassSecurityTrustUrl(this.src.fileValue.fileUrl);
+
+ this._valueOperationEventService.emit(
+ new EmitEvent(Events.FileValueUpdated, new UpdatedFileEventValue(
+ res2.properties[Constants.HasAudioFileValue][0])));
+
+ const audioElem = document.getElementById('audio');
+ (audioElem as HTMLAudioElement).load();
+
+ },
+ (error: ApiResponseError) => {
+ this._errorHandler.showMessage(error);
+ }
+ );
+ }
+
}
diff --git a/src/app/workspace/resource/representation/document/document.component.html b/src/app/workspace/resource/representation/document/document.component.html
index bdc00cae60..df3b6f16a7 100644
--- a/src/app/workspace/resource/representation/document/document.component.html
+++ b/src/app/workspace/resource/representation/document/document.component.html
@@ -27,6 +27,9 @@
+
launch
diff --git a/src/app/workspace/resource/representation/document/document.component.ts b/src/app/workspace/resource/representation/document/document.component.ts
index b7ceea727b..e16397e872 100644
--- a/src/app/workspace/resource/representation/document/document.component.ts
+++ b/src/app/workspace/resource/representation/document/document.component.ts
@@ -1,5 +1,12 @@
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
+import { Component, Inject, Input, OnInit, ViewChild } from '@angular/core';
+import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
+import { ApiResponseError, Constants, KnoraApiConnection, ReadDocumentFileValue, ReadResource, UpdateFileValue, UpdateResource, UpdateValue, WriteValueResponse } from '@dasch-swiss/dsp-js';
import { PdfViewerComponent } from 'ng2-pdf-viewer';
+import { mergeMap } from 'rxjs/operators';
+import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
+import { DialogComponent } from 'src/app/main/dialog/dialog.component';
+import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
+import { EmitEvent, Events, UpdatedFileEventValue, ValueOperationEventService } from '../../services/value-operation-event.service';
import { FileRepresentation } from '../file-representation';
@Component({
@@ -10,6 +17,7 @@ import { FileRepresentation } from '../file-representation';
export class DocumentComponent implements OnInit {
@Input() src: FileRepresentation;
+ @Input() parentResource: ReadResource;
@ViewChild(PdfViewerComponent) private _pdfComponent: PdfViewerComponent;
@@ -17,7 +25,12 @@ export class DocumentComponent implements OnInit {
pdfQuery = '';
- constructor() { }
+ constructor(
+ @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection,
+ private _dialog: MatDialog,
+ private _errorHandler: ErrorHandlerService,
+ private _valueOperationEventService: ValueOperationEventService
+ ) { }
ngOnInit(): void {
@@ -38,4 +51,56 @@ export class DocumentComponent implements OnInit {
}
}
+ openReplaceFileDialog(){
+ const propId = this.parentResource.properties[Constants.HasDocumentFileValue][0].id;
+
+ const dialogConfig: MatDialogConfig = {
+ width: '800px',
+ maxHeight: '80vh',
+ position: {
+ top: '112px'
+ },
+ data: { mode: 'replaceFile', title: 'Document', subtitle: 'Update the document file of this resource' , representation: 'document', id: propId },
+ disableClose: true
+ };
+ const dialogRef = this._dialog.open(
+ DialogComponent,
+ dialogConfig
+ );
+
+ dialogRef.afterClosed().subscribe((data) => {
+ this._replaceFile(data);
+ });
+ }
+
+ private _replaceFile(file: UpdateFileValue) {
+ const updateRes = new UpdateResource();
+ updateRes.id = this.parentResource.id;
+ updateRes.type = this.parentResource.type;
+ updateRes.property = Constants.HasDocumentFileValue;
+ updateRes.value = file;
+
+ this._dspApiConnection.v2.values.updateValue(updateRes as UpdateResource).pipe(
+ mergeMap((res: WriteValueResponse) => this._dspApiConnection.v2.values.getValue(this.parentResource.id, res.uuid))
+ ).subscribe(
+ (res2: ReadResource) => {
+
+ this.src.fileValue.fileUrl = (res2.properties[Constants.HasDocumentFileValue][0] as ReadDocumentFileValue).fileUrl;
+ this.src.fileValue.filename = (res2.properties[Constants.HasDocumentFileValue][0] as ReadDocumentFileValue).filename;
+ this.src.fileValue.strval = (res2.properties[Constants.HasDocumentFileValue][0] as ReadDocumentFileValue).strval;
+ this.src.fileValue.valueCreationDate = (res2.properties[Constants.HasDocumentFileValue][0] as ReadDocumentFileValue).valueCreationDate;
+
+ this.zoomFactor = 1.0;
+ this.pdfQuery = '';
+
+ this._valueOperationEventService.emit(
+ new EmitEvent(Events.FileValueUpdated, new UpdatedFileEventValue(
+ res2.properties[Constants.HasDocumentFileValue][0])));
+ },
+ (error: ApiResponseError) => {
+ this._errorHandler.showMessage(error);
+ }
+ );
+ }
+
}
diff --git a/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.html b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.html
new file mode 100644
index 0000000000..243e4f5658
--- /dev/null
+++ b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.html
@@ -0,0 +1,27 @@
+
+
+
+ warning
+
+
+
{{ warningMessages[0] }}
+
+
{{ warningMessages[1] }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.scss b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.scss
new file mode 100644
index 0000000000..b0487f4b88
--- /dev/null
+++ b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.scss
@@ -0,0 +1,29 @@
+.warning {
+ background-color: #FFFBEB;
+ border-radius: 5px;
+
+ .container {
+ padding: 2%;
+
+ .icon,
+ .message {
+ display: inline-block;
+ vertical-align: top;
+ }
+
+ .icon {
+ color: #FBBF24
+ }
+
+ .message {
+ padding-left: 2%;
+ color: #92400E;
+
+ p {
+ margin-block-start: 0em;
+ margin-block-end: 0em;
+ }
+ }
+ }
+
+}
diff --git a/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.spec.ts b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.spec.ts
new file mode 100644
index 0000000000..793328f104
--- /dev/null
+++ b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.spec.ts
@@ -0,0 +1,71 @@
+import { Component, Input, OnInit, ViewChild } from '@angular/core';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { FormGroup } from '@angular/forms';
+import { MatIconModule } from '@angular/material/icon';
+import { TranslateModule } from '@ngx-translate/core';
+import { UploadComponent } from '../upload/upload.component';
+
+import { ReplaceFileFormComponent } from './replace-file-form.component';
+
+@Component({
+ selector: 'test-host-component',
+ template: `
+
+ `
+})
+class TestHostComponent implements OnInit {
+ @ViewChild('replaceFileForm') replaceFileFormComp: ReplaceFileFormComponent;
+
+ representation: 'stillImage' | 'movingImage' | 'audio' | 'document' | 'text' | 'archive';
+ propId: string;
+
+ ngOnInit(): void {
+ this.representation = 'stillImage';
+ this.propId = 'http://rdfh.ch/0123/yryzB6ROTaGER3F9kMZoUA/values/mEm67WJiSAqaWf572GzA9Q';
+ }
+
+}
+
+@Component({
+ selector: 'app-upload',
+ template: ''
+})
+class TestUploadComponent {
+ @Input() parentForm?: FormGroup;
+
+ @Input() representation: 'stillImage' | 'movingImage' | 'audio' | 'document' | 'text' | 'archive';
+
+ @Input() formName: string;
+}
+
+describe('ReplaceFileFormComponent', () => {
+ let testHostComponent: TestHostComponent;
+ let testHostFixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [
+ TestHostComponent,
+ TestUploadComponent,
+ ReplaceFileFormComponent
+ ],
+ imports: [
+ MatIconModule,
+ TranslateModule.forRoot()
+ ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ testHostFixture = TestBed.createComponent(TestHostComponent);
+ testHostComponent = testHostFixture.componentInstance;
+ testHostFixture.detectChanges();
+ expect(testHostComponent).toBeTruthy();
+ });
+
+ it('generate the error messages for a still image file representation', () => {
+ expect(testHostComponent.replaceFileFormComp.warningMessages[0]).toEqual('Image will be replaced.');
+ expect(testHostComponent.replaceFileFormComp.warningMessages[1]).toEqual('Please note that you are about to replace the image.');
+ });
+});
diff --git a/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.ts b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.ts
new file mode 100644
index 0000000000..83904b879c
--- /dev/null
+++ b/src/app/workspace/resource/representation/replace-file-form/replace-file-form.component.ts
@@ -0,0 +1,73 @@
+import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
+import { UpdateFileValue } from '@dasch-swiss/dsp-js';
+import { UploadComponent } from '../upload/upload.component';
+
+@Component({
+ selector: 'app-replace-file-form',
+ templateUrl: './replace-file-form.component.html',
+ styleUrls: ['./replace-file-form.component.scss']
+})
+export class ReplaceFileFormComponent implements OnInit {
+ @Input() representation: 'stillImage' | 'movingImage' | 'audio' | 'document' | 'text' | 'archive';
+ @Input() propId: string;
+
+ @Output() closeDialog: EventEmitter = new EventEmitter();
+
+ @ViewChild('upload') uploadComponent: UploadComponent;
+
+ fileValue: UpdateFileValue;
+ warningMessages: string[];
+
+ constructor() { }
+
+ ngOnInit(): void {
+ this._generateWarningMessage(this.representation);
+ }
+
+ setFileValue(file: UpdateFileValue) {
+ this.fileValue = file;
+ }
+
+ saveFile() {
+ const updateVal = this.uploadComponent.getUpdatedValue(this.propId);
+
+ if(updateVal instanceof UpdateFileValue) {
+ updateVal.filename = this.fileValue.filename;
+ updateVal.id = this.propId;
+ this.closeDialog.emit(updateVal);
+ } else {
+ console.log('expected UpdateFileValue, got: ', updateVal);
+ }
+ }
+
+ // generate the warning message strings with the correct representation type
+ _generateWarningMessage(representationType: string) {
+
+ this.warningMessages = [];
+
+ if(representationType === undefined){
+ this.warningMessages.push('File will be replaced.');
+ this.warningMessages.push('Please note that you are about to replace the file');
+ }
+
+ let repType = representationType;
+
+ if (representationType === 'stillImage' || representationType === 'movingImage') {
+ switch (representationType) {
+ case 'stillImage':
+ repType = 'image';
+ break;
+
+ case 'movingImage':
+ repType = 'video';
+ break;
+ }
+ }
+
+ const capitalized = repType[0].toUpperCase() + repType.substring(1).toLowerCase();
+
+ this.warningMessages.push(capitalized + ' will be replaced.');
+ this.warningMessages.push('Please note that you are about to replace the ' + repType + '.');
+ }
+
+}
diff --git a/src/app/workspace/resource/representation/still-image/still-image.component.html b/src/app/workspace/resource/representation/still-image/still-image.component.html
index 3e60c3308e..b5f2ea2268 100644
--- a/src/app/workspace/resource/representation/still-image/still-image.component.html
+++ b/src/app/workspace/resource/representation/still-image/still-image.component.html
@@ -42,6 +42,9 @@
+
diff --git a/src/app/workspace/resource/representation/still-image/still-image.component.spec.ts b/src/app/workspace/resource/representation/still-image/still-image.component.spec.ts
index 691a55edf5..f8e814a21c 100644
--- a/src/app/workspace/resource/representation/still-image/still-image.component.spec.ts
+++ b/src/app/workspace/resource/representation/still-image/still-image.component.spec.ts
@@ -1,13 +1,19 @@
+import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
+import { OverlayContainer } from '@angular/cdk/overlay';
+import { HarnessLoader } from '@angular/cdk/testing';
+import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HttpClientModule } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
-import { MatDialogModule } from '@angular/material/dialog';
+import { MatButtonHarness } from '@angular/material/button/testing';
+import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { MatDialogHarness } from '@angular/material/dialog/testing';
import { MatIconModule } from '@angular/material/icon';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { By } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { Constants, ReadGeomValue, ReadResource, ReadValue } from '@dasch-swiss/dsp-js';
+import { Constants, MockResource, ReadGeomValue, ReadResource, ReadValue } from '@dasch-swiss/dsp-js';
import { AppInitService } from 'src/app/app-init.service';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { FileRepresentation } from '../file-representation';
@@ -79,6 +85,7 @@ function makeRegion(geomString: string[], iri: string): ReadResource {
[iiifUrl]="iiifUrl"
[activateRegion]="inputActivateRegion"
[currentTab]="'annotations'"
+ [parentResource]="readresource"
(regionClicked)="regHovered($event)">
`
})
@@ -86,6 +93,7 @@ class TestHostComponent implements OnInit {
@ViewChild(StillImageComponent) osdViewerComp: StillImageComponent;
+ readResource: ReadResource;
stillImageFileRepresentations: FileRepresentation[] = [];
caption = 'test image';
iiifUrl = 'https://iiif.test.dasch.swiss:443/0803/incunabula_0000003840.jp2/full/3210,5144/0/default.jpg';
@@ -95,6 +103,10 @@ class TestHostComponent implements OnInit {
ngOnInit() {
+ MockResource.getTestThing().subscribe(res => {
+ this.readResource = res;
+ });
+
this.stillImageFileRepresentations
= [
new FileRepresentation(stillImageFileValue,
@@ -112,6 +124,8 @@ class TestHostComponent implements OnInit {
describe('StillImageComponent', () => {
let testHostComponent: TestHostComponent;
let testHostFixture: ComponentFixture