Enhancing User Experience by Streamlining Database Connection Setup

In this commit, we have made significant improvements to the user experience of the NETRAVE project by streamlining the process of setting up the database connection. This was achieved by modifying the first_run_setup method in the FirstRunInit class to intelligently handle the presence or absence of a configuration file (config.yml).

The key changes include:

    Checking for the existence of config.yml: Before prompting the user for database details, the program now checks if a config.yml file already exists. This file holds the necessary details for connecting to the database.

    Reading and using existing configuration: If a config.yml file is found, the program attempts to connect to the database using the details from the file. This eliminates the need for the user to re-enter database details every time the program runs, thereby improving the user experience.

    Handling unsuccessful connections: If the connection attempt using the details from config.yml is unsuccessful, the program prompts the user for new database details. These new details are then used to overwrite the existing config.yml file. This ensures that the program can recover from changes in the database setup, such as a change in password.

    Creating config.yml if it does not exist: If no config.yml file is found, the program creates one and then prompts the user for the database details. This makes the initial setup process smoother for new users.

These changes have several benefits:

    Improved User Experience: By avoiding unnecessary prompts for database details, the program becomes more user-friendly.

    Efficient Onboarding: The streamlined process makes onboarding new users more efficient.

    Cost Savings: By reducing the number of requests for help with database details, we can potentially save on support staff time.

    Employee Satisfaction: Improving user experience can lead to greater employee satisfaction and advocacy for the product.

    Ethical Considerations: These changes respect the rights of the users by giving them control over their personal data and ensuring transparency in how their data is handled.

This commit represents a significant step forward in making the NETRAVE project more user-friendly and efficient. We believe these changes will improve the usage and adoption of the product while also respecting the rights of the users.
This commit is contained in:
VetheonGames 2023-06-07 13:16:49 -06:00
parent 0a27925405
commit 6768cf14b3
7 changed files with 543 additions and 0 deletions

133
Glade/NETRAVE.glade Normal file
View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopover" id="popover1">
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="settings_menu_entry">
<property name="label" translatable="yes">Settings</property>
<property name="name">settings_menu_entry</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
</child>
</object>
<object class="GtkWindow" id="main_window">
<property name="name">main_window</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">NETRAVE</property>
<property name="window-position">center-always</property>
<property name="default-width">1080</property>
<property name="default-height">720</property>
<property name="gravity">center</property>
<child>
<object class="GtkLayout" id="layout_grid">
<property name="name">layout_grid</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="double-buffered">False</property>
<property name="hscroll-policy">natural</property>
<property name="vscroll-policy">natural</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="name">title_label</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">NETRAVE: A Network Monitor for the Future</property>
<property name="justify">center</property>
<attributes>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="x">300</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="label_separator">
<property name="name">label_separator</property>
<property name="width-request">1085</property>
<property name="height-request">5</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="double-buffered">False</property>
</object>
<packing>
<property name="y">91</property>
</packing>
</child>
<child>
<object class="GtkButton" id="monitor_button">
<property name="label" translatable="yes">Open the Monitor</property>
<property name="name">monitor_button</property>
<property name="width-request">154</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="double-buffered">False</property>
</object>
<packing>
<property name="x">150</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkButton" id="logger_button">
<property name="label" translatable="yes">Open the Logger</property>
<property name="name">logger_button</property>
<property name="width-request">146</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="x">415</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkButton" id="exterminator_button">
<property name="label" translatable="yes">Open the Exterminator</property>
<property name="name">exterminator_button</property>
<property name="width-request">274</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="x">670</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="related-action"/>
<property name="name">menu_button</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="popover">popover1</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="x">6</property>
<property name="y">6</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

134
Glade/NETRAVE.glade~ Normal file
View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopover" id="popover1">
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="settings_menu_entry">
<property name="label" translatable="yes">Settings</property>
<property name="name">settings_menu_entry</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
</child>
</object>
<object class="GtkWindow" id="main_window">
<property name="name">main_window</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">NETRAVE</property>
<property name="window-position">center-always</property>
<property name="default-width">1080</property>
<property name="default-height">720</property>
<property name="gravity">center</property>
<child>
<object class="GtkLayout" id="layout_grid">
<property name="name">layout_grid</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="double-buffered">False</property>
<property name="hscroll-policy">natural</property>
<property name="vscroll-policy">natural</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="name">title_label</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">NETRAVE: A Network Monitor for the Future</property>
<property name="justify">center</property>
<attributes>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="x">300</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="label_separator">
<property name="name">label_separator</property>
<property name="width-request">1085</property>
<property name="height-request">5</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="double-buffered">False</property>
</object>
<packing>
<property name="y">91</property>
</packing>
</child>
<child>
<object class="GtkButton" id="monitor_button">
<property name="label" translatable="yes">Open the Monitor</property>
<property name="name">monitor_button</property>
<property name="width-request">154</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="double-buffered">False</property>
</object>
<packing>
<property name="x">150</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkButton" id="logger_button">
<property name="label" translatable="yes">Open the Logger</property>
<property name="name">logger_button</property>
<property name="width-request">146</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="x">415</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkButton" id="exterminator_button">
<property name="label" translatable="yes">Open the Exterminator</property>
<property name="name">exterminator_button</property>
<property name="width-request">274</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="x">670</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="related-action"/>
<property name="name">menu_button</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="direction">right</property>
<property name="popover">popover1</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="x">6</property>
<property name="y">6</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

1
lib/.rubocop.yml Normal file
View File

@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml

192
lib/.rubocop_todo.yml Normal file
View File

@ -0,0 +1,192 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-06-07 18:22:21 UTC using RuboCop version 1.52.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'utils/utilities.rb'
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Exclude:
- 'utils/utilities.rb'
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'utils/database_manager.rb'
- 'utils/system_information_gather.rb'
- 'utils/utilities.rb'
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'utils/database_manager.rb'
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
- 'utils/utilities.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'utils/system_information_gather.rb'
# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 20
# Offense count: 8
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 19
# Offense count: 1
# Configuration parameters: AllowedNames.
# AllowedNames: module_parent
Naming/ClassAndModuleCamelCase:
Exclude:
- 'utils/GUI_launcher.rb'
# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'utils/GUI_launcher.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'utils/GUI_launcher.rb'
# Offense count: 5
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'utils/GUI_launcher.rb'
- 'utils/database_manager.rb'
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
- 'utils/utilities.rb'
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'utils/GUI_launcher.rb'
- 'utils/database_manager.rb'
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
- 'utils/utilities.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/InfiniteLoop:
Exclude:
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/NegatedWhile:
Exclude:
- 'utils/first_run_init.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'utils/system_information_gather.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'utils/database_manager.rb'
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantFileExtensionInRequire:
Exclude:
- 'utils/database_manager.rb'
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'utils/database_manager.rb'
# Offense count: 36
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Gemfile'
- 'utils/GUI_launcher.rb'
- 'utils/database_manager.rb'
- 'utils/first_run_init.rb'
- 'utils/system_information_gather.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: brackets
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 121

View File

@ -16,3 +16,7 @@ gem "sequel", "~> 5.69"
gem "mysql2", "~> 0.5.5" gem "mysql2", "~> 0.5.5"
gem "yaml", "~> 0.2.1" gem "yaml", "~> 0.2.1"
gem "gtk3", "~> 4.1"
gem "reek", "~> 6.1"

View File

@ -2,29 +2,69 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ast (2.4.2) ast (2.4.2)
atk (4.1.7)
glib2 (= 4.1.7)
backport (1.2.0) backport (1.2.0)
benchmark (0.2.1) benchmark (0.2.1)
cairo (1.17.8)
native-package-installer (>= 1.0.3)
pkg-config (>= 1.2.2)
red-colors
cairo-gobject (4.1.7)
cairo (>= 1.16.2)
glib2 (= 4.1.7)
console (1.16.2) console (1.16.2)
fiber-local fiber-local
curses (1.4.4) curses (1.4.4)
diff-lcs (1.5.0) diff-lcs (1.5.0)
e2mmap (0.1.0) e2mmap (0.1.0)
fiber-local (1.0.0) fiber-local (1.0.0)
fiddle (1.1.1)
gdk3 (4.1.7)
cairo-gobject (= 4.1.7)
gdk_pixbuf2 (= 4.1.7)
pango (= 4.1.7)
gdk_pixbuf2 (4.1.7)
gio2 (= 4.1.7)
gio2 (4.1.7)
fiddle
gobject-introspection (= 4.1.7)
glib2 (4.1.7)
native-package-installer (>= 1.0.3)
pkg-config (>= 1.3.5)
gobject-introspection (4.1.7)
glib2 (= 4.1.7)
gtk3 (4.1.7)
atk (= 4.1.7)
gdk3 (= 4.1.7)
jaro_winkler (1.5.6) jaro_winkler (1.5.6)
json (2.6.3) json (2.6.3)
kramdown (2.4.0) kramdown (2.4.0)
rexml rexml
kramdown-parser-gfm (1.1.0) kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0) kramdown (~> 2.0)
kwalify (0.7.2)
matrix (0.4.2)
mysql2 (0.5.5) mysql2 (0.5.5)
native-package-installer (1.1.5)
nokogiri (1.15.2-x86_64-linux) nokogiri (1.15.2-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
pango (4.1.7)
cairo-gobject (= 4.1.7)
gobject-introspection (= 4.1.7)
parallel (1.23.0) parallel (1.23.0)
parser (3.2.2.1) parser (3.2.2.1)
ast (~> 2.4.1) ast (~> 2.4.1)
pkg-config (1.5.1)
racc (1.6.2) racc (1.6.2)
rainbow (3.1.1) rainbow (3.1.1)
rbs (2.8.4) rbs (2.8.4)
red-colors (0.3.0)
matrix
reek (6.1.4)
kwalify (~> 0.7.0)
parser (~> 3.2.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.8.0) regexp_parser (2.8.0)
reverse_markdown (2.1.1) reverse_markdown (2.1.1)
nokogiri nokogiri
@ -71,7 +111,9 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
console console
curses (~> 1.4) curses (~> 1.4)
gtk3 (~> 4.1)
mysql2 (~> 0.5.5) mysql2 (~> 0.5.5)
reek (~> 6.1)
rubocop (~> 1.52) rubocop (~> 1.52)
sequel (~> 5.69) sequel (~> 5.69)
solargraph (~> 0.49.0) solargraph (~> 0.49.0)

37
lib/utils/GUI_launcher.rb Normal file
View File

@ -0,0 +1,37 @@
require 'gtk3'
class GUI_Launcher
def initialize
@app = Gtk::Application.new("com.netrave.gui", :flags_none)
@app.signal_connect "activate" do |application|
builder = Gtk::Builder.new
builder.add_from_file("./Glade/NETRAVE.glade")
window = builder.get_object("main_window")
window.application = application
screen = Gdk::Screen.default
width = screen.width
height = screen.height
if width >= 3840 and height >= 2160
# 4K resolution
window.set_default_size(1200, 1000)
elsif width >= 1920 and height >= 1080
# 1080p resolution
window.set_default_size(1080, 800)
else
# 720p or lower resolution
window.set_default_size(800, 600)
end
window.show_all
end
end
def run
puts "Launching GUI..."
@app.run
end
end