aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-26 16:44:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitb5b687550d8ef8beafdf706e45d6556fb5f4c876 (patch)
tree232412d463c78af1f7ab5797db5aecf1096d08da /client/src/app/shared
parentef680f68351ec10ab73a1131570a6d14ce14c195 (diff)
downloadPeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.gz
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.zst
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.zip
Add ability to save live replay
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts32
-rw-r--r--client/src/app/shared/shared-main/angular/index.ts1
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts14
-rw-r--r--client/src/app/shared/shared-main/video/live-video.service.ts10
4 files changed, 53 insertions, 4 deletions
diff --git a/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts b/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts
new file mode 100644
index 000000000..29ff864ec
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/duration-formatter.pipe.ts
@@ -0,0 +1,32 @@
1import { Pipe, PipeTransform } from '@angular/core'
2
3@Pipe({
4 name: 'myDurationFormatter'
5})
6export class DurationFormatterPipe implements PipeTransform {
7
8 transform (value: number): string {
9 const hours = Math.floor(value / 3600)
10 const minutes = Math.floor((value % 3600) / 60)
11 const seconds = value % 60
12
13 if (hours > 0) {
14 let result = $localize`${hours}h`
15
16 if (minutes !== 0) result += ' ' + $localize`${minutes}min`
17 if (seconds !== 0) result += ' ' + $localize`${seconds}sec`
18
19 return result
20 }
21
22 if (minutes > 0) {
23 let result = $localize`${minutes}min`
24
25 if (seconds !== 0) result += ' ' + `${seconds}sec`
26
27 return result
28 }
29
30 return $localize`${seconds} sec`
31 }
32}
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts
index 9ba815136..29f8b3650 100644
--- a/client/src/app/shared/shared-main/angular/index.ts
+++ b/client/src/app/shared/shared-main/angular/index.ts
@@ -1,4 +1,5 @@
1export * from './bytes.pipe' 1export * from './bytes.pipe'
2export * from './duration-formatter.pipe'
2export * from './from-now.pipe' 3export * from './from-now.pipe'
3export * from './infinite-scroller.directive' 4export * from './infinite-scroller.directive'
4export * from './number-formatter.pipe' 5export * from './number-formatter.pipe'
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index 0580872f4..3816cab19 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -15,7 +15,14 @@ import {
15} from '@ng-bootstrap/ng-bootstrap' 15} from '@ng-bootstrap/ng-bootstrap'
16import { SharedGlobalIconModule } from '../shared-icons' 16import { SharedGlobalIconModule } from '../shared-icons'
17import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account' 17import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account'
18import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective, BytesPipe } from './angular' 18import {
19 BytesPipe,
20 DurationFormatterPipe,
21 FromNowPipe,
22 InfiniteScrollerDirective,
23 NumberFormatterPipe,
24 PeerTubeTemplateDirective
25} from './angular'
19import { AUTH_INTERCEPTOR_PROVIDER } from './auth' 26import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
20import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' 27import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons'
21import { DateToggleComponent } from './date' 28import { DateToggleComponent } from './date'
@@ -23,7 +30,7 @@ import { FeedComponent } from './feeds'
23import { LoaderComponent, SmallLoaderComponent } from './loaders' 30import { LoaderComponent, SmallLoaderComponent } from './loaders'
24import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' 31import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc'
25import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' 32import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
26import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService, LiveVideoService } from './video' 33import { LiveVideoService, RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video'
27import { VideoCaptionService } from './video-caption' 34import { VideoCaptionService } from './video-caption'
28import { VideoChannelService } from './video-channel' 35import { VideoChannelService } from './video-channel'
29 36
@@ -56,6 +63,8 @@ import { VideoChannelService } from './video-channel'
56 FromNowPipe, 63 FromNowPipe,
57 NumberFormatterPipe, 64 NumberFormatterPipe,
58 BytesPipe, 65 BytesPipe,
66 DurationFormatterPipe,
67
59 InfiniteScrollerDirective, 68 InfiniteScrollerDirective,
60 PeerTubeTemplateDirective, 69 PeerTubeTemplateDirective,
61 70
@@ -103,6 +112,7 @@ import { VideoChannelService } from './video-channel'
103 FromNowPipe, 112 FromNowPipe,
104 BytesPipe, 113 BytesPipe,
105 NumberFormatterPipe, 114 NumberFormatterPipe,
115 DurationFormatterPipe,
106 116
107 InfiniteScrollerDirective, 117 InfiniteScrollerDirective,
108 PeerTubeTemplateDirective, 118 PeerTubeTemplateDirective,
diff --git a/client/src/app/shared/shared-main/video/live-video.service.ts b/client/src/app/shared/shared-main/video/live-video.service.ts
index 2cd1c66a5..093d65e83 100644
--- a/client/src/app/shared/shared-main/video/live-video.service.ts
+++ b/client/src/app/shared/shared-main/video/live-video.service.ts
@@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { RestExtractor } from '@app/core' 4import { RestExtractor } from '@app/core'
5import { VideoCreate, LiveVideo } from '@shared/models' 5import { LiveVideo, LiveVideoCreate, LiveVideoUpdate } from '@shared/models'
6import { environment } from '../../../../environments/environment' 6import { environment } from '../../../../environments/environment'
7 7
8@Injectable() 8@Injectable()
@@ -14,7 +14,7 @@ export class LiveVideoService {
14 private restExtractor: RestExtractor 14 private restExtractor: RestExtractor
15 ) {} 15 ) {}
16 16
17 goLive (video: VideoCreate) { 17 goLive (video: LiveVideoCreate) {
18 return this.authHttp 18 return this.authHttp
19 .post<{ video: { id: number, uuid: string } }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) 19 .post<{ video: { id: number, uuid: string } }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video)
20 .pipe(catchError(err => this.restExtractor.handleError(err))) 20 .pipe(catchError(err => this.restExtractor.handleError(err)))
@@ -25,4 +25,10 @@ export class LiveVideoService {
25 .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) 25 .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId)
26 .pipe(catchError(err => this.restExtractor.handleError(err))) 26 .pipe(catchError(err => this.restExtractor.handleError(err)))
27 } 27 }
28
29 updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) {
30 return this.authHttp
31 .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate)
32 .pipe(catchError(err => this.restExtractor.handleError(err)))
33 }
28} 34}