diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts
index a2af9a942..59aba22ff 100644
--- a/client/src/app/+search/search-filters.component.ts
+++ b/client/src/app/+search/search-filters.component.ts
@@ -3,6 +3,8 @@ import { ServerService } from '@app/core'
import { AdvancedSearch } from '@app/shared/shared-search'
import { ServerConfig, VideoConstant } from '@shared/models'
+type FormOption = { id: string, label: string }
+
@Component({
selector: 'my-search-filters',
styleUrls: [ './search-filters.component.scss' ],
@@ -17,9 +19,10 @@ export class SearchFiltersComponent implements OnInit {
videoLicences: VideoConstant
[] = []
videoLanguages: VideoConstant[] = []
- 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
@@ -33,10 +36,6 @@ export class SearchFiltersComponent implements OnInit {
private serverService: ServerService
) {
this.publishedDateRanges = [
- {
- id: 'any_published_date',
- label: $localize`Any`
- },
{
id: 'today',
label: $localize`Today`
@@ -55,11 +54,18 @@ export class SearchFiltersComponent implements OnInit {
}
]
- 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)`
@@ -104,24 +110,26 @@ export class SearchFiltersComponent implements OnInit {
this.loadOriginallyPublishedAtYears()
}
- inputUpdated () {
+ onInputUpdated () {
this.updateModelFromDurationRange()
this.updateModelFromPublishedRange()
this.updateModelFromOriginallyPublishedAtYears()
}
formUpdated () {
- this.inputUpdated()
+ this.onInputUpdated()
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.onInputUpdated()
}
resetField (fieldName: string, value?: any) {
@@ -130,7 +138,7 @@ export class SearchFiltersComponent implements OnInit {
resetLocalField (fieldName: string, value?: any) {
this[fieldName] = value
- this.inputUpdated()
+ this.onInputUpdated()
}
resetOriginalPublicationYears () {
diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts
index 0e3924841..2c83f53b6 100644
--- a/client/src/app/shared/shared-search/advanced-search.model.ts
+++ b/client/src/app/shared/shared-search/advanced-search.model.ts
@@ -1,4 +1,4 @@
-import { BooleanBothQuery, SearchTargetType } from '@shared/models'
+import { BooleanBothQuery, BooleanQuery, SearchTargetType, VideosSearchQuery } from '@shared/models'
export class AdvancedSearch {
startDate: string // ISO 8601
@@ -21,6 +21,8 @@ export class AdvancedSearch {
durationMin: number // seconds
durationMax: number // seconds
+ isLive: BooleanQuery
+
sort: string
searchTarget: SearchTargetType
@@ -41,6 +43,8 @@ export class AdvancedSearch {
tagsOneOf?: any
tagsAllOf?: any
+ isLive?: BooleanQuery
+
durationMin?: string
durationMax?: string
sort?: string
@@ -54,6 +58,8 @@ export class AdvancedSearch {
this.originallyPublishedEndDate = options.originallyPublishedEndDate || undefined
this.nsfw = options.nsfw || undefined
+ this.isLive = options.isLive || undefined
+
this.categoryOneOf = options.categoryOneOf || undefined
this.licenceOneOf = options.licenceOneOf || undefined
this.languageOneOf = options.languageOneOf || undefined
@@ -94,6 +100,7 @@ export class AdvancedSearch {
this.tagsAllOf = undefined
this.durationMin = undefined
this.durationMax = undefined
+ this.isLive = undefined
this.sort = '-match'
}
@@ -112,12 +119,16 @@ export class AdvancedSearch {
tagsAllOf: this.tagsAllOf,
durationMin: this.durationMin,
durationMax: this.durationMax,
+ isLive: this.isLive,
sort: this.sort,
searchTarget: this.searchTarget
}
}
- toAPIObject () {
+ toAPIObject (): VideosSearchQuery {
+ let isLive: boolean
+ if (this.isLive) isLive = this.isLive === 'true'
+
return {
startDate: this.startDate,
endDate: this.endDate,
@@ -131,6 +142,7 @@ export class AdvancedSearch {
tagsAllOf: this.tagsAllOf,
durationMin: this.durationMin,
durationMax: this.durationMax,
+ isLive,
sort: this.sort,
searchTarget: this.searchTarget
}
diff --git a/shared/models/search/boolean-both-query.model.ts b/shared/models/search/boolean-both-query.model.ts
index 57b0e8d44..d6a438249 100644
--- a/shared/models/search/boolean-both-query.model.ts
+++ b/shared/models/search/boolean-both-query.model.ts
@@ -1 +1,2 @@
export type BooleanBothQuery = 'true' | 'false' | 'both'
+export type BooleanQuery = 'true' | 'false'