Skip to content
Permalink
Browse files
feat(resource): upload video (DEV-204) (#577)
* feat(resource): upload video

* feat(resource): upload video

* feat(resource): upload video

* fix(upload): bug fix after merge conflict

* chore(deps): update package-lock after running npm i

* chore(deps): bump js-lib to latest

* style(resource-instance): optimize submit button

* refactor(upload): remove commented code
  • Loading branch information
kilchenmann committed Apr 6, 2022
1 parent 8e9e143 commit 29201d40b224d4bbf72f0ffdb1874f6ee94c429a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 16 deletions.

Some generated files are not rendered by default. Learn more.

@@ -34,7 +34,7 @@
"@angular/platform-browser-dynamic": "^13.2.6",
"@angular/router": "^13.2.6",
"@ckeditor/ckeditor5-angular": "^2.0.2",
"@dasch-swiss/dsp-js": "^7.0.1",
"@dasch-swiss/dsp-js": "^7.0.2",
"@datadog/browser-rum": "^3.11.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "6.0.0",
@@ -6,11 +6,13 @@ import {
CreateAudioFileValue,
CreateDocumentFileValue,
CreateFileValue,
CreateMovingImageFileValue,
CreateStillImageFileValue,
UpdateArchiveFileValue,
UpdateAudioFileValue,
UpdateDocumentFileValue,
UpdateFileValue,
UpdateMovingImageFileValue,
UpdateStillImageFileValue
} from '@dasch-swiss/dsp-js';
import { NotificationService } from 'src/app/main/services/notification.service';
@@ -46,6 +48,7 @@ export class UploadComponent implements OnInit {
supportedImageTypes = ['image/jpeg', 'image/jp2', 'image/tiff', 'image/tiff-fx', 'image/png'];
supportedDocumentTypes = ['application/pdf'];
supportedAudioTypes = ['audio/mpeg'];
supportedVideoTypes = ['video/mp4'];
supportedArchiveTypes = ['application/zip', 'application/x-tar', 'application/gzip'];

constructor(
@@ -99,10 +102,7 @@ export class UploadComponent implements OnInit {
break;

case 'document':
// the preview thumbnail is deactivated for the moment;
// --> TODO: it will be activated as soon as we implement a pdf viewer
// this.thumbnailUrl = res.uploadedFiles[0].temporaryUrl;
this.thumbnailUrl = undefined;
this.thumbnailUrl = res.uploadedFiles[0].temporaryUrl;
break;

default:
@@ -224,6 +224,10 @@ export class UploadComponent implements OnInit {
fileValue = new CreateAudioFileValue();
break;

case 'movingImage':
fileValue = new CreateMovingImageFileValue();
break;

case 'archive':
fileValue = new CreateArchiveFileValue();
break;
@@ -268,6 +272,10 @@ export class UploadComponent implements OnInit {
fileValue = new UpdateAudioFileValue();
break;

case 'movingImage':
fileValue = new UpdateMovingImageFileValue();
break;

case 'archive':
fileValue = new UpdateArchiveFileValue();
break;
@@ -311,6 +319,10 @@ export class UploadComponent implements OnInit {
this.allowedFileTypes = this.supportedAudioTypes;
break;

case 'movingImage':
this.allowedFileTypes = this.supportedVideoTypes;
break;

case 'archive':
this.allowedFileTypes = this.supportedArchiveTypes;
break;
@@ -88,8 +88,10 @@
</button>
<span class="fill-remaining-space"></span>
<span>
<button mat-raised-button type="submit" color="primary" class="form-submit" [disabled]="!propertiesParentForm.valid">
{{ 'appLabels.form.action.submit' | translate}}
<button mat-raised-button type="submit" [color]="error ? 'warn' : 'primary'" class="form-submit" [disabled]="!propertiesParentForm.valid">
<app-progress-indicator *ngIf="loading && !error" [color]="'white'" [status]="0" class="submit-progress"></app-progress-indicator>
<mat-icon *ngIf="!loading && error">close</mat-icon>
{{ !loading && error ? ('appLabels.form.action.retry' | translate) : ('appLabels.form.action.submit' | translate) }}
</button>
</span>
</div>
@@ -79,6 +79,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {

valueOperationEventSubscription: Subscription;

loading = false;
// in case of any error
error = false;
errorMessage: any;

propertiesObj = {};
@@ -155,6 +158,8 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {

submitData() {

this.loading = true;

if (this.propertiesParentForm.valid) {

const createResource = new CreateResource();
@@ -193,6 +198,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
case 'audio':
this.propertiesObj[Constants.HasAudioFileValue] = [this.fileValue];
break;
case 'movingImage':
this.propertiesObj[Constants.HasMovingImageFileValue] = [this.fileValue];
break;
case 'archive':
this.propertiesObj[Constants.HasArchiveFileValue] = [this.fileValue];
}
@@ -212,6 +220,8 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
this.closeDialog.emit();
},
(error: ApiResponseError) => {
this.error = true;
this.loading = false;
this._errorHandler.showMessage(error);
}
);
@@ -366,7 +376,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
prop.id !== Constants.HasStillImageFileValue &&
prop.id !== Constants.HasDocumentFileValue &&
prop.id !== Constants.HasAudioFileValue &&
prop.id !== Constants.HasArchiveFileValue // --> TODO for UPLOAD: expand with other representation file values
prop.id !== Constants.HasMovingImageFileValue &&
prop.id !== Constants.HasArchiveFileValue
// --> TODO for UPLOAD: expand with other representation file values
);

if (onto.properties[Constants.HasStillImageFileValue]) {
@@ -375,6 +387,8 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
this.hasFileValue = 'document';
} else if (onto.properties[Constants.HasAudioFileValue]) {
this.hasFileValue = 'audio';
} else if (onto.properties[Constants.HasMovingImageFileValue]) {
this.hasFileValue = 'movingImage';
} else if (onto.properties[Constants.HasArchiveFileValue]) {
this.hasFileValue = 'archive';
} else {
@@ -35,7 +35,6 @@ export class TextValueAsStringComponent extends BaseValueDirective implements On
editor: Editor;
editorConfig;


constructor(@Inject(FormBuilder) private _fb: FormBuilder) {
super();
}
@@ -48,6 +48,8 @@
"cancel": "Cancel",
"close": "Close",
"submit": "Save",
"submitting": "Submitting",
"retry": "Retry",
"add": "Add",
"update": "Update",
"next": "Next",
@@ -176,6 +176,10 @@
text-align: right;
}

.inline {
display: inline-flex;
}

// --------------------------------------

// ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-

0 comments on commit 29201d4

Please sign in to comment.