-
In this channel
+
In this instance
- In the vidiverse
- ↵
+ In the vidiverse
-
-
- Jump to channel
- ↵
-
-
\ No newline at end of file
+
diff --git a/client/src/app/header/suggestion.component.ts b/client/src/app/header/suggestion.component.ts
index 69641b511..250a5411e 100644
--- a/client/src/app/header/suggestion.component.ts
+++ b/client/src/app/header/suggestion.component.ts
@@ -1,24 +1,24 @@
-import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core'
+import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy, OnChanges } from '@angular/core'
import { RouterLink } from '@angular/router'
import { ListKeyManagerOption } from '@angular/cdk/a11y'
-export type Result = {
+export type SuggestionPayload = {
text: string
- type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
- routerLink?: RouterLink,
- default?: boolean
+ type: SuggestionPayloadType
+ routerLink?: RouterLink
+ default: boolean
}
+export type SuggestionPayloadType = 'search-instance' | 'search-index'
+
@Component({
selector: 'my-suggestion',
templateUrl: './suggestion.component.html',
- styleUrls: [ './suggestion.component.scss' ],
- changeDetection: ChangeDetectionStrategy.OnPush
+ styleUrls: [ './suggestion.component.scss' ]
})
export class SuggestionComponent implements OnInit, ListKeyManagerOption {
- @Input() result: Result
+ @Input() result: SuggestionPayload
@Input() highlight: string
- @Output() selected = new EventEmitter()
disabled = false
active = false
@@ -30,8 +30,4 @@ export class SuggestionComponent implements OnInit, ListKeyManagerOption {
ngOnInit () {
if (this.result.default) this.active = true
}
-
- selectItem () {
- this.selected.emit(this.result)
- }
}
diff --git a/client/src/app/header/suggestions.component.html b/client/src/app/header/suggestions.component.html
deleted file mode 100644
index 8d017d78d..000000000
--- a/client/src/app/header/suggestions.component.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
\ No newline at end of file
diff --git a/client/src/app/header/suggestions.component.ts b/client/src/app/header/suggestions.component.ts
deleted file mode 100644
index ee3ef73c2..000000000
--- a/client/src/app/header/suggestions.component.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Input, QueryList, Component, Output, AfterViewInit, EventEmitter, ViewChildren, ChangeDetectionStrategy } from '@angular/core'
-import { SuggestionComponent } from './suggestion.component'
-
-@Component({
- selector: 'my-suggestions',
- templateUrl: './suggestions.component.html',
- changeDetection: ChangeDetectionStrategy.OnPush
-})
-export class SuggestionsComponent implements AfterViewInit {
- @Input() results: any[]
- @Input() highlight: string
- @ViewChildren(SuggestionComponent) listItems: QueryList
- @Output() init = new EventEmitter()
-
- ngAfterViewInit () {
- this.listItems.changes.subscribe(
- _ => this.init.emit({ items: this.listItems })
- )
- }
-
- hoverItem (index: number) {
- this.init.emit({ items: this.listItems, index: index })
- }
-}
diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts
index 50f00bc27..643cc9a29 100644
--- a/client/src/app/search/advanced-search.model.ts
+++ b/client/src/app/search/advanced-search.model.ts
@@ -1,3 +1,4 @@
+import { SearchTargetType } from '@shared/models/search/search-target-query.model'
import { NSFWQuery } from '../../../../shared/models/search'
export class AdvancedSearch {
@@ -23,6 +24,11 @@ export class AdvancedSearch {
sort: string
+ searchTarget: SearchTargetType
+
+ // Filters we don't want to count, because they are mandatory
+ private silentFilters = new Set([ 'sort', 'searchTarget' ])
+
constructor (options?: {
startDate?: string
endDate?: string
@@ -37,6 +43,7 @@ export class AdvancedSearch {
durationMin?: string
durationMax?: string
sort?: string
+ searchTarget?: SearchTargetType
}) {
if (!options) return
@@ -54,6 +61,8 @@ export class AdvancedSearch {
this.durationMin = parseInt(options.durationMin, 10)
this.durationMax = parseInt(options.durationMax, 10)
+ this.searchTarget = options.searchTarget || undefined
+
if (isNaN(this.durationMin)) this.durationMin = undefined
if (isNaN(this.durationMax)) this.durationMax = undefined
@@ -61,9 +70,11 @@ export class AdvancedSearch {
}
containsValues () {
+ const exceptions = new Set([ 'sort', 'searchTarget' ])
+
const obj = this.toUrlObject()
for (const k of Object.keys(obj)) {
- if (k === 'sort') continue // Exception
+ if (this.silentFilters.has(k)) continue
if (obj[k] !== undefined && obj[k] !== '') return true
}
@@ -102,7 +113,8 @@ export class AdvancedSearch {
tagsAllOf: this.tagsAllOf,
durationMin: this.durationMin,
durationMax: this.durationMax,
- sort: this.sort
+ sort: this.sort,
+ searchTarget: this.searchTarget
}
}
@@ -120,7 +132,8 @@ export class AdvancedSearch {
tagsAllOf: this.intoArray(this.tagsAllOf),
durationMin: this.durationMin,
durationMax: this.durationMax,
- sort: this.sort
+ sort: this.sort,
+ searchTarget: this.searchTarget
}
}
@@ -129,7 +142,7 @@ export class AdvancedSearch {
const obj = this.toUrlObject()
for (const k of Object.keys(obj)) {
- if (k === 'sort') continue // Exception
+ if (this.silentFilters.has(k)) continue
if (obj[k] !== undefined && obj[k] !== '') acc++
}
diff --git a/client/src/app/search/channel-lazy-load.resolver.ts b/client/src/app/search/channel-lazy-load.resolver.ts
new file mode 100644
index 000000000..8be089cdd
--- /dev/null
+++ b/client/src/app/search/channel-lazy-load.resolver.ts
@@ -0,0 +1,45 @@
+import { map } from 'rxjs/operators'
+import { Injectable } from '@angular/core'
+import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'
+import { SearchService } from './search.service'
+import { RedirectService } from '@app/core'
+
+@Injectable()
+export class ChannelLazyLoadResolver implements Resolve {
+ constructor (
+ private router: Router,
+ private searchService: SearchService,
+ private redirectService: RedirectService
+ ) { }
+
+ resolve (route: ActivatedRouteSnapshot) {
+ const url = route.params.url
+ const externalRedirect = route.params.externalRedirect
+ const fromPath = route.params.fromPath
+
+ if (!url) {
+ console.error('Could not find url param.', { params: route.params })
+ return this.router.navigateByUrl('/404')
+ }
+
+ if (externalRedirect === 'true') {
+ window.open(url)
+ this.router.navigateByUrl(fromPath)
+ return
+ }
+
+ return this.searchService.searchVideoChannels({ search: url })
+ .pipe(
+ map(result => {
+ if (result.data.length !== 1) {
+ console.error('Cannot find result for this URL')
+ return this.router.navigateByUrl('/404')
+ }
+
+ const channel = result.data[0]
+
+ return this.router.navigateByUrl('/video-channels/' + channel.nameWithHost)
+ })
+ )
+ }
+}
diff --git a/client/src/app/search/search-filters.component.html b/client/src/app/search/search-filters.component.html
index 54fc7338f..e20aef8fb 100644
--- a/client/src/app/search/search-filters.component.html
+++ b/client/src/app/search/search-filters.component.html
@@ -16,6 +16,25 @@