mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Userland: Make representation of 'null' IPv4-address friendlier
Show an empty column rather than 'null' in SystemMonitor and show 'no IP' in the network applet if the adapter has no IPv4-address configured.
This commit is contained in:
parent
3a40287776
commit
df6db8b8cc
2 changed files with 5 additions and 2 deletions
|
@ -122,7 +122,7 @@ private:
|
|||
int connected_adapters = 0;
|
||||
json.value().as_array().for_each([&adapter_info, include_loopback, &connected_adapters](auto& value) {
|
||||
auto& if_object = value.as_object();
|
||||
auto ip_address = if_object.get("ipv4_address").to_string();
|
||||
auto ip_address = if_object.get("ipv4_address").as_string_or("no IP");
|
||||
auto ifname = if_object.get("name").to_string();
|
||||
auto link_up = if_object.get("link_up").as_bool();
|
||||
auto link_speed = if_object.get("link_speed").to_i32();
|
||||
|
|
|
@ -56,7 +56,10 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
return String::formatted("{} Mb/s {}-duplex", object.get("link_speed").to_i32(),
|
||||
object.get("link_full_duplex").as_bool() ? "full" : "half");
|
||||
});
|
||||
net_adapters_fields.empend("ipv4_address", "IPv4", Gfx::TextAlignment::CenterLeft);
|
||||
net_adapters_fields.empend("IPv4", Gfx::TextAlignment::CenterLeft,
|
||||
[this](JsonObject const& object) -> String {
|
||||
return object.get("ipv4_address").as_string_or("");
|
||||
});
|
||||
net_adapters_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight);
|
||||
net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
|
||||
net_adapters_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight);
|
||||
|
|
Loading…
Add table
Reference in a new issue