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/auth/auth-http.service.ts | 82 +++++++++++----------- client/src/app/shared/auth/index.ts | 2 +- client/src/app/shared/forms/form-reactive.ts | 30 ++++---- .../shared/forms/form-validators/host.validator.ts | 8 +-- .../src/app/shared/forms/form-validators/index.ts | 8 +-- .../src/app/shared/forms/form-validators/user.ts | 12 ++-- .../shared/forms/form-validators/video-abuse.ts | 4 +- .../src/app/shared/forms/form-validators/video.ts | 14 ++-- client/src/app/shared/forms/index.ts | 4 +- client/src/app/shared/index.ts | 16 ++--- client/src/app/shared/rest/index.ts | 8 +-- client/src/app/shared/rest/rest-data-source.ts | 60 ++++++++-------- .../src/app/shared/rest/rest-extractor.service.ts | 48 ++++++------- client/src/app/shared/rest/rest-pagination.ts | 8 +-- client/src/app/shared/rest/rest.service.ts | 22 +++--- 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 ++--- client/src/app/shared/shared.module.ts | 36 +++++----- client/src/app/shared/users/index.ts | 4 +- client/src/app/shared/users/user.model.ts | 34 ++++----- client/src/app/shared/users/user.service.ts | 44 ++++++------ client/src/app/shared/utils.ts | 10 +-- client/src/app/shared/video-abuse/index.ts | 4 +- .../app/shared/video-abuse/video-abuse.model.ts | 12 ++-- .../app/shared/video-abuse/video-abuse.service.ts | 42 +++++------ 28 files changed, 297 insertions(+), 297 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts index c4114aa02..0fbaab0a8 100644 --- a/client/src/app/shared/auth/auth-http.service.ts +++ b/client/src/app/shared/auth/auth-http.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable } from '@angular/core' import { ConnectionBackend, Headers, @@ -9,79 +9,79 @@ import { RequestOptionsArgs, Response, XHRBackend -} from '@angular/http'; -import { Observable } from 'rxjs/Observable'; +} from '@angular/http' +import { Observable } from 'rxjs/Observable' -import { AuthService } from '../../core'; +import { AuthService } from '../../core' @Injectable() export class AuthHttp extends Http { - constructor(backend: ConnectionBackend, defaultOptions: RequestOptions, private authService: AuthService) { - super(backend, defaultOptions); + constructor (backend: ConnectionBackend, defaultOptions: RequestOptions, private authService: AuthService) { + super(backend, defaultOptions) } - request(url: string | Request, options?: RequestOptionsArgs): Observable { - if (!options) options = {}; + request (url: string | Request, options?: RequestOptionsArgs): Observable { + if (!options) options = {} - options.headers = new Headers(); - this.setAuthorizationHeader(options.headers); + options.headers = new Headers() + this.setAuthorizationHeader(options.headers) return super.request(url, options) .catch((err) => { if (err.status === 401) { - return this.handleTokenExpired(url, options); + return this.handleTokenExpired(url, options) } - return Observable.throw(err); - }); + return Observable.throw(err) + }) } - delete(url: string, options?: RequestOptionsArgs): Observable { - if (!options) options = {}; - options.method = RequestMethod.Delete; + delete (url: string, options?: RequestOptionsArgs): Observable { + if (!options) options = {} + options.method = RequestMethod.Delete - return this.request(url, options); + return this.request(url, options) } - get(url: string, options?: RequestOptionsArgs): Observable { - if (!options) options = {}; - options.method = RequestMethod.Get; + get (url: string, options?: RequestOptionsArgs): Observable { + if (!options) options = {} + options.method = RequestMethod.Get - return this.request(url, options); + return this.request(url, options) } - post(url: string, body: any, options?: RequestOptionsArgs): Observable { - if (!options) options = {}; - options.method = RequestMethod.Post; - options.body = body; + post (url: string, body: any, options?: RequestOptionsArgs): Observable { + if (!options) options = {} + options.method = RequestMethod.Post + options.body = body - return this.request(url, options); + return this.request(url, options) } - put(url: string, body: any, options?: RequestOptionsArgs): Observable { - if (!options) options = {}; - options.method = RequestMethod.Put; - options.body = body; + put (url: string, body: any, options?: RequestOptionsArgs): Observable { + if (!options) options = {} + options.method = RequestMethod.Put + options.body = body - return this.request(url, options); + return this.request(url, options) } - private handleTokenExpired(url: string | Request, options: RequestOptionsArgs) { + private handleTokenExpired (url: string | Request, options: RequestOptionsArgs) { return this.authService.refreshAccessToken() .flatMap(() => { - this.setAuthorizationHeader(options.headers); + this.setAuthorizationHeader(options.headers) - return super.request(url, options); - }); + return super.request(url, options) + }) } - private setAuthorizationHeader(headers: Headers) { - headers.set('Authorization', this.authService.getRequestHeaderValue()); + private setAuthorizationHeader (headers: Headers) { + headers.set('Authorization', this.authService.getRequestHeaderValue()) } } -export function useFactory(backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) { - return new AuthHttp(backend, defaultOptions, authService); +export function useFactory (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) { + return new AuthHttp(backend, defaultOptions, authService) } export const AUTH_HTTP_PROVIDERS = [ @@ -89,5 +89,5 @@ export const AUTH_HTTP_PROVIDERS = [ provide: AuthHttp, useFactory, deps: [ XHRBackend, RequestOptions, AuthService ] - }, -]; + } +] diff --git a/client/src/app/shared/auth/index.ts b/client/src/app/shared/auth/index.ts index c488aed69..0f2bfb0d6 100644 --- a/client/src/app/shared/auth/index.ts +++ b/client/src/app/shared/auth/index.ts @@ -1 +1 @@ -export * from './auth-http.service'; +export * from './auth-http.service' diff --git a/client/src/app/shared/forms/form-reactive.ts b/client/src/app/shared/forms/form-reactive.ts index a5732e083..e7764d069 100644 --- a/client/src/app/shared/forms/form-reactive.ts +++ b/client/src/app/shared/forms/form-reactive.ts @@ -1,38 +1,38 @@ -import { FormGroup } from '@angular/forms'; +import { FormGroup } from '@angular/forms' export abstract class FormReactive { - abstract form: FormGroup; - abstract formErrors: Object; - abstract validationMessages: Object; + abstract form: FormGroup + abstract formErrors: Object + abstract validationMessages: Object - abstract buildForm(): void; + abstract buildForm (): void - protected onValueChanged(data?: any) { + protected onValueChanged (data?: any) { for (const field in this.formErrors) { // clear previous error message (if any) - this.formErrors[field] = ''; - const control = this.form.get(field); + this.formErrors[field] = '' + const control = this.form.get(field) if (control && control.dirty && !control.valid) { - const messages = this.validationMessages[field]; + const messages = this.validationMessages[field] for (const key in control.errors) { - this.formErrors[field] += messages[key] + ' '; + this.formErrors[field] += messages[key] + ' ' } } } } // Same as onValueChanged but force checking even if the field is not dirty - protected forceCheck() { + protected forceCheck () { for (const field in this.formErrors) { // clear previous error message (if any) - this.formErrors[field] = ''; - const control = this.form.get(field); + this.formErrors[field] = '' + const control = this.form.get(field) if (control && !control.valid) { - const messages = this.validationMessages[field]; + const messages = this.validationMessages[field] for (const key in control.errors) { - this.formErrors[field] += messages[key] + ' '; + this.formErrors[field] += messages[key] + ' ' } } } diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts index ec417e079..03e810fdb 100644 --- a/client/src/app/shared/forms/form-validators/host.validator.ts +++ b/client/src/app/shared/forms/form-validators/host.validator.ts @@ -1,14 +1,14 @@ -import { FormControl } from '@angular/forms'; +import { FormControl } from '@angular/forms' -export function validateHost(c: FormControl) { +export function validateHost (c: FormControl) { // Thanks to http://stackoverflow.com/a/106223 const HOST_REGEXP = new RegExp( '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' - ); + ) return HOST_REGEXP.test(c.value) ? null : { validateHost: { valid: false } - }; + } } diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index ab7c2df31..efe77d4ae 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts @@ -1,4 +1,4 @@ -export * from './host.validator'; -export * from './user'; -export * from './video-abuse'; -export * from './video'; +export * from './host.validator' +export * from './user' +export * from './video-abuse' +export * from './video' diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index 259d2b868..fd316583e 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts @@ -1,4 +1,4 @@ -import { Validators } from '@angular/forms'; +import { Validators } from '@angular/forms' export const USER_USERNAME = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ], @@ -7,18 +7,18 @@ export const USER_USERNAME = { 'minlength': 'Username must be at least 3 characters long.', 'maxlength': 'Username cannot be more than 20 characters long.' } -}; +} export const USER_EMAIL = { VALIDATORS: [ Validators.required, Validators.email ], MESSAGES: { 'required': 'Email is required.', - 'email': 'Email must be valid.', + 'email': 'Email must be valid.' } -}; +} export const USER_PASSWORD = { VALIDATORS: [ Validators.required, Validators.minLength(6) ], MESSAGES: { 'required': 'Password is required.', - 'minlength': 'Password must be at least 6 characters long.', + 'minlength': 'Password must be at least 6 characters long.' } -}; +} diff --git a/client/src/app/shared/forms/form-validators/video-abuse.ts b/client/src/app/shared/forms/form-validators/video-abuse.ts index 94a29a3b7..3c7f26205 100644 --- a/client/src/app/shared/forms/form-validators/video-abuse.ts +++ b/client/src/app/shared/forms/form-validators/video-abuse.ts @@ -1,4 +1,4 @@ -import { Validators } from '@angular/forms'; +import { Validators } from '@angular/forms' export const VIDEO_ABUSE_REASON = { VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], @@ -7,4 +7,4 @@ export const VIDEO_ABUSE_REASON = { 'minlength': 'Report reson must be at least 2 characters long.', 'maxlength': 'Report reson cannot be more than 300 characters long.' } -}; +} diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts index f7e4e5e4b..6542cf8f6 100644 --- a/client/src/app/shared/forms/form-validators/video.ts +++ b/client/src/app/shared/forms/form-validators/video.ts @@ -1,4 +1,4 @@ -import { Validators } from '@angular/forms'; +import { Validators } from '@angular/forms' export const VIDEO_NAME = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(50) ], @@ -7,26 +7,26 @@ export const VIDEO_NAME = { 'minlength': 'Video name must be at least 3 characters long.', 'maxlength': 'Video name cannot be more than 50 characters long.' } -}; +} export const VIDEO_CATEGORY = { VALIDATORS: [ Validators.required ], MESSAGES: { 'required': 'Video category is required.' } -}; +} export const VIDEO_LICENCE = { VALIDATORS: [ Validators.required ], MESSAGES: { 'required': 'Video licence is required.' } -}; +} export const VIDEO_LANGUAGE = { VALIDATORS: [ ], MESSAGES: {} -}; +} export const VIDEO_DESCRIPTION = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ], @@ -35,7 +35,7 @@ export const VIDEO_DESCRIPTION = { 'minlength': 'Video description must be at least 3 characters long.', 'maxlength': 'Video description cannot be more than 250 characters long.' } -}; +} export const VIDEO_TAGS = { VALIDATORS: [ Validators.minLength(2), Validators.maxLength(10) ], @@ -43,4 +43,4 @@ export const VIDEO_TAGS = { 'minlength': 'A tag should be more than 2 characters long.', 'maxlength': 'A tag should be less than 10 characters long.' } -}; +} diff --git a/client/src/app/shared/forms/index.ts b/client/src/app/shared/forms/index.ts index 588ebb4be..7464bb022 100644 --- a/client/src/app/shared/forms/index.ts +++ b/client/src/app/shared/forms/index.ts @@ -1,2 +1,2 @@ -export * from './form-validators'; -export * from './form-reactive'; +export * from './form-validators' +export * from './form-reactive' diff --git a/client/src/app/shared/index.ts b/client/src/app/shared/index.ts index 61e8ed523..212645c51 100644 --- a/client/src/app/shared/index.ts +++ b/client/src/app/shared/index.ts @@ -1,8 +1,8 @@ -export * from './auth'; -export * from './forms'; -export * from './rest'; -export * from './search'; -export * from './users'; -export * from './video-abuse'; -export * from './shared.module'; -export * from './utils'; +export * from './auth' +export * from './forms' +export * from './rest' +export * from './search' +export * from './users' +export * from './video-abuse' +export * from './shared.module' +export * from './utils' diff --git a/client/src/app/shared/rest/index.ts b/client/src/app/shared/rest/index.ts index 3cb123c3b..e0be155cf 100644 --- a/client/src/app/shared/rest/index.ts +++ b/client/src/app/shared/rest/index.ts @@ -1,4 +1,4 @@ -export * from './rest-data-source'; -export * from './rest-extractor.service'; -export * from './rest-pagination'; -export * from './rest.service'; +export * from './rest-data-source' +export * from './rest-extractor.service' +export * from './rest-pagination' +export * from './rest.service' diff --git a/client/src/app/shared/rest/rest-data-source.ts b/client/src/app/shared/rest/rest-data-source.ts index 1def38c73..2ef5d38da 100644 --- a/client/src/app/shared/rest/rest-data-source.ts +++ b/client/src/app/shared/rest/rest-data-source.ts @@ -1,51 +1,51 @@ -import { Http, RequestOptionsArgs, URLSearchParams, } from '@angular/http'; +import { Http, RequestOptionsArgs, URLSearchParams, Response } from '@angular/http' -import { ServerDataSource } from 'ng2-smart-table'; +import { ServerDataSource } from 'ng2-smart-table' export class RestDataSource extends ServerDataSource { - constructor(http: Http, endpoint: string) { - const options = { - endPoint: endpoint, - sortFieldKey: 'sort', - dataKey: 'data' - }; - - super(http, options); - } - - protected extractTotalFromResponse(res) { - const rawData = res.json(); - return rawData ? parseInt(rawData.total) : 0; + constructor (http: Http, endpoint: string) { + const options = { + endPoint: endpoint, + sortFieldKey: 'sort', + dataKey: 'data' + } + + super(http, options) + } + + protected extractTotalFromResponse (res: Response) { + const rawData = res.json() + return rawData ? parseInt(rawData.total, 10) : 0 } - protected addSortRequestOptions(requestOptions: RequestOptionsArgs) { - let searchParams: URLSearchParams = requestOptions.search; + protected addSortRequestOptions (requestOptions: RequestOptionsArgs) { + const searchParams = requestOptions.search as URLSearchParams if (this.sortConf) { this.sortConf.forEach((fieldConf) => { - const sortPrefix = fieldConf.direction === 'desc' ? '-' : ''; + const sortPrefix = fieldConf.direction === 'desc' ? '-' : '' - searchParams.set(this.conf.sortFieldKey, sortPrefix + fieldConf.field); - }); + searchParams.set(this.conf.sortFieldKey, sortPrefix + fieldConf.field) + }) } - return requestOptions; + return requestOptions } - protected addPagerRequestOptions(requestOptions: RequestOptionsArgs) { - let searchParams: URLSearchParams = requestOptions.search; + protected addPagerRequestOptions (requestOptions: RequestOptionsArgs) { + const searchParams = requestOptions.search as URLSearchParams if (this.pagingConf && this.pagingConf['page'] && this.pagingConf['perPage']) { - const perPage = this.pagingConf['perPage']; - const page = this.pagingConf['page']; + const perPage = this.pagingConf['perPage'] + const page = this.pagingConf['page'] - const start = (page - 1) * perPage; - const count = perPage; + const start = (page - 1) * perPage + const count = perPage - searchParams.set('start', start.toString()); - searchParams.set('count', count.toString()); + searchParams.set('start', start.toString()) + searchParams.set('count', count.toString()) } - return requestOptions; + return requestOptions } } diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index fcb1598f4..f6a818ec8 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -1,52 +1,52 @@ -import { Injectable } from '@angular/core'; -import { Response } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; +import { Injectable } from '@angular/core' +import { Response } from '@angular/http' +import { Observable } from 'rxjs/Observable' export interface ResultList { - data: any[]; - total: number; + data: any[] + total: number } @Injectable() export class RestExtractor { - constructor () { ; } - - extractDataBool(res: Response) { - return true; + extractDataBool (res: Response) { + return true } - extractDataList(res: Response) { - const body = res.json(); + extractDataList (res: Response) { + const body = res.json() const ret: ResultList = { data: body.data, total: body.total - }; + } - return ret; + return ret } - extractDataGet(res: Response) { - return res.json(); + extractDataGet (res: Response) { + return res.json() } - handleError(res: Response) { - let text = 'Server error: '; - text += res.text(); - let json = ''; + handleError (res: Response) { + let text = 'Server error: ' + text += res.text() + let json = '' try { - json = res.json(); - } catch (err) { ; } + json = res.json() + } catch (err) { + console.error('Cannot get JSON from response.') + } const error = { json, text - }; + } - console.error(error); + console.error(error) - return Observable.throw(error); + return Observable.throw(error) } } diff --git a/client/src/app/shared/rest/rest-pagination.ts b/client/src/app/shared/rest/rest-pagination.ts index 0cfa4f468..766e7a9e5 100644 --- a/client/src/app/shared/rest/rest-pagination.ts +++ b/client/src/app/shared/rest/rest-pagination.ts @@ -1,5 +1,5 @@ export interface RestPagination { - currentPage: number; - itemsPerPage: number; - totalItems: number; -}; + currentPage: number + itemsPerPage: number + totalItems: number +} diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts index 16b47e957..43dc20b34 100644 --- a/client/src/app/shared/rest/rest.service.ts +++ b/client/src/app/shared/rest/rest.service.ts @@ -1,27 +1,27 @@ -import { Injectable } from '@angular/core'; -import { URLSearchParams } from '@angular/http'; +import { Injectable } from '@angular/core' +import { URLSearchParams } from '@angular/http' -import { RestPagination } from './rest-pagination'; +import { RestPagination } from './rest-pagination' @Injectable() export class RestService { - buildRestGetParams(pagination?: RestPagination, sort?: string) { - const params = new URLSearchParams(); + buildRestGetParams (pagination?: RestPagination, sort?: string) { + const params = new URLSearchParams() if (pagination) { - const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage; - const count: number = pagination.itemsPerPage; + const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage + const count: number = pagination.itemsPerPage - params.set('start', start.toString()); - params.set('count', count.toString()); + params.set('start', start.toString()) + params.set('count', count.toString()) } if (sort) { - params.set('sort', sort); + params.set('sort', sort) } - return params; + return params } } 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) } } diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 8ffaf964b..99b51aa4e 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -1,23 +1,23 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { HttpModule } from '@angular/http'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { HttpModule } from '@angular/http' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { RouterModule } from '@angular/router' -import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; -import { KeysPipe } from 'angular-pipes/src/object/keys.pipe'; -import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { ProgressbarModule } from 'ngx-bootstrap/progressbar'; -import { PaginationModule } from 'ngx-bootstrap/pagination'; -import { ModalModule } from 'ngx-bootstrap/modal'; -import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; -import { Ng2SmartTableModule } from 'ng2-smart-table'; +import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe' +import { KeysPipe } from 'angular-pipes/src/object/keys.pipe' +import { BsDropdownModule } from 'ngx-bootstrap/dropdown' +import { ProgressbarModule } from 'ngx-bootstrap/progressbar' +import { PaginationModule } from 'ngx-bootstrap/pagination' +import { ModalModule } from 'ngx-bootstrap/modal' +import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload' +import { Ng2SmartTableModule } from 'ng2-smart-table' -import { AUTH_HTTP_PROVIDERS } from './auth'; -import { RestExtractor, RestService } from './rest'; -import { SearchComponent, SearchService } from './search'; -import { UserService } from './users'; -import { VideoAbuseService } from './video-abuse'; +import { AUTH_HTTP_PROVIDERS } from './auth' +import { RestExtractor, RestService } from './rest' +import { SearchComponent, SearchService } from './search' +import { UserService } from './users' +import { VideoAbuseService } from './video-abuse' @NgModule({ imports: [ diff --git a/client/src/app/shared/users/index.ts b/client/src/app/shared/users/index.ts index ff009e89b..7b5a67bc7 100644 --- a/client/src/app/shared/users/index.ts +++ b/client/src/app/shared/users/index.ts @@ -1,2 +1,2 @@ -export * from './user.model'; -export * from './user.service'; +export * from './user.model' +export * from './user.service' diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index d4695ab67..1c2b481e3 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -1,33 +1,33 @@ -import { User as UserServerModel, UserRole } from '../../../../../shared'; +import { User as UserServerModel, UserRole } from '../../../../../shared' export class User implements UserServerModel { - id: number; - username: string; - email: string; - role: UserRole; - displayNSFW: boolean; - createdAt: Date; + id: number + username: string + email: string + role: UserRole + displayNSFW: boolean + createdAt: Date - constructor(hash: { + constructor (hash: { id: number, username: string, email: string, role: UserRole, displayNSFW?: boolean, - createdAt?: Date, + createdAt?: Date }) { - this.id = hash.id; - this.username = hash.username; - this.email = hash.email; - this.role = hash.role; - this.displayNSFW = hash.displayNSFW; + this.id = hash.id + this.username = hash.username + this.email = hash.email + this.role = hash.role + this.displayNSFW = hash.displayNSFW if (hash.createdAt) { - this.createdAt = hash.createdAt; + this.createdAt = hash.createdAt } } - isAdmin() { - return this.role === 'admin'; + isAdmin () { + return this.role === 'admin' } } diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index f1265be0a..e956df5b1 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -1,58 +1,58 @@ -import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/map'; +import { Injectable } from '@angular/core' +import { Http } from '@angular/http' +import 'rxjs/add/operator/catch' +import 'rxjs/add/operator/map' -import { AuthService } from '../../core'; -import { AuthHttp } from '../auth'; -import { RestExtractor } from '../rest'; +import { AuthService } from '../../core' +import { AuthHttp } from '../auth' +import { RestExtractor } from '../rest' @Injectable() export class UserService { - static BASE_USERS_URL = API_URL + '/api/v1/users/'; + static BASE_USERS_URL = API_URL + '/api/v1/users/' - constructor( + constructor ( private http: Http, private authHttp: AuthHttp, private authService: AuthService, private restExtractor: RestExtractor ) {} - checkTokenValidity() { - const url = UserService.BASE_USERS_URL + 'me'; + checkTokenValidity () { + const url = UserService.BASE_USERS_URL + 'me' // AuthHttp will redirect us to the login page if the oken is not valid anymore - this.authHttp.get(url).subscribe(() => { ; }); + this.authHttp.get(url).subscribe() } - changePassword(newPassword: string) { - const url = UserService.BASE_USERS_URL + this.authService.getUser().id; + changePassword (newPassword: string) { + const url = UserService.BASE_USERS_URL + this.authService.getUser().id const body = { password: newPassword - }; + } return this.authHttp.put(url, body) .map(this.restExtractor.extractDataBool) - .catch((res) => this.restExtractor.handleError(res)); + .catch((res) => this.restExtractor.handleError(res)) } - updateDetails(details: { displayNSFW: boolean }) { - const url = UserService.BASE_USERS_URL + this.authService.getUser().id; + updateDetails (details: { displayNSFW: boolean }) { + const url = UserService.BASE_USERS_URL + this.authService.getUser().id return this.authHttp.put(url, details) .map(this.restExtractor.extractDataBool) - .catch((res) => this.restExtractor.handleError(res)); + .catch((res) => this.restExtractor.handleError(res)) } - signup(username: string, password: string, email: string) { + signup (username: string, password: string, email: string) { const body = { username, email, password - }; + } return this.http.post(UserService.BASE_USERS_URL + 'register', body) .map(this.restExtractor.extractDataBool) - .catch(this.restExtractor.handleError); + .catch(this.restExtractor.handleError) } } diff --git a/client/src/app/shared/utils.ts b/client/src/app/shared/utils.ts index 5ab41fe5a..832311f89 100644 --- a/client/src/app/shared/utils.ts +++ b/client/src/app/shared/utils.ts @@ -1,12 +1,12 @@ -import { DatePipe } from '@angular/common'; +import { DatePipe } from '@angular/common' export class Utils { - static dateToHuman(date: String) { - return new DatePipe('en').transform(date, 'medium'); + static dateToHuman (date: String) { + return new DatePipe('en').transform(date, 'medium') } - static getRowDeleteButton() { - return ''; + static getRowDeleteButton () { + return '' } } diff --git a/client/src/app/shared/video-abuse/index.ts b/client/src/app/shared/video-abuse/index.ts index 563533ba5..7cf24c87d 100644 --- a/client/src/app/shared/video-abuse/index.ts +++ b/client/src/app/shared/video-abuse/index.ts @@ -1,2 +1,2 @@ -export * from './video-abuse.service'; -export * from './video-abuse.model'; +export * from './video-abuse.service' +export * from './video-abuse.model' diff --git a/client/src/app/shared/video-abuse/video-abuse.model.ts b/client/src/app/shared/video-abuse/video-abuse.model.ts index bb0373027..49c87d6b8 100644 --- a/client/src/app/shared/video-abuse/video-abuse.model.ts +++ b/client/src/app/shared/video-abuse/video-abuse.model.ts @@ -1,8 +1,8 @@ export interface VideoAbuse { - id: string; - reason: string; - reporterPodHost: string; - reporterUsername: string; - videoId: string; - createdAt: Date; + id: string + reason: string + reporterPodHost: string + reporterUsername: string + videoId: string + createdAt: Date } diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index da7b2ef8a..4317f9353 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts @@ -1,42 +1,42 @@ -import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/map'; +import { Injectable } from '@angular/core' +import { Http } from '@angular/http' +import { Observable } from 'rxjs/Observable' +import 'rxjs/add/operator/catch' +import 'rxjs/add/operator/map' -import { AuthService } from '../core'; -import { AuthHttp } from '../auth'; -import { RestDataSource, RestExtractor, ResultList } from '../rest'; -import { VideoAbuse } from './video-abuse.model'; +import { AuthService } from '../core' +import { AuthHttp } from '../auth' +import { RestDataSource, RestExtractor, ResultList } from '../rest' +import { VideoAbuse } from './video-abuse.model' @Injectable() export class VideoAbuseService { - private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/'; + private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/' - constructor( + constructor ( private authHttp: AuthHttp, private restExtractor: RestExtractor ) {} - getDataSource() { - return new RestDataSource(this.authHttp, VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse'); + getDataSource () { + return new RestDataSource(this.authHttp, VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse') } - reportVideo(id: string, reason: string) { + reportVideo (id: string, reason: string) { const body = { reason - }; - const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse'; + } + const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse' return this.authHttp.post(url, body) .map(this.restExtractor.extractDataBool) - .catch((res) => this.restExtractor.handleError(res)); + .catch((res) => this.restExtractor.handleError(res)) } - private extractVideoAbuses(result: ResultList) { - const videoAbuses: VideoAbuse[] = result.data; - const totalVideoAbuses = result.total; + private extractVideoAbuses (result: ResultList) { + const videoAbuses: VideoAbuse[] = result.data + const totalVideoAbuses = result.total - return { videoAbuses, totalVideoAbuses }; + return { videoAbuses, totalVideoAbuses } } } -- cgit v1.2.3