# Network Devices - Unified Page Design **Date:** 2025-10-23 **Approach:** Single "Network Devices" page showing all infrastructure with filtering **Files Required:** 4 files total --- ## Concept: One Page to Rule Them All Instead of separate pages per device type, create a unified **Network Devices** page that shows: - Servers - Switches - 📹 Cameras - Access Points (if you add them later) - IDFs (Intermediate Distribution Frames) **User Experience:** - Click "Network Devices" → See ALL devices in one table - Filter by type using tabs/dropdown - Click any device → Detail page (works for all types) - "Add Device" button → Select type, then add --- ## Page Architecture ### Main Pages (4 files) ``` network_devices.asp → List all devices with type filter network_device_detail.asp?type=server&id=5 → View/edit any device add_network_device.asp?type=server → Add new device (any type) save_network_device.asp → Universal save endpoint ``` ### Navigation ``` Main Menu: └─ Network Devices (single menu item) └─ Opens network_devices.asp with tabs for filtering ``` --- ## File 1: network_devices.asp (Main List View) ### Features - **Tabs/Filter:** All | Servers | Switches | Cameras | Access Points | IDFs - **Unified Table:** Shows all device types in one view - **Device Type Badge:** Visual indicator (Server, Switch, Camera, etc.) - **Search:** Filter by vendor, model, IP, serial number - **Actions:** View/Edit/Delete per device ### UI Mockup ``` ┌─────────────────────────────────────────────────────────────┐ │ Network Devices [+ Add Device] │ ├─────────────────────────────────────────────────────────────┤ │ [ All ] [ Servers ] [ Switches ] [ Cameras ] [ More ▼ ] │ ├─────────────────────────────────────────────────────────────┤ │ Type | Vendor | Model | Serial | IP │ ├─────────────────────────────────────────────────────────────┤ │ [Server] | Dell | PowerEdge | ABC123 | 10.0.1.5 │ │ [Switch] | Cisco | Catalyst 2960| XYZ789 | 10.0.1.1 │ │ [Camera] | Hikvision | DS-2CD2142FWD| CAM001 | 10.0.2.10 │ │ [Server] | HP | ProLiant | SRV456 | 10.0.1.6 │ └─────────────────────────────────────────────────────────────┘ ``` ### Code Structure ```vbscript <% ' Get filter parameter (default = all) Dim filterType filterType = Request.QueryString("filter") If filterType = "" Then filterType = "all" ' Build query using vw_network_devices view Dim strSQL If filterType = "all" Then strSQL = "SELECT * FROM vw_network_devices WHERE isactive = 1 ORDER BY device_type, device_id DESC" Else ' Filter by specific type (server, switch, camera) strSQL = "SELECT * FROM vw_network_devices WHERE device_type = '" & filterType & "' AND isactive = 1 ORDER BY device_id DESC" End If Set rs = objConn.Execute(strSQL) %> <% Do While Not rs.EOF %> <% rs.MoveNext Loop %>
Type Vendor Model Serial Number IP Address Description Actions
<% ' Device type badge with icon Dim badgeClass, iconClass Select Case rs("device_type") Case "Server" badgeClass = "badge-primary" iconClass = "zmdi-storage" Case "Switch" badgeClass = "badge-success" iconClass = "zmdi-device-hub" Case "Camera" badgeClass = "badge-info" iconClass = "zmdi-videocam" End Select %> <%=rs("device_type")%> <%=Server.HTMLEncode(rs("vendor") & "")%> <%=Server.HTMLEncode(rs("modelnumber") & "")%> <%=Server.HTMLEncode(rs("serialnumber") & "")%> <%=Server.HTMLEncode(rs("ipaddress") & "")%> <%=Server.HTMLEncode(rs("description") & "")%> &id=<%=rs("device_id")%>"> View
``` --- ## File 2: network_device_detail.asp (Detail/Edit View) ### Features - Shows device details with vendor/model - Inline edit form (click Edit button) - Works for ANY device type - Map coordinates (if provided) - Link back to network_devices.asp ### Code Structure ```vbscript <% ' Get type and ID from URL Dim deviceType, deviceId deviceType = Request.QueryString("type") ' server, switch, camera deviceId = Request.QueryString("id") ' Validate type If deviceType <> "server" AND deviceType <> "switch" AND deviceType <> "camera" Then Response.Redirect("network_devices.asp") Response.End End If ' Map type to table/field names Dim tableName, idField, displayName Select Case deviceType Case "server" tableName = "servers" idField = "serverid" displayName = "Server" Case "switch" tableName = "switches" idField = "switchid" displayName = "Switch" Case "camera" tableName = "cameras" idField = "cameraid" displayName = "Camera" End Select ' Fetch device with model/vendor strSQL = "SELECT d.*, m.modelnumber, m.modelnumberid, v.vendor, v.vendorid " & _ "FROM " & tableName & " d " & _ "LEFT JOIN models m ON d.modelid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "WHERE d." & idField & " = " & deviceId Set rs = objConn.Execute(strSQL) If rs.EOF Then Response.Write("Device not found") Response.End End If %>
Back to Network Devices

<%=displayName%> #<%=deviceId%>

Vendor <%=Server.HTMLEncode(rs("vendor") & "N/A")%>
Model <%=Server.HTMLEncode(rs("modelnumber") & "N/A")%>
Serial Number <%=Server.HTMLEncode(rs("serialnumber") & "")%>
IP Address <%=Server.HTMLEncode(rs("ipaddress") & "")%>
Description <%=Server.HTMLEncode(rs("description") & "")%>
Map Position <% If Not IsNull(rs("maptop")) And Not IsNull(rs("mapleft")) Then %> Top: <%=rs("maptop")%>, Left: <%=rs("mapleft")%> View on Map <% Else %> Not mapped <% End If %>
``` --- ## File 3: add_network_device.asp (Add Form) ### Features - **First:** Select device type (Server, Switch, Camera, etc.) - **Then:** Show form with fields - Model/vendor dropdown - All standard fields - Optional map coordinates ### Code Structure ```vbscript <% ' Get device type (from URL or form) Dim deviceType deviceType = Request.QueryString("type") ' If no type selected, show type selector If deviceType = "" OR (deviceType <> "server" AND deviceType <> "switch" AND deviceType <> "camera") Then %>

Add Network Device

Select the type of device you want to add:

Cancel
<% Response.End End If ' Type is selected, show form Dim displayName Select Case deviceType Case "server": displayName = "Server" Case "switch": displayName = "Switch" Case "camera": displayName = "Camera" End Select %>

Add <%=displayName%>

Don't see your model? Add a new model first
Used for network map visualization. Leave blank if unknown.
Cancel
``` --- ## File 4: save_network_device.asp (Universal Save) ### Features - Handles INSERT and UPDATE for all device types - Validates all inputs - Redirects back to appropriate page ### Code Structure ```vbscript <% ' Get device type Dim deviceType deviceType = Request.Form("type") ' Validate type If deviceType <> "server" AND deviceType <> "switch" AND deviceType <> "camera" Then Response.Write("Error: Invalid device type") Response.End End If ' Map to table/field names Dim tableName, idField Select Case deviceType Case "server" tableName = "servers" idField = "serverid" Case "switch" tableName = "switches" idField = "switchid" Case "camera" tableName = "cameras" idField = "cameraid" End Select ' Get and validate form data Dim deviceId, modelid, serialnumber, ipaddress, description, maptop, mapleft deviceId = GetSafeInteger("FORM", "id", 0, 0, 999999) modelid = GetSafeInteger("FORM", "modelid", 0, 0, 999999) serialnumber = GetSafeString("FORM", "serialnumber", "", 0, 100, "^[A-Za-z0-9\-\s]*$") ipaddress = GetSafeString("FORM", "ipaddress", "", 0, 15, "^[0-9\.]*$") description = GetSafeString("FORM", "description", "", 0, 255, "") maptop = GetSafeInteger("FORM", "maptop", 0, 0, 999999) mapleft = GetSafeInteger("FORM", "mapleft", 0, 0, 999999) ' Convert 0 to NULL for optional fields If modelid = 0 Then modelid = Null If maptop = 0 Then maptop = Null If mapleft = 0 Then mapleft = Null ' Validate required fields If IsNull(modelid) Then Response.Write("Error: Model is required") Response.End End If ' Build query Dim strSQL If deviceId = 0 Then ' INSERT - New device strSQL = "INSERT INTO " & tableName & " " & _ "(modelid, serialnumber, ipaddress, description, maptop, mapleft, isactive) " & _ "VALUES (?, ?, ?, ?, ?, ?, 1)" Set rs = ExecuteParameterizedQuery(objConn, strSQL, _ Array(modelid, serialnumber, ipaddress, description, maptop, mapleft)) ' Get new ID for redirect deviceId = objConn.Execute("SELECT LAST_INSERT_ID() as newid")(0) Else ' UPDATE - Existing device strSQL = "UPDATE " & tableName & " " & _ "SET modelid = ?, serialnumber = ?, ipaddress = ?, description = ?, " & _ " maptop = ?, mapleft = ? " & _ "WHERE " & idField & " = ?" Set rs = ExecuteParameterizedQuery(objConn, strSQL, _ Array(modelid, serialnumber, ipaddress, description, maptop, mapleft, deviceId)) End If Call CleanupResources() ' Redirect to detail page Response.Redirect("network_device_detail.asp?type=" & deviceType & "&id=" & deviceId) %> ``` --- ## Navigation Update ### leftsidebar.asp ```html
  • Network Devices
  • Network Map
  • Subnets
  • ``` --- ## Database View: vw_network_devices The migration script already creates this! It unifies all infrastructure: ```sql CREATE VIEW vw_network_devices AS SELECT 'Server' AS device_type, serverid AS device_id, modelid, modelnumber, vendor, serialnumber, ipaddress, description, maptop, mapleft, isactive FROM servers LEFT JOIN models ON servers.modelid = models.modelnumberid LEFT JOIN vendors ON models.vendorid = vendors.vendorid UNION ALL SELECT 'Switch' AS device_type, switchid AS device_id, modelid, modelnumber, vendor, serialnumber, ipaddress, description, maptop, mapleft, isactive FROM switches LEFT JOIN models ON switches.modelid = models.modelnumberid LEFT JOIN vendors ON models.vendorid = vendors.vendorid UNION ALL SELECT 'Camera' AS device_type, cameraid AS device_id, modelid, modelnumber, vendor, serialnumber, ipaddress, description, maptop, mapleft, isactive FROM cameras LEFT JOIN models ON cameras.modelid = models.modelnumberid LEFT JOIN vendors ON models.vendorid = vendors.vendorid ``` --- ## Future: Adding More Device Types To add **Access Points** or **IDFs** later: 1. **Database:** ```sql CREATE TABLE accesspoints ( accesspointid INT(11) PRIMARY KEY AUTO_INCREMENT, modelid INT(11), serialnumber VARCHAR(100), ipaddress VARCHAR(15), description VARCHAR(255), maptop INT(11), mapleft INT(11), isactive BIT(1) DEFAULT b'1', FOREIGN KEY (modelid) REFERENCES models(modelnumberid) ); -- Add to view ALTER VIEW vw_network_devices AS -- ... existing unions ... UNION ALL SELECT 'Access Point' AS device_type, accesspointid AS device_id, ... FROM accesspoints ... ``` 2. **Code:** Just add new case to Select statements! ```vbscript Case "accesspoint" tableName = "accesspoints" idField = "accesspointid" displayName = "Access Point" ``` 3. **UI:** Add new tab to network_devices.asp **That's it!** The unified design makes it trivial to extend. --- ## Summary: Why This Is Better **Single source of truth** - One page for all infrastructure **Easy filtering** - Tabs to view by type or see all **Consistent UX** - Same interface for all device types **Uses existing view** - `vw_network_devices` already unifies them **Only 4 files** - vs 12 separate files **Easy to extend** - Add new device types without file duplication **Matches mental model** - "Network Devices" is how users think **Search/filter across all** - Find any device in one place --- **Ready to build?** This is the cleanest approach!