Commit graph

768 commits

Author SHA1 Message Date
8382b5df6a
make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
1a054fd598
make sites optional 2026-02-04 13:05:32 -06:00
4ef4f4fbf6
handle exceptions gracefully on api endpoints 2026-02-04 12:18:14 -06:00
09f2907ede
Remove debugging logs, fix Mix.env call 2026-02-04 12:10:48 -06:00
c93144cc37
snmp v3 support 2026-02-04 12:02:38 -06:00
3583624e0d
fix: prevent nil boolean error in device edit page
Fixed production bug where visiting the edit page for a device with no
SNMP discovery data would crash with "expected boolean on left-side of
'and', got: nil" error.

The mikrotik_device?/1 function was using && operator which returns nil
when device.snmp_device is nil, instead of returning false. The template
conditional on line 455 requires a proper boolean value.

Changed from:
  device.snmp_device && (...)

To:
  not is_nil(device.snmp_device) and (...)

This ensures the function always returns a boolean (true/false) instead
of potentially returning nil.

Added regression test to verify the page renders correctly when a device
has no SNMP discovery data yet.

Fixes: https://app.honeybadger.io/projects/136860/faults/127120431
2026-02-03 15:32:51 -06:00
f6509cac08
more tests 2026-02-03 15:27:05 -06:00
891fb04f5a
change runner for forgejo 2026-02-03 14:06:24 -06:00
7c5493b31f
forejo ci update 2026-02-03 14:04:55 -06:00
6505e958cb
add forgejo ci 2026-02-03 13:55:19 -06:00
3276a1cd8c
fix user session controller test
Update email input ID assertion to match actual template implementation
2026-02-03 13:42:24 -06:00
50257dbe68
more tests 2026-02-03 13:20:33 -06:00
ecf6edaf85
update docker compose instructions 2026-02-03 13:00:51 -06:00
c198fdeaa1
add snmp port 2026-02-03 12:51:50 -06:00
88d549cd92
more tests 2026-02-03 12:03:54 -06:00
b78a40555c
more tests 2026-02-03 11:16:43 -06:00
8667d6a288
more tests 2026-02-03 11:02:38 -06:00
ec5c98781f
fix org test 2026-02-03 10:45:58 -06:00
086085156f
more tests 2026-02-03 10:43:30 -06:00
13b3810010
more tests 2026-02-03 10:28:39 -06:00
1ce3763e5f
more tests 2026-02-03 10:19:56 -06:00
5b84844e97
doc update 2026-02-03 09:07:06 -06:00
e181c17f78
fix: resolve MikroTik sensor values and empty SNMP communities
Fixes three critical issues affecting agent-based SNMP polling:

1. MikroTik gauge sensors incorrectly showing 10x values (223°C instead of 22.3°C)
   - Root cause: get_int_value() rejected zero values, causing mtxrGaugeUnit
     to be treated as nil and bypassing divisor logic
   - Fixed: Accept zero values and apply correct divisor=10 for temp/voltage/current/power

2. Empty SNMP community strings sent to agents causing authentication failures
   - Root cause: Devices with source="device" but null community weren't falling
     back to organization/site inheritance
   - Fixed: Enhanced resolve_snmp_community() to fall back to inheritance chain
     even when source="device" but community is empty

3. Continuous MikroTik API commands sent every 60s instead of once per 24h
   - Root cause: MikroTik jobs built on every poll cycle, not just discovery
   - Fixed: Only build MikroTik jobs during discovery phase

Migrations update existing data to fix incorrect divisor values and community
source tracking. Added comprehensive debug logging to diagnose future issues.
2026-02-02 17:12:36 -06:00
aaf8c38b78
handle mikrotik ssh 2026-02-02 16:42:18 -06:00
17348bb7e3
docs: mark gettext migration as complete 2026-02-02 13:24:27 -06:00
9a60bfec58
feat: migrate user settings and agent management to gettext
Migrates all remaining user settings and agent management flash messages to gettext:

User Settings:
- session_manager.ex: mobile device removal, alert preferences, browser session revocation, revoke all sessions
- totp_manager.ex: device creation, verification, deletion, recovery code generation
- api_token_manager.ex: token creation, deletion, validation errors
- user_auth.ex: policy consent acceptance message

Agent Management:
- agent_live/edit.ex: agent update success
- agent_live/index.ex: agent/cloud poller creation, token regeneration, agent deletion, global default settings

All flash messages now use domain-specific helpers (t_auth, t_equipment) for proper internationalization.

Tests passing: 4165 tests, 0 failures
2026-02-02 13:20:54 -06:00
3633ff1626
more gettext 2026-02-02 13:10:08 -06:00
0d85e85884
feat: migrate all remaining authentication and session flash messages to gettext
Completes the flash message migration by converting all remaining user-facing strings:

**UserAuth.ex changes:**
- All Plug functions: require_sudo_mode, require_authenticated_user, require_superuser
- load_current_organization error messages (3 messages)
- All LiveView on_mount callbacks (8 auth-related messages)
- Policy consent success message

**SessionManager.ex changes:**
- Mobile device session management (2 messages)
- Alert preferences updates (3 messages including conditional)

All messages now use t_auth() for consistent translation in the auth domain.

All tests passing (100 tests).
2026-02-02 13:02:44 -06:00
005235a54a
more gettext 2026-02-02 13:00:27 -06:00
2ef154e4d7
feat: migrate core components to gettext
Migrates consent prompt component strings to gettext for internationalization:
- Updated Policies modal title
- Policy review message
- Policy acceptance checkbox labels (Privacy Policy, Terms of Service)
- Consent disclaimer text
- Accept button text

All strings now use gettext() for translation support.
2026-02-02 12:49:13 -06:00
a995e6283f
feat: migrate admin features to gettext
Migrates all admin-related flash messages to gettext for internationalization:
- Admin.UserLive.Index: user deletion messages
- Admin.OrgLive.Index: organization deletion messages
- UserAuth: impersonation start/stop messages

Adds Gettext backend and helpers import to UserAuth module to support translations.

All admin and auth tests passing (87 tests).
2026-02-02 12:45:38 -06:00
89a076fb67
feat: migrate equipment features to gettext and fix sudo mode tests
Migrates all equipment-related flash messages to gettext for internationalization:
- DeviceLive.Index: device discovery, reordering, error messages
- DeviceLive.Show: backup messages, permission errors
- DeviceLive.Form: device CRUD operations
- AlertLive.Index: alert acknowledgment messages
- SiteLive.Show: site discovery messages
- SiteLive.Form: site CRUD and SNMP/agent propagation

Fixes sudo mode test suite issues:
- Updates Accounts.sudo_mode?/2 test to check last_sudo_at instead of authenticated_at
- Adds register_and_log_in_user_with_sudo/1 helper to ConnCase
- Fixes UserAuth sudo mode tests to use session-based authentication
- Updates MyData tests to use sudo mode (now required per router config)
- Removes obsolete UserSettingsLive "without sudo mode" test
- Fixes grant_sudo_mode/1 DateTime truncation to seconds

All equipment module tests passing. Ready for Phase 3 (Admin Features).
2026-02-02 12:41:58 -06:00
f6195cd5c6
sudo redirect fix 2026-02-02 10:54:32 -06:00
949cfaf4e0
add default org 2026-02-02 10:45:37 -06:00
1ba55ce451
mikrotik api update 2026-02-02 10:35:44 -06:00
bd6dad85e1
purge more passkey and gettext updates 2026-02-02 10:20:59 -06:00
02413d5cfd
cleanup forms 2026-02-02 10:07:37 -06:00
5d5116681a
device edit refactor 2026-02-02 10:00:00 -06:00
19b635c46f
feat: migrate email templates to gettext (Phase 2 - Emails)
- Update UserNotifier to use t_email() helper for all email content
- Extract 4 email subjects and 4 email bodies to emails domain:
  * Update email instructions
  * Log in instructions
  * Confirmation instructions
  * Reset password instructions
- Replace string interpolation with Gettext bindings (%{email}, %{url})
- Auto-populate English translations (msgstr = msgid)
- All emails now ready for future internationalization

First module migration complete per design plan.
2026-02-02 09:48:30 -06:00
cfb60cd186
feat: implement gettext infrastructure (Phase 1)
- Create domain-specific .pot template files (auth, equipment, admin, emails)
- Create corresponding English .po files for all domains
- Add GettextHelpers module with domain-specific helper functions:
  * t() for default domain (common UI)
  * t_auth() for authentication flows
  * t_equipment() for equipment/device management
  * t_admin() for admin features
  * t_email() for email templates
- Import GettextHelpers in html_helpers() for automatic availability in LiveViews/components
- Add mix populate_english task to auto-fill English translations (msgstr = msgid)
- Task properly handles plural forms and multi-line strings

Phase 1 complete - infrastructure ready for module-by-module migration.
2026-02-02 09:40:32 -06:00
6c8e670dae
docs: add gettext internationalization design
- Add comprehensive i18n design document with domain-based organization
  (default, errors, auth, equipment, admin, emails domains)
- Document helper functions, implementation patterns, and migration workflow
- Fix multiple test suite issues:
  * user_settings_live_test.exs: Update all tests to match current UI structure
    - Fix user.name references (use first_name/last_name)
    - Fix TOTP device creation (use create_totp_device/2)
    - Update tab URLs and form IDs
    - Update tab names (Account, API, Notifications)
    - Remove obsolete tabs (Organizations, Activity)
    - Fix password tests (pattern match redirect without flash token)
    - Update sudo mode behavior
  * account_data_controller_test.exs: Fix user profile assertions
  * rate_limit_test.exs: Fix unused variable warning
  * settings_live_test.exs: Fix organization form validation test
2026-02-02 09:33:01 -06:00
f938b263cd
Mikrotik backup and gettext start 2026-02-02 09:11:22 -06:00
a48cb292da
update org settings layout 2026-02-01 17:42:14 -06:00
1414f087fc
bug fix 2026-02-01 17:25:16 -06:00
1790db8d5a
update mikrotik port with/without ssl 2026-02-01 17:09:52 -06:00
6b63dc9295
encryption updates 2026-02-01 17:05:55 -06:00
23af86ba73
add mikrotik device handling 2026-02-01 16:42:39 -06:00
bcd2570b10
user settings test update 2026-02-01 15:02:35 -06:00
a66aec675e Merge branch 'gmcintire/user-first-last-name' into 'main'
Replace single name field with first_name and last_name

See merge request towerops/towerops!3
2026-02-01 15:00:24 -06:00
e46ecbfca2 Replace single name field with first_name and last_name 2026-02-01 15:00:23 -06:00