aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/friends/friend-add/friend-add.component.ts2
-rw-r--r--client/src/app/+admin/users/shared/user.service.ts11
-rw-r--r--client/src/app/+admin/users/user-add/user-add.component.ts7
-rw-r--r--client/src/app/account/account-details/account-details.component.ts3
-rw-r--r--client/src/app/core/auth/auth-user.model.ts2
-rw-r--r--client/src/app/shared/users/user.service.ts15
-rw-r--r--client/src/app/signup/signup.component.ts7
-rw-r--r--client/src/app/videos/shared/video.service.ts63
-rw-r--r--client/src/app/videos/video-edit/video-add.component.ts27
9 files changed, 63 insertions, 74 deletions
diff --git a/client/src/app/+admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
index 35cf4a1f7..0449d26a9 100644
--- a/client/src/app/+admin/friends/friend-add/friend-add.component.ts
+++ b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
@@ -15,7 +15,7 @@ import { FriendService } from '../shared'
15}) 15})
16export class FriendAddComponent implements OnInit { 16export class FriendAddComponent implements OnInit {
17 form: FormGroup 17 form: FormGroup
18 hosts = [ ] 18 hosts: string[] = [ ]
19 error: string = null 19 error: string = null
20 20
21 constructor ( 21 constructor (
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts
index d52993a29..1c1cd575e 100644
--- a/client/src/app/+admin/users/shared/user.service.ts
+++ b/client/src/app/+admin/users/shared/user.service.ts
@@ -3,6 +3,7 @@ import 'rxjs/add/operator/catch'
3import 'rxjs/add/operator/map' 3import 'rxjs/add/operator/map'
4 4
5import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' 5import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared'
6import { UserCreate } from '../../../../../../shared'
6 7
7@Injectable() 8@Injectable()
8export class UserService { 9export class UserService {
@@ -13,14 +14,8 @@ export class UserService {
13 private restExtractor: RestExtractor 14 private restExtractor: RestExtractor
14 ) {} 15 ) {}
15 16
16 addUser (username: string, password: string, email: string) { 17 addUser (userCreate: UserCreate) {
17 const body = { 18 return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
18 username,
19 email,
20 password
21 }
22
23 return this.authHttp.post(UserService.BASE_USERS_URL, body)
24 .map(this.restExtractor.extractDataBool) 19 .map(this.restExtractor.extractDataBool)
25 .catch(this.restExtractor.handleError) 20 .catch(this.restExtractor.handleError)
26 } 21 }
diff --git a/client/src/app/+admin/users/user-add/user-add.component.ts b/client/src/app/+admin/users/user-add/user-add.component.ts
index 2d25ab469..0dd99eccd 100644
--- a/client/src/app/+admin/users/user-add/user-add.component.ts
+++ b/client/src/app/+admin/users/user-add/user-add.component.ts
@@ -11,6 +11,7 @@ import {
11 USER_EMAIL, 11 USER_EMAIL,
12 USER_PASSWORD 12 USER_PASSWORD
13} from '../../../shared' 13} from '../../../shared'
14import { UserCreate } from '../../../../../../shared'
14 15
15@Component({ 16@Component({
16 selector: 'my-user-add', 17 selector: 'my-user-add',
@@ -57,11 +58,11 @@ export class UserAddComponent extends FormReactive implements OnInit {
57 addUser () { 58 addUser () {
58 this.error = null 59 this.error = null
59 60
60 const { username, password, email } = this.form.value 61 const userCreate: UserCreate = this.form.value
61 62
62 this.userService.addUser(username, password, email).subscribe( 63 this.userService.addUser(userCreate).subscribe(
63 () => { 64 () => {
64 this.notificationsService.success('Success', `User ${username} created.`) 65 this.notificationsService.success('Success', `User ${userCreate.username} created.`)
65 this.router.navigate([ '/admin/users/list' ]) 66 this.router.navigate([ '/admin/users/list' ])
66 }, 67 },
67 68
diff --git a/client/src/app/account/account-details/account-details.component.ts b/client/src/app/account/account-details/account-details.component.ts
index d7531cb55..547f045c4 100644
--- a/client/src/app/account/account-details/account-details.component.ts
+++ b/client/src/app/account/account-details/account-details.component.ts
@@ -11,6 +11,7 @@ import {
11 UserService, 11 UserService,
12 USER_PASSWORD 12 USER_PASSWORD
13} from '../../shared' 13} from '../../shared'
14import { UserUpdate } from '../../../../../shared'
14 15
15@Component({ 16@Component({
16 selector: 'my-account-details', 17 selector: 'my-account-details',
@@ -50,7 +51,7 @@ export class AccountDetailsComponent extends FormReactive implements OnInit {
50 51
51 updateDetails () { 52 updateDetails () {
52 const displayNSFW = this.form.value['displayNSFW'] 53 const displayNSFW = this.form.value['displayNSFW']
53 const details = { 54 const details: UserUpdate = {
54 displayNSFW 55 displayNSFW
55 } 56 }
56 57
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index 65c37bcfa..9cb201907 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -1,5 +1,5 @@
1// Do not use the barrel (dependency loop) 1// Do not use the barrel (dependency loop)
2import { UserRole } from '../../../../../shared/models/user.model' 2import { UserRole } from '../../../../../shared/models/users/user-role.type'
3import { User } from '../../shared/users/user.model' 3import { User } from '../../shared/users/user.model'
4 4
5export type TokenOptions = { 5export type TokenOptions = {
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index e956df5b1..b479ac034 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -6,6 +6,7 @@ import 'rxjs/add/operator/map'
6import { AuthService } from '../../core' 6import { AuthService } from '../../core'
7import { AuthHttp } from '../auth' 7import { AuthHttp } from '../auth'
8import { RestExtractor } from '../rest' 8import { RestExtractor } from '../rest'
9import { UserCreate, UserUpdate } from '../../../../../shared'
9 10
10@Injectable() 11@Injectable()
11export class UserService { 12export class UserService {
@@ -27,7 +28,7 @@ export class UserService {
27 28
28 changePassword (newPassword: string) { 29 changePassword (newPassword: string) {
29 const url = UserService.BASE_USERS_URL + this.authService.getUser().id 30 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
30 const body = { 31 const body: UserUpdate = {
31 password: newPassword 32 password: newPassword
32 } 33 }
33 34
@@ -36,7 +37,7 @@ export class UserService {
36 .catch((res) => this.restExtractor.handleError(res)) 37 .catch((res) => this.restExtractor.handleError(res))
37 } 38 }
38 39
39 updateDetails (details: { displayNSFW: boolean }) { 40 updateDetails (details: UserUpdate) {
40 const url = UserService.BASE_USERS_URL + this.authService.getUser().id 41 const url = UserService.BASE_USERS_URL + this.authService.getUser().id
41 42
42 return this.authHttp.put(url, details) 43 return this.authHttp.put(url, details)
@@ -44,14 +45,8 @@ export class UserService {
44 .catch((res) => this.restExtractor.handleError(res)) 45 .catch((res) => this.restExtractor.handleError(res))
45 } 46 }
46 47
47 signup (username: string, password: string, email: string) { 48 signup (userCreate: UserCreate) {
48 const body = { 49 return this.http.post(UserService.BASE_USERS_URL + 'register', userCreate)
49 username,
50 email,
51 password
52 }
53
54 return this.http.post(UserService.BASE_USERS_URL + 'register', body)
55 .map(this.restExtractor.extractDataBool) 50 .map(this.restExtractor.extractDataBool)
56 .catch(this.restExtractor.handleError) 51 .catch(this.restExtractor.handleError)
57 } 52 }
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts
index bcbc8ded3..981fe3c3b 100644
--- a/client/src/app/signup/signup.component.ts
+++ b/client/src/app/signup/signup.component.ts
@@ -12,6 +12,7 @@ import {
12 USER_EMAIL, 12 USER_EMAIL,
13 USER_PASSWORD 13 USER_PASSWORD
14} from '../shared' 14} from '../shared'
15import { UserCreate } from '../../../../shared'
15 16
16@Component({ 17@Component({
17 selector: 'my-signup', 18 selector: 'my-signup',
@@ -58,11 +59,11 @@ export class SignupComponent extends FormReactive implements OnInit {
58 signup () { 59 signup () {
59 this.error = null 60 this.error = null
60 61
61 const { username, password, email } = this.form.value 62 const userCreate: UserCreate = this.form.value
62 63
63 this.userService.signup(username, password, email).subscribe( 64 this.userService.signup(userCreate).subscribe(
64 () => { 65 () => {
65 this.notificationsService.success('Success', `Registration for ${username} complete.`) 66 this.notificationsService.success('Success', `Registration for ${userCreate.username} complete.`)
66 this.router.navigate([ '/videos/list' ]) 67 this.router.navigate([ '/videos/list' ])
67 }, 68 },
68 69
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index 7658d8ff0..dc12c0637 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -16,7 +16,13 @@ import {
16 UserService 16 UserService
17} from '../../shared' 17} from '../../shared'
18import { Video } from './video.model' 18import { Video } from './video.model'
19import { UserVideoRate, VideoRateType } from '../../../../../shared' 19import {
20 UserVideoRate,
21 VideoRateType,
22 VideoUpdate,
23 VideoAbuseCreate,
24 UserVideoRateUpdate
25} from '../../../../../shared'
20 26
21@Injectable() 27@Injectable()
22export class VideoService { 28export class VideoService {
@@ -35,42 +41,15 @@ export class VideoService {
35 ) {} 41 ) {}
36 42
37 loadVideoCategories () { 43 loadVideoCategories () {
38 return this.http.get(VideoService.BASE_VIDEO_URL + 'categories') 44 return this.loadVideoAttributeEnum('categories', this.videoCategories)
39 .map(this.restExtractor.extractDataGet)
40 .subscribe(data => {
41 Object.keys(data).forEach(categoryKey => {
42 this.videoCategories.push({
43 id: parseInt(categoryKey, 10),
44 label: data[categoryKey]
45 })
46 })
47 })
48 } 45 }
49 46
50 loadVideoLicences () { 47 loadVideoLicences () {
51 return this.http.get(VideoService.BASE_VIDEO_URL + 'licences') 48 return this.loadVideoAttributeEnum('licences', this.videoLicences)
52 .map(this.restExtractor.extractDataGet)
53 .subscribe(data => {
54 Object.keys(data).forEach(licenceKey => {
55 this.videoLicences.push({
56 id: parseInt(licenceKey, 10),
57 label: data[licenceKey]
58 })
59 })
60 })
61 } 49 }
62 50
63 loadVideoLanguages () { 51 loadVideoLanguages () {
64 return this.http.get(VideoService.BASE_VIDEO_URL + 'languages') 52 return this.loadVideoAttributeEnum('languages', this.videoLanguages)
65 .map(this.restExtractor.extractDataGet)
66 .subscribe(data => {
67 Object.keys(data).forEach(languageKey => {
68 this.videoLanguages.push({
69 id: parseInt(languageKey, 10),
70 label: data[languageKey]
71 })
72 })
73 })
74 } 53 }
75 54
76 getVideo (id: string): Observable<Video> { 55 getVideo (id: string): Observable<Video> {
@@ -83,13 +62,14 @@ export class VideoService {
83 updateVideo (video: Video) { 62 updateVideo (video: Video) {
84 const language = video.language ? video.language : null 63 const language = video.language ? video.language : null
85 64
86 const body = { 65 const body: VideoUpdate = {
87 name: video.name, 66 name: video.name,
88 category: video.category, 67 category: video.category,
89 licence: video.licence, 68 licence: video.licence,
90 language, 69 language,
91 description: video.description, 70 description: video.description,
92 tags: video.tags 71 tags: video.tags,
72 nsfw: video.nsfw
93 } 73 }
94 74
95 const headers = new Headers({ 'Content-Type': 'application/json' }) 75 const headers = new Headers({ 'Content-Type': 'application/json' })
@@ -128,7 +108,7 @@ export class VideoService {
128 108
129 reportVideo (id: string, reason: string) { 109 reportVideo (id: string, reason: string) {
130 const url = VideoService.BASE_VIDEO_URL + id + '/abuse' 110 const url = VideoService.BASE_VIDEO_URL + id + '/abuse'
131 const body = { 111 const body: VideoAbuseCreate = {
132 reason 112 reason
133 } 113 }
134 114
@@ -161,7 +141,7 @@ export class VideoService {
161 141
162 private setVideoRate (id: string, rateType: VideoRateType) { 142 private setVideoRate (id: string, rateType: VideoRateType) {
163 const url = VideoService.BASE_VIDEO_URL + id + '/rate' 143 const url = VideoService.BASE_VIDEO_URL + id + '/rate'
164 const body = { 144 const body: UserVideoRateUpdate = {
165 rating: rateType 145 rating: rateType
166 } 146 }
167 147
@@ -180,4 +160,17 @@ export class VideoService {
180 160
181 return { videos, totalVideos } 161 return { videos, totalVideos }
182 } 162 }
163
164 private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) {
165 return this.http.get(VideoService.BASE_VIDEO_URL + attributeName)
166 .map(this.restExtractor.extractDataGet)
167 .subscribe(data => {
168 Object.keys(data).forEach(dataKey => {
169 hashToPopulate.push({
170 id: parseInt(dataKey, 10),
171 label: data[dataKey]
172 })
173 })
174 })
175 }
183} 176}
diff --git a/client/src/app/videos/video-edit/video-add.component.ts b/client/src/app/videos/video-edit/video-add.component.ts
index 0653f5ac4..5d6c0e0c7 100644
--- a/client/src/app/videos/video-edit/video-add.component.ts
+++ b/client/src/app/videos/video-edit/video-add.component.ts
@@ -16,6 +16,7 @@ import {
16 VIDEO_TAGS 16 VIDEO_TAGS
17} from '../../shared' 17} from '../../shared'
18import { VideoService } from '../shared' 18import { VideoService } from '../shared'
19import { VideoCreate } from '../../../../../shared'
19 20
20@Component({ 21@Component({
21 selector: 'my-videos-add', 22 selector: 'my-videos-add',
@@ -98,23 +99,25 @@ export class VideoAddComponent extends FormReactive implements OnInit {
98 removeAfterUpload: true 99 removeAfterUpload: true
99 }) 100 })
100 101
101 this.uploader.onBuildItemForm = (item, form) => { 102 this.uploader.onBuildItemForm = (item, form: FormData) => {
102 const name = this.form.value['name'] 103 const formValue: VideoCreate = this.form.value
103 const nsfw = this.form.value['nsfw'] 104
104 const category = this.form.value['category'] 105 const name = formValue.name
105 const licence = this.form.value['licence'] 106 const nsfw = formValue.nsfw
106 const language = this.form.value['language'] 107 const category = formValue.category
107 const description = this.form.value['description'] 108 const licence = formValue.licence
108 const tags = this.form.value['tags'] 109 const language = formValue.language
110 const description = formValue.description
111 const tags = formValue.tags
109 112
110 form.append('name', name) 113 form.append('name', name)
111 form.append('category', category) 114 form.append('category', '' + category)
112 form.append('nsfw', nsfw) 115 form.append('nsfw', '' + nsfw)
113 form.append('licence', licence) 116 form.append('licence', '' + licence)
114 117
115 // Language is optional 118 // Language is optional
116 if (language) { 119 if (language) {
117 form.append('language', language) 120 form.append('language', '' + language)
118 } 121 }
119 122
120 form.append('description', description) 123 form.append('description', description)