From df98563e2104b82b119c00a3cd83cd0dc1242d25 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jun 2017 14:32:15 +0200 Subject: Use typescript standard and lint all files --- client/src/app/shared/search/index.ts | 8 ++-- client/src/app/shared/search/search-field.type.ts | 2 +- client/src/app/shared/search/search.component.ts | 48 +++++++++++------------ client/src/app/shared/search/search.model.ts | 6 +-- client/src/app/shared/search/search.service.ts | 18 ++++----- 5 files changed, 41 insertions(+), 41 deletions(-) (limited to 'client/src/app/shared/search') diff --git a/client/src/app/shared/search/index.ts b/client/src/app/shared/search/index.ts index a897ed099..d4016cf89 100644 --- a/client/src/app/shared/search/index.ts +++ b/client/src/app/shared/search/index.ts @@ -1,4 +1,4 @@ -export * from './search-field.type'; -export * from './search.component'; -export * from './search.model'; -export * from './search.service'; +export * from './search-field.type' +export * from './search.component' +export * from './search.model' +export * from './search.service' diff --git a/client/src/app/shared/search/search-field.type.ts b/client/src/app/shared/search/search-field.type.ts index 6be584ed1..63557898a 100644 --- a/client/src/app/shared/search/search-field.type.ts +++ b/client/src/app/shared/search/search-field.type.ts @@ -1 +1 @@ -export type SearchField = "name" | "author" | "host" | "magnetUri" | "tags"; +export type SearchField = 'name' | 'author' | 'host' | 'magnetUri' | 'tags' diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts index 48413b4f2..ecce20666 100644 --- a/client/src/app/shared/search/search.component.ts +++ b/client/src/app/shared/search/search.component.ts @@ -1,9 +1,9 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { Component, OnInit } from '@angular/core' +import { Router } from '@angular/router' -import { Search } from './search.model'; -import { SearchField } from './search-field.type'; -import { SearchService } from './search.service'; +import { Search } from './search.model' +import { SearchField } from './search-field.type' +import { SearchService } from './search.service' @Component({ selector: 'my-search', @@ -18,53 +18,53 @@ export class SearchComponent implements OnInit { host: 'Pod Host', magnetUri: 'Magnet URI', tags: 'Tags' - }; + } searchCriterias: Search = { field: 'name', value: '' - }; + } - constructor(private searchService: SearchService, private router: Router) {} + constructor (private searchService: SearchService, private router: Router) {} - ngOnInit() { + ngOnInit () { // Subscribe if the search changed // Usually changed by videos list component this.searchService.updateSearch.subscribe( newSearchCriterias => { // Put a field by default if (!newSearchCriterias.field) { - newSearchCriterias.field = 'name'; + newSearchCriterias.field = 'name' } - this.searchCriterias = newSearchCriterias; + this.searchCriterias = newSearchCriterias } - ); + ) } - get choiceKeys() { - return Object.keys(this.fieldChoices); + get choiceKeys () { + return Object.keys(this.fieldChoices) } - choose($event: MouseEvent, choice: SearchField) { - $event.preventDefault(); - $event.stopPropagation(); + choose ($event: MouseEvent, choice: SearchField) { + $event.preventDefault() + $event.stopPropagation() - this.searchCriterias.field = choice; + this.searchCriterias.field = choice if (this.searchCriterias.value) { - this.doSearch(); + this.doSearch() } } - doSearch() { + doSearch () { if (this.router.url.indexOf('/videos/list') === -1) { - this.router.navigate([ '/videos/list' ]); + this.router.navigate([ '/videos/list' ]) } - this.searchService.searchUpdated.next(this.searchCriterias); + this.searchService.searchUpdated.next(this.searchCriterias) } - getStringChoice(choiceKey: SearchField) { - return this.fieldChoices[choiceKey]; + getStringChoice (choiceKey: SearchField) { + return this.fieldChoices[choiceKey] } } diff --git a/client/src/app/shared/search/search.model.ts b/client/src/app/shared/search/search.model.ts index 932a6566c..174adf2c6 100644 --- a/client/src/app/shared/search/search.model.ts +++ b/client/src/app/shared/search/search.model.ts @@ -1,6 +1,6 @@ -import { SearchField } from './search-field.type'; +import { SearchField } from './search-field.type' export interface Search { - field: SearchField; - value: string; + field: SearchField + value: string } diff --git a/client/src/app/shared/search/search.service.ts b/client/src/app/shared/search/search.service.ts index 717a7fa50..0480b46bd 100644 --- a/client/src/app/shared/search/search.service.ts +++ b/client/src/app/shared/search/search.service.ts @@ -1,18 +1,18 @@ -import { Injectable } from '@angular/core'; -import { Subject } from 'rxjs/Subject'; -import { ReplaySubject } from 'rxjs/ReplaySubject'; +import { Injectable } from '@angular/core' +import { Subject } from 'rxjs/Subject' +import { ReplaySubject } from 'rxjs/ReplaySubject' -import { Search } from './search.model'; +import { Search } from './search.model' // This class is needed to communicate between videos/ and search component // Remove it when we'll be able to subscribe to router changes @Injectable() export class SearchService { - searchUpdated: Subject; - updateSearch: Subject; + searchUpdated: Subject + updateSearch: Subject - constructor() { - this.updateSearch = new Subject(); - this.searchUpdated = new ReplaySubject(1); + constructor () { + this.updateSearch = new Subject() + this.searchUpdated = new ReplaySubject(1) } } -- cgit v1.2.3