import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { ServerService } from '@app/core'
import { AdvancedSearch } from '@app/shared/shared-search'
-import { ServerConfig, VideoConstant } from '@shared/models'
+import { HTMLServerConfig, VideoConstant } from '@shared/models'
+
+type FormOption = { id: string, label: string }
@Component({
selector: 'my-search-filters',
videoLicences: VideoConstant<number>[] = []
videoLanguages: VideoConstant<string>[] = []
- publishedDateRanges: { id: string, label: string }[] = []
- sorts: { id: string, label: string }[] = []
- durationRanges: { id: string, label: string }[] = []
+ publishedDateRanges: FormOption[] = []
+ sorts: FormOption[] = []
+ durationRanges: FormOption[] = []
+ videoType: FormOption[] = []
publishedDateRange: string
durationRange: string
originallyPublishedStartYear: string
originallyPublishedEndYear: string
- private serverConfig: ServerConfig
+ private serverConfig: HTMLServerConfig
constructor (
private serverService: ServerService
) {
this.publishedDateRanges = [
- {
- id: 'any_published_date',
- label: $localize`Any`
- },
{
id: 'today',
label: $localize`Today`
}
]
- this.durationRanges = [
+ this.videoType = [
{
- id: 'any_duration',
- label: $localize`Any`
+ id: 'vod',
+ label: $localize`VOD videos`
},
+ {
+ id: 'live',
+ label: $localize`Live videos`
+ }
+ ]
+
+ this.durationRanges = [
{
id: 'short',
label: $localize`Short (< 4 min)`
}
ngOnInit () {
- this.serverConfig = this.serverService.getTmpConfig()
- this.serverService.getConfig()
- .subscribe(config => this.serverConfig = config)
+ this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getVideoCategories().subscribe(categories => this.videoCategories = categories)
this.serverService.getVideoLicences().subscribe(licences => this.videoLicences = licences)
this.loadOriginallyPublishedAtYears()
}
- inputUpdated () {
+ onDurationOrPublishedUpdated () {
this.updateModelFromDurationRange()
this.updateModelFromPublishedRange()
this.updateModelFromOriginallyPublishedAtYears()
}
formUpdated () {
- this.inputUpdated()
+ this.onDurationOrPublishedUpdated()
this.filtered.emit(this.advancedSearch)
}
reset () {
this.advancedSearch.reset()
+
+ this.resetOriginalPublicationYears()
+
this.durationRange = undefined
this.publishedDateRange = undefined
- this.originallyPublishedStartYear = undefined
- this.originallyPublishedEndYear = undefined
- this.inputUpdated()
+
+ this.onDurationOrPublishedUpdated()
}
resetField (fieldName: string, value?: any) {
resetLocalField (fieldName: string, value?: any) {
this[fieldName] = value
- this.inputUpdated()
+ this.onDurationOrPublishedUpdated()
}
resetOriginalPublicationYears () {