Skip to content

Commit

Permalink
About: better upgrade cycle UI
Browse files Browse the repository at this point in the history
  • Loading branch information
stephendade committed May 18, 2022
1 parent d9421a5 commit 2be7b3f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"lint": "eslint .",
"eject": "react-scripts eject",
"server": "node-env-run server --exec nodemon | pino-colada",
"service": "node-env-run server",
"dev": "run-p server start",
"version": "auto-changelog -p --commit-limit false && git add CHANGELOG.md"
},
Expand Down
2 changes: 1 addition & 1 deletion rpanion.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
Environment=PORT=3000
WorkingDirectory=/home/pi/Rpanion-server
ExecStart=/usr/bin/npm run server
ExecStart=/usr/bin/npm run service
Restart=on-failure
User=pi

Expand Down
4 changes: 4 additions & 0 deletions server/aboutInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,27 @@ function updateRS (io) {
// update Rpanion-server
console.log('Upgrading')
winston.info('Upgrading')
io.sockets.emit('upgradeStatus', 'InProgress')
const ug = spawn('bash', ['./deploy/upgrade.sh'], { shell: true })
ug.stdout.on('data', function (data) {
console.log('stdout: ' + data.toString())
winston.info('stdout: ' + data.toString())
io.sockets.emit('upgradeText', data.toString())
io.sockets.emit('upgradeStatus', 'InProgress')
})

ug.stderr.on('data', function (data) {
console.log('Upgrade fail: ' + data.toString())
winston.info('Upgrade fail: ' + data.toString())
io.sockets.emit('upgradeText', data.toString())
io.sockets.emit('upgradeStatus', 'InProgress')
})

ug.on('exit', function (code) {
console.log('Upgrade complete: ' + code.toString())
winston.info('Upgrade complete: ' + code.toString())
io.sockets.emit('upgradeText', '---Upgrade Complete (' + code.toString() + ')---')
io.sockets.emit('upgradeStatus', 'Complete')
})
}

Expand Down
14 changes: 12 additions & 2 deletions src/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class AboutPage extends basePage {
infoMessage: null,
showModal: false,
showModalResult: "",
UpgradeStatus: ''
UpgradeStatus: '',
UpgradeIntStat: ''
}

this.upgradeTextContainer = React.createRef();
Expand All @@ -30,6 +31,9 @@ class AboutPage extends basePage {
const prevText = this.state.UpgradeStatus
this.setState({ UpgradeStatus: (prevText + msg) })
}.bind(this));
this.socket.on('upgradeStatus', function (msg) {
this.setState({ UpgradeIntStat: msg })
}.bind(this));
this.socket.on('reconnect', function () {
//refresh state
this.componentDidMount();
Expand Down Expand Up @@ -104,8 +108,14 @@ class AboutPage extends basePage {
<p><Button size="sm" onClick={this.handleUpdateMaster}>Upgrade to lastest Github master</Button></p>
<p><Button size="sm" onClick={this.confirmShutdown}>Shutdown Companion Computer</Button></p>

<div style={{ display: (this.state.UpgradeStatus !== '') ? "block" : "none" }}>
<div style={{ display: (this.state.UpgradeIntStat === 'InProgress' || this.state.UpgradeIntStat === 'Complete') ? "block" : "none" }}>
<h2>Upgrade Status</h2>
<div style={{ display: (this.state.UpgradeIntStat === 'InProgress') ? "block" : "none" }}>
<p>Upgrade is in progress ... please wait</p>
</div>
<div style={{ display: (this.state.UpgradeIntStat === 'Complete') ? "block" : "none" }}>
<p>Upgrade complete</p>
</div>
<textarea ref={this.upgradeTextContainer} readOnly rows="20" cols="60" value={this.state.UpgradeStatus}></textarea>
</div>

Expand Down

0 comments on commit 2be7b3f

Please sign in to comment.