]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/header/suggestion.component.ts
75c44a5839037720154f43f90442636d5bb92914
[github/Chocobozzz/PeerTube.git] / client / src / app / header / suggestion.component.ts
1 import { Input, Component, Output, EventEmitter, OnInit } from '@angular/core'
2 import { RouterLink } from '@angular/router'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { ListKeyManagerOption } from '@angular/cdk/a11y'
5
6 type Result = {
7 text: string
8 type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
9 routerLink?: RouterLink
10 }
11
12 @Component({
13 selector: 'my-suggestion',
14 templateUrl: './suggestion.component.html',
15 styleUrls: [ './suggestion.component.scss' ]
16 })
17 export class SuggestionComponent implements OnInit, ListKeyManagerOption {
18 @Input() result: Result
19 @Input() highlight: string
20 @Output() selected = new EventEmitter()
21
22 inAllText: string
23 inThisChannelText: string
24 inThisInstanceText: string
25
26 disabled = false
27 active = false
28
29 constructor (
30 private i18n: I18n
31 ) {
32 this.inAllText = this.i18n('In the vidiverse')
33 this.inThisChannelText = this.i18n('In this channel')
34 this.inThisInstanceText = this.i18n('In this instance')
35 }
36
37 getLabel () {
38 return this.result.text
39 }
40
41 ngOnInit () {
42 this.active = false
43 }
44
45 selectItem () {
46 this.selected.emit(this.result)
47 }
48 }