Show list of addresses

This commit is contained in:
Ildar Kamalov
2019-02-04 17:13:59 +03:00
committed by Eugene Bujak
parent f379d34813
commit 31b855f9ab
9 changed files with 166 additions and 72 deletions

View File

@@ -0,0 +1,60 @@
import React from 'react';
import PropTypes from 'prop-types';
import { getIpList, getAddress } from '../../helpers/helpers';
const AddressList = (props) => {
let webAddress = getAddress(props.address, props.port);
let dnsAddress = getAddress(props.address, props.port, true);
if (props.address === '0.0.0.0') {
return getIpList(props.interfaces).map((ip) => {
webAddress = getAddress(ip, props.port);
dnsAddress = getAddress(ip, props.port, true);
if (props.isDns) {
return (
<li key={ip}>
<strong>
{dnsAddress}
</strong>
</li>
);
}
return (
<li key={ip}>
<a href={webAddress}>
{webAddress}
</a>
</li>
);
});
}
if (props.isDns) {
return (
<strong>
{dnsAddress}
</strong>
);
}
return (
<a href={webAddress}>
{webAddress}
</a>
);
};
AddressList.propTypes = {
interfaces: PropTypes.object.isRequired,
address: PropTypes.string.isRequired,
port: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
isDns: PropTypes.bool,
};
export default AddressList;