Skip to content

Commit

Permalink
feat(resource): upload video (DEV-204) (#577)
Browse files Browse the repository at this point in the history
* 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 29201d4
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 16 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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>
Expand Down
Expand Up @@ -79,6 +79,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {

valueOperationEventSubscription: Subscription;

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

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

submitData() {

this.loading = true;

if (this.propertiesParentForm.valid) {

const createResource = new CreateResource();
Expand Down Expand Up @@ -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];
}
Expand All @@ -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);
}
);
Expand Down Expand Up @@ -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]) {
Expand All @@ -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 {
Expand Down
Expand Up @@ -35,7 +35,6 @@ export class TextValueAsStringComponent extends BaseValueDirective implements On
editor: Editor;
editorConfig;


constructor(@Inject(FormBuilder) private _fb: FormBuilder) {
super();
}
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json
Expand Up @@ -48,6 +48,8 @@
"cancel": "Cancel",
"close": "Close",
"submit": "Save",
"submitting": "Submitting",
"retry": "Retry",
"add": "Add",
"update": "Update",
"next": "Next",
Expand Down
4 changes: 4 additions & 0 deletions src/assets/style/_layout.scss
Expand Up @@ -176,6 +176,10 @@
text-align: right;
}

.inline {
display: inline-flex;
}

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

// ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-
Expand Down

0 comments on commit 29201d4

Please sign in to comment.