aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/users
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/shared/users
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/shared/users')
-rw-r--r--client/src/app/shared/users/index.ts4
-rw-r--r--client/src/app/shared/users/user.model.ts34
-rw-r--r--client/src/app/shared/users/user.service.ts44
3 files changed, 41 insertions, 41 deletions
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 @@
1export * from './user.model'; 1export * from './user.model'
2export * from './user.service'; 2export * 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 @@
1import { User as UserServerModel, UserRole } from '../../../../../shared'; 1import { User as UserServerModel, UserRole } from '../../../../../shared'
2 2
3export class User implements UserServerModel { 3export class User implements UserServerModel {
4 id: number; 4 id: number
5 username: string; 5 username: string
6 email: string; 6 email: string
7 role: UserRole; 7 role: UserRole
8 displayNSFW: boolean; 8 displayNSFW: boolean
9 createdAt: Date; 9 createdAt: Date
10 10
11 constructor(hash: { 11 constructor (hash: {
12 id: number, 12 id: number,
13 username: string, 13 username: string,
14 email: string, 14 email: string,
15 role: UserRole, 15 role: UserRole,
16 displayNSFW?: boolean, 16 displayNSFW?: boolean,
17 createdAt?: Date, 17 createdAt?: Date
18 }) { 18 }) {
19 this.id = hash.id; 19 this.id = hash.id
20 this.username = hash.username; 20 this.username = hash.username
21 this.email = hash.email; 21 this.email = hash.email
22 this.role = hash.role; 22 this.role = hash.role
23 this.displayNSFW = hash.displayNSFW; 23 this.displayNSFW = hash.displayNSFW
24 24
25 if (hash.createdAt) { 25 if (hash.createdAt) {
26 this.createdAt = hash.createdAt; 26 this.createdAt = hash.createdAt
27 } 27 }
28 } 28 }
29 29
30 isAdmin() { 30 isAdmin () {
31 return this.role === 'admin'; 31 return this.role === 'admin'
32 } 32 }
33} 33}
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 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core'
2import { Http } from '@angular/http'; 2import { Http } from '@angular/http'
3import 'rxjs/add/operator/catch'; 3import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map'; 4import 'rxjs/add/operator/map'
5 5
6import { AuthService } from '../../core'; 6import { AuthService } from '../../core'
7import { AuthHttp } from '../auth'; 7import { AuthHttp } from '../auth'
8import { RestExtractor } from '../rest'; 8import { RestExtractor } from '../rest'
9 9
10@Injectable() 10@Injectable()
11export class UserService { 11export class UserService {
12 static BASE_USERS_URL = API_URL + '/api/v1/users/'; 12 static BASE_USERS_URL = API_URL + '/api/v1/users/'
13 13
14 constructor( 14 constructor (
15 private http: Http, 15 private http: Http,
16 private authHttp: AuthHttp, 16 private authHttp: AuthHttp,
17 private authService: AuthService, 17 private authService: AuthService,
18 private restExtractor: RestExtractor 18 private restExtractor: RestExtractor
19 ) {} 19 ) {}
20 20
21 checkTokenValidity() { 21 checkTokenValidity () {
22 const url = UserService.BASE_USERS_URL + 'me'; 22 const url = UserService.BASE_USERS_URL + 'me'
23 23
24 // AuthHttp will redirect us to the login page if the oken is not valid anymore 24 // AuthHttp will redirect us to the login page if the oken is not valid anymore
25 this.authHttp.get(url).subscribe(() => { ; }); 25 this.authHttp.get(url).subscribe()
26 } 26 }
27 27
28 changePassword(newPassword: string) { 28 changePassword (newPassword: string) {
29 const url = UserService.BASE_USERS_URL + this.authService.getUser().id; 29 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
30 const body = { 30 const body = {
31 password: newPassword 31 password: newPassword
32 }; 32 }
33 33
34 return this.authHttp.put(url, body) 34 return this.authHttp.put(url, body)
35 .map(this.restExtractor.extractDataBool) 35 .map(this.restExtractor.extractDataBool)
36 .catch((res) => this.restExtractor.handleError(res)); 36 .catch((res) => this.restExtractor.handleError(res))
37 } 37 }
38 38
39 updateDetails(details: { displayNSFW: boolean }) { 39 updateDetails (details: { displayNSFW: boolean }) {
40 const url = UserService.BASE_USERS_URL + this.authService.getUser().id; 40 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
41 41
42 return this.authHttp.put(url, details) 42 return this.authHttp.put(url, details)
43 .map(this.restExtractor.extractDataBool) 43 .map(this.restExtractor.extractDataBool)
44 .catch((res) => this.restExtractor.handleError(res)); 44 .catch((res) => this.restExtractor.handleError(res))
45 } 45 }
46 46
47 signup(username: string, password: string, email: string) { 47 signup (username: string, password: string, email: string) {
48 const body = { 48 const body = {
49 username, 49 username,
50 email, 50 email,
51 password 51 password
52 }; 52 }
53 53
54 return this.http.post(UserService.BASE_USERS_URL + 'register', body) 54 return this.http.post(UserService.BASE_USERS_URL + 'register', body)
55 .map(this.restExtractor.extractDataBool) 55 .map(this.restExtractor.extractDataBool)
56 .catch(this.restExtractor.handleError); 56 .catch(this.restExtractor.handleError)
57 } 57 }
58} 58}