Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade inspect table #442

Merged
merged 29 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
944bff5
feat: defined widths for each inspect table's column and clip text wh…
GyulyVGC Jan 23, 2024
8e6c740
feat: search filters for each inspect table column (WIP)
GyulyVGC Jan 25, 2024
b27ef6d
feat: completely renew inspect table sort strategy
GyulyVGC Jan 25, 2024
c20d6f6
correctly represent bytes strings
GyulyVGC Jan 25, 2024
74552ba
minor fixes
GyulyVGC Jan 25, 2024
1fb31f8
country is now at the left in inspect table
GyulyVGC Jan 25, 2024
b26dd2d
moved country out of inspect table
GyulyVGC Jan 26, 2024
a29c176
cleaned get_searched_entries filter code and fixed some lints
GyulyVGC Jan 26, 2024
f117dd8
fixed panic in get_searched_entries
GyulyVGC Jan 26, 2024
6a11b35
refactored sort types enums into SortType
GyulyVGC Jan 26, 2024
2b4cf67
added toggler widget for favourites filter
GyulyVGC Jan 27, 2024
cdaf1f2
fixed inspect table header maximum allowed glyphs for Chinese, Japane…
GyulyVGC Jan 28, 2024
2cf6513
fix possible panic when loading paths with Chinese, Japanese, or Kore…
GyulyVGC Jan 28, 2024
33af34e
add possibility to set input filters strict equality checks; table he…
GyulyVGC Jan 28, 2024
5e76808
fix font family names and fix capitalization in inspect table header
GyulyVGC Jan 28, 2024
3951adc
fix font inconsistencies and remove unecessary advanced shaping usages
GyulyVGC Jan 28, 2024
fcf2a89
use ellipsis character to represent truncation
GyulyVGC Jan 28, 2024
7f435a4
fix warnings and tests
GyulyVGC Jan 29, 2024
13a5954
fix icons inconsistencies in case of directed broadcast address
GyulyVGC Jan 29, 2024
73ad266
minor fix
GyulyVGC Jan 29, 2024
247f1b0
Merge branch 'main' into upgrade-inspect
GyulyVGC Jan 30, 2024
f70dc6b
added constants for font family names
GyulyVGC Jan 30, 2024
e1e0c8d
tested ReportSortType::next_sort method
GyulyVGC Jan 30, 2024
6f7740c
minor improvements
GyulyVGC Jan 30, 2024
218ce8f
show direction info in table header with reduced font size
GyulyVGC Jan 31, 2024
b75dfba
create and test method to generate strings for inspect table column t…
GyulyVGC Jan 31, 2024
932db12
use Length::Fill for filter inputs' width
GyulyVGC Jan 31, 2024
b19f413
centered filter inputs with sort arrows and swapped country & domain …
GyulyVGC Jan 31, 2024
26b0e1a
updated CHANGELOG, optimized imports
GyulyVGC Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All Sniffnet releases with the relative changes are documented in this file.
- Introduced new filtering capabilities to allow users specify custom values of ports and IP addresses ([#414](https://github.com/GyulyVGC/sniffnet/pull/414))
- The size of text and widgets can now be customised by setting a proper zoom value (fixes [#202](https://github.com/GyulyVGC/sniffnet/issues/202) and [#344](https://github.com/GyulyVGC/sniffnet/issues/344))
- Added possibility to totally customize the app's theme via styles defined in TOML files ([#286](https://github.com/GyulyVGC/sniffnet/pull/286) and [#419](https://github.com/GyulyVGC/sniffnet/pull/419))
- Upgraded inspect page table: multiple new search filters, additional sorting options, and always keep a correct fields alignment ([#442](https://github.com/GyulyVGC/sniffnet/pull/442) — fixes [#63](https://github.com/GyulyVGC/sniffnet/issues/63))
- Added support for more link types in addition to Ethernet: raw IP packets and null/loopback packets are now correctly parsed ([#421](https://github.com/GyulyVGC/sniffnet/pull/421))
- IP addresses can now be copied to clipboard from the popup related to a given entry of the connections table, and a new search parameter has been introduced in Inspect page to allow users filter their connections based on IP address values ([#409](https://github.com/GyulyVGC/sniffnet/pull/409))
- Added Japanese translation 🇯🇵 ([#343](https://github.com/GyulyVGC/sniffnet/pull/343))
Expand All @@ -25,6 +26,7 @@ All Sniffnet releases with the relative changes are documented in this file.
- Fixed bug causing the application's icon not to be visible in some Linux environments
- Fixed a build failure on `powerpc64` ([#356](https://github.com/GyulyVGC/sniffnet/pull/356) — fixes [#353](https://github.com/GyulyVGC/sniffnet/issues/353))
- Fixed a typo in Russian translation ([#389](https://github.com/GyulyVGC/sniffnet/pull/389))
- Fixed icon inconsistency in case of directed broadcast traffic

## [1.2.2] - 2023-08-08
- Added option to set different shades of color gradients for each of the available themes
Expand Down
Binary file modified resources/fonts/full/sarasa-mono-sc-bold.ttf
Binary file not shown.
Binary file modified resources/fonts/full/sarasa-mono-sc-regular.ttf
Binary file not shown.
3 changes: 3 additions & 0 deletions resources/fonts/full/subset_characters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!
"
#
$
%
&
'
Expand Down Expand Up @@ -191,6 +192,7 @@ z
ώ
І
А
Б
В
Г
Д
Expand Down Expand Up @@ -287,6 +289,7 @@ z
۰
۳
Expand Down
Binary file modified resources/fonts/subset/icons.ttf
Binary file not shown.
Binary file modified resources/fonts/subset/sarasa-mono-sc-bold.subset.ttf
Binary file not shown.
Binary file modified resources/fonts/subset/sarasa-mono-sc-regular.subset.ttf
Binary file not shown.
7 changes: 4 additions & 3 deletions src/chart/types/traffic_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use iced::{Element, Renderer};
use plotters::prelude::*;
use plotters_iced::{Chart, ChartBuilder, ChartWidget, DrawingBackend};

use crate::gui::app::FONT_FAMILY_NAME;
use crate::gui::styles::style_constants::CHARTS_LINE_BORDER;
use crate::gui::styles::types::palette::to_rgb_color;
use crate::gui::types::message::Message;
Expand Down Expand Up @@ -136,15 +137,15 @@ impl Chart<Message> for TrafficChart {
.y_max_light_lines(1)
.y_labels(7)
.label_style(
("Sarasa Mono SC", 12)
(FONT_FAMILY_NAME, 12.5)
.into_font()
.style(font_weight)
.color(&color_font),
)
.y_label_formatter(if self.chart_type.eq(&ChartType::Packets) {
&|packets| packets.abs().to_string()
} else {
&|bytes| get_formatted_bytes_string_with_b(u128::from(bytes.unsigned_abs()))
&|bytes| get_formatted_bytes_string_with_b(u128::from(bytes.unsigned_abs()), 0)
})
.draw()
.unwrap();
Expand Down Expand Up @@ -196,7 +197,7 @@ impl Chart<Message> for TrafficChart {
.background_style(buttons_color.mix(0.6))
.border_style(buttons_color.stroke_width(CHARTS_LINE_BORDER * 2))
.label_font(
("Sarasa Mono SC", 13.5)
(FONT_FAMILY_NAME, 13.5)
.into_font()
.style(font_weight)
.color(&color_font),
Expand Down
16 changes: 8 additions & 8 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ fn get_flag_from_country(
tooltip = your_network_adapter_translation(language);
svg_style = SvgType::AdaptColor;
COMPUTER
} else if is_local {
tooltip = local_translation(language);
svg_style = SvgType::AdaptColor;
HOME
} else if traffic_type.eq(&TrafficType::Multicast) {
tooltip = "Multicast".to_string();
svg_style = SvgType::AdaptColor;
Expand All @@ -302,6 +298,10 @@ fn get_flag_from_country(
tooltip = "Broadcast".to_string();
svg_style = SvgType::AdaptColor;
BROADCAST
} else if is_local {
tooltip = local_translation(language);
svg_style = SvgType::AdaptColor;
HOME
} else {
tooltip = unknown_translation(language);
svg_style = SvgType::AdaptColor;
Expand Down Expand Up @@ -357,9 +357,9 @@ pub fn get_computer_tooltip(
let content = Svg::new(Handle::from_memory(Vec::from(
match (is_my_address, is_local, traffic_type) {
(true, _, _) => COMPUTER,
(false, _, TrafficType::Multicast) => MULTICAST,
(false, _, TrafficType::Broadcast) => BROADCAST,
(false, true, _) => HOME,
(false, false, TrafficType::Multicast) => MULTICAST,
(false, false, TrafficType::Broadcast) => BROADCAST,
(false, false, TrafficType::Unicast) => UNKNOWN,
},
)))
Expand All @@ -369,9 +369,9 @@ pub fn get_computer_tooltip(

let tooltip = match (is_my_address, is_local, traffic_type) {
(true, _, _) => your_network_adapter_translation(language),
(false, _, TrafficType::Multicast) => "Multicast".to_string(),
(false, _, TrafficType::Broadcast) => "Broadcast".to_string(),
(false, true, _) => local_translation(language),
(false, false, TrafficType::Multicast) => "Multicast".to_string(),
(false, false, TrafficType::Broadcast) => "Broadcast".to_string(),
(false, false, TrafficType::Unicast) => unknown_translation(language),
};

Expand Down
3 changes: 3 additions & 0 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ use crate::{ConfigSettings, StyleType, SNIFFNET_TITLECASE};
/// Update period (milliseconds)
pub const PERIOD_TICK: u64 = 1000;

pub const FONT_FAMILY_NAME: &str = "Sarasa Mono SC for Sniffnet";
pub const ICON_FONT_FAMILY_NAME: &str = "Icons for Sniffnet";

impl Application for Sniffer {
type Executor = executor::Default;
type Message = Message;
Expand Down
1 change: 1 addition & 0 deletions src/gui/components/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn get_button_github(font: Font) -> Tooltip<'static, Message, Renderer<StyleType
fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, Renderer<StyleType>> {
let content = button(
Text::new('❤'.to_string())
.font(font)
.size(23)
.style(TextType::Sponsor)
.horizontal_alignment(Horizontal::Center)
Expand Down
10 changes: 2 additions & 8 deletions src/gui/pages/connection_details_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use crate::networking::types::traffic_direction::TrafficDirection;
use crate::translations::translations::{
address_translation, application_protocol_translation, incoming_translation,
outgoing_translation, packets_translation, protocol_translation,
transport_protocol_translation,
};
use crate::translations::translations_2::{
administrative_entity_translation, connection_details_translation, destination_translation,
Expand Down Expand Up @@ -189,11 +188,6 @@ fn col_info(
language: Language,
) -> Column<'static, Message, Renderer<StyleType>> {
let is_icmp = key.protocol.eq(&Protocol::ICMP);
let protocol_caption = if is_icmp {
protocol_translation(language)
} else {
transport_protocol_translation(language)
};

let mut ret_val = Column::new()
.spacing(10)
Expand All @@ -211,7 +205,7 @@ fn col_info(
),
)
.push(TextType::highlighted_subtitle_with_desc(
protocol_caption,
protocol_translation(language),
&key.protocol.to_string(),
font,
));
Expand All @@ -236,7 +230,7 @@ fn col_info(
),
&format!(
"{}\n {} {}",
get_formatted_bytes_string_with_b(val.transmitted_bytes),
get_formatted_bytes_string_with_b(val.transmitted_bytes, 1),
val.transmitted_packets,
packets_translation(language)
),
Expand Down
3 changes: 0 additions & 3 deletions src/gui/pages/initial_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::collections::HashSet;

use iced::alignment::{Horizontal, Vertical};
use iced::widget::scrollable::Direction;
use iced::widget::text::Shaping;
use iced::widget::tooltip::Position;
use iced::widget::{
button, horizontal_space, vertical_space, Button, Column, Container, Row, Rule, Scrollable,
Expand Down Expand Up @@ -119,7 +118,6 @@ fn col_ip_buttons(
buttons_row = buttons_row.push(
Button::new(
Text::new(format!("{option} {check_symbol}"))
.shaping(Shaping::Advanced)
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center)
.font(font),
Expand Down Expand Up @@ -160,7 +158,6 @@ fn col_protocol_buttons(
Button::new(
Text::new(format!("{option} {check_symbol}"))
.width(Length::Fill)
.shaping(Shaping::Advanced)
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center)
.font(font),
Expand Down
Loading