From ea16378a37c7e5b39543f1b9b6c536168b9e6694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Mon, 19 Jul 2021 10:04:33 +0200 Subject: [PATCH 1/5] feat(resource): support audio file upload --- .../representation/upload/upload.component.html | 6 ++++-- .../representation/upload/upload.component.ts | 17 ++++++++++++++++- .../resource-instance-form.component.ts | 9 ++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/app/workspace/resource/representation/upload/upload.component.html b/src/app/workspace/resource/representation/upload/upload.component.html index 98a29eb584..3611bdf72b 100644 --- a/src/app/workspace/resource/representation/upload/upload.component.html +++ b/src/app/workspace/resource/representation/upload/upload.component.html @@ -9,8 +9,10 @@

Upload file
The following file types are supported:
- {{ item | split: '/':1 }} + {{ item | split: '/':1 }} + + +  (= mp3)

diff --git a/src/app/workspace/resource/representation/upload/upload.component.ts b/src/app/workspace/resource/representation/upload/upload.component.ts index aa39b66882..fbb58a54b8 100644 --- a/src/app/workspace/resource/representation/upload/upload.component.ts +++ b/src/app/workspace/resource/representation/upload/upload.component.ts @@ -1,9 +1,11 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { + CreateAudioFileValue, CreateDocumentFileValue, CreateFileValue, CreateStillImageFileValue, + UpdateAudioFileValue, UpdateDocumentFileValue, UpdateFileValue, UpdateStillImageFileValue @@ -41,6 +43,7 @@ export class UploadComponent implements OnInit { // todo: maybe we can use this list to display which file format is allowed to supportedImageTypes = ['image/jpeg', 'image/jp2', 'image/tiff', 'image/tiff-fx', 'image/png']; supportedDocumentTypes = ['application/pdf']; + supportedAudioTypes = ['audio/mpeg']; // readonly fromLabels = { // upload: 'Upload file', @@ -87,6 +90,7 @@ export class UploadComponent implements OnInit { this._upload.upload(formData).subscribe( (res: UploadedFileResponse) => { + // prepare thumbnail url to display something after upload switch (this.representation) { case 'stillImage': const temporaryUrl = res.uploadedFiles[0].temporaryUrl; @@ -215,6 +219,10 @@ export class UploadComponent implements OnInit { fileValue = new CreateDocumentFileValue(); break; + case 'audio': + fileValue = new CreateAudioFileValue(); + break; + default: // --> TODO for UPLOAD: expand with other representation file types break; @@ -239,7 +247,7 @@ export class UploadComponent implements OnInit { const filename = this.fileControl.value.internalFilename; - let fileValue: UpdateStillImageFileValue | UpdateDocumentFileValue; + let fileValue: UpdateStillImageFileValue | UpdateDocumentFileValue | UpdateAudioFileValue; switch (this.representation) { @@ -250,6 +258,10 @@ export class UploadComponent implements OnInit { case 'document': fileValue = new UpdateDocumentFileValue(); break; + + case 'audio': + fileValue = new UpdateAudioFileValue(); + break; default: // --> TODO for UPLOAD: expand with other representation file types break; @@ -283,6 +295,9 @@ export class UploadComponent implements OnInit { case 'document': this.allowedFileTypes = this.supportedDocumentTypes; break; + case 'audio': + this.allowedFileTypes = this.supportedAudioTypes; + break; default: this.allowedFileTypes = []; break; 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 14cd628514..4bece69b92 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 @@ -172,6 +172,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { case 'document': this.propertiesObj[Constants.HasDocumentFileValue] = [this.fileValue]; break; + case 'audio': + this.propertiesObj[Constants.HasAudioFileValue] = [this.fileValue]; + break; } } @@ -381,7 +384,8 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { !prop.isLinkProperty && prop.isEditable && prop.id !== Constants.HasStillImageFileValue && - prop.id !== Constants.HasDocumentFileValue // --> TODO for UPLOAD: expand with other representation file values + prop.id !== Constants.HasDocumentFileValue && + prop.id !== Constants.HasAudioFileValue // --> TODO for UPLOAD: expand with other representation file values ); if (onto.properties[Constants.HasStillImageFileValue]) { @@ -390,6 +394,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { if (onto.properties[Constants.HasDocumentFileValue]) { this.hasFileValue = 'document'; } + if (onto.properties[Constants.HasAudioFileValue]) { + this.hasFileValue = 'audio'; + } // notifies the user that the selected resource does not have any properties defined yet. if (!this.selectPropertiesComponent && this.properties.length === 0) { From 3589103e72de6c212574067b189ef77f8b390ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 20 Jul 2021 17:42:42 +0200 Subject: [PATCH 2/5] chore(deps): bump dsp-js to latest version --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e15727d44..6a23209992 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@angular/platform-browser-dynamic": "^11.2.9", "@angular/router": "^11.2.9", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "^2.6.1", + "@dasch-swiss/dsp-js": "^2.7.0", "@dasch-swiss/dsp-ui": "^1.6.0", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "5.0.0", @@ -2258,9 +2258,9 @@ } }, "node_modules/@dasch-swiss/dsp-js": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.6.1.tgz", - "integrity": "sha512-hI5UKHn8yVdWKtq6KZXfje9ZI7CiyMmElnKOzqy1T2P/IbFT5VGbr3XAYEO0p1sQ00+Xq+LHZZNv3xUcttWkEA==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.7.0.tgz", + "integrity": "sha512-E7ZPoxMLHaX0wxYo7HNJHuuXT5JLoXrxzeh04yQwWvvYJLSrBBSZjYZ1ZDpsCCsZgwievjx1OkPOvlAbHU7LFg==", "dependencies": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", @@ -21733,9 +21733,9 @@ } }, "@dasch-swiss/dsp-js": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.6.1.tgz", - "integrity": "sha512-hI5UKHn8yVdWKtq6KZXfje9ZI7CiyMmElnKOzqy1T2P/IbFT5VGbr3XAYEO0p1sQ00+Xq+LHZZNv3xUcttWkEA==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.7.0.tgz", + "integrity": "sha512-E7ZPoxMLHaX0wxYo7HNJHuuXT5JLoXrxzeh04yQwWvvYJLSrBBSZjYZ1ZDpsCCsZgwievjx1OkPOvlAbHU7LFg==", "requires": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", diff --git a/package.json b/package.json index 4515afdffa..566f4cb4ae 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@angular/platform-browser-dynamic": "^11.2.9", "@angular/router": "^11.2.9", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "^2.6.1", + "@dasch-swiss/dsp-js": "^2.7.0", "@dasch-swiss/dsp-ui": "^1.6.0", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "5.0.0", From 8f6c0e4ef80c4d8aef38bcaca76edb7f59d0237d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 22 Jul 2021 15:53:41 +0200 Subject: [PATCH 3/5] refactor(resource): clean up code --- .../resource/representation/upload/upload.component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/workspace/resource/representation/upload/upload.component.ts b/src/app/workspace/resource/representation/upload/upload.component.ts index fbb58a54b8..e5e5107c7d 100644 --- a/src/app/workspace/resource/representation/upload/upload.component.ts +++ b/src/app/workspace/resource/representation/upload/upload.component.ts @@ -262,6 +262,7 @@ export class UploadComponent implements OnInit { case 'audio': fileValue = new UpdateAudioFileValue(); break; + default: // --> TODO for UPLOAD: expand with other representation file types break; @@ -292,12 +293,15 @@ export class UploadComponent implements OnInit { case 'stillImage': this.allowedFileTypes = this.supportedImageTypes; break; + case 'document': this.allowedFileTypes = this.supportedDocumentTypes; break; + case 'audio': this.allowedFileTypes = this.supportedAudioTypes; break; + default: this.allowedFileTypes = []; break; From c571e496266726a447e78e441cf5982aae82547d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 22 Jul 2021 15:54:00 +0200 Subject: [PATCH 4/5] fix(resource): disable submit button --- .../resource-instance-form.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html index 5f2a1e3d1f..479aae4111 100644 --- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html +++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html @@ -91,7 +91,7 @@ - From bcd41cdad59c5a1f1afc22c31a3ecf77c7654a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 22 Jul 2021 17:17:48 +0200 Subject: [PATCH 5/5] chore(resource): some improvements in res instance form --- .../resource/representation/upload/upload.component.ts | 1 + .../resource-instance-form.component.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/workspace/resource/representation/upload/upload.component.ts b/src/app/workspace/resource/representation/upload/upload.component.ts index e5e5107c7d..dee48a2f0a 100644 --- a/src/app/workspace/resource/representation/upload/upload.component.ts +++ b/src/app/workspace/resource/representation/upload/upload.component.ts @@ -161,6 +161,7 @@ export class UploadComponent implements OnInit { */ deleteAttachment(): void { this.fileControl.reset(); + this.fileInfo.emit(undefined); } /** 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 4bece69b92..59a0aea139 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 @@ -390,12 +390,12 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { if (onto.properties[Constants.HasStillImageFileValue]) { this.hasFileValue = 'stillImage'; - } - if (onto.properties[Constants.HasDocumentFileValue]) { + } else if (onto.properties[Constants.HasDocumentFileValue]) { this.hasFileValue = 'document'; - } - if (onto.properties[Constants.HasAudioFileValue]) { + } else if (onto.properties[Constants.HasAudioFileValue]) { this.hasFileValue = 'audio'; + } else { + this.hasFileValue = undefined; } // notifies the user that the selected resource does not have any properties defined yet.