diff options
Diffstat (limited to 'client/src/app/shared')
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 @@ | |||
1 | import { Pipe, PipeTransform } from '@angular/core' | ||
2 | |||
3 | @Pipe({ | ||
4 | name: 'myDurationFormatter' | ||
5 | }) | ||
6 | export 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 @@ | |||
1 | export * from './bytes.pipe' | 1 | export * from './bytes.pipe' |
2 | export * from './duration-formatter.pipe' | ||
2 | export * from './from-now.pipe' | 3 | export * from './from-now.pipe' |
3 | export * from './infinite-scroller.directive' | 4 | export * from './infinite-scroller.directive' |
4 | export * from './number-formatter.pipe' | 5 | export * 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' |
16 | import { SharedGlobalIconModule } from '../shared-icons' | 16 | import { SharedGlobalIconModule } from '../shared-icons' |
17 | import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account' | 17 | import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account' |
18 | import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective, BytesPipe } from './angular' | 18 | import { |
19 | BytesPipe, | ||
20 | DurationFormatterPipe, | ||
21 | FromNowPipe, | ||
22 | InfiniteScrollerDirective, | ||
23 | NumberFormatterPipe, | ||
24 | PeerTubeTemplateDirective | ||
25 | } from './angular' | ||
19 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' | 26 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' |
20 | import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' | 27 | import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' |
21 | import { DateToggleComponent } from './date' | 28 | import { DateToggleComponent } from './date' |
@@ -23,7 +30,7 @@ import { FeedComponent } from './feeds' | |||
23 | import { LoaderComponent, SmallLoaderComponent } from './loaders' | 30 | import { LoaderComponent, SmallLoaderComponent } from './loaders' |
24 | import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' | 31 | import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' |
25 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' | 32 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' |
26 | import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService, LiveVideoService } from './video' | 33 | import { LiveVideoService, RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' |
27 | import { VideoCaptionService } from './video-caption' | 34 | import { VideoCaptionService } from './video-caption' |
28 | import { VideoChannelService } from './video-channel' | 35 | import { 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' | |||
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { RestExtractor } from '@app/core' | 4 | import { RestExtractor } from '@app/core' |
5 | import { VideoCreate, LiveVideo } from '@shared/models' | 5 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate } from '@shared/models' |
6 | import { environment } from '../../../../environments/environment' | 6 | import { 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 | } |