aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-search/advanced-search.model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-29 15:19:22 +0200
committerChocobozzz <me@florianbigard.com>2021-07-29 15:19:22 +0200
commitaf7fd04a6706fb781e4622167b08dc6c9376f06a (patch)
tree4d6a84cd67143e07d762ba967f9d29e947e7436c /client/src/app/shared/shared-search/advanced-search.model.ts
parent9c9a236b541a286e165d67341e4ddd6ea2fabdf1 (diff)
downloadPeerTube-af7fd04a6706fb781e4622167b08dc6c9376f06a.tar.gz
PeerTube-af7fd04a6706fb781e4622167b08dc6c9376f06a.tar.zst
PeerTube-af7fd04a6706fb781e4622167b08dc6c9376f06a.zip
Add ability to filter by host in search page
Diffstat (limited to 'client/src/app/shared/shared-search/advanced-search.model.ts')
-rw-r--r--client/src/app/shared/shared-search/advanced-search.model.ts34
1 files changed, 32 insertions, 2 deletions
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 2c83f53b6..9c55f6cd8 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,11 @@
1import { BooleanBothQuery, BooleanQuery, SearchTargetType, VideosSearchQuery } from '@shared/models' 1import {
2 BooleanBothQuery,
3 BooleanQuery,
4 SearchTargetType,
5 VideoChannelsSearchQuery,
6 VideoPlaylistsSearchQuery,
7 VideosSearchQuery
8} from '@shared/models'
2 9
3export class AdvancedSearch { 10export class AdvancedSearch {
4 startDate: string // ISO 8601 11 startDate: string // ISO 8601
@@ -23,6 +30,8 @@ export class AdvancedSearch {
23 30
24 isLive: BooleanQuery 31 isLive: BooleanQuery
25 32
33 host: string
34
26 sort: string 35 sort: string
27 36
28 searchTarget: SearchTargetType 37 searchTarget: SearchTargetType
@@ -45,6 +54,8 @@ export class AdvancedSearch {
45 54
46 isLive?: BooleanQuery 55 isLive?: BooleanQuery
47 56
57 host?: string
58
48 durationMin?: string 59 durationMin?: string
49 durationMax?: string 60 durationMax?: string
50 sort?: string 61 sort?: string
@@ -68,6 +79,8 @@ export class AdvancedSearch {
68 this.durationMin = parseInt(options.durationMin, 10) 79 this.durationMin = parseInt(options.durationMin, 10)
69 this.durationMax = parseInt(options.durationMax, 10) 80 this.durationMax = parseInt(options.durationMax, 10)
70 81
82 this.host = options.host || undefined
83
71 this.searchTarget = options.searchTarget || undefined 84 this.searchTarget = options.searchTarget || undefined
72 85
73 if (isNaN(this.durationMin)) this.durationMin = undefined 86 if (isNaN(this.durationMin)) this.durationMin = undefined
@@ -101,6 +114,7 @@ export class AdvancedSearch {
101 this.durationMin = undefined 114 this.durationMin = undefined
102 this.durationMax = undefined 115 this.durationMax = undefined
103 this.isLive = undefined 116 this.isLive = undefined
117 this.host = undefined
104 118
105 this.sort = '-match' 119 this.sort = '-match'
106 } 120 }
@@ -120,12 +134,13 @@ export class AdvancedSearch {
120 durationMin: this.durationMin, 134 durationMin: this.durationMin,
121 durationMax: this.durationMax, 135 durationMax: this.durationMax,
122 isLive: this.isLive, 136 isLive: this.isLive,
137 host: this.host,
123 sort: this.sort, 138 sort: this.sort,
124 searchTarget: this.searchTarget 139 searchTarget: this.searchTarget
125 } 140 }
126 } 141 }
127 142
128 toAPIObject (): VideosSearchQuery { 143 toVideosAPIObject (): VideosSearchQuery {
129 let isLive: boolean 144 let isLive: boolean
130 if (this.isLive) isLive = this.isLive === 'true' 145 if (this.isLive) isLive = this.isLive === 'true'
131 146
@@ -142,12 +157,27 @@ export class AdvancedSearch {
142 tagsAllOf: this.tagsAllOf, 157 tagsAllOf: this.tagsAllOf,
143 durationMin: this.durationMin, 158 durationMin: this.durationMin,
144 durationMax: this.durationMax, 159 durationMax: this.durationMax,
160 host: this.host,
145 isLive, 161 isLive,
146 sort: this.sort, 162 sort: this.sort,
147 searchTarget: this.searchTarget 163 searchTarget: this.searchTarget
148 } 164 }
149 } 165 }
150 166
167 toPlaylistAPIObject (): VideoPlaylistsSearchQuery {
168 return {
169 host: this.host,
170 searchTarget: this.searchTarget
171 }
172 }
173
174 toChannelAPIObject (): VideoChannelsSearchQuery {
175 return {
176 host: this.host,
177 searchTarget: this.searchTarget
178 }
179 }
180
151 size () { 181 size () {
152 let acc = 0 182 let acc = 0
153 183