fix bug that makes the dashboard blank
This commit is contained in:
parent
ecd56b9ced
commit
7477319a68
50
src/App.js
50
src/App.js
@ -81,15 +81,15 @@ class App extends Component {
|
||||
this.fetchVersionInfo()
|
||||
this.fetchInfos()
|
||||
|
||||
// get server stats every 5 seconds
|
||||
if (this.infoInterval === undefined) this.infoInterval = setInterval(this.fetchInfos, 5000)
|
||||
// get server stats every 1 seconds
|
||||
if (this.infoInterval === undefined) this.infoInterval = setInterval(this.fetchInfos, 1000)
|
||||
|
||||
// make the view look more responsive by counting every second
|
||||
if (this.timeInterval === undefined) this.timeInterval = setInterval(() => {
|
||||
let { stats } = this.state
|
||||
stats.elapsedTime++
|
||||
this.setState({ stats })
|
||||
}, 1000)
|
||||
// if (this.timeInterval === undefined) this.timeInterval = setInterval(() => {
|
||||
// let { stats } = this.state
|
||||
// stats.elapsedTime++
|
||||
// this.setState({ stats })
|
||||
// }, 1000)
|
||||
|
||||
// check api status every second
|
||||
if (this.apiInterval === undefined) this.apiInterval = setInterval(this.checkApiEndpoint, 1000)
|
||||
@ -321,20 +321,38 @@ class App extends Component {
|
||||
* @returns {Job}
|
||||
*/
|
||||
renderActiveJobs = () => {
|
||||
if (typeof this.state.stats.transferring !== "object") return;
|
||||
const transferring = this.state.stats.transferring
|
||||
|
||||
let activeJobIds = []
|
||||
// If it's not an array or empty, render nothing
|
||||
if (!Array.isArray(transferring) || transferring.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const { transferring } = this.state.stats
|
||||
|
||||
transferring.forEach(v => {
|
||||
if (!activeJobIds.includes(v.group)) activeJobIds.push(v.group)
|
||||
})
|
||||
// Collect unique, defined group IDs
|
||||
const activeJobIds = Array.from(
|
||||
new Set(
|
||||
transferring
|
||||
.map(v => v.group)
|
||||
.filter(g => typeof g === 'string')
|
||||
)
|
||||
)
|
||||
|
||||
return activeJobIds.map(group => {
|
||||
// Protection: convert to string
|
||||
const safeGroup = String(group)
|
||||
const jobid = safeGroup.replace(/\D/g, '')
|
||||
|
||||
// All transfers in this group
|
||||
const fileTransfers = transferring.filter(v => v.group === group)
|
||||
|
||||
return <Job key={group} fileTransfers={fileTransfers} jobid={group.replace(/\D/g, '')} refreshStats={this.fetchInfos} />
|
||||
return (
|
||||
<Job
|
||||
key={safeGroup}
|
||||
fileTransfers={fileTransfers}
|
||||
jobid={jobid}
|
||||
refreshStats={this.fetchInfos}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@ -363,7 +381,7 @@ class App extends Component {
|
||||
|
||||
<HeaderContainer>
|
||||
<LogoContainer>
|
||||
<img src="/favicon-64x64.png" alt="Rclone WebUI logo" width="64" height="64" />
|
||||
<img src="/favicon-64x64.png" alt="Rclone Dashboard" width="64" height="64" />
|
||||
<h1> Rclone Dashboard </h1>
|
||||
</LogoContainer>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user