diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-27 16:23:10 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-27 16:23:10 +0200 |
commit | 41a2aee38cf812510010da09de9bae53590ec119 (patch) | |
tree | 79d55d6ae0ef6f66ccb88890cf1ef1946dc65fb4 /client/app/shared | |
parent | 157cb9c9713e08ff70078660a32dd77ecb87eabc (diff) | |
download | PeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.gz PeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.zst PeerTube-41a2aee38cf812510010da09de9bae53590ec119.zip |
Follow the angular styleguide for the directories structure
Diffstat (limited to 'client/app/shared')
-rw-r--r-- | client/app/shared/index.ts | 3 | ||||
-rw-r--r-- | client/app/shared/search-field.type.ts | 1 | ||||
-rw-r--r-- | client/app/shared/search.component.html | 17 | ||||
-rw-r--r-- | client/app/shared/search.component.ts | 47 | ||||
-rw-r--r-- | client/app/shared/search.model.ts | 6 |
5 files changed, 74 insertions, 0 deletions
diff --git a/client/app/shared/index.ts b/client/app/shared/index.ts new file mode 100644 index 000000000..a49a4f1a9 --- /dev/null +++ b/client/app/shared/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './search-field.type'; | ||
2 | export * from './search.component'; | ||
3 | export * from './search.model'; | ||
diff --git a/client/app/shared/search-field.type.ts b/client/app/shared/search-field.type.ts new file mode 100644 index 000000000..846236290 --- /dev/null +++ b/client/app/shared/search-field.type.ts | |||
@@ -0,0 +1 @@ | |||
export type SearchField = "name" | "author" | "podUrl" | "magnetUri"; | |||
diff --git a/client/app/shared/search.component.html b/client/app/shared/search.component.html new file mode 100644 index 000000000..fb13ac72e --- /dev/null +++ b/client/app/shared/search.component.html | |||
@@ -0,0 +1,17 @@ | |||
1 | <div class="input-group"> | ||
2 | <div class="input-group-btn" dropdown> | ||
3 | <button id="simple-btn-keyboard-nav" type="button" class="btn btn-default" dropdownToggle> | ||
4 | {{ getStringChoice(searchCriterias.field) }} <span class="caret"></span> | ||
5 | </button> | ||
6 | <ul class="dropdown-menu" role="menu" aria-labelledby="simple-btn-keyboard-nav"> | ||
7 | <li *ngFor="let choice of choiceKeys" class="dropdown-item"> | ||
8 | <a class="dropdown-item" href="#" (click)="choose($event, choice)">{{ getStringChoice(choice) }}</a> | ||
9 | </li> | ||
10 | </ul> | ||
11 | </div> | ||
12 | |||
13 | <input | ||
14 | type="text" id="search-video" name="search-video" class="form-control" placeholder="Search a video..." class="form-control" | ||
15 | [(ngModel)]="searchCriterias.value" (keyup.enter)="doSearch()" | ||
16 | > | ||
17 | </div> | ||
diff --git a/client/app/shared/search.component.ts b/client/app/shared/search.component.ts new file mode 100644 index 000000000..519810f9b --- /dev/null +++ b/client/app/shared/search.component.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import { Component, EventEmitter, Output } from '@angular/core'; | ||
2 | |||
3 | import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; | ||
4 | |||
5 | import { Search } from './search.model'; | ||
6 | import { SearchField } from './search-field.type'; | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-search', | ||
10 | templateUrl: 'client/app/shared/search.component.html', | ||
11 | directives: [ DROPDOWN_DIRECTIVES ] | ||
12 | }) | ||
13 | |||
14 | export class SearchComponent { | ||
15 | @Output() search: EventEmitter<Search> = new EventEmitter<Search>(); | ||
16 | |||
17 | searchCriterias: Search = { | ||
18 | field: 'name', | ||
19 | value: '' | ||
20 | }; | ||
21 | fieldChoices = { | ||
22 | name: 'Name', | ||
23 | author: 'Author', | ||
24 | podUrl: 'Pod Url', | ||
25 | magnetUri: 'Magnet Uri' | ||
26 | }; | ||
27 | |||
28 | get choiceKeys() { | ||
29 | return Object.keys(this.fieldChoices); | ||
30 | } | ||
31 | |||
32 | getStringChoice(choiceKey: SearchField): string { | ||
33 | return this.fieldChoices[choiceKey]; | ||
34 | } | ||
35 | |||
36 | choose($event:MouseEvent, choice: SearchField) { | ||
37 | $event.preventDefault(); | ||
38 | $event.stopPropagation(); | ||
39 | |||
40 | this.searchCriterias.field = choice; | ||
41 | } | ||
42 | |||
43 | doSearch(): void { | ||
44 | this.search.emit(this.searchCriterias); | ||
45 | } | ||
46 | |||
47 | } | ||
diff --git a/client/app/shared/search.model.ts b/client/app/shared/search.model.ts new file mode 100644 index 000000000..932a6566c --- /dev/null +++ b/client/app/shared/search.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | import { SearchField } from './search-field.type'; | ||
2 | |||
3 | export interface Search { | ||
4 | field: SearchField; | ||
5 | value: string; | ||
6 | } | ||