1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

fetch faucet

This commit is contained in:
Matthias Kretschmann 2019-06-18 13:37:38 +02:00
parent d92c3e92f4
commit 15ebb34931
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 17 additions and 16 deletions

View File

@ -82,19 +82,16 @@ const VersionTable = ({ data }: { data: VersionNumbersState }) => (
<tr> <tr>
<td> <td>
<a <a
href={ href={`https://github.com/oceanprotocol/${slugify(
value.name && value.name || value.software
`https://github.com/oceanprotocol/${slugify( )}`}
value.name
)}`
}
> >
<strong>{value.name}</strong> <strong>{value.name}</strong>
</a> </a>
</td> </td>
<td> <td>
<VersionNumber <VersionNumber
name={value.name} name={value.name || value.software}
version={value.version} version={value.version}
status={value.status} status={value.status}
network={value.network} network={value.network}

View File

@ -8,7 +8,7 @@ import axios from 'axios'
import { version } from '../../../../package.json' import { version } from '../../../../package.json'
import styles from './index.module.scss' import styles from './index.module.scss'
// import { faucetUri } from '../../../config' import { faucetUri } from '../../../config'
import { User } from '../../../context' import { User } from '../../../context'
import VersionTable from './VersionTable' import VersionTable from './VersionTable'
@ -73,6 +73,7 @@ export default class VersionNumbers extends PureComponent<
public componentDidMount() { public componentDidMount() {
this.getOceanVersions() this.getOceanVersions()
this.getFaucetVersion()
} }
public componentWillUnmount() { public componentWillUnmount() {
@ -81,28 +82,24 @@ export default class VersionNumbers extends PureComponent<
private async getOceanVersions() { private async getOceanVersions() {
const { ocean } = this.context const { ocean } = this.context
// wait until ocean object is properly populated // wait until ocean object is properly populated
if (ocean.versions === undefined) return if (ocean.versions === undefined) return
const response = await ocean.versions.get() const response = await ocean.versions.get()
const { squid, brizo, aquarius, status } = response const { squid, brizo, aquarius, status } = response
// const faucet = await this.getData(faucetUri)
this.setState({ this.setState({
commons: { ...this.state.commons }, ...this.state,
squid, squid,
brizo, brizo,
aquarius, aquarius,
status status
// faucet
}) })
} }
private async getData(uri: string) { private async getFaucetVersion() {
try { try {
const response = await axios.get(uri, { const response = await axios.get(faucetUri, {
headers: { Accept: 'application/json' }, headers: { Accept: 'application/json' },
cancelToken: this.signal.token cancelToken: this.signal.token
}) })
@ -110,7 +107,14 @@ export default class VersionNumbers extends PureComponent<
// fail silently // fail silently
if (response.status !== 200) return if (response.status !== 200) return
return response.data this.setState({
...this.state,
faucet: {
...this.state.faucet,
version: response.data.version,
status: OceanPlatformTechStatus.Working
}
})
} catch (error) { } catch (error) {
!axios.isCancel(error) && Logger.error(error.message) !axios.isCancel(error) && Logger.error(error.message)
} }