}
this.videoService.loadVideoCategories();
+ this.videoService.loadVideoLicences();
}
isInAdmin() {
'maxlength': 'Video name cannot be more than 50 characters long.'
}
};
+
export const VIDEO_CATEGORY = {
VALIDATORS: [ Validators.required ],
MESSAGES: {
'required': 'Video category is required.'
}
};
+
+export const VIDEO_LICENCE = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': 'Video licence is required.'
+ }
+};
+
export const VIDEO_DESCRIPTION = {
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],
MESSAGES: {
by: string;
createdAt: Date;
categoryLabel: string;
+ licenceLabel: string;
description: string;
duration: string;
id: string;
author: string,
createdAt: string,
categoryLabel: string,
+ licenceLabel: string,
description: string,
duration: number;
id: string,
this.author = hash.author;
this.createdAt = new Date(hash.createdAt);
this.categoryLabel = hash.categoryLabel;
+ this.licenceLabel = hash.licenceLabel;
this.description = hash.description;
this.duration = Video.createDurationString(hash.duration);
this.id = hash.id;
private static BASE_VIDEO_URL = '/api/v1/videos/';
videoCategories: Array<{ id: number, label: string }> = [];
+ videoLicences: Array<{ id: number, label: string }> = [];
constructor(
private authService: AuthService,
});
}
+ loadVideoLicences() {
+ return this.http.get(VideoService.BASE_VIDEO_URL + 'licences')
+ .map(this.restExtractor.extractDataGet)
+ .subscribe(data => {
+ Object.keys(data).forEach(licenceKey => {
+ this.videoLicences.push({
+ id: parseInt(licenceKey),
+ label: data[licenceKey]
+ });
+ });
+ });
+ }
+
getVideo(id: string): Observable<Video> {
return this.http.get(VideoService.BASE_VIDEO_URL + id)
.map(this.restExtractor.extractDataGet)
</div>
</div>
+ <div class="form-group">
+ <label for="licence">Licence</label>
+ <select class="form-control" id="licence" formControlName="licence">
+ <option></option>
+ <option *ngFor="let licence of videoLicences" [value]="licence.id">{{ licence.label }}</option>
+ </select>
+
+ <div *ngIf="formErrors.licence" class="alert alert-danger">
+ {{ formErrors.licence }}
+ </div>
+ </div>
+
<div class="form-group">
<label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
<input
FormReactive,
VIDEO_NAME,
VIDEO_CATEGORY,
+ VIDEO_LICENCE,
VIDEO_DESCRIPTION,
VIDEO_TAGS
} from '../../shared';
tags: string[] = [];
uploader: FileUploader;
videoCategories = [];
+ videoLicences = [];
error: string = null;
form: FormGroup;
formErrors = {
name: '',
category: '',
+ licence: '',
description: '',
currentTag: ''
};
validationMessages = {
name: VIDEO_NAME.MESSAGES,
category: VIDEO_CATEGORY.MESSAGES,
+ licence: VIDEO_LICENCE.MESSAGES,
description: VIDEO_DESCRIPTION.MESSAGES,
currentTag: VIDEO_TAGS.MESSAGES
};
this.form = this.formBuilder.group({
name: [ '', VIDEO_NAME.VALIDATORS ],
category: [ '', VIDEO_CATEGORY.VALIDATORS ],
+ licence: [ '', VIDEO_LICENCE.VALIDATORS ],
description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
});
ngOnInit() {
this.videoCategories = this.videoService.videoCategories;
+ this.videoLicences = this.videoService.videoLicences;
this.uploader = new FileUploader({
authToken: this.authService.getRequestHeaderValue(),
this.uploader.onBuildItemForm = (item, form) => {
const name = this.form.value['name'];
const category = this.form.value['category'];
+ const licence = this.form.value['licence'];
const description = this.form.value['description'];
form.append('name', name);
form.append('category', category);
+ form.append('licence', licence);
form.append('description', description);
for (let i = 0; i < this.tags.length; i++) {
</div>
</div>
+ <div id="video-licence" class="row">
+ <div class="col-md-12">
+ <span id="licence-label">Licence:</span>
+ {{ video.licenceLabel }}
+ </div>
+ </div>
+
<div id="video-description" class="row">
<div class="col-md-12">
<div id="description-label">Description</div>
}
}
+ #video-licence #licence-label {
+ font-weight: bold;
+ }
+
#video-description {
margin-top: 10px;