mirror of https://github.com/Chocobozzz/PeerTube
Client: add support for video licences
parent
6f0c39e2de
commit
d07137b90b
|
@ -39,6 +39,7 @@ export class AppComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.videoService.loadVideoCategories();
|
this.videoService.loadVideoCategories();
|
||||||
|
this.videoService.loadVideoLicences();
|
||||||
}
|
}
|
||||||
|
|
||||||
isInAdmin() {
|
isInAdmin() {
|
||||||
|
|
|
@ -8,12 +8,21 @@ export const VIDEO_NAME = {
|
||||||
'maxlength': 'Video name cannot be more than 50 characters long.'
|
'maxlength': 'Video name cannot be more than 50 characters long.'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VIDEO_CATEGORY = {
|
export const VIDEO_CATEGORY = {
|
||||||
VALIDATORS: [ Validators.required ],
|
VALIDATORS: [ Validators.required ],
|
||||||
MESSAGES: {
|
MESSAGES: {
|
||||||
'required': 'Video category is required.'
|
'required': 'Video category is required.'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const VIDEO_LICENCE = {
|
||||||
|
VALIDATORS: [ Validators.required ],
|
||||||
|
MESSAGES: {
|
||||||
|
'required': 'Video licence is required.'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const VIDEO_DESCRIPTION = {
|
export const VIDEO_DESCRIPTION = {
|
||||||
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],
|
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ],
|
||||||
MESSAGES: {
|
MESSAGES: {
|
||||||
|
|
|
@ -3,6 +3,7 @@ export class Video {
|
||||||
by: string;
|
by: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
categoryLabel: string;
|
categoryLabel: string;
|
||||||
|
licenceLabel: string;
|
||||||
description: string;
|
description: string;
|
||||||
duration: string;
|
duration: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -33,6 +34,7 @@ export class Video {
|
||||||
author: string,
|
author: string,
|
||||||
createdAt: string,
|
createdAt: string,
|
||||||
categoryLabel: string,
|
categoryLabel: string,
|
||||||
|
licenceLabel: string,
|
||||||
description: string,
|
description: string,
|
||||||
duration: number;
|
duration: number;
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -49,6 +51,7 @@ export class Video {
|
||||||
this.author = hash.author;
|
this.author = hash.author;
|
||||||
this.createdAt = new Date(hash.createdAt);
|
this.createdAt = new Date(hash.createdAt);
|
||||||
this.categoryLabel = hash.categoryLabel;
|
this.categoryLabel = hash.categoryLabel;
|
||||||
|
this.licenceLabel = hash.licenceLabel;
|
||||||
this.description = hash.description;
|
this.description = hash.description;
|
||||||
this.duration = Video.createDurationString(hash.duration);
|
this.duration = Video.createDurationString(hash.duration);
|
||||||
this.id = hash.id;
|
this.id = hash.id;
|
||||||
|
|
|
@ -23,6 +23,7 @@ export class VideoService {
|
||||||
private static BASE_VIDEO_URL = '/api/v1/videos/';
|
private static BASE_VIDEO_URL = '/api/v1/videos/';
|
||||||
|
|
||||||
videoCategories: Array<{ id: number, label: string }> = [];
|
videoCategories: Array<{ id: number, label: string }> = [];
|
||||||
|
videoLicences: Array<{ id: number, label: string }> = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
|
@ -45,6 +46,19 @@ export class VideoService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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> {
|
getVideo(id: string): Observable<Video> {
|
||||||
return this.http.get(VideoService.BASE_VIDEO_URL + id)
|
return this.http.get(VideoService.BASE_VIDEO_URL + id)
|
||||||
.map(this.restExtractor.extractDataGet)
|
.map(this.restExtractor.extractDataGet)
|
||||||
|
|
|
@ -26,6 +26,18 @@
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="form-group">
|
||||||
<label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
|
<label for="tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
FormReactive,
|
FormReactive,
|
||||||
VIDEO_NAME,
|
VIDEO_NAME,
|
||||||
VIDEO_CATEGORY,
|
VIDEO_CATEGORY,
|
||||||
|
VIDEO_LICENCE,
|
||||||
VIDEO_DESCRIPTION,
|
VIDEO_DESCRIPTION,
|
||||||
VIDEO_TAGS
|
VIDEO_TAGS
|
||||||
} from '../../shared';
|
} from '../../shared';
|
||||||
|
@ -25,18 +26,21 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
tags: string[] = [];
|
tags: string[] = [];
|
||||||
uploader: FileUploader;
|
uploader: FileUploader;
|
||||||
videoCategories = [];
|
videoCategories = [];
|
||||||
|
videoLicences = [];
|
||||||
|
|
||||||
error: string = null;
|
error: string = null;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
formErrors = {
|
formErrors = {
|
||||||
name: '',
|
name: '',
|
||||||
category: '',
|
category: '',
|
||||||
|
licence: '',
|
||||||
description: '',
|
description: '',
|
||||||
currentTag: ''
|
currentTag: ''
|
||||||
};
|
};
|
||||||
validationMessages = {
|
validationMessages = {
|
||||||
name: VIDEO_NAME.MESSAGES,
|
name: VIDEO_NAME.MESSAGES,
|
||||||
category: VIDEO_CATEGORY.MESSAGES,
|
category: VIDEO_CATEGORY.MESSAGES,
|
||||||
|
licence: VIDEO_LICENCE.MESSAGES,
|
||||||
description: VIDEO_DESCRIPTION.MESSAGES,
|
description: VIDEO_DESCRIPTION.MESSAGES,
|
||||||
currentTag: VIDEO_TAGS.MESSAGES
|
currentTag: VIDEO_TAGS.MESSAGES
|
||||||
};
|
};
|
||||||
|
@ -68,6 +72,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
name: [ '', VIDEO_NAME.VALIDATORS ],
|
name: [ '', VIDEO_NAME.VALIDATORS ],
|
||||||
category: [ '', VIDEO_CATEGORY.VALIDATORS ],
|
category: [ '', VIDEO_CATEGORY.VALIDATORS ],
|
||||||
|
licence: [ '', VIDEO_LICENCE.VALIDATORS ],
|
||||||
description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
|
description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
|
||||||
currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
|
currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
|
||||||
});
|
});
|
||||||
|
@ -77,6 +82,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.videoCategories = this.videoService.videoCategories;
|
this.videoCategories = this.videoService.videoCategories;
|
||||||
|
this.videoLicences = this.videoService.videoLicences;
|
||||||
|
|
||||||
this.uploader = new FileUploader({
|
this.uploader = new FileUploader({
|
||||||
authToken: this.authService.getRequestHeaderValue(),
|
authToken: this.authService.getRequestHeaderValue(),
|
||||||
|
@ -88,10 +94,12 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
this.uploader.onBuildItemForm = (item, form) => {
|
this.uploader.onBuildItemForm = (item, form) => {
|
||||||
const name = this.form.value['name'];
|
const name = this.form.value['name'];
|
||||||
const category = this.form.value['category'];
|
const category = this.form.value['category'];
|
||||||
|
const licence = this.form.value['licence'];
|
||||||
const description = this.form.value['description'];
|
const description = this.form.value['description'];
|
||||||
|
|
||||||
form.append('name', name);
|
form.append('name', name);
|
||||||
form.append('category', category);
|
form.append('category', category);
|
||||||
|
form.append('licence', licence);
|
||||||
form.append('description', description);
|
form.append('description', description);
|
||||||
|
|
||||||
for (let i = 0; i < this.tags.length; i++) {
|
for (let i = 0; i < this.tags.length; i++) {
|
||||||
|
|
|
@ -114,6 +114,13 @@
|
||||||
</div>
|
</div>
|
||||||
</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 id="video-description" class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div id="description-label">Description</div>
|
<div id="description-label">Description</div>
|
||||||
|
|
|
@ -119,6 +119,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#video-licence #licence-label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
#video-description {
|
#video-description {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue