Skip to content

Commit

Permalink
Mark offline taps
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartkoopmann committed May 7, 2022
1 parent 5d47f33 commit 88d9944
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import horse.wtf.nzyme.taps.Tap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime;

import javax.inject.Inject;
import javax.ws.rs.*;
Expand Down Expand Up @@ -120,6 +121,7 @@ private TapDetailsResponse buildTapResponse(Tap tap) {
tap.memoryFree(),
tap.memoryUsed(),
tap.cpuLoad(),
tap.updatedAt().isAfter(DateTime.now().minusMinutes(2)),
tap.createdAt(),
tap.updatedAt(),
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public abstract class TapDetailsResponse {
@JsonProperty("cpu_load")
public abstract Double cpuLoad();

@JsonProperty("active")
public abstract Boolean active();

@JsonProperty("created_at")
public abstract DateTime createdAt();

Expand All @@ -42,7 +45,7 @@ public abstract class TapDetailsResponse {
@JsonProperty("buses")
public abstract List<BusDetailsResponse> buses();

public static TapDetailsResponse create(String name, DateTime localTime, TotalWithAverageResponse processedBytes, Long memoryTotal, Long memoryFree, Long memoryUsed, Double cpuLoad, DateTime createdAt, DateTime updatedAt, String description, List<BusDetailsResponse> buses) {
public static TapDetailsResponse create(String name, DateTime localTime, TotalWithAverageResponse processedBytes, Long memoryTotal, Long memoryFree, Long memoryUsed, Double cpuLoad, Boolean active, DateTime createdAt, DateTime updatedAt, String description, List<BusDetailsResponse> buses) {
return builder()
.name(name)
.localTime(localTime)
Expand All @@ -51,6 +54,7 @@ public static TapDetailsResponse create(String name, DateTime localTime, TotalWi
.memoryFree(memoryFree)
.memoryUsed(memoryUsed)
.cpuLoad(cpuLoad)
.active(active)
.createdAt(createdAt)
.updatedAt(updatedAt)
.description(description)
Expand Down Expand Up @@ -78,6 +82,8 @@ public abstract static class Builder {

public abstract Builder cpuLoad(Double cpuLoad);

public abstract Builder active(Boolean active);

public abstract Builder createdAt(DateTime createdAt);

public abstract Builder updatedAt(DateTime updatedAt);
Expand Down
8 changes: 6 additions & 2 deletions web-interface/src/components/taps/Buses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import Bus from "./Bus";

function Buses(props) {

if (!props.tap.active) {
return <div className="alert alert-danger">No recent data.</div>
}

return (
<div>
{Object.keys(props.buses).map(function (key, i) {
return <Bus key={"bus-" + i} bus={props.buses[i]} />
{Object.keys(props.tap.buses).map(function (key, i) {
return <Bus key={"bus-" + i} bus={props.tap.buses[i]} />
})}
</div>
)
Expand Down
2 changes: 2 additions & 0 deletions web-interface/src/components/taps/ChannelRow.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import numeral from "numeral";
import byteAverageToMbit from "../../util/Tools";

function ChannelRow(props) {

Expand All @@ -14,6 +15,7 @@ function ChannelRow(props) {
</td>
<td>
{numeral(c.throughput_bytes.average/10).format("0,0b")}/sec
({byteAverageToMbit(c.throughput_bytes.average)})
</td>
<td>
{numeral(c.errors.average/10).format("0,0")} errors/sec
Expand Down
5 changes: 4 additions & 1 deletion web-interface/src/components/taps/TapDetailsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Routes from "../../util/ApiRoutes";
import numeral from "numeral";
import byteAverageToMbit from "../../util/Tools";
import Buses from "./Buses";
import TapInactiveWarning from "./TapInactiveWarning";

const tapsService = new TapsService();

Expand Down Expand Up @@ -51,6 +52,8 @@ function TapDetailsPage() {
<h1>Tap "{tap.name}"</h1>
</div>

<TapInactiveWarning tap={tap} />

<div className="row mt-3">
<div className="col-md-4">
<div className="card">
Expand Down Expand Up @@ -121,7 +124,7 @@ function TapDetailsPage() {
<div className="card-body">
<h3>Buses &amp; Channels</h3>

<Buses buses={tap.buses} />
<Buses tap={tap} />
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions web-interface/src/components/taps/TapInactiveWarning.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";

function TapInactiveWarning(props) {

if (!props.tap.active) {
return (
<div className="alert alert-danger">
<i className="fa-solid fa-triangle-exclamation"></i> This tap has not recently reported data and is
offline. Some data you see on this page is likely outdated.
</div>
)
}

}

export default TapInactiveWarning;
9 changes: 8 additions & 1 deletion web-interface/src/components/taps/TapRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ function TapsRow(props) {

return (
<tr>
<td><a href={ApiRoutes.SYSTEM.TAPS.DETAILS(tap.name)}>{tap.name}</a></td>
<td>
<a href={ApiRoutes.SYSTEM.TAPS.DETAILS(tap.name)}>{tap.name}</a>

{tap.active ? "" :
<span>&nbsp;
<i className="fa-solid fa-triangle-exclamation text-danger" title="Tap is offline." />
</span>}
</td>
<td>{numeral(tap.processed_bytes.average/10).format('0 b')}/sec ({byteAverageToMbit(tap.processed_bytes.average)})</td>
<td>{numeral(tap.processed_bytes.total).format('0.0 b')}</td>
<td>{numeral(tap.cpu_load).format('0.0')}%</td>
Expand Down

0 comments on commit 88d9944

Please sign in to comment.