Merge "Be more specific with remaining time"
This commit is contained in:
commit
69be4dfa23
|
@ -16,7 +16,11 @@ import * as React from 'react'
|
|||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import * as moment from 'moment'
|
||||
|
||||
const SECOND = 1000
|
||||
const MINUTE = SECOND * 60
|
||||
const HOUR = MINUTE * 60
|
||||
const DAY = HOUR * 24
|
||||
|
||||
|
||||
class ChangePanel extends React.Component {
|
||||
|
@ -193,13 +197,36 @@ class ChangePanel extends React.Component {
|
|||
let className
|
||||
let progressWidth = progressPercent
|
||||
let title = ''
|
||||
let remaining = remainingTime
|
||||
if (Number.isNaN(progressPercent)) {
|
||||
progressWidth = 100
|
||||
progressPercent = 0
|
||||
className = 'progress-bar-striped progress-bar-animated'
|
||||
}
|
||||
if (remainingTime !== null) {
|
||||
title = 'estimated time remaining ' + moment.duration(remainingTime, 'milliseconds').humanize()
|
||||
if (remaining !== null) {
|
||||
title = 'Estimated time remaining: '
|
||||
if (remaining < MINUTE) {
|
||||
title = title + 'less than a minute'
|
||||
} else {
|
||||
let days = 0
|
||||
let hours = 0
|
||||
let minutes = 0
|
||||
|
||||
days = Math.trunc(remaining/DAY)
|
||||
remaining = Math.trunc(remaining%DAY)
|
||||
hours = Math.trunc(remaining/HOUR)
|
||||
remaining = Math.trunc(remaining%HOUR)
|
||||
minutes = Math.trunc(remaining/MINUTE)
|
||||
if (days > 0) {
|
||||
title = title + days + ' days '
|
||||
}
|
||||
if (hours > 0) {
|
||||
title = title + hours + ' hours '
|
||||
}
|
||||
if (minutes > 0) {
|
||||
title = title + minutes + ' minutes '
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue