Commit graph

29 commits

Author SHA1 Message Date
ddabb3f030
Add detailed graph view with date range selection
- Create GraphLive.Show for detailed sensor graph visualization
- Add route for /equipment/:id/graph/:sensor_type endpoint
- Make all chart headers clickable with navigation to detail view
- Implement date range selector (1h, 6h, 12h, 24h, 7d, 30d)
- Fix chart rendering by destroying and recreating on data updates
- Fix duplicate data loading in LiveView event handlers
- Fix MikroTik profile typing warning for entity sensor discovery
2026-01-05 11:09:21 -06:00
05f1aec227
Add sensor charts and improve equipment detail page
- Add Chart.js integration for interactive sensor graphs
- Add processor, memory, storage, temperature, and voltage charts showing 24 hours of data
- Fix device information box to use natural height instead of stretching
- Update MikroTik profile to discover ENTITY-SENSOR-MIB sensors
- Support multiple sensor types per chart (celsius/temperature, volts/voltage)
- Use 24-hour time format in chart tooltips and x-axis labels
- Support auto-scaling y-axis for non-percentage metrics
2026-01-05 11:01:21 -06:00
4ad4e3a673
cleanup 2026-01-05 10:44:21 -06:00
cac54b46a2
Implement event logging system and fix sensor display
- Add equipment_events table and Event schema for tracking device changes
- Implement automatic change detection for interface attributes during SNMP polling
  - Detects operational status changes (up/down)
  - Detects admin status changes
  - Detects speed changes with warning severity for speed drops
  - Detects MAC address changes
- Add Logs tab to equipment detail page with event display
- Fix temperature sensor display bug (was showing 4.3C instead of 43C due to double division)
- Remove response time tracking from monitoring checks and UI
- Move Rediscover Device button to equipment edit page
2026-01-05 10:42:34 -06:00
9eca2e7069
Fix database schema mismatches preventing SNMP and monitoring data collection
This fixes critical issues where SNMP sensor readings, interface stats, and
monitoring checks were not being saved to the database due to schema mismatches.

Database schema fixes:
- Recreate snmp_sensor_readings table with binary_id primary key
- Recreate snmp_interface_stats table with binary_id primary key
- Recreate monitoring_checks table with binary_id primary key

The original migrations used default integer primary keys, but the schemas
expected binary_id (UUID). This caused Ecto to generate UUID strings that
Postgrex tried to encode as binaries, resulting in silent insert failures.

SNMP interface stats fixes:
- Fix field name mismatch in get_interface_stats (if_in_octets vs in_octets)
- Remove unnecessary tuple handling code (Client already unwraps SNMPKit tuples)
- Clean up decode_snmp_value function and improve error messages

Monitoring check fixes:
- Fix response_time type from float to integer in Poller.check_device
- Add error logging to catch and report check creation failures

These changes enable:
- SNMP sensor readings to be collected and stored (disk usage, memory, CPU, etc.)
- Interface statistics to be collected (Counter64 octets, errors, discards)
- Equipment availability metrics to update on the dashboard
2026-01-05 08:26:16 -06:00
2e650c2be8
Add UTC timestamp tooltip to Last Check time
Shows the full UTC timestamp when hovering over the relative 'time ago'
text on the equipment detail page.

Changes:
- Wrapped time_ago display in a span with title attribute
- Title shows full datetime in UTC format
- Added cursor-help class for visual hint that tooltip is available

Users can now see both the easy-to-read relative time ('5m ago') and
the precise UTC timestamp (2026-01-04 19:30:15Z) by hovering.
2026-01-04 13:39:50 -06:00
40a329ea78
Add back navigation links to edit pages
Added back navigation links at the top of all edit/new pages to
improve UX and make it easier to navigate back to previous pages.

Changes:
- Added back link to equipment edit/new pages
  - Edit: goes back to equipment detail page
  - New: goes back to equipment list
- Added back link to site edit/new pages
  - Edit: goes back to site detail page
  - New: goes back to sites list
- Links styled with arrow icon and subtle hover effect
- Added error handling to Counter64 decoder with try/rescue

The back links appear above the page header and provide clear
navigation context for users.
2026-01-04 13:35:31 -06:00
d209b3295a
Add danger variant for delete buttons
Added a new 'danger' button variant to the button component for
destructive actions like deleting equipment or sites.

Changes:
- Added 'danger' variant to button component (red background/hover)
- Updated equipment delete button to use variant="danger"
- Updated site delete button to use variant="danger"
- Removed custom red color classes in favor of standardized variant

This provides consistent styling for all delete/destructive actions
across the application while maintaining proper button base styles
(padding, rounded corners, shadow, focus ring, etc).
2026-01-04 13:34:02 -06:00
3fe3a01726
Remove 'Check Now' button and clean up equipment detail page
Removed the manual 'Check Now' functionality since polling happens
automatically on a schedule with distributed coordination. Manual
triggers would interfere with the coordinated polling system.

Changes:
- Removed 'Check Now' button from equipment detail page
- Removed trigger_check event handler
- Simplified Discover and Edit buttons to use standard button styling
- Removed custom classes in favor of default button component styling

The equipment is now polled automatically based on its configured
check_interval_seconds, coordinated across all pods.
2026-01-04 13:31:14 -06:00
52f8af382c
Move delete buttons to edit pages for sites and equipment
- Remove delete buttons from show pages
- Add 'Danger Zone' section to edit pages with delete functionality
- Improves UX by keeping destructive actions on edit pages
- Add clear warnings about deletion consequences
2026-01-04 12:25:31 -06:00
50e7fa13af
Improve onboarding: redirect to site page after creation
- After creating a site, redirect to site detail page instead of list
- Show helpful empty state on site page with instructions to add equipment
- Flash message guides user to add their first device
2026-01-04 12:22:50 -06:00
ef06170c0d
Make site cards fully clickable and remove View button 2026-01-04 11:53:32 -06:00
e3c3056aca
Add onboarding wizard to guide users through site creation
- Dashboard shows welcome wizard when no sites exist
- Equipment page redirects to site creation when no sites exist
- Equipment form redirects users to create a site if none exist
- Equipment list hides "New Equipment" button when no sites exist
- Update layouts to accept nil current_organization for org-less pages
2026-01-04 11:47:25 -06:00
6bc802b22a
Add global header to new organization page
All authenticated pages now have consistent navigation header.
Login/registration pages keep simple layout as they're for
unauthenticated users.
2026-01-04 11:41:26 -06:00
5fdb0e81fd
Add main menubar to /orgs page
- Change /orgs to use Layouts.authenticated instead of Layouts.app
- Update authenticated layout to show user menu without organization
- Menu button shows org name when in org, 'Menu' on org list page
- Always show Settings and Log out options
2026-01-04 11:34:21 -06:00
c87630f472
Make org boxes clickable and add global layout
- Wrap /orgs page in Layouts.app to include header/footer
- Make entire org box clickable by using .link component
- Remove 'Open' button - entire card is now the link
- Add cursor-pointer for better UX
2026-01-04 11:27:36 -06:00
d6a9bb11d7
Redesign equipment view with compact LibreNMS-style dashboard
- Add real-time updates with 10-second refresh and PubSub integration
- Implement pure SVG charts: response time sparkline and uptime gauge
- Create compact dashboard layout with status cards, metrics, and graphs
- Add relative time display (e.g., '5s ago') for last check
- Redesign SNMP data display: compact device info, sensors grid, interfaces table
- Calculate and display uptime percentage and average response time
- Update tests to match new compact layout
2026-01-03 15:11:47 -06:00
8cbca259fc
snmp bits 2026-01-03 14:41:28 -06:00
0f9266027f
fix dialyzer things 2026-01-03 12:56:40 -06:00
5ae974d7aa
Fix Dialyzer unmatched return warning in trigger_check handler
- Explicitly discard return value from trigger_check call
- The return value is not needed for this fire-and-forget operation
- Resolves unmatched_return warning at line 58
2026-01-03 12:43:05 -06:00
7d4f7dd7d4
Add active page navigation highlighting
- Add active_page attribute to authenticated layout
- Update nav_link component to show active state with border and text styling
- Update all LiveView templates to pass active_page parameter
- Fix datetime truncation issues in tests and schemas for :utc_datetime fields
- Fix dashboard test assertions for equipment status text
2026-01-03 12:28:26 -06:00
b0a17e7ea6
Add comprehensive test coverage for LiveView modules and contexts
- Add LiveView tests for DashboardLive, AlertLive, SiteLive, EquipmentLive, OrgLive
- Add comprehensive tests for Organizations context (memberships, invitations, auth)
- Add tests for AlertNotifier email delivery
- Improve test coverage from 54.78% to 86.65%
- Add 101 new tests (256 total tests)
2026-01-03 11:21:53 -06:00
f7b681e8f7
Add authenticated layout to form and show pages
- Add authenticated layout with navigation to equipment/site forms and show pages
- Remove remaining DaisyUI classes from detail pages
- Update buttons to use proper component variants
- Ensure consistent styling across all authenticated pages
2026-01-03 11:06:21 -06:00
dffa46dfde
Improve UI styling and remove DaisyUI dependencies
- Remove default Phoenix branding and create custom layouts
- Replace DaisyUI classes with custom Tailwind components throughout
- Add authenticated layout with navigation bar for organization pages
- Redesign all core components (buttons, forms, tables, alerts)
- Make dashboard stat cards clickable to navigate to respective pages
- Update alert acknowledge button to only show for equipment down alerts
- Add consistent dark mode support across all pages
- Implement modern design with zinc color palette and improved spacing
2026-01-03 11:02:38 -06:00
93e0b869be
more features 2026-01-02 14:06:44 -06:00
fd5c6b3d72
more tests 2025-12-21 17:29:01 -06:00
d431db37bb
What Was Built
Monitoring Infrastructure:
  - lib/towerops/monitoring/ping.ex - OS-agnostic ping functionality that works on macOS, Linux, and Windows
  - lib/towerops/monitoring/equipment_monitor.ex - GenServer that monitors individual equipment at configurable intervals
  - lib/towerops/monitoring/supervisor.ex - DynamicSupervisor with Registry for managing monitor workers
  - lib/towerops/monitoring.ex - Context for creating and querying monitoring checks

  Database:
  - monitoring_checks table stores historical ping results with status, response time, and timestamps
  - Indexed on (equipment_id, checked_at) for efficient querying

  Real-Time Updates:
  - PubSub broadcasting on equipment:#{id} topic when status changes
  - Equipment show page subscribes to updates and refreshes automatically
  - Manual "Check Now" button to trigger immediate checks

  Application Integration:
  - Monitoring.Supervisor added to application supervision tree
  - All monitored equipment starts monitoring automatically on app startup
  - Recent checks displayed in Equipment show page

  How It Works

  1. On application start, a monitor GenServer is spawned for each equipment with monitoring_enabled: true
  2. Each monitor pings its equipment at the configured interval (default 5 minutes)
  3. Results are saved to monitoring_checks table
  4. Equipment status is updated if it changes (up ↔ down)
  5. Status changes are broadcast via PubSub to all connected LiveViews
  6. The Equipment show page updates in real-time when status changes
2025-12-21 16:52:23 -06:00
1bd72dac78
1. Sites Management
- Sites schema with hierarchical parent-child relationships
  - CRUD operations for sites
  - Sites context with helper functions
  - LiveView pages:
    - /orgs/:slug/sites - List all sites
    - /orgs/:slug/sites/new - Create new site
    - /orgs/:slug/sites/:id - View site details
    - /orgs/:slug/sites/:id/edit - Edit site
  - Support for site locations and descriptions
  - Site tree builder for hierarchy visualization

  2. Equipment Management
  - Equipment schema with monitoring fields
  - IP address validation (IPv4 & IPv6)
  - Equipment status tracking (up/down/unknown)
  - Customizable check intervals per equipment
  - Equipment context with CRUD operations
  - LiveView pages:
    - /orgs/:slug/equipment - List all equipment
    - /orgs/:slug/equipment/new - Add equipment
    - /orgs/:slug/equipment/:id - View equipment details
    - /orgs/:slug/equipment/:id/edit - Edit equipment
  - Equipment can be added from site pages
  - Status badges and last checked timestamps

  3. Database Schema
  - sites table with self-referencing parent_site_id
  - equipment table with status tracking
  - All migrations run successfully
  - Proper indexes on foreign keys and status

  4. Features Implemented
  -  IP address validation using :inet.parse_address
  -  Site hierarchy with parent-child relationships
  -  Equipment linked to sites
  -  Monitoring enabled/disabled per equipment
  -  Customizable check intervals (30s - 3600s)
  -  Status tracking (up/down/unknown)
  -  Timestamps for last check and last status change
  -  Organization-scoped data (users only see their org's data)
2025-12-21 13:39:19 -06:00
c52f313e2d
1. User Authentication
- Full auth system with email/password (using phx.gen.auth)
  - Login, registration, password reset
  - Session management with remember-me functionality
  - Magic link login support

  2. Organization Management
  - Multi-tenant organization system
  - Organizations schema with unique slugs
  - Automatic organization creation when users register
  - Organization switcher UI at /orgs

  3. Membership System
  - Users can belong to multiple organizations
  - 4 permission levels: Owner, Admin, Member, Viewer
  - Complete permission matrix implemented
  - Join/leave organizations

  4. Invitation System
  - Email-based invitations with secure tokens
  - 7-day expiration on invites
  - Track who invited and who accepted

  5. Authorization
  - Full policy system (Organizations.Policy)
  - can?(membership, :action, :resource) helper
  - Enforced via plugs in router

  6. LiveView Pages
  - /orgs - List all your organizations
  - /orgs/new - Create new organization
  - /orgs/:slug - Organization dashboard (placeholder)

  7. Database Schema
  - users table
  - organizations table
  - organization_memberships table
  - organization_invitations table
  - All migrations run successfully
2025-12-21 13:31:59 -06:00