Merge pull request #46 from timothyle97/feat-update_online_parsing

Update Peer Online/Offline Parsing and Add Peer Data
This commit is contained in:
dec0dOS 2021-12-19 19:01:58 +03:00 committed by GitHub
commit 504ce7f4b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 13 deletions

View file

@ -37,13 +37,21 @@ async function getMemberAdditionalData(data) {
let peerData = {};
if (peer) {
peerData.latency = peer.latency;
peerData.online = peer.latency !== -1;
if (peer.latency !== -1)
peerData.online = 1;
if (peer.latency == -1)
peerData.online = 2;
peerData.clientVersion = peer.version;
if (peer.paths[0]) {
peerData.lastOnline = peer.paths[0].lastReceive;
peerData.physicalAddress = peer.paths[0].address.split("/")[0];
peerData.physicalPort = peer.paths[0].address.split("/")[1];
}
}
else
{
peerData.online = 0;
}
delete data.lastAuthorizedCredential;
delete data.lastAuthorizedCredentialType;

View file

@ -101,19 +101,46 @@ function NetworkMembers({ network }) {
name: "Peer status",
minWidth: "100px",
cell: (row) =>
row.online ? (
<Typography style={{ color: "#008000" }}>
{"ONLINE (v" +
row.config.vMajor +
"." +
row.config.vMinor +
"." +
row.config.vRev +
")"}
</Typography>
) : (
(row.online === 0) ? (
<Typography color="error">OFFLINE</Typography>
),
) : ( (row.online === 1) ? (
<Typography style={{ color: "#008000" }}>
{"ONLINE (v" +
row.config.vMajor +
"." +
row.config.vMinor +
"." +
row.config.vRev +
")"}
</Typography>
) : (
<Typography style={{ color: "#f1c232" }}>
{"RELAYED (v" +
row.config.vMajor +
"." +
row.config.vMinor +
"." +
row.config.vRev +
")"}
</Typography>
)),
},
{
id: "physicalip",
name: "Physical IP / Latency",
minWidth: "220px",
cell: (row) =>
(row.online === 1) ? (
<p>
{row.physicalAddress +
"/" +
row.physicalPort}<br />{
"(" +
row.latency +
" ms)"}
</p>
) : (""),
},
{
id: "delete",