diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-27 15:59:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:04:06 +0200 |
commit | 11b8762f9c815930982599f4ff90c0db60eaf0ca (patch) | |
tree | bfca3003c619559284e00fe804d080e66c3ede12 /client/src/app/shared | |
parent | c9d5c64f98c1f1fe7950de60c58edeaf3ace070d (diff) | |
download | PeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.tar.gz PeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.tar.zst PeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.zip |
Add start at checkbox in share modal
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/misc/utils.ts | 13 | ||||
-rw-r--r-- | client/src/app/shared/video/video.model.ts | 16 |
2 files changed, 15 insertions, 14 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index 018271efe..c8b7ebc67 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts | |||
@@ -51,6 +51,18 @@ function dateToHuman (date: string) { | |||
51 | return datePipe.transform(date, 'medium') | 51 | return datePipe.transform(date, 'medium') |
52 | } | 52 | } |
53 | 53 | ||
54 | function durationToString (duration: number) { | ||
55 | const hours = Math.floor(duration / 3600) | ||
56 | const minutes = Math.floor((duration % 3600) / 60) | ||
57 | const seconds = duration % 60 | ||
58 | |||
59 | const minutesPadding = minutes >= 10 ? '' : '0' | ||
60 | const secondsPadding = seconds >= 10 ? '' : '0' | ||
61 | const displayedHours = hours > 0 ? hours.toString() + ':' : '' | ||
62 | |||
63 | return displayedHours + minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString() | ||
64 | } | ||
65 | |||
54 | function immutableAssign <A, B> (target: A, source: B) { | 66 | function immutableAssign <A, B> (target: A, source: B) { |
55 | return Object.assign({}, target, source) | 67 | return Object.assign({}, target, source) |
56 | } | 68 | } |
@@ -114,6 +126,7 @@ function sortBy (obj: any[], key1: string, key2?: string) { | |||
114 | 126 | ||
115 | export { | 127 | export { |
116 | sortBy, | 128 | sortBy, |
129 | durationToString, | ||
117 | objectToUrlEncoded, | 130 | objectToUrlEncoded, |
118 | getParameterByName, | 131 | getParameterByName, |
119 | populateAsyncUserVideoChannels, | 132 | populateAsyncUserVideoChannels, |
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index d80c10459..80794faa6 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts | |||
@@ -2,7 +2,7 @@ import { User } from '../' | |||
2 | import { Video as VideoServerModel, VideoPrivacy, VideoState } from '../../../../../shared' | 2 | import { Video as VideoServerModel, VideoPrivacy, VideoState } from '../../../../../shared' |
3 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 3 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
4 | import { VideoConstant } from '../../../../../shared/models/videos/video-constant.model' | 4 | import { VideoConstant } from '../../../../../shared/models/videos/video-constant.model' |
5 | import { getAbsoluteAPIUrl } from '../misc/utils' | 5 | import { durationToString, getAbsoluteAPIUrl } from '../misc/utils' |
6 | import { peertubeTranslate, ServerConfig } from '../../../../../shared/models' | 6 | import { peertubeTranslate, ServerConfig } from '../../../../../shared/models' |
7 | import { Actor } from '@app/shared/actor/actor.model' | 7 | import { Actor } from '@app/shared/actor/actor.model' |
8 | import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model' | 8 | import { VideoScheduleUpdate } from '../../../../../shared/models/videos/video-schedule-update.model' |
@@ -70,18 +70,6 @@ export class Video implements VideoServerModel { | |||
70 | return '/videos/watch/' + videoUUID | 70 | return '/videos/watch/' + videoUUID |
71 | } | 71 | } |
72 | 72 | ||
73 | private static createDurationString (duration: number) { | ||
74 | const hours = Math.floor(duration / 3600) | ||
75 | const minutes = Math.floor((duration % 3600) / 60) | ||
76 | const seconds = duration % 60 | ||
77 | |||
78 | const minutesPadding = minutes >= 10 ? '' : '0' | ||
79 | const secondsPadding = seconds >= 10 ? '' : '0' | ||
80 | const displayedHours = hours > 0 ? hours.toString() + ':' : '' | ||
81 | |||
82 | return displayedHours + minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString() | ||
83 | } | ||
84 | |||
85 | constructor (hash: VideoServerModel, translations = {}) { | 73 | constructor (hash: VideoServerModel, translations = {}) { |
86 | const absoluteAPIUrl = getAbsoluteAPIUrl() | 74 | const absoluteAPIUrl = getAbsoluteAPIUrl() |
87 | 75 | ||
@@ -95,7 +83,7 @@ export class Video implements VideoServerModel { | |||
95 | this.state = hash.state | 83 | this.state = hash.state |
96 | this.description = hash.description | 84 | this.description = hash.description |
97 | this.duration = hash.duration | 85 | this.duration = hash.duration |
98 | this.durationLabel = Video.createDurationString(hash.duration) | 86 | this.durationLabel = durationToString(hash.duration) |
99 | this.id = hash.id | 87 | this.id = hash.id |
100 | this.uuid = hash.uuid | 88 | this.uuid = hash.uuid |
101 | this.isLocal = hash.isLocal | 89 | this.isLocal = hash.isLocal |