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

Feature/editable routing tables #103

Merged
merged 20 commits into from
Feb 1, 2025
Merged

Conversation

pgallino
Copy link
Collaborator

@pgallino pgallino commented Jan 22, 2025

  • Routing Table Editing:

    • Implemented functionality to allow manual edits on routing table entries.
    • Changes persist across system updates and refreshes.
    • Validation added to ensure correct IP, mask and interface formatting.
  • Persistence Improvements:

    • Routing tables are now stored and retrieved correctly when devices are added or removed.
    • Manually edited entries are preserved if the corresponding connection still exists.
  • Undo/Redo Enhancements:

    • Fixed the RemoveDevice undo operation to restore the routing tables correctly.
    • Fixed the RemoveEdge undo operation to restore the routing tables correctly
    • Improved the logic to prevent loss of manually modified entries during undo/redo actions.

TODO: Evaluate alternative UI approaches for routing table editing to improve user experience.

closes #73

pgallino and others added 9 commits January 20, 2025 20:25
…acking

- Implemented editable fields for routing table entries, allowing users to modify IP, mask, and interface values directly.
- Introduced a 'manuallyEdited' flag in each routing table entry to track manual modifications and prevent them from being overwritten during table regeneration.
- Modified the regenerateRoutingTable function to retain manually edited entries while updating only non-modified ones.

Currently, only changes to the 'interface' column have an effect, while modifications to the IP and mask columns do not affect the logic yet.
- Added a focus check to prevent shortcut execution when the user is typing in input or textarea fields.
…d manual entry issues

- Implemented persistence for routing tables to ensure they are saved and restored correctly.
- Fixed the undo functionality for RemoveDevice to properly restore device connections and routing tables.
- Resolved issues related to manually edited routing table entries:
  - Ensured manually edited entries are retained only if the corresponding connection exists.
  - Fixed overwriting issues caused by index-based management by switching to IP-based matching.
  - Improved consistency when regenerating routing tables after topology changes.

These improvements enhance the stability and accuracy of the routing table management system.
@pgallino pgallino marked this pull request as draft January 23, 2025 16:31
Refactored the logic for preserving manually edited entries in the routing table.
The previous implementation conditionally added entries to the new table if they were still connected.
The updated logic now only updates existing entries and logs a warning if no matching entry is found,
preventing unintended additions and ensuring data consistency.
Implemented logic to store and restore routing tables when a device is removed and then restored.
Now, when a router is deleted, its routing table, along with the routing tables of connected devices,
is saved. During an undo operation, the device and its connections are restored, ensuring that all
routing tables are reinstated correctly.
@pgallino pgallino marked this pull request as ready for review January 24, 2025 13:19
Improved the user interface by implementing a popup modal for cell editing. Now, when a cell is clicked, a modal appears allowing users to edit values with validation and a better user experience. The modal is positioned next to the right sidebar for better accessibility.
@pgallino pgallino closed this Jan 25, 2025
@pgallino pgallino reopened this Jan 25, 2025
@pgallino pgallino marked this pull request as draft January 25, 2025 14:35
pgallino and others added 4 commits January 29, 2025 20:38
- Added functionality to refresh the routing table.
- Added support for row deletion, ensuring both UI and data are updated.
- Integrated event listeners for handling table updates and row removal.
## 📌 Main Changes:

### 🛠 Refactored Routing Table Regeneration:
- Created a `generateRoutingTable(id, preserveEdits)` function to eliminate duplicated code in `regenerateRoutingTableClean` and `regenerateRoutingTable`.
- `generateRoutingTable` now handles route generation, and if `preserveEdits = true`, it preserves manually edited and deleted entries.
- Improved code clarity with a cleaner and more reusable structure.

### 🎨 Improved Editable UI in Routing Table:
- Removed the modal, making table cells directly editable (`contentEditable = "true"`).
- Added column-based validation before saving changes:
  - **IP** → Ensures valid IP format.
  - **Subnet Mask** → Validates correct subnet mask values.
  - **Interface** → Only allows values in the `ethX` format.
- If an invalid value is entered, it is reverted to the previous one, and a warning is displayed in the console.

### ⌨️ Keyboard Shortcut Handling:
- Added a `keydown` event listener to prevent `Delete` or `Backspace` from triggering the shortcut for removing a device when editing a cell.

✅ **Results**:
- More modular and reusable code.
- Improved user experience when editing the table.
- Easier maintenance for route generation logic.

🚀 Ready for testing and future enhancements!
@pgallino pgallino marked this pull request as ready for review February 1, 2025 00:12
Copy link
Owner

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a single comment. LGTM otherwise

Comment on lines +59 to +60
connections: DeviceId[],
viewgraph: ViewGraph, // Pasamos la vista para obtener las tablas de enrutamiento
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to do this anymore. I previously refactored CreateDevice to store the node data from the datagraph, so if the data is in the datagraph, CreateDevice has it.

@Manuel-Pol Manuel-Pol merged commit 6da8f97 into main Feb 1, 2025
3 checks passed
@Manuel-Pol Manuel-Pol deleted the feature/editable-routing-tables branch February 1, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit routing tables
3 participants