add mock-up data
This commit is contained in:
11
src/App.js
11
src/App.js
@@ -26,7 +26,16 @@ class App extends Component {
|
|||||||
totalChecks: 0,
|
totalChecks: 0,
|
||||||
totalTransfers: 0,
|
totalTransfers: 0,
|
||||||
transferTime: 0,
|
transferTime: 0,
|
||||||
transfers: 0
|
transfers: 0,
|
||||||
|
transferring: [
|
||||||
|
{
|
||||||
|
speed: 23534245,
|
||||||
|
group: "job/1",
|
||||||
|
size: 23457826345,
|
||||||
|
eta: 3600,
|
||||||
|
name: "a very very very long absurdly unneccesarily long name this is if you cant tell"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
remotes: [],
|
remotes: [],
|
||||||
mounts: [],
|
mounts: [],
|
||||||
|
|||||||
@@ -8,25 +8,29 @@ class Job extends Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
this.state = {
|
||||||
jobstatus: {
|
|
||||||
progress: 0,
|
|
||||||
eta: 0
|
|
||||||
},
|
|
||||||
stats: {
|
stats: {
|
||||||
|
elapsedTime: 0,
|
||||||
|
eta: 3600,
|
||||||
|
bytes: 1024 * 1024 * 128,
|
||||||
|
totalBytes: 1024 * 1024 * 1024,
|
||||||
|
transferring: [
|
||||||
|
{
|
||||||
|
speed: 23534245,
|
||||||
|
group: "job/1",
|
||||||
|
size: 23457826345,
|
||||||
|
eta: 3600,
|
||||||
|
name: "a very very very long absurdly unneccesarily long name this is if you cant tell"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
jobid: 0
|
jobid: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
this.decreaseEtaInterval = undefined
|
this.decreaseEtaInterval = undefined
|
||||||
this.fetchStatsInterval = undefined
|
this.fetchStatsInterval = undefined
|
||||||
this.fetchJobInterval = undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
// this.setState({ jobid: this.props.fileTransfers[0].group.replace(/\D/g, '') })
|
|
||||||
|
|
||||||
this.fetchJobInfo(this.props.fileTransfers[0].group.replace(/\D/g, ''))
|
|
||||||
this.fetchStats()
|
this.fetchStats()
|
||||||
|
|
||||||
if (this.decreaseEtaInterval === undefined) this.decreaseEtaInterval = setInterval(() => {
|
if (this.decreaseEtaInterval === undefined) this.decreaseEtaInterval = setInterval(() => {
|
||||||
@@ -40,13 +44,11 @@ class Job extends Component {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
if (this.fetchStatsInterval === undefined) this.fetchStatsInterval = setInterval(this.fetchStats, 5 * 1000)
|
if (this.fetchStatsInterval === undefined) this.fetchStatsInterval = setInterval(this.fetchStats, 5 * 1000)
|
||||||
if (this.fetchJobInterval === undefined) this.fetchJobInterval = setInterval(this.fetchJobInfo, 30 * 1000)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount = () => {
|
componentWillUnmount = () => {
|
||||||
clearInterval(this.decreaseEtaInterval)
|
clearInterval(this.decreaseEtaInterval)
|
||||||
// clearInterval(this.fetchStatsInterval)
|
clearInterval(this.fetchStatsInterval)
|
||||||
clearInterval(this.fetchJobInterval)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchStats = () => {
|
fetchStats = () => {
|
||||||
@@ -64,23 +66,6 @@ class Job extends Component {
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchJobInfo = id => {
|
|
||||||
if (!id) id = this.state.jobid
|
|
||||||
|
|
||||||
return API.request({
|
|
||||||
url: "/job/status",
|
|
||||||
data: {
|
|
||||||
jobid: this.props.jobid
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (typeof response.data !== "object") throw new Error("invalid response")
|
|
||||||
|
|
||||||
this.setState({ jobstatus: response.data })
|
|
||||||
})
|
|
||||||
.catch(() => {})
|
|
||||||
}
|
|
||||||
|
|
||||||
stopJob = () => {
|
stopJob = () => {
|
||||||
return API.request({
|
return API.request({
|
||||||
url: "/job/stop",
|
url: "/job/stop",
|
||||||
@@ -131,7 +116,7 @@ class Job extends Component {
|
|||||||
<p> Time left: </p>
|
<p> Time left: </p>
|
||||||
<p> { secondsToTimeString(stats.eta) } </p>
|
<p> { secondsToTimeString(stats.eta) } </p>
|
||||||
<p> Progress: </p>
|
<p> Progress: </p>
|
||||||
<p> { ((stats.bytes / stats.totalBytes) * 100).toFixed(2) } % </p>
|
<p> { ((stats.bytes / stats.totalBytes) * 100 || 0).toFixed(2) } % </p>
|
||||||
<span/>
|
<span/>
|
||||||
|
|
||||||
<StopButton onClick={this.stopJob}> Cancel </StopButton>
|
<StopButton onClick={this.stopJob}> Cancel </StopButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user