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/users/index.ts | 4 +-- client/src/app/shared/users/user.model.ts | 34 +++++++++++----------- client/src/app/shared/users/user.service.ts | 44 ++++++++++++++--------------- 3 files changed, 41 insertions(+), 41 deletions(-) (limited to 'client/src/app/shared/users') 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) } } -- cgit v1.2.3