Fix network device description/machinenotes display and edit
- Fix ADO cursor issue where reading rs("description") twice caused
empty values (IsNull check consumed the field value)
- Change all device pages to read description field once using
`description = rs("description") & ""` pattern
- Add deviceDescription variable in displaydevice.asp
- Fix machinetypeid mapping: IDF=17, Camera=18 (was swapped)
- Add model dropdown fix to include currently assigned model
- Add server application tracking feature
- Various other improvements and fixes
Files affected:
- displaydevice.asp, displaylocationdevice.asp
- deviceaccesspoint.asp, deviceserver.asp, deviceswitch.asp
- devicecamera.asp, deviceidf.asp
- savenetworkdevice.asp, networkdevices.asp
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,26 +27,26 @@
|
||||
|
||||
' Build query based on device type
|
||||
' All network devices now use unified machines table with machinetypeid:
|
||||
' 16 = Access Point, 17 = Camera, 18 = IDF, 19 = Switch, 20 = Server
|
||||
' 16 = Access Point, 17 = IDF, 18 = Camera, 19 = Switch, 20 = Server
|
||||
Dim strSQL, rs, tableName, idField, editUrl, listUrl, machineTypeId
|
||||
Select Case LCase(deviceType)
|
||||
Case "idf"
|
||||
machineTypeId = 18
|
||||
machineTypeId = 17
|
||||
editUrl = "deviceidf.asp?id=" & deviceId
|
||||
listUrl = "networkdevices.asp?filter=IDF"
|
||||
strSQL = "SELECT mac.machineid, COALESCE(mac.alias, mac.machinenumber) AS idfname, " & _
|
||||
"mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _
|
||||
"NULL AS vendor, NULL AS modelnumber, NULL AS serialnumber, NULL AS ipaddress, NULL AS macaddress, " & _
|
||||
"NULL AS vendor, NULL AS modelnumber, NULL AS image, NULL AS serialnumber, NULL AS ipaddress, NULL AS macaddress, " & _
|
||||
"'IDF' AS devicetype " & _
|
||||
"FROM machines mac " & _
|
||||
"WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 18"
|
||||
"WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 17"
|
||||
Case "server"
|
||||
machineTypeId = 20
|
||||
editUrl = "deviceserver.asp?id=" & deviceId
|
||||
listUrl = "networkdevices.asp?filter=Server"
|
||||
strSQL = "SELECT mac.machineid, mac.alias AS servername, mac.machinenotes AS description, " & _
|
||||
"mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, " & _
|
||||
"v.vendor, m.modelnumber, c.address AS ipaddress, c.macaddress, " & _
|
||||
"mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, mac.logicmonitorurl, " & _
|
||||
"v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _
|
||||
"NULL AS idfname, 'Server' AS devicetype, " & _
|
||||
"mac.alias AS devicename " & _
|
||||
"FROM machines mac " & _
|
||||
@@ -59,8 +59,8 @@
|
||||
editUrl = "deviceswitch.asp?id=" & deviceId
|
||||
listUrl = "networkdevices.asp?filter=Switch"
|
||||
strSQL = "SELECT mac.machineid, mac.alias AS switchname, mac.machinenotes AS description, " & _
|
||||
"mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, " & _
|
||||
"v.vendor, m.modelnumber, c.address AS ipaddress, c.macaddress, " & _
|
||||
"mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, mac.logicmonitorurl, " & _
|
||||
"v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _
|
||||
"NULL AS idfname, 'Switch' AS devicetype, " & _
|
||||
"mac.alias AS devicename " & _
|
||||
"FROM machines mac " & _
|
||||
@@ -69,12 +69,12 @@
|
||||
"LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _
|
||||
"WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 19"
|
||||
Case "camera"
|
||||
machineTypeId = 17
|
||||
machineTypeId = 18
|
||||
editUrl = "devicecamera.asp?id=" & deviceId
|
||||
listUrl = "networkdevices.asp?filter=Camera"
|
||||
strSQL = "SELECT mac.machineid, mac.alias AS cameraname, mac.machinenotes AS description, " & _
|
||||
"mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, " & _
|
||||
"v.vendor, m.modelnumber, c.address AS ipaddress, c.macaddress, " & _
|
||||
"v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _
|
||||
"idf.alias AS idfname, idf.machineid AS idfid, 'Camera' AS devicetype, " & _
|
||||
"mac.alias AS devicename " & _
|
||||
"FROM machines mac " & _
|
||||
@@ -82,15 +82,15 @@
|
||||
"LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _
|
||||
"LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _
|
||||
"LEFT JOIN machinerelationships mr ON mac.machineid = mr.machineid AND mr.isactive = 1 " & _
|
||||
"LEFT JOIN machines idf ON mr.related_machineid = idf.machineid AND idf.machinetypeid = 18 " & _
|
||||
"WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 17"
|
||||
"LEFT JOIN machines idf ON mr.related_machineid = idf.machineid AND idf.machinetypeid = 17 " & _
|
||||
"WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 18"
|
||||
Case "accesspoint", "access point"
|
||||
machineTypeId = 16
|
||||
editUrl = "deviceaccesspoint.asp?id=" & deviceId
|
||||
listUrl = "networkdevices.asp?filter=Access Point"
|
||||
strSQL = "SELECT mac.machineid AS apid, mac.alias AS devicename, mac.modelnumberid AS modelid, " & _
|
||||
"mac.serialnumber, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _
|
||||
"v.vendor, m.modelnumber, c.address AS ipaddress, c.macaddress, " & _
|
||||
"mac.serialnumber, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, mac.logicmonitorurl, " & _
|
||||
"v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _
|
||||
"NULL AS idfname, NULL AS idfid, 'Access Point' AS devicetype " & _
|
||||
"FROM machines mac " & _
|
||||
"LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _
|
||||
@@ -113,7 +113,7 @@
|
||||
End If
|
||||
|
||||
' Get device name based on type
|
||||
Dim deviceName
|
||||
Dim deviceName, deviceDescription
|
||||
Select Case LCase(deviceType)
|
||||
Case "idf"
|
||||
deviceName = rs("idfname")
|
||||
@@ -126,6 +126,9 @@
|
||||
Case "accesspoint", "access point"
|
||||
deviceName = rs("devicename")
|
||||
End Select
|
||||
|
||||
' Store description in variable (reading rs fields twice can cause issues with ADO cursors)
|
||||
deviceDescription = rs("description") & ""
|
||||
%>
|
||||
|
||||
<body class="bg-theme <%Response.Write(theme)%>">
|
||||
@@ -148,14 +151,14 @@
|
||||
<div class="col-lg-4">
|
||||
<div class="card profile-card-2">
|
||||
<div class="card-img-block">
|
||||
<img class="img-fluid" src="./images/devices/<%=LCase(deviceType)%>.png" alt="Card image cap" onerror="this.onerror=null; this.src='./images/devices/default.png'">
|
||||
<img class="img-fluid" src="./images/machines/<%If Not IsNull(rs("image")) And rs("image") & "" <> "" Then Response.Write(Server.HTMLEncode(rs("image") & "")) Else Response.Write(LCase(deviceType) & ".png") End If%>" alt="Card image cap" onerror="this.onerror=null; this.src='./images/machines/default.png'">
|
||||
</div>
|
||||
<div class="card-body pt-5">
|
||||
<img src="./images/devices/<%=LCase(deviceType)%>.png" alt="profile-image" class="profile" onerror="this.onerror=null; this.src='./images/devices/default.png'">
|
||||
<img src="./images/machines/<%If Not IsNull(rs("image")) And rs("image") & "" <> "" Then Response.Write(Server.HTMLEncode(rs("image") & "")) Else Response.Write(LCase(deviceType) & ".png") End If%>" alt="profile-image" class="profile" onerror="this.onerror=null; this.src='./images/machines/default.png'">
|
||||
<h5 class="card-title"><%=Server.HTMLEncode(deviceName)%></h5>
|
||||
<h5 class="card-title"><%If Not IsNull(rs("vendor")) Then Response.Write(Server.HTMLEncode(rs("vendor"))) Else Response.Write(" ") End If%></h5>
|
||||
<h5 class="card-text"><%=Server.HTMLEncode(rs("devicetype"))%></h5>
|
||||
<p class="card-text"><%If Not IsNull(rs("description")) Then Response.Write(Server.HTMLEncode(rs("description"))) Else Response.Write(" ") End If%></p>
|
||||
<p class="card-text"><%If deviceDescription <> "" Then Response.Write(Server.HTMLEncode(deviceDescription)) Else Response.Write(" ") End If%></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -199,8 +202,22 @@
|
||||
<%End If%>
|
||||
<%If Not IsNull(rs("idfname")) Then%>
|
||||
<p class="mb-2"><strong>IDF:</strong></p>
|
||||
<%End If%>
|
||||
<%
|
||||
Dim showLogicMonitor
|
||||
showLogicMonitor = False
|
||||
If LCase(deviceType) = "server" Or LCase(deviceType) = "switch" Or LCase(deviceType) = "accesspoint" Or LCase(deviceType) = "access point" Then
|
||||
If Not IsNull(rs("logicmonitorurl")) Then
|
||||
If rs("logicmonitorurl") & "" <> "" Then showLogicMonitor = True
|
||||
End If
|
||||
End If
|
||||
If showLogicMonitor Then%>
|
||||
<p class="mb-2"><strong>Logic Monitor:</strong></p>
|
||||
<%End If%>
|
||||
<p class="mb-2"><strong>Location:</strong></p>
|
||||
<%If deviceDescription <> "" Then%>
|
||||
<p class="mb-2"><strong>Notes:</strong></p>
|
||||
<%End If%>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<p class="mb-2"><%=Server.HTMLEncode(rs("devicetype"))%></p>
|
||||
@@ -220,6 +237,9 @@
|
||||
<%End If%>
|
||||
<%If Not IsNull(rs("idfname")) Then%>
|
||||
<p class="mb-2"><a href="displaydevice.asp?type=idf&id=<%=rs("idfid")%>"><%=Server.HTMLEncode(rs("idfname"))%></a></p>
|
||||
<%End If%>
|
||||
<%If showLogicMonitor Then%>
|
||||
<p class="mb-2"><a href="<%=Server.HTMLEncode(rs("logicmonitorurl") & "")%>" target="_blank"><i class="zmdi zmdi-open-in-new"></i> View in Logic Monitor</a></p>
|
||||
<%End If%>
|
||||
<p class="mb-2">
|
||||
<%If Not IsNull(rs("maptop")) And Not IsNull(rs("mapleft")) Then%>
|
||||
@@ -230,20 +250,59 @@
|
||||
<em>Not set</em>
|
||||
<%End If%>
|
||||
</p>
|
||||
<%If deviceDescription <> "" Then%>
|
||||
<p class="mb-2"><%=Server.HTMLEncode(deviceDescription)%></p>
|
||||
<%End If%>
|
||||
</div>
|
||||
</div>
|
||||
<!--/row-->
|
||||
</div>
|
||||
|
||||
<%If LCase(deviceType) = "server" Then%>
|
||||
<%If LCase(deviceType) = "server" Then
|
||||
' Query installed applications for this server
|
||||
Dim rsApps, strAppSQL, appCount
|
||||
appCount = 0
|
||||
strAppSQL = "SELECT ia.installedappid, a.appid, a.appname, a.appdescription, " & _
|
||||
"av.version, ia.isactive " & _
|
||||
"FROM installedapps ia " & _
|
||||
"INNER JOIN applications a ON ia.appid = a.appid " & _
|
||||
"LEFT JOIN appversions av ON ia.appversionid = av.appversionid " & _
|
||||
"WHERE ia.machineid = " & CLng(deviceId) & " AND ia.isactive = 1 " & _
|
||||
"ORDER BY a.appname"
|
||||
Set rsApps = objConn.Execute(strAppSQL)
|
||||
%>
|
||||
<div class="tab-pane" id="applications">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application</th>
|
||||
<th>Version</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td><span class='text-muted'><em>Application tracking not yet implemented for servers</em></span></td></tr>
|
||||
<% If rsApps.EOF Then %>
|
||||
<tr><td colspan="3"><span class='text-muted'><em>No applications assigned to this server</em></span></td></tr>
|
||||
<% Else
|
||||
Do While Not rsApps.EOF
|
||||
appCount = appCount + 1 %>
|
||||
<tr>
|
||||
<td><a href="displayapplication.asp?appid=<%=rsApps("appid")%>"><%=Server.HTMLEncode(rsApps("appname") & "")%></a></td>
|
||||
<td><%If Not IsNull(rsApps("version")) Then Response.Write(Server.HTMLEncode(rsApps("version") & "")) Else Response.Write("<em class='text-muted'>-</em>")%></td>
|
||||
<td><%If Not IsNull(rsApps("appdescription")) Then Response.Write(Server.HTMLEncode(rsApps("appdescription") & "")) Else Response.Write("<em class='text-muted'>-</em>")%></td>
|
||||
</tr>
|
||||
<% rsApps.MoveNext
|
||||
Loop
|
||||
End If
|
||||
rsApps.Close
|
||||
Set rsApps = Nothing %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<small class="text-muted"><%=appCount%> application(s) hosted on this server</small>
|
||||
</div>
|
||||
</div>
|
||||
<%End If%>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user