aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-27 16:11:53 +0100
committerChocobozzz <me@florianbigard.com>2017-12-27 16:11:53 +0100
commit4635f59d7c3fea4b97029f10886c62fdf38b2084 (patch)
treed97357a00042bbfb33c4177ee24c01171d28dfce /client/src/app/shared
parentea44f375f5d3da06ca0aebfe871b9f924a26ec29 (diff)
downloadPeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.tar.gz
PeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.tar.zst
PeerTube-4635f59d7c3fea4b97029f10886c62fdf38b2084.zip
Add video comment components
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/forms/form-validators/video-comment.ts10
-rw-r--r--client/src/app/shared/misc/button.component.scss2
-rw-r--r--client/src/app/shared/rest/component-pagination.model.ts (renamed from client/src/app/shared/video/video-pagination.model.ts)2
-rw-r--r--client/src/app/shared/rest/rest.service.ts7
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts4
-rw-r--r--client/src/app/shared/video/video-miniature.component.scss1
-rw-r--r--client/src/app/shared/video/video.service.ts25
7 files changed, 32 insertions, 19 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-comment.ts b/client/src/app/shared/forms/form-validators/video-comment.ts
new file mode 100644
index 000000000..42a97e300
--- /dev/null
+++ b/client/src/app/shared/forms/form-validators/video-comment.ts
@@ -0,0 +1,10 @@
1import { Validators } from '@angular/forms'
2
3export const VIDEO_COMMENT_TEXT = {
4 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
5 MESSAGES: {
6 'required': 'Comment is required.',
7 'minlength': 'Comment must be at least 2 characters long.',
8 'maxlength': 'Comment cannot be more than 3000 characters long.'
9 }
10}
diff --git a/client/src/app/shared/misc/button.component.scss b/client/src/app/shared/misc/button.component.scss
index c380c7ae1..145a3474a 100644
--- a/client/src/app/shared/misc/button.component.scss
+++ b/client/src/app/shared/misc/button.component.scss
@@ -20,7 +20,7 @@
20 top: -2px; 20 top: -2px;
21 21
22 &.icon-edit { 22 &.icon-edit {
23 background-image: url('../../../assets/images/global/edit.svg'); 23 background-image: url('../../../assets/images/global/edit-grey.svg');
24 } 24 }
25 25
26 &.icon-delete-grey { 26 &.icon-delete-grey {
diff --git a/client/src/app/shared/video/video-pagination.model.ts b/client/src/app/shared/rest/component-pagination.model.ts
index e9db61596..0b8ecc318 100644
--- a/client/src/app/shared/video/video-pagination.model.ts
+++ b/client/src/app/shared/rest/component-pagination.model.ts
@@ -1,4 +1,4 @@
1export interface VideoPagination { 1export interface ComponentPagination {
2 currentPage: number 2 currentPage: number
3 itemsPerPage: number 3 itemsPerPage: number
4 totalItems?: number 4 totalItems?: number
diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts
index a1c301050..5d5410de9 100644
--- a/client/src/app/shared/rest/rest.service.ts
+++ b/client/src/app/shared/rest/rest.service.ts
@@ -1,6 +1,7 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { HttpParams } from '@angular/common/http' 2import { HttpParams } from '@angular/common/http'
3import { SortMeta } from 'primeng/components/common/sortmeta' 3import { SortMeta } from 'primeng/components/common/sortmeta'
4import { ComponentPagination } from './component-pagination.model'
4 5
5import { RestPagination } from './rest-pagination' 6import { RestPagination } from './rest-pagination'
6 7
@@ -31,4 +32,10 @@ export class RestService {
31 return newParams 32 return newParams
32 } 33 }
33 34
35 componentPaginationToRestPagination (componentPagination: ComponentPagination): RestPagination {
36 const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage
37 const count: number = componentPagination.itemsPerPage
38
39 return { start, count }
40 }
34} 41}
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 2b6870a78..bfe46bcdd 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -3,12 +3,12 @@ import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { Observable } from 'rxjs/Observable' 4import { Observable } from 'rxjs/Observable'
5import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
6import { ComponentPagination } from '../rest/component-pagination.model'
6import { SortField } from './sort-field.type' 7import { SortField } from './sort-field.type'
7import { VideoPagination } from './video-pagination.model'
8import { Video } from './video.model' 8import { Video } from './video.model'
9 9
10export abstract class AbstractVideoList implements OnInit { 10export abstract class AbstractVideoList implements OnInit {
11 pagination: VideoPagination = { 11 pagination: ComponentPagination = {
12 currentPage: 1, 12 currentPage: 1,
13 itemsPerPage: 25, 13 itemsPerPage: 25,
14 totalItems: null 14 totalItems: null
diff --git a/client/src/app/shared/video/video-miniature.component.scss b/client/src/app/shared/video/video-miniature.component.scss
index 49ba1e51c..f0888ad9f 100644
--- a/client/src/app/shared/video/video-miniature.component.scss
+++ b/client/src/app/shared/video/video-miniature.component.scss
@@ -18,7 +18,6 @@
18 overflow: hidden; 18 overflow: hidden;
19 text-overflow: ellipsis; 19 text-overflow: ellipsis;
20 white-space: nowrap; 20 white-space: nowrap;
21 font-weight: bold;
22 transition: color 0.2s; 21 transition: color 0.2s;
23 font-size: 16px; 22 font-size: 16px;
24 font-weight: $font-semibold; 23 font-weight: $font-semibold;
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 91dd3977a..fc7505a51 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -10,13 +10,13 @@ import { UserVideoRate } from '../../../../../shared/models/videos/user-video-ra
10import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type' 10import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type'
11import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model' 11import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model'
12import { environment } from '../../../environments/environment' 12import { environment } from '../../../environments/environment'
13import { ComponentPagination } from '../rest/component-pagination.model'
13import { RestExtractor } from '../rest/rest-extractor.service' 14import { RestExtractor } from '../rest/rest-extractor.service'
14import { RestService } from '../rest/rest.service' 15import { RestService } from '../rest/rest.service'
15import { UserService } from '../users/user.service' 16import { UserService } from '../users/user.service'
16import { SortField } from './sort-field.type' 17import { SortField } from './sort-field.type'
17import { VideoDetails } from './video-details.model' 18import { VideoDetails } from './video-details.model'
18import { VideoEdit } from './video-edit.model' 19import { VideoEdit } from './video-edit.model'
19import { VideoPagination } from './video-pagination.model'
20import { Video } from './video.model' 20import { Video } from './video.model'
21 21
22@Injectable() 22@Injectable()
@@ -71,8 +71,8 @@ export class VideoService {
71 .catch(this.restExtractor.handleError) 71 .catch(this.restExtractor.handleError)
72 } 72 }
73 73
74 getMyVideos (videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { 74 getMyVideos (videoPagination: ComponentPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> {
75 const pagination = this.videoPaginationToRestPagination(videoPagination) 75 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
76 76
77 let params = new HttpParams() 77 let params = new HttpParams()
78 params = this.restService.addRestGetParams(params, pagination, sort) 78 params = this.restService.addRestGetParams(params, pagination, sort)
@@ -82,8 +82,8 @@ export class VideoService {
82 .catch((res) => this.restExtractor.handleError(res)) 82 .catch((res) => this.restExtractor.handleError(res))
83 } 83 }
84 84
85 getVideos (videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { 85 getVideos (videoPagination: ComponentPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> {
86 const pagination = this.videoPaginationToRestPagination(videoPagination) 86 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
87 87
88 let params = new HttpParams() 88 let params = new HttpParams()
89 params = this.restService.addRestGetParams(params, pagination, sort) 89 params = this.restService.addRestGetParams(params, pagination, sort)
@@ -94,10 +94,14 @@ export class VideoService {
94 .catch((res) => this.restExtractor.handleError(res)) 94 .catch((res) => this.restExtractor.handleError(res))
95 } 95 }
96 96
97 searchVideos (search: string, videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { 97 searchVideos (
98 search: string,
99 videoPagination: ComponentPagination,
100 sort: SortField
101 ): Observable<{ videos: Video[], totalVideos: number}> {
98 const url = VideoService.BASE_VIDEO_URL + 'search' 102 const url = VideoService.BASE_VIDEO_URL + 'search'
99 103
100 const pagination = this.videoPaginationToRestPagination(videoPagination) 104 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
101 105
102 let params = new HttpParams() 106 let params = new HttpParams()
103 params = this.restService.addRestGetParams(params, pagination, sort) 107 params = this.restService.addRestGetParams(params, pagination, sort)
@@ -139,13 +143,6 @@ export class VideoService {
139 .catch(res => this.restExtractor.handleError(res)) 143 .catch(res => this.restExtractor.handleError(res))
140 } 144 }
141 145
142 private videoPaginationToRestPagination (videoPagination: VideoPagination) {
143 const start: number = (videoPagination.currentPage - 1) * videoPagination.itemsPerPage
144 const count: number = videoPagination.itemsPerPage
145
146 return { start, count }
147 }
148
149 private setVideoRate (id: number, rateType: VideoRateType) { 146 private setVideoRate (id: number, rateType: VideoRateType) {
150 const url = VideoService.BASE_VIDEO_URL + id + '/rate' 147 const url = VideoService.BASE_VIDEO_URL + id + '/rate'
151 const body: UserVideoRateUpdate = { 148 const body: UserVideoRateUpdate = {