diff options
author | buoyantair <buoyantair@protonmail.com> | 2018-11-16 02:37:16 +0530 |
---|---|---|
committer | buoyantair <buoyantair@protonmail.com> | 2018-11-16 02:37:16 +0530 |
commit | ae28cdf327d782e629379eee1999096ca2a5d74b (patch) | |
tree | bfe0d4b3a232d75161fe5bba9196553a388fc02a /client/src/app/shared | |
parent | d4681c0074ba51c62a3aeb9fb3f2cd071dd21e32 (diff) | |
parent | 8cf998733496d44fa564e2e252356b871756c984 (diff) | |
download | PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.gz PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.zst PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.zip |
Merge from upstream
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/forms/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/forms/textarea-autoresize.directive.ts | 25 | ||||
-rw-r--r-- | client/src/app/shared/misc/from-now.pipe.ts | 5 | ||||
-rw-r--r-- | client/src/app/shared/shared.module.ts | 10 | ||||
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.html | 4 | ||||
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 4 |
6 files changed, 40 insertions, 9 deletions
diff --git a/client/src/app/shared/forms/index.ts b/client/src/app/shared/forms/index.ts index 41c321c4c..8febbfee9 100644 --- a/client/src/app/shared/forms/index.ts +++ b/client/src/app/shared/forms/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './form-validators' | 1 | export * from './form-validators' |
2 | export * from './form-reactive' | 2 | export * from './form-reactive' |
3 | export * from './reactive-file.component' | 3 | export * from './reactive-file.component' |
4 | export * from './textarea-autoresize.directive' | ||
diff --git a/client/src/app/shared/forms/textarea-autoresize.directive.ts b/client/src/app/shared/forms/textarea-autoresize.directive.ts new file mode 100644 index 000000000..f8c855c16 --- /dev/null +++ b/client/src/app/shared/forms/textarea-autoresize.directive.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | // Thanks: https://github.com/evseevdev/ngx-textarea-autosize | ||
2 | import { AfterViewInit, Directive, ElementRef, HostBinding, HostListener } from '@angular/core' | ||
3 | |||
4 | @Directive({ | ||
5 | selector: 'textarea[myAutoResize]' | ||
6 | }) | ||
7 | export class TextareaAutoResizeDirective implements AfterViewInit { | ||
8 | @HostBinding('attr.rows') rows = '1' | ||
9 | @HostBinding('style.overflow') overflow = 'hidden' | ||
10 | |||
11 | constructor (private elem: ElementRef) { } | ||
12 | |||
13 | public ngAfterViewInit () { | ||
14 | this.resize() | ||
15 | } | ||
16 | |||
17 | @HostListener('input') | ||
18 | resize () { | ||
19 | const textarea = this.elem.nativeElement as HTMLTextAreaElement | ||
20 | // Reset textarea height to auto that correctly calculate the new height | ||
21 | textarea.style.height = 'auto' | ||
22 | // Set new height | ||
23 | textarea.style.height = `${textarea.scrollHeight}px` | ||
24 | } | ||
25 | } | ||
diff --git a/client/src/app/shared/misc/from-now.pipe.ts b/client/src/app/shared/misc/from-now.pipe.ts index 33e6d25fe..00b5be6c9 100644 --- a/client/src/app/shared/misc/from-now.pipe.ts +++ b/client/src/app/shared/misc/from-now.pipe.ts | |||
@@ -7,8 +7,9 @@ export class FromNowPipe implements PipeTransform { | |||
7 | 7 | ||
8 | constructor (private i18n: I18n) { } | 8 | constructor (private i18n: I18n) { } |
9 | 9 | ||
10 | transform (value: number) { | 10 | transform (arg: number | Date | string) { |
11 | const seconds = Math.floor((Date.now() - value) / 1000) | 11 | const argDate = new Date(arg) |
12 | const seconds = Math.floor((Date.now() - argDate.getTime()) / 1000) | ||
12 | 13 | ||
13 | let interval = Math.floor(seconds / 31536000) | 14 | let interval = Math.floor(seconds / 31536000) |
14 | if (interval > 1) { | 15 | if (interval > 1) { |
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 0ec2a9b15..a2fa27b72 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -37,13 +37,15 @@ import { | |||
37 | LoginValidatorsService, | 37 | LoginValidatorsService, |
38 | ReactiveFileComponent, | 38 | ReactiveFileComponent, |
39 | ResetPasswordValidatorsService, | 39 | ResetPasswordValidatorsService, |
40 | TextareaAutoResizeDirective, | ||
40 | UserValidatorsService, | 41 | UserValidatorsService, |
41 | VideoAbuseValidatorsService, | 42 | VideoAbuseValidatorsService, |
43 | VideoAcceptOwnershipValidatorsService, | ||
42 | VideoBlacklistValidatorsService, | 44 | VideoBlacklistValidatorsService, |
45 | VideoChangeOwnershipValidatorsService, | ||
43 | VideoChannelValidatorsService, | 46 | VideoChannelValidatorsService, |
44 | VideoCommentValidatorsService, | 47 | VideoCommentValidatorsService, |
45 | VideoValidatorsService, | 48 | VideoValidatorsService |
46 | VideoChangeOwnershipValidatorsService, VideoAcceptOwnershipValidatorsService | ||
47 | } from '@app/shared/forms' | 49 | } from '@app/shared/forms' |
48 | import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' | 50 | import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' |
49 | import { ScreenService } from '@app/shared/misc/screen.service' | 51 | import { ScreenService } from '@app/shared/misc/screen.service' |
@@ -53,7 +55,7 @@ import { PeertubeCheckboxComponent } from '@app/shared/forms/peertube-checkbox.c | |||
53 | import { VideoImportService } from '@app/shared/video-import/video-import.service' | 55 | import { VideoImportService } from '@app/shared/video-import/video-import.service' |
54 | import { ActionDropdownComponent } from '@app/shared/buttons/action-dropdown.component' | 56 | import { ActionDropdownComponent } from '@app/shared/buttons/action-dropdown.component' |
55 | import { NgbDropdownModule, NgbModalModule, NgbPopoverModule, NgbTabsetModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' | 57 | import { NgbDropdownModule, NgbModalModule, NgbPopoverModule, NgbTabsetModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' |
56 | import { SubscribeButtonComponent, RemoteSubscribeComponent, UserSubscriptionService } from '@app/shared/user-subscription' | 58 | import { RemoteSubscribeComponent, SubscribeButtonComponent, UserSubscriptionService } from '@app/shared/user-subscription' |
57 | import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-features-table.component' | 59 | import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-features-table.component' |
58 | import { OverviewService } from '@app/shared/overview' | 60 | import { OverviewService } from '@app/shared/overview' |
59 | import { UserBanModalComponent } from '@app/shared/moderation' | 61 | import { UserBanModalComponent } from '@app/shared/moderation' |
@@ -92,6 +94,7 @@ import { BlocklistService } from '@app/shared/blocklist' | |||
92 | FromNowPipe, | 94 | FromNowPipe, |
93 | MarkdownTextareaComponent, | 95 | MarkdownTextareaComponent, |
94 | InfiniteScrollerDirective, | 96 | InfiniteScrollerDirective, |
97 | TextareaAutoResizeDirective, | ||
95 | HelpComponent, | 98 | HelpComponent, |
96 | ReactiveFileComponent, | 99 | ReactiveFileComponent, |
97 | PeertubeCheckboxComponent, | 100 | PeertubeCheckboxComponent, |
@@ -129,6 +132,7 @@ import { BlocklistService } from '@app/shared/blocklist' | |||
129 | ActionDropdownComponent, | 132 | ActionDropdownComponent, |
130 | MarkdownTextareaComponent, | 133 | MarkdownTextareaComponent, |
131 | InfiniteScrollerDirective, | 134 | InfiniteScrollerDirective, |
135 | TextareaAutoResizeDirective, | ||
132 | HelpComponent, | 136 | HelpComponent, |
133 | ReactiveFileComponent, | 137 | ReactiveFileComponent, |
134 | PeertubeCheckboxComponent, | 138 | PeertubeCheckboxComponent, |
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index 277a0cf35..2c635fa2f 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html | |||
@@ -7,10 +7,10 @@ | |||
7 | class="video-miniature-name" | 7 | class="video-miniature-name" |
8 | [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" | 8 | [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" |
9 | > | 9 | > |
10 | {{ video.name }} | ||
11 | |||
12 | <span *ngIf="isUnlistedVideo()" class="badge badge-warning" i18n>Unlisted</span> | 10 | <span *ngIf="isUnlistedVideo()" class="badge badge-warning" i18n>Unlisted</span> |
13 | <span *ngIf="isPrivateVideo()" class="badge badge-danger" i18n>Private</span> | 11 | <span *ngIf="isPrivateVideo()" class="badge badge-danger" i18n>Private</span> |
12 | |||
13 | {{ video.name }} | ||
14 | </a> | 14 | </a> |
15 | 15 | ||
16 | <span i18n class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> | 16 | <span i18n class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 65297d7a1..55844f988 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -6,11 +6,11 @@ import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } fr | |||
6 | import { ResultList } from '../../../../../shared/models/result-list.model' | 6 | import { ResultList } from '../../../../../shared/models/result-list.model' |
7 | import { | 7 | import { |
8 | UserVideoRate, | 8 | UserVideoRate, |
9 | UserVideoRateType, | ||
9 | UserVideoRateUpdate, | 10 | UserVideoRateUpdate, |
10 | VideoConstant, | 11 | VideoConstant, |
11 | VideoFilter, | 12 | VideoFilter, |
12 | VideoPrivacy, | 13 | VideoPrivacy, |
13 | VideoRateType, | ||
14 | VideoUpdate | 14 | VideoUpdate |
15 | } from '../../../../../shared/models/videos' | 15 | } from '../../../../../shared/models/videos' |
16 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' | 16 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' |
@@ -332,7 +332,7 @@ export class VideoService implements VideosProvider { | |||
332 | return privacies | 332 | return privacies |
333 | } | 333 | } |
334 | 334 | ||
335 | private setVideoRate (id: number, rateType: VideoRateType) { | 335 | private setVideoRate (id: number, rateType: UserVideoRateType) { |
336 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | 336 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' |
337 | const body: UserVideoRateUpdate = { | 337 | const body: UserVideoRateUpdate = { |
338 | rating: rateType | 338 | rating: rateType |