diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/forms/form-validators/user.ts | 7 | ||||
-rw-r--r-- | client/src/app/shared/rest/rest-data-source.ts | 21 | ||||
-rw-r--r-- | client/src/app/shared/users/user.model.ts | 13 |
3 files changed, 37 insertions, 4 deletions
diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index fd316583e..087a99760 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts | |||
@@ -22,3 +22,10 @@ export const USER_PASSWORD = { | |||
22 | 'minlength': 'Password must be at least 6 characters long.' | 22 | 'minlength': 'Password must be at least 6 characters long.' |
23 | } | 23 | } |
24 | } | 24 | } |
25 | export const USER_VIDEO_QUOTA = { | ||
26 | VALIDATORS: [ Validators.required, Validators.min(-1) ], | ||
27 | MESSAGES: { | ||
28 | 'required': 'Video quota is required.', | ||
29 | 'min': 'Quota must be greater than -1.' | ||
30 | } | ||
31 | } \ No newline at end of file | ||
diff --git a/client/src/app/shared/rest/rest-data-source.ts b/client/src/app/shared/rest/rest-data-source.ts index 7956637e0..5c205d280 100644 --- a/client/src/app/shared/rest/rest-data-source.ts +++ b/client/src/app/shared/rest/rest-data-source.ts | |||
@@ -3,14 +3,31 @@ import { Http, RequestOptionsArgs, URLSearchParams, Response } from '@angular/ht | |||
3 | import { ServerDataSource } from 'ng2-smart-table' | 3 | import { ServerDataSource } from 'ng2-smart-table' |
4 | 4 | ||
5 | export class RestDataSource extends ServerDataSource { | 5 | export class RestDataSource extends ServerDataSource { |
6 | constructor (http: Http, endpoint: string) { | 6 | private updateResponse: (input: any[]) => any[] |
7 | |||
8 | constructor (http: Http, endpoint: string, updateResponse?: (input: any[]) => any[]) { | ||
7 | const options = { | 9 | const options = { |
8 | endPoint: endpoint, | 10 | endPoint: endpoint, |
9 | sortFieldKey: 'sort', | 11 | sortFieldKey: 'sort', |
10 | dataKey: 'data' | 12 | dataKey: 'data' |
11 | } | 13 | } |
12 | |||
13 | super(http, options) | 14 | super(http, options) |
15 | |||
16 | if (updateResponse) { | ||
17 | this.updateResponse = updateResponse | ||
18 | } | ||
19 | } | ||
20 | |||
21 | protected extractDataFromResponse (res: Response) { | ||
22 | const json = res.json() | ||
23 | if (!json) return [] | ||
24 | let data = json.data | ||
25 | |||
26 | if (this.updateResponse !== undefined) { | ||
27 | data = this.updateResponse(data) | ||
28 | } | ||
29 | |||
30 | return data | ||
14 | } | 31 | } |
15 | 32 | ||
16 | protected extractTotalFromResponse (res: Response) { | 33 | protected extractTotalFromResponse (res: Response) { |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 1c2b481e3..bf12876c7 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -6,6 +6,7 @@ export class User implements UserServerModel { | |||
6 | email: string | 6 | email: string |
7 | role: UserRole | 7 | role: UserRole |
8 | displayNSFW: boolean | 8 | displayNSFW: boolean |
9 | videoQuota: number | ||
9 | createdAt: Date | 10 | createdAt: Date |
10 | 11 | ||
11 | constructor (hash: { | 12 | constructor (hash: { |
@@ -13,6 +14,7 @@ export class User implements UserServerModel { | |||
13 | username: string, | 14 | username: string, |
14 | email: string, | 15 | email: string, |
15 | role: UserRole, | 16 | role: UserRole, |
17 | videoQuota?: number, | ||
16 | displayNSFW?: boolean, | 18 | displayNSFW?: boolean, |
17 | createdAt?: Date | 19 | createdAt?: Date |
18 | }) { | 20 | }) { |
@@ -20,9 +22,16 @@ export class User implements UserServerModel { | |||
20 | this.username = hash.username | 22 | this.username = hash.username |
21 | this.email = hash.email | 23 | this.email = hash.email |
22 | this.role = hash.role | 24 | this.role = hash.role |
23 | this.displayNSFW = hash.displayNSFW | ||
24 | 25 | ||
25 | if (hash.createdAt) { | 26 | if (hash.videoQuota !== undefined) { |
27 | this.videoQuota = hash.videoQuota | ||
28 | } | ||
29 | |||
30 | if (hash.displayNSFW !== undefined) { | ||
31 | this.displayNSFW = hash.displayNSFW | ||
32 | } | ||
33 | |||
34 | if (hash.createdAt !== undefined) { | ||
26 | this.createdAt = hash.createdAt | 35 | this.createdAt = hash.createdAt |
27 | } | 36 | } |
28 | } | 37 | } |