X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bsearch%2Fsearch-filters.component.ts;h=59aba22ff8b6a13239ad02ae2ad5ccf9647adbb0;hb=7a22a0a56aa75fbb1ba986a5d2c606e1343f30c2;hp=fc1db3258a59e747b5cb83f9c58aada5b38cce3b;hpb=1942f11d5ee6926ad93dc1b79fae18325ba5de18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts index fc1db3258..59aba22ff 100644 --- a/client/src/app/+search/search-filters.component.ts +++ b/client/src/app/+search/search-filters.component.ts @@ -1,11 +1,10 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' -import { ValidatorFn } from '@angular/forms' import { ServerService } from '@app/core' -import { VideoValidatorsService } from '@app/shared/shared-forms' import { AdvancedSearch } from '@app/shared/shared-search' -import { I18n } from '@ngx-translate/i18n-polyfill' import { ServerConfig, VideoConstant } from '@shared/models' +type FormOption = { id: string, label: string } + @Component({ selector: 'my-search-filters', styleUrls: [ './search-filters.component.scss' ], @@ -20,12 +19,10 @@ export class SearchFiltersComponent implements OnInit { videoLicences: VideoConstant[] = [] videoLanguages: VideoConstant[] = [] - tagValidators: ValidatorFn[] - tagValidatorsMessages: { [ name: string ]: 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 @@ -36,66 +33,65 @@ export class SearchFiltersComponent implements OnInit { private serverConfig: ServerConfig constructor ( - private i18n: I18n, - private videoValidatorsService: VideoValidatorsService, private serverService: ServerService ) { - this.tagValidators = this.videoValidatorsService.VIDEO_TAGS.VALIDATORS - this.tagValidatorsMessages = this.videoValidatorsService.VIDEO_TAGS.MESSAGES this.publishedDateRanges = [ - { - id: 'any_published_date', - label: this.i18n('Any') - }, { id: 'today', - label: this.i18n('Today') + label: $localize`Today` }, { id: 'last_7days', - label: this.i18n('Last 7 days') + label: $localize`Last 7 days` }, { id: 'last_30days', - label: this.i18n('Last 30 days') + label: $localize`Last 30 days` }, { id: 'last_365days', - label: this.i18n('Last 365 days') + label: $localize`Last 365 days` } ] - this.durationRanges = [ + this.videoType = [ { - id: 'any_duration', - label: this.i18n('Any') + id: 'vod', + label: $localize`VOD videos` }, + { + id: 'live', + label: $localize`Live videos` + } + ] + + this.durationRanges = [ { id: 'short', - label: this.i18n('Short (< 4 min)') + label: $localize`Short (< 4 min)` }, { id: 'medium', - label: this.i18n('Medium (4-10 min)') + label: $localize`Medium (4-10 min)` }, { id: 'long', - label: this.i18n('Long (> 10 min)') + label: $localize`Long (> 10 min)` } ] this.sorts = [ { id: '-match', - label: this.i18n('Relevance') + label: $localize`Relevance` }, { id: '-publishedAt', - label: this.i18n('Publish date') + label: $localize`Publish date` }, { id: '-views', - label: this.i18n('Views') + label: $localize`Views` } ] } @@ -114,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) { @@ -140,7 +138,7 @@ export class SearchFiltersComponent implements OnInit { resetLocalField (fieldName: string, value?: any) { this[fieldName] = value - this.inputUpdated() + this.onInputUpdated() } resetOriginalPublicationYears () {