diff options
Diffstat (limited to 'client/src')
10 files changed, 58 insertions, 67 deletions
diff --git a/client/src/app/admin/friends/friend-add/friend-add.component.html b/client/src/app/admin/friends/friend-add/friend-add.component.html index 788f3b44d..621822860 100644 --- a/client/src/app/admin/friends/friend-add/friend-add.component.html +++ b/client/src/app/admin/friends/friend-add/friend-add.component.html | |||
@@ -3,13 +3,13 @@ | |||
3 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> | 3 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> |
4 | 4 | ||
5 | <form (ngSubmit)="makeFriends()" [formGroup]="form"> | 5 | <form (ngSubmit)="makeFriends()" [formGroup]="form"> |
6 | <div class="form-group" *ngFor="let url of urls; let id = index; trackBy:customTrackBy"> | 6 | <div class="form-group" *ngFor="let host of hosts; let id = index; trackBy:customTrackBy"> |
7 | <label for="username">Url</label> | 7 | <label for="username">Host</label> |
8 | 8 | ||
9 | <div class="input-group"> | 9 | <div class="input-group"> |
10 | <input | 10 | <input |
11 | type="text" class="form-control" placeholder="http://domain.com" | 11 | type="text" class="form-control" placeholder="domain.tld" |
12 | [id]="'url-' + id" [formControlName]="'url-' + id" | 12 | [id]="'host-' + id" [formControlName]="'host-' + id" |
13 | /> | 13 | /> |
14 | <span class="input-group-btn"> | 14 | <span class="input-group-btn"> |
15 | <button *ngIf="displayAddField(id)" (click)="addField()" class="btn btn-default" type="button">+</button> | 15 | <button *ngIf="displayAddField(id)" (click)="addField()" class="btn btn-default" type="button">+</button> |
@@ -17,8 +17,8 @@ | |||
17 | </span> | 17 | </span> |
18 | </div> | 18 | </div> |
19 | 19 | ||
20 | <div [hidden]="form.controls['url-' + id].valid || form.controls['url-' + id].pristine" class="alert alert-warning"> | 20 | <div [hidden]="form.controls['host-' + id].valid || form.controls['host-' + id].pristine" class="alert alert-warning"> |
21 | It should be a valid url. | 21 | It should be a valid host. |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
24 | 24 | ||
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 64165a9a5..86b018de2 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 | |||
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; | |||
2 | import { FormControl, FormGroup } from '@angular/forms'; | 2 | import { FormControl, FormGroup } from '@angular/forms'; |
3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router'; |
4 | 4 | ||
5 | import { validateUrl } from '../../../shared'; | 5 | import { validateHost } from '../../../shared'; |
6 | import { FriendService } from '../shared'; | 6 | import { FriendService } from '../shared'; |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
@@ -12,7 +12,7 @@ import { FriendService } from '../shared'; | |||
12 | }) | 12 | }) |
13 | export class FriendAddComponent implements OnInit { | 13 | export class FriendAddComponent implements OnInit { |
14 | form: FormGroup; | 14 | form: FormGroup; |
15 | urls = [ ]; | 15 | hosts = [ ]; |
16 | error: string = null; | 16 | error: string = null; |
17 | 17 | ||
18 | constructor(private router: Router, private friendService: FriendService) {} | 18 | constructor(private router: Router, private friendService: FriendService) {} |
@@ -23,8 +23,8 @@ export class FriendAddComponent implements OnInit { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | addField() { | 25 | addField() { |
26 | this.form.addControl(`url-${this.urls.length}`, new FormControl('', [ validateUrl ])); | 26 | this.form.addControl(`host-${this.hosts.length}`, new FormControl('', [ validateHost ])); |
27 | this.urls.push(''); | 27 | this.hosts.push(''); |
28 | } | 28 | } |
29 | 29 | ||
30 | customTrackBy(index: number, obj: any): any { | 30 | customTrackBy(index: number, obj: any): any { |
@@ -32,52 +32,52 @@ export class FriendAddComponent implements OnInit { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | displayAddField(index: number) { | 34 | displayAddField(index: number) { |
35 | return index === (this.urls.length - 1); | 35 | return index === (this.hosts.length - 1); |
36 | } | 36 | } |
37 | 37 | ||
38 | displayRemoveField(index: number) { | 38 | displayRemoveField(index: number) { |
39 | return (index !== 0 || this.urls.length > 1) && index !== (this.urls.length - 1); | 39 | return (index !== 0 || this.hosts.length > 1) && index !== (this.hosts.length - 1); |
40 | } | 40 | } |
41 | 41 | ||
42 | isFormValid() { | 42 | isFormValid() { |
43 | // Do not check the last input | 43 | // Do not check the last input |
44 | for (let i = 0; i < this.urls.length - 1; i++) { | 44 | for (let i = 0; i < this.hosts.length - 1; i++) { |
45 | if (!this.form.controls[`url-${i}`].valid) return false; | 45 | if (!this.form.controls[`host-${i}`].valid) return false; |
46 | } | 46 | } |
47 | 47 | ||
48 | const lastIndex = this.urls.length - 1; | 48 | const lastIndex = this.hosts.length - 1; |
49 | // If the last input (which is not the first) is empty, it's ok | 49 | // If the last input (which is not the first) is empty, it's ok |
50 | if (this.urls[lastIndex] === '' && lastIndex !== 0) { | 50 | if (this.hosts[lastIndex] === '' && lastIndex !== 0) { |
51 | return true; | 51 | return true; |
52 | } else { | 52 | } else { |
53 | return this.form.controls[`url-${lastIndex}`].valid; | 53 | return this.form.controls[`host-${lastIndex}`].valid; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | removeField(index: number) { | 57 | removeField(index: number) { |
58 | // Remove the last control | 58 | // Remove the last control |
59 | this.form.removeControl(`url-${this.urls.length - 1}`); | 59 | this.form.removeControl(`host-${this.hosts.length - 1}`); |
60 | this.urls.splice(index, 1); | 60 | this.hosts.splice(index, 1); |
61 | } | 61 | } |
62 | 62 | ||
63 | makeFriends() { | 63 | makeFriends() { |
64 | this.error = ''; | 64 | this.error = ''; |
65 | 65 | ||
66 | const notEmptyUrls = this.getNotEmptyUrls(); | 66 | const notEmptyHosts = this.getNotEmptyHosts(); |
67 | if (notEmptyUrls.length === 0) { | 67 | if (notEmptyHosts.length === 0) { |
68 | this.error = 'You need to specify at less 1 url.'; | 68 | this.error = 'You need to specify at least 1 host.'; |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | 71 | ||
72 | if (!this.isUrlsUnique(notEmptyUrls)) { | 72 | if (!this.isHostsUnique(notEmptyHosts)) { |
73 | this.error = 'Urls need to be unique.'; | 73 | this.error = 'Hosts need to be unique.'; |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | 76 | ||
77 | const confirmMessage = 'Are you sure to make friends with:\n - ' + notEmptyUrls.join('\n - '); | 77 | const confirmMessage = 'Are you sure to make friends with:\n - ' + notEmptyHosts.join('\n - '); |
78 | if (!confirm(confirmMessage)) return; | 78 | if (!confirm(confirmMessage)) return; |
79 | 79 | ||
80 | this.friendService.makeFriends(notEmptyUrls).subscribe( | 80 | this.friendService.makeFriends(notEmptyHosts).subscribe( |
81 | status => { | 81 | status => { |
82 | // TODO: extractdatastatus | 82 | // TODO: extractdatastatus |
83 | // if (status === 409) { | 83 | // if (status === 409) { |
@@ -91,18 +91,18 @@ export class FriendAddComponent implements OnInit { | |||
91 | ); | 91 | ); |
92 | } | 92 | } |
93 | 93 | ||
94 | private getNotEmptyUrls() { | 94 | private getNotEmptyHosts() { |
95 | const notEmptyUrls = []; | 95 | const notEmptyHosts = []; |
96 | 96 | ||
97 | Object.keys(this.form.value).forEach((urlKey) => { | 97 | Object.keys(this.form.value).forEach((hostKey) => { |
98 | const url = this.form.value[urlKey]; | 98 | const host = this.form.value[hostKey]; |
99 | if (url !== '') notEmptyUrls.push(url); | 99 | if (host !== '') notEmptyHosts.push(host); |
100 | }); | 100 | }); |
101 | 101 | ||
102 | return notEmptyUrls; | 102 | return notEmptyHosts; |
103 | } | 103 | } |
104 | 104 | ||
105 | private isUrlsUnique(urls: string[]) { | 105 | private isHostsUnique(hosts: string[]) { |
106 | return urls.every(url => urls.indexOf(url) === urls.lastIndexOf(url)); | 106 | return hosts.every(host => hosts.indexOf(host) === hosts.lastIndexOf(host)); |
107 | } | 107 | } |
108 | } | 108 | } |
diff --git a/client/src/app/admin/friends/friend-list/friend-list.component.html b/client/src/app/admin/friends/friend-list/friend-list.component.html index 20b4d12db..4236fc5f6 100644 --- a/client/src/app/admin/friends/friend-list/friend-list.component.html +++ b/client/src/app/admin/friends/friend-list/friend-list.component.html | |||
@@ -4,7 +4,7 @@ | |||
4 | <thead> | 4 | <thead> |
5 | <tr> | 5 | <tr> |
6 | <th class="table-column-id">ID</th> | 6 | <th class="table-column-id">ID</th> |
7 | <th>Url</th> | 7 | <th>Host</th> |
8 | <th>Score</th> | 8 | <th>Score</th> |
9 | <th>Created Date</th> | 9 | <th>Created Date</th> |
10 | </tr> | 10 | </tr> |
@@ -13,7 +13,7 @@ | |||
13 | <tbody> | 13 | <tbody> |
14 | <tr *ngFor="let friend of friends"> | 14 | <tr *ngFor="let friend of friends"> |
15 | <td>{{ friend.id }}</td> | 15 | <td>{{ friend.id }}</td> |
16 | <td>{{ friend.url }}</td> | 16 | <td>{{ friend.host }}</td> |
17 | <td>{{ friend.score }}</td> | 17 | <td>{{ friend.score }}</td> |
18 | <td>{{ friend.createdDate | date: 'medium' }}</td> | 18 | <td>{{ friend.createdDate | date: 'medium' }}</td> |
19 | </tr> | 19 | </tr> |
diff --git a/client/src/app/admin/friends/shared/friend.model.ts b/client/src/app/admin/friends/shared/friend.model.ts index 7cb28f440..3c23feebc 100644 --- a/client/src/app/admin/friends/shared/friend.model.ts +++ b/client/src/app/admin/friends/shared/friend.model.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | export interface Friend { | 1 | export interface Friend { |
2 | id: string; | 2 | id: string; |
3 | url: string; | 3 | host: string; |
4 | score: number; | 4 | score: number; |
5 | createdDate: Date; | 5 | createdDate: Date; |
6 | } | 6 | } |
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts index 75826fc17..8a1ba6b02 100644 --- a/client/src/app/admin/friends/shared/friend.service.ts +++ b/client/src/app/admin/friends/shared/friend.service.ts | |||
@@ -21,9 +21,9 @@ export class FriendService { | |||
21 | .catch((res) => this.restExtractor.handleError(res)); | 21 | .catch((res) => this.restExtractor.handleError(res)); |
22 | } | 22 | } |
23 | 23 | ||
24 | makeFriends(notEmptyUrls) { | 24 | makeFriends(notEmptyHosts) { |
25 | const body = { | 25 | const body = { |
26 | urls: notEmptyUrls | 26 | hosts: notEmptyHosts |
27 | }; | 27 | }; |
28 | 28 | ||
29 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body) | 29 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body) |
diff --git a/client/src/app/shared/forms/form-validators/host.validator.ts b/client/src/app/shared/forms/form-validators/host.validator.ts new file mode 100644 index 000000000..9cb46d361 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/host.validator.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { FormControl } from '@angular/forms'; | ||
2 | |||
3 | export function validateHost(c: FormControl) { | ||
4 | let HOST_REGEXP = new RegExp('^(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$'); | ||
5 | |||
6 | return HOST_REGEXP.test(c.value) ? null : { | ||
7 | validateHost: { | ||
8 | valid: false | ||
9 | } | ||
10 | }; | ||
11 | } | ||
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index 1d2ae6f68..4c6cc6637 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts | |||
@@ -1,3 +1,3 @@ | |||
1 | export * from './url.validator'; | 1 | export * from './host.validator'; |
2 | export * from './user'; | 2 | export * from './user'; |
3 | export * from './video'; | 3 | export * from './video'; |
diff --git a/client/src/app/shared/forms/form-validators/url.validator.ts b/client/src/app/shared/forms/form-validators/url.validator.ts deleted file mode 100644 index 67163b4e9..000000000 --- a/client/src/app/shared/forms/form-validators/url.validator.ts +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | import { FormControl } from '@angular/forms'; | ||
2 | |||
3 | export function validateUrl(c: FormControl) { | ||
4 | let URL_REGEXP = new RegExp('^https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$'); | ||
5 | |||
6 | return URL_REGEXP.test(c.value) ? null : { | ||
7 | validateUrl: { | ||
8 | valid: false | ||
9 | } | ||
10 | }; | ||
11 | } | ||
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 873c83ff1..b51a0e9de 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts | |||
@@ -8,21 +8,12 @@ export class Video { | |||
8 | isLocal: boolean; | 8 | isLocal: boolean; |
9 | magnetUri: string; | 9 | magnetUri: string; |
10 | name: string; | 10 | name: string; |
11 | podUrl: string; | 11 | podHost: string; |
12 | tags: string[]; | 12 | tags: string[]; |
13 | thumbnailPath: string; | 13 | thumbnailPath: string; |
14 | 14 | ||
15 | private static createByString(author: string, podUrl: string) { | 15 | private static createByString(author: string, podHost: string) { |
16 | let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':'); | 16 | return author + '@' + podHost; |
17 | |||
18 | if (port === '80' || port === '443') { | ||
19 | port = ''; | ||
20 | } else { | ||
21 | port = ':' + port; | ||
22 | } | ||
23 | |||
24 | |||
25 | return author + '@' + host + port; | ||
26 | } | 17 | } |
27 | 18 | ||
28 | private static createDurationString(duration: number) { | 19 | private static createDurationString(duration: number) { |
@@ -43,7 +34,7 @@ export class Video { | |||
43 | isLocal: boolean, | 34 | isLocal: boolean, |
44 | magnetUri: string, | 35 | magnetUri: string, |
45 | name: string, | 36 | name: string, |
46 | podUrl: string, | 37 | podHost: string, |
47 | tags: string[], | 38 | tags: string[], |
48 | thumbnailPath: string | 39 | thumbnailPath: string |
49 | }) { | 40 | }) { |
@@ -55,11 +46,11 @@ export class Video { | |||
55 | this.isLocal = hash.isLocal; | 46 | this.isLocal = hash.isLocal; |
56 | this.magnetUri = hash.magnetUri; | 47 | this.magnetUri = hash.magnetUri; |
57 | this.name = hash.name; | 48 | this.name = hash.name; |
58 | this.podUrl = hash.podUrl; | 49 | this.podHost = hash.podHost; |
59 | this.tags = hash.tags; | 50 | this.tags = hash.tags; |
60 | this.thumbnailPath = hash.thumbnailPath; | 51 | this.thumbnailPath = hash.thumbnailPath; |
61 | 52 | ||
62 | this.by = Video.createByString(hash.author, hash.podUrl); | 53 | this.by = Video.createByString(hash.author, hash.podHost); |
63 | } | 54 | } |
64 | 55 | ||
65 | isRemovableBy(user) { | 56 | isRemovableBy(user) { |
diff --git a/client/src/app/videos/video-watch/video-watch.component.html b/client/src/app/videos/video-watch/video-watch.component.html index f3a416367..cb91bae7e 100644 --- a/client/src/app/videos/video-watch/video-watch.component.html +++ b/client/src/app/videos/video-watch/video-watch.component.html | |||
@@ -2,7 +2,7 @@ | |||
2 | <div class="alert alert-danger"> | 2 | <div class="alert alert-danger"> |
3 | The video load seems to be abnormally long. | 3 | The video load seems to be abnormally long. |
4 | <ul> | 4 | <ul> |
5 | <li>Maybe the server {{ video.podUrl }} is down :(</li> | 5 | <li>Maybe the server {{ video.podHost }} is down :(</li> |
6 | <li> | 6 | <li> |
7 | If not, you can report an issue on | 7 | If not, you can report an issue on |
8 | <a href="https://github.com/Chocobozzz/PeerTube/issues" title="Report an issue"> | 8 | <a href="https://github.com/Chocobozzz/PeerTube/issues" title="Report an issue"> |