forked from p15670423/monkey
UI: Compare version numbers in VersionComponent
This commit is contained in:
parent
f13d55d89a
commit
ae468f9832
|
@ -7,8 +7,8 @@ class VersionComponent extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
currentVersion: undefined,
|
versionNumber: undefined,
|
||||||
newerVersion: undefined,
|
latestVersion: undefined,
|
||||||
downloadLink: undefined
|
downloadLink: undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,19 +18,27 @@ class VersionComponent extends React.Component {
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.setState({
|
this.setState({
|
||||||
currentVersion: res['current_version'],
|
versionNumber: res['version_number'],
|
||||||
newerVersion: res['newer_version'],
|
latestVersion: res['latest_version'],
|
||||||
downloadLink: res['download_link']
|
downloadLink: res['download_link']
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newerVersionAvailable() {
|
||||||
|
const semverGt = require('semver/functions/gt');
|
||||||
|
if(this.state.latestVersion !== undefined && this.state.versionNumber !== undefined) {
|
||||||
|
return semverGt(this.state.latestVersion, this.state.versionNumber);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="version-text text-center">
|
<div className="version-text text-center">
|
||||||
Infection Monkey Version: {this.state.currentVersion}
|
Infection Monkey Version: {this.state.versionNumber}
|
||||||
{
|
{
|
||||||
this.state.newerVersion ?
|
this.newerVersionAvailable() ?
|
||||||
<div>
|
<div>
|
||||||
<b>Newer version available!</b>
|
<b>Newer version available!</b>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
Loading…
Reference in New Issue