Skip to content

Commit

Permalink
Merge pull request #660 from votdev/issue_7036_handle_resize
Browse files Browse the repository at this point in the history
All components handle window resizing events incorrectly
  • Loading branch information
votdev authored Nov 13, 2023
2 parents 1b75d71 + d19bd84 commit 0b54117
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 101 deletions.
18 changes: 10 additions & 8 deletions src/routes/backingImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ class BackingImage extends React.Component {
}

componentDidMount() {
let height = document.getElementById('backingImageTable').offsetHeight - C.ContainerMarginHeight
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('backingImageTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('backingImageTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
}

uploadFile = (file, record) => {
Expand Down
24 changes: 10 additions & 14 deletions src/routes/backup/BackupList.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,19 @@ class List extends React.Component {
}

componentDidMount() {
let height = document.getElementById('backDetailTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('backDetailTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.onresize = () => {
this.props.dispatch({ type: 'app/changeNavbar' })
}
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('backDetailTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
}

fomartData = (data, key) => {
Expand Down
24 changes: 10 additions & 14 deletions src/routes/backup/BackupVolumeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,25 @@ class List extends React.Component {
}

componentDidMount() {
let height = document.getElementById('backTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('backTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
this.onResize()
window.addEventListener('resize', this.onResize)
window.addEventListener('keydown', this.onkeydown)
window.addEventListener('keyup', this.onkeyup)
}

componentWillUnmount() {
window.onresize = () => {
this.props.dispatch({ type: 'app/changeNavbar' })
}
window.removeEventListener('resize', this.onResize)
window.removeEventListener('keydown', this.onkeydown)
window.removeEventListener('keyup', this.onkeyup)
}

onResize = () => {
const height = document.getElementById('backTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
}

fomartData = (data, key) => {
if (this.isJson(data)) {
let obj = JSON.parse(data)
Expand Down
24 changes: 10 additions & 14 deletions src/routes/host/HostList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,8 @@ class List extends React.Component {
}

componentDidMount() {
let height = document.getElementById('hostTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('hostTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
this.onResize()
window.addEventListener('resize', this.onResize)
window.addEventListener('keydown', this.onkeydown)
window.addEventListener('keyup', this.onkeyup)
}
Expand All @@ -57,9 +48,14 @@ class List extends React.Component {
})
window.removeEventListener('keydown', this.onkeydown)
window.removeEventListener('keyup', this.onkeyup)
window.onresize = () => {
this.props.dispatch({ type: 'app/changeNavbar' })
}
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('hostTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
}

onkeyup = () => {
Expand Down
18 changes: 10 additions & 8 deletions src/routes/instanceManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ class InstanceManager extends React.Component {
}

componentDidMount() {
let height = document.getElementById('instanceManagerTable').offsetHeight - C.ContainerMarginHeight
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('instanceManagerTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('instanceManagerTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
}

render() {
Expand Down
18 changes: 10 additions & 8 deletions src/routes/orphanedData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ class OrphanedData extends React.Component {
}

componentDidMount() {
let height = document.getElementById('orphanedDataTable').offsetHeight - C.ContainerMarginHeight
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('orphanedDataTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('orphanedDataTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
}

onResourceTypeChange = () => {
Expand Down
18 changes: 10 additions & 8 deletions src/routes/recurringJob/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ class RecurringJob extends React.Component {
}

componentDidMount() {
let height = document.getElementById('recurringJobTable').offsetHeight - C.ContainerMarginHeight
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const height = document.getElementById('recurringJobTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('recurringJobTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
}

showCreateRecurringJobModal =() => {
Expand Down
24 changes: 11 additions & 13 deletions src/routes/systemBackups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,24 @@ class SystemBackups extends React.Component {
}

componentDidMount() {
let systemBackupsHeight = document.getElementById('systemBackupsTable').offsetHeight - C.ContainerMarginHeight - 60
let systemRestoresHeight = document.getElementById('systemRestoresTable').offsetHeight - C.ContainerMarginHeight + 5
this.onResize()
window.addEventListener('resize', this.onResize)
}

componentWillUnmount() {
window.removeEventListener('resize', this.onResize)
}

onResize = () => {
const systemBackupsHeight = document.getElementById('systemBackupsTable').offsetHeight - C.ContainerMarginHeight - 60
const systemRestoresHeight = document.getElementById('systemRestoresTable').offsetHeight - C.ContainerMarginHeight + 5
this.setState({
...this.state,
systemBackupsHeight,
systemRestoresHeight,
})
window.onresize = () => {
systemBackupsHeight = document.getElementById('systemBackupsTable').offsetHeight - C.ContainerMarginHeight - 60
systemRestoresHeight = document.getElementById('systemRestoresTable').offsetHeight - C.ContainerMarginHeight + 5
this.setState({
...this.state,
systemBackupsHeight,
systemRestoresHeight,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
}


render() {
const { loading, dispatch, location } = this.props
const me = this
Expand Down
24 changes: 10 additions & 14 deletions src/routes/volume/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,25 @@ class Volume extends React.Component {
}

componentDidMount() {
let height = document.getElementById('volumeTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
window.onresize = () => {
height = document.getElementById('volumeTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
this.props.dispatch({ type: 'app/changeNavbar' })
}
this.onResize()
window.addEventListener('resize', this.onResize)
window.addEventListener('keydown', this.onkeydown)
window.addEventListener('keyup', this.onkeyup)
}

componentWillUnmount() {
window.onresize = () => {
this.props.dispatch({ type: 'app/changeNavbar' })
}
window.removeEventListener('resize', this.onResize)
window.removeEventListener('keydown', this.onkeydown)
window.removeEventListener('keyup', this.onkeyup)
}

onResize = () => {
const height = document.getElementById('volumeTable').offsetHeight - C.ContainerMarginHeight
this.setState({
height,
})
}

onkeyup = () => {
this.setState({
...this.state,
Expand Down

0 comments on commit 0b54117

Please sign in to comment.