Client: support video language
This commit is contained in:
parent
3092476e64
commit
db216afd98
|
@ -42,6 +42,7 @@ export class AppComponent implements OnInit {
|
||||||
this.configService.loadConfig();
|
this.configService.loadConfig();
|
||||||
this.videoService.loadVideoCategories();
|
this.videoService.loadVideoCategories();
|
||||||
this.videoService.loadVideoLicences();
|
this.videoService.loadVideoLicences();
|
||||||
|
this.videoService.loadVideoLanguages();
|
||||||
}
|
}
|
||||||
|
|
||||||
isInAdmin() {
|
isInAdmin() {
|
||||||
|
|
|
@ -23,6 +23,11 @@ export const VIDEO_LICENCE = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const VIDEO_LANGUAGE = {
|
||||||
|
VALIDATORS: [ ],
|
||||||
|
MESSAGES: {}
|
||||||
|
};
|
||||||
|
|
||||||
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: {
|
||||||
|
|
|
@ -6,6 +6,7 @@ export class Video {
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
categoryLabel: string;
|
categoryLabel: string;
|
||||||
licenceLabel: string;
|
licenceLabel: string;
|
||||||
|
languageLabel: string;
|
||||||
description: string;
|
description: string;
|
||||||
duration: string;
|
duration: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -38,6 +39,7 @@ export class Video {
|
||||||
createdAt: string,
|
createdAt: string,
|
||||||
categoryLabel: string,
|
categoryLabel: string,
|
||||||
licenceLabel: string,
|
licenceLabel: string,
|
||||||
|
languageLabel: string;
|
||||||
description: string,
|
description: string,
|
||||||
duration: number;
|
duration: number;
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -56,6 +58,7 @@ export class Video {
|
||||||
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.licenceLabel = hash.licenceLabel;
|
||||||
|
this.languageLabel = hash.languageLabel;
|
||||||
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;
|
||||||
|
|
|
@ -24,6 +24,7 @@ export class VideoService {
|
||||||
|
|
||||||
videoCategories: Array<{ id: number, label: string }> = [];
|
videoCategories: Array<{ id: number, label: string }> = [];
|
||||||
videoLicences: Array<{ id: number, label: string }> = [];
|
videoLicences: Array<{ id: number, label: string }> = [];
|
||||||
|
videoLanguages: Array<{ id: number, label: string }> = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
|
@ -59,6 +60,19 @@ export class VideoService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadVideoLanguages() {
|
||||||
|
return this.http.get(VideoService.BASE_VIDEO_URL + 'languages')
|
||||||
|
.map(this.restExtractor.extractDataGet)
|
||||||
|
.subscribe(data => {
|
||||||
|
Object.keys(data).forEach(languageKey => {
|
||||||
|
this.videoLanguages.push({
|
||||||
|
id: parseInt(languageKey),
|
||||||
|
label: data[languageKey]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -46,6 +46,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="language">Language</label>
|
||||||
|
<select class="form-control" id="language" formControlName="language">
|
||||||
|
<option></option>
|
||||||
|
<option *ngFor="let language of videoLanguages" [value]="language.id">{{ language.label }}</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div *ngIf="formErrors.language" class="alert alert-danger">
|
||||||
|
{{ formErrors.language }}
|
||||||
|
</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
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
VIDEO_NAME,
|
VIDEO_NAME,
|
||||||
VIDEO_CATEGORY,
|
VIDEO_CATEGORY,
|
||||||
VIDEO_LICENCE,
|
VIDEO_LICENCE,
|
||||||
|
VIDEO_LANGUAGE,
|
||||||
VIDEO_DESCRIPTION,
|
VIDEO_DESCRIPTION,
|
||||||
VIDEO_TAGS
|
VIDEO_TAGS
|
||||||
} from '../../shared';
|
} from '../../shared';
|
||||||
|
@ -27,6 +28,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
uploader: FileUploader;
|
uploader: FileUploader;
|
||||||
videoCategories = [];
|
videoCategories = [];
|
||||||
videoLicences = [];
|
videoLicences = [];
|
||||||
|
videoLanguages = [];
|
||||||
|
|
||||||
error: string = null;
|
error: string = null;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
|
@ -34,6 +36,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
name: '',
|
name: '',
|
||||||
category: '',
|
category: '',
|
||||||
licence: '',
|
licence: '',
|
||||||
|
language: '',
|
||||||
description: '',
|
description: '',
|
||||||
currentTag: ''
|
currentTag: ''
|
||||||
};
|
};
|
||||||
|
@ -41,6 +44,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
name: VIDEO_NAME.MESSAGES,
|
name: VIDEO_NAME.MESSAGES,
|
||||||
category: VIDEO_CATEGORY.MESSAGES,
|
category: VIDEO_CATEGORY.MESSAGES,
|
||||||
licence: VIDEO_LICENCE.MESSAGES,
|
licence: VIDEO_LICENCE.MESSAGES,
|
||||||
|
language: VIDEO_LANGUAGE.MESSAGES,
|
||||||
description: VIDEO_DESCRIPTION.MESSAGES,
|
description: VIDEO_DESCRIPTION.MESSAGES,
|
||||||
currentTag: VIDEO_TAGS.MESSAGES
|
currentTag: VIDEO_TAGS.MESSAGES
|
||||||
};
|
};
|
||||||
|
@ -74,6 +78,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
nsfw: [ false ],
|
nsfw: [ false ],
|
||||||
category: [ '', VIDEO_CATEGORY.VALIDATORS ],
|
category: [ '', VIDEO_CATEGORY.VALIDATORS ],
|
||||||
licence: [ '', VIDEO_LICENCE.VALIDATORS ],
|
licence: [ '', VIDEO_LICENCE.VALIDATORS ],
|
||||||
|
language: [ '', VIDEO_LANGUAGE.VALIDATORS ],
|
||||||
description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
|
description: [ '', VIDEO_DESCRIPTION.VALIDATORS ],
|
||||||
currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
|
currentTag: [ '', VIDEO_TAGS.VALIDATORS ]
|
||||||
});
|
});
|
||||||
|
@ -84,6 +89,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.videoLicences = this.videoService.videoLicences;
|
||||||
|
this.videoLanguages = this.videoService.videoLanguages;
|
||||||
|
|
||||||
this.uploader = new FileUploader({
|
this.uploader = new FileUploader({
|
||||||
authToken: this.authService.getRequestHeaderValue(),
|
authToken: this.authService.getRequestHeaderValue(),
|
||||||
|
@ -97,12 +103,19 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
const nsfw = this.form.value['nsfw'];
|
const nsfw = this.form.value['nsfw'];
|
||||||
const category = this.form.value['category'];
|
const category = this.form.value['category'];
|
||||||
const licence = this.form.value['licence'];
|
const licence = this.form.value['licence'];
|
||||||
|
const language = this.form.value['language'];
|
||||||
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('nsfw', nsfw);
|
form.append('nsfw', nsfw);
|
||||||
form.append('licence', licence);
|
form.append('licence', licence);
|
||||||
|
|
||||||
|
// Language is optional
|
||||||
|
if (language) {
|
||||||
|
form.append('language', language);
|
||||||
|
}
|
||||||
|
|
||||||
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++) {
|
||||||
|
|
|
@ -121,6 +121,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="video-language" class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<span id="language-label">Language:</span>
|
||||||
|
{{ video.languageLabel }}
|
||||||
|
</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,7 +119,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#video-licence #licence-label {
|
#video-licence #licence-label, #video-language #language-label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue