diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/search/advanced-search.model.ts | 15 | ||||
-rw-r--r-- | client/src/app/search/search-filters.component.html | 9 | ||||
-rw-r--r-- | client/src/app/search/search-filters.component.ts | 22 |
3 files changed, 41 insertions, 5 deletions
diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts index aad436788..ce22c3f84 100644 --- a/client/src/app/search/advanced-search.model.ts +++ b/client/src/app/search/advanced-search.model.ts | |||
@@ -18,6 +18,8 @@ export class AdvancedSearch { | |||
18 | durationMin: number // seconds | 18 | durationMin: number // seconds |
19 | durationMax: number // seconds | 19 | durationMax: number // seconds |
20 | 20 | ||
21 | sort: string | ||
22 | |||
21 | constructor (options?: { | 23 | constructor (options?: { |
22 | startDate?: string | 24 | startDate?: string |
23 | endDate?: string | 25 | endDate?: string |
@@ -29,6 +31,7 @@ export class AdvancedSearch { | |||
29 | tagsAllOf?: string | 31 | tagsAllOf?: string |
30 | durationMin?: string | 32 | durationMin?: string |
31 | durationMax?: string | 33 | durationMax?: string |
34 | sort?: string | ||
32 | }) { | 35 | }) { |
33 | if (!options) return | 36 | if (!options) return |
34 | 37 | ||
@@ -45,11 +48,15 @@ export class AdvancedSearch { | |||
45 | 48 | ||
46 | if (isNaN(this.durationMin)) this.durationMin = undefined | 49 | if (isNaN(this.durationMin)) this.durationMin = undefined |
47 | if (isNaN(this.durationMax)) this.durationMax = undefined | 50 | if (isNaN(this.durationMax)) this.durationMax = undefined |
51 | |||
52 | this.sort = options.sort || '-match' | ||
48 | } | 53 | } |
49 | 54 | ||
50 | containsValues () { | 55 | containsValues () { |
51 | const obj = this.toUrlObject() | 56 | const obj = this.toUrlObject() |
52 | for (const k of Object.keys(obj)) { | 57 | for (const k of Object.keys(obj)) { |
58 | if (k === 'sort') continue // Exception | ||
59 | |||
53 | if (obj[k] !== undefined) return true | 60 | if (obj[k] !== undefined) return true |
54 | } | 61 | } |
55 | 62 | ||
@@ -67,6 +74,8 @@ export class AdvancedSearch { | |||
67 | this.tagsAllOf = undefined | 74 | this.tagsAllOf = undefined |
68 | this.durationMin = undefined | 75 | this.durationMin = undefined |
69 | this.durationMax = undefined | 76 | this.durationMax = undefined |
77 | |||
78 | this.sort = '-match' | ||
70 | } | 79 | } |
71 | 80 | ||
72 | toUrlObject () { | 81 | toUrlObject () { |
@@ -80,7 +89,8 @@ export class AdvancedSearch { | |||
80 | tagsOneOf: this.tagsOneOf, | 89 | tagsOneOf: this.tagsOneOf, |
81 | tagsAllOf: this.tagsAllOf, | 90 | tagsAllOf: this.tagsAllOf, |
82 | durationMin: this.durationMin, | 91 | durationMin: this.durationMin, |
83 | durationMax: this.durationMax | 92 | durationMax: this.durationMax, |
93 | sort: this.sort | ||
84 | } | 94 | } |
85 | } | 95 | } |
86 | 96 | ||
@@ -95,7 +105,8 @@ export class AdvancedSearch { | |||
95 | tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined, | 105 | tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined, |
96 | tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined, | 106 | tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined, |
97 | durationMin: this.durationMin, | 107 | durationMin: this.durationMin, |
98 | durationMax: this.durationMax | 108 | durationMax: this.durationMax, |
109 | sort: this.sort | ||
99 | } | 110 | } |
100 | } | 111 | } |
101 | } | 112 | } |
diff --git a/client/src/app/search/search-filters.component.html b/client/src/app/search/search-filters.component.html index f8b3675e5..74bb781f4 100644 --- a/client/src/app/search/search-filters.component.html +++ b/client/src/app/search/search-filters.component.html | |||
@@ -3,6 +3,15 @@ | |||
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-lg-4 col-md-6 col-xs-12"> | 4 | <div class="col-lg-4 col-md-6 col-xs-12"> |
5 | <div class="form-group"> | 5 | <div class="form-group"> |
6 | <div i18n class="radio-label">Sort</div> | ||
7 | |||
8 | <div class="peertube-radio-container" *ngFor="let sort of sorts"> | ||
9 | <input type="radio" name="sort" [id]="sort.id" [value]="sort.id" [(ngModel)]="advancedSearch.sort"> | ||
10 | <label [for]="sort.id" class="radio">{{ sort.label }}</label> | ||
11 | </div> | ||
12 | </div> | ||
13 | |||
14 | <div class="form-group"> | ||
6 | <div i18n class="radio-label">Published date</div> | 15 | <div i18n class="radio-label">Published date</div> |
7 | 16 | ||
8 | <div class="peertube-radio-container" *ngFor="let date of publishedDateRanges"> | 17 | <div class="peertube-radio-container" *ngFor="let date of publishedDateRanges"> |
diff --git a/client/src/app/search/search-filters.component.ts b/client/src/app/search/search-filters.component.ts index 4219f99a9..a40648eb4 100644 --- a/client/src/app/search/search-filters.component.ts +++ b/client/src/app/search/search-filters.component.ts | |||
@@ -23,6 +23,7 @@ export class SearchFiltersComponent implements OnInit { | |||
23 | videoLanguages: VideoConstant<string>[] = [] | 23 | videoLanguages: VideoConstant<string>[] = [] |
24 | 24 | ||
25 | publishedDateRanges: { id: string, label: string }[] = [] | 25 | publishedDateRanges: { id: string, label: string }[] = [] |
26 | sorts: { id: string, label: string }[] = [] | ||
26 | durationRanges: { id: string, label: string }[] = [] | 27 | durationRanges: { id: string, label: string }[] = [] |
27 | 28 | ||
28 | publishedDateRange: string | 29 | publishedDateRange: string |
@@ -59,15 +60,30 @@ export class SearchFiltersComponent implements OnInit { | |||
59 | this.durationRanges = [ | 60 | this.durationRanges = [ |
60 | { | 61 | { |
61 | id: 'short', | 62 | id: 'short', |
62 | label: this.i18n('Short (< 4 minutes)') | 63 | label: this.i18n('Short (< 4 min)') |
63 | }, | 64 | }, |
64 | { | 65 | { |
65 | id: 'long', | 66 | id: 'long', |
66 | label: this.i18n('Long (> 10 minutes)') | 67 | label: this.i18n('Long (> 10 min)') |
67 | }, | 68 | }, |
68 | { | 69 | { |
69 | id: 'medium', | 70 | id: 'medium', |
70 | label: this.i18n('Medium (4-10 minutes)') | 71 | label: this.i18n('Medium (4-10 min)') |
72 | } | ||
73 | ] | ||
74 | |||
75 | this.sorts = [ | ||
76 | { | ||
77 | id: '-match', | ||
78 | label: this.i18n('Relevance') | ||
79 | }, | ||
80 | { | ||
81 | id: '-publishedAt', | ||
82 | label: this.i18n('Publish date') | ||
83 | }, | ||
84 | { | ||
85 | id: '-views', | ||
86 | label: this.i18n('Views') | ||
71 | } | 87 | } |
72 | ] | 88 | ] |
73 | } | 89 | } |