Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #872 from replicatedhq/move-get-online-install-sta…
…tus-to-go move getOnlineInstallStatus query to go
- Loading branch information
Showing
5 changed files
with
113 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,71 @@ | ||
import React from "react" | ||
import { withRouter } from "react-router-dom"; | ||
import { compose, withApollo, graphql} from "react-apollo"; | ||
import { getOnlineInstallStatus } from "../queries/AppsQueries"; | ||
import { Utilities } from "@src/utilities/utilities"; | ||
import { Repeater } from "@src/utilities/repeater"; | ||
import "@src/scss/components/AirgapUploadProgress.scss"; | ||
|
||
function LicenseUploadProgress(props) { | ||
const { getOnlineInstallStatus } = props.data; | ||
class LicenseUploadProgress extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
props.data?.startPolling(2000); | ||
this.state = { | ||
installStatus: "", | ||
currentMessage: "", | ||
getOnlineInstallStatusJob: new Repeater(), | ||
}; | ||
} | ||
|
||
const statusMsg = getOnlineInstallStatus?.currentMessage; | ||
componentDidMount() { | ||
this.state.getOnlineInstallStatusJob.start(this.getOnlineInstallStatus, 2000); | ||
} | ||
|
||
let statusDiv = ( | ||
<div className={`u-marginTop--10 u-lineHeight--medium u-textAlign--center`}> | ||
<p className="u-color--tundora u-fontSize--normal u-fontWeight--bold u-marginBottom--10 u-paddingBottom--5">{statusMsg}</p> | ||
<p className="u-fontSize--small u-color--dustyGray u-fontWeight--medium">This may take a while depending on your network connection.</p> | ||
</div> | ||
); | ||
componentWillUnmount() { | ||
this.state.getOnlineInstallStatusJob.stop(); | ||
} | ||
|
||
return ( | ||
<div className="AirgapUploadProgress--wrapper flex1 flex-column alignItems--center justifyContent--center"> | ||
<div className="flex1 flex-column alignItems--center justifyContent--center u-color--tuna"> | ||
<p className="u-marginTop--10 u-paddingTop--5 u-marginBottom--5 u-fontSize--header u-color--tuna u-fontWeight--bold">Installing your license</p> | ||
<div className="u-marginTop--20"> | ||
<div className="progressbar medium"> | ||
<div id="myBar" className="progressbar-meter" style={{width: "0%"}}></div> | ||
getOnlineInstallStatus = async () => { | ||
try { | ||
const res = await fetch(`${window.env.API_ENDPOINT}/app/online/status`, { | ||
headers: { | ||
"Authorization": Utilities.getToken(), | ||
"Content-Type": "application/json", | ||
}, | ||
method: "GET", | ||
}); | ||
|
||
const response = await res.json(); | ||
|
||
this.setState({ | ||
installStatus: response.installStatus, | ||
currentMessage: response.currentMessage, | ||
}); | ||
} catch(err) { | ||
console.log(err); | ||
} | ||
} | ||
|
||
render() { | ||
let statusDiv = ( | ||
<div className={`u-marginTop--10 u-lineHeight--medium u-textAlign--center`}> | ||
<p className="u-color--tundora u-fontSize--normal u-fontWeight--bold u-marginBottom--10 u-paddingBottom--5">{this.state.currentMessage}</p> | ||
<p className="u-fontSize--small u-color--dustyGray u-fontWeight--medium">This may take a while depending on your network connection.</p> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="AirgapUploadProgress--wrapper flex1 flex-column alignItems--center justifyContent--center"> | ||
<div className="flex1 flex-column alignItems--center justifyContent--center u-color--tuna"> | ||
<p className="u-marginTop--10 u-paddingTop--5 u-marginBottom--5 u-fontSize--header u-color--tuna u-fontWeight--bold">Installing your license</p> | ||
<div className="u-marginTop--20"> | ||
<div className="progressbar medium"> | ||
<div id="myBar" className="progressbar-meter" style={{width: "0%"}}></div> | ||
</div> | ||
</div> | ||
{statusDiv} | ||
</div> | ||
{statusDiv} | ||
</div> | ||
</div> | ||
); | ||
); | ||
} | ||
} | ||
|
||
export default compose( | ||
withRouter, | ||
withApollo, | ||
graphql(getOnlineInstallStatus, { | ||
options: () => { | ||
return { | ||
fetchPolicy: "network-only" | ||
}; | ||
} | ||
}) | ||
)(LicenseUploadProgress); | ||
export default withRouter(LicenseUploadProgress); |