Commit 4c74067
authored
Refactor/routing-arp-switching tables (#258)
This pull request introduces significant enhancements to the `Table`
component and its usage across various files. The changes include adding
support for row-level metadata, enabling dynamic row addition, and
refining callback methods for editing and deleting rows. These updates
improve flexibility and maintainability for tables in the application.
### Enhancements to the `Table` Component
(`src/graphics/basic_components/table.ts`):
* Introduced the `TableRow` interface to encapsulate row data and
metadata (e.g., `edited` status). Updated the `rows` property in
`TableOptions` to use `TableRow[]` instead of `string[][]`.
* Added support for dynamically adding rows via the `onAddRow` callback
and a new "Add Row" button in the table UI.
* Improved row rendering by applying a CSS class (`edited-row`) for rows
marked as edited and updated the logic for handling editable cells.
[[1]](diffhunk://#diff-94a19a6c54d3f3da90efed3af1c8c06201e699a1eaa13c9db24624a4b7ea444aL83-R111)
[[2]](diffhunk://#diff-94a19a6c54d3f3da90efed3af1c8c06201e699a1eaa13c9db24624a4b7ea444aL155-L190)
* Added a utility method `getRowHash` to generate a key-value mapping of
a row's data based on table headers. This is used for callbacks like
`onEdit`.
### Updates to ARP Table (`src/graphics/renderables/arp_table.ts`):
* Refactored ARP table rows to use the `TableRow` interface, enabling
metadata tracking (e.g., `edited` status).
* Enhanced callbacks for editing and deleting rows to work with row keys
(e.g., IP address) instead of indices. Added support for adding new
rows.
* Replaced direct calls to ARP table methods with utility functions
(e.g., `getArpTable`, `removeArpTableEntry`) for improved modularity.
### Updates to Device Info (`src/graphics/renderables/device_info.ts`):
* Updated methods for adding ARP, routing, and switching tables to use
`TableRow` for rows and track metadata like `edited` status.
[[1]](diffhunk://#diff-965a7810b34f8fb22a13101c89a873c18aa7d3c9c0dc67f0c79f178859084809L127-R135)
[[2]](diffhunk://#diff-965a7810b34f8fb22a13101c89a873c18aa7d3c9c0dc67f0c79f178859084809L191-R198)
[[3]](diffhunk://#diff-965a7810b34f8fb22a13101c89a873c18aa7d3c9c0dc67f0c79f178859084809L217-R228)
* Replaced direct method calls with utility functions for fetching table
data (e.g., `getRoutingTable`, `getSwitchingTable`).
[[1]](diffhunk://#diff-965a7810b34f8fb22a13101c89a873c18aa7d3c9c0dc67f0c79f178859084809L127-R135)
[[2]](diffhunk://#diff-965a7810b34f8fb22a13101c89a873c18aa7d3c9c0dc67f0c79f178859084809L217-R228)
### Updates to Program Runner Info
(`src/graphics/renderables/program_runner_info.ts`):
* Refactored rows in the program runner table to use `TableRow` for
consistency and added metadata support. Updated the `onDelete` callback
to work with row keys (e.g., PID) instead of indices.
These changes collectively improve the extensibility and usability of
tables across the application while ensuring better alignment with
modern design patterns.
close #1501 parent fac06e8 commit 4c74067
File tree
32 files changed
+1461
-868
lines changed- src
- graphics
- basic_components
- renderables
- packets
- styles
- types
- data-devices
- graphs
- network-modules/tables
- undo-redo/moves
- view-devices
- utils/constants
32 files changed
+1461
-868
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
8 | | - | |
| 14 | + | |
9 | 15 | | |
10 | | - | |
11 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
| |||
80 | 91 | | |
81 | 92 | | |
82 | 93 | | |
83 | | - | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
88 | 103 | | |
89 | | - | |
| 104 | + | |
90 | 105 | | |
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
95 | | - | |
| 110 | + | |
96 | 111 | | |
97 | | - | |
| 112 | + | |
98 | 113 | | |
99 | 114 | | |
100 | 115 | | |
| |||
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
110 | 130 | | |
111 | 131 | | |
112 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
113 | 175 | | |
114 | 176 | | |
115 | 177 | | |
116 | 178 | | |
117 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
118 | 184 | | |
119 | 185 | | |
120 | 186 | | |
| |||
131 | 197 | | |
132 | 198 | | |
133 | 199 | | |
134 | | - | |
| 200 | + | |
135 | 201 | | |
136 | 202 | | |
137 | 203 | | |
138 | 204 | | |
139 | | - | |
| 205 | + | |
| 206 | + | |
140 | 207 | | |
141 | | - | |
142 | | - | |
| 208 | + | |
| 209 | + | |
143 | 210 | | |
144 | 211 | | |
145 | 212 | | |
| |||
152 | 219 | | |
153 | 220 | | |
154 | 221 | | |
155 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
156 | 227 | | |
157 | 228 | | |
158 | 229 | | |
159 | 230 | | |
160 | 231 | | |
161 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
162 | 238 | | |
163 | 239 | | |
164 | 240 | | |
165 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
166 | 245 | | |
167 | 246 | | |
168 | | - | |
169 | 247 | | |
170 | 248 | | |
171 | 249 | | |
172 | | - | |
| 250 | + | |
173 | 251 | | |
174 | 252 | | |
175 | | - | |
176 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
177 | 257 | | |
178 | 258 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 259 | | |
184 | 260 | | |
185 | 261 | | |
186 | 262 | | |
187 | | - | |
| 263 | + | |
188 | 264 | | |
189 | 265 | | |
190 | | - | |
191 | 266 | | |
192 | 267 | | |
193 | 268 | | |
| |||
198 | 273 | | |
199 | 274 | | |
200 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
201 | 290 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
0 commit comments