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:
@@ -123,12 +123,13 @@ Else
|
||||
End If
|
||||
|
||||
' Get model and serial number (common fields)
|
||||
Dim modelid, serialnumber, ipaddress, fqdn, macaddress
|
||||
Dim modelid, serialnumber, ipaddress, fqdn, macaddress, logicmonitorurl
|
||||
modelid = Trim(Request.Form("modelid"))
|
||||
serialnumber = Trim(Request.Form("serialnumber"))
|
||||
ipaddress = Trim(Request.Form("ipaddress"))
|
||||
fqdn = Trim(Request.Form("fqdn"))
|
||||
macaddress = Trim(Request.Form("macaddress"))
|
||||
logicmonitorurl = Trim(Request.Form("logicmonitorurl"))
|
||||
|
||||
' Handle new model creation
|
||||
If modelid = "new" Then
|
||||
@@ -326,7 +327,7 @@ strSQL = ""
|
||||
|
||||
If deviceId = "0" Then
|
||||
' INSERT into machines table
|
||||
strSQL = "INSERT INTO machines (machinenumber, alias, modelnumberid, machinetypeid, pctypeid, serialnumber, fqdn, machinenotes, mapleft, maptop, isactive, lastupdated) VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, NOW())"
|
||||
strSQL = "INSERT INTO machines (machinenumber, alias, modelnumberid, machinetypeid, pctypeid, serialnumber, fqdn, logicmonitorurl, machinenotes, mapleft, maptop, isactive, lastupdated) VALUES (?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, NOW())"
|
||||
Set cmdDevice = Server.CreateObject("ADODB.Command")
|
||||
cmdDevice.ActiveConnection = objConn
|
||||
cmdDevice.CommandText = strSQL
|
||||
@@ -337,6 +338,7 @@ If deviceId = "0" Then
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@machinetypeid", 3, 1, , machineTypeId)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@serialnumber", 200, 1, 100, serialnumber)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@fqdn", 200, 1, 255, fqdn)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@logicmonitorurl", 200, 1, 512, logicmonitorurl)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@machinenotes", 200, 1, 255, description)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@mapleft", 3, 1, , mapleftValue)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@maptop", 3, 1, , maptopValue)
|
||||
@@ -364,7 +366,7 @@ If deviceId = "0" Then
|
||||
|
||||
Else
|
||||
' UPDATE machines table
|
||||
strSQL = "UPDATE machines SET machinenumber = ?, alias = ?, modelnumberid = ?, serialnumber = ?, fqdn = ?, machinenotes = ?, mapleft = ?, maptop = ?, isactive = ?, lastupdated = NOW() WHERE machineid = ?"
|
||||
strSQL = "UPDATE machines SET machinenumber = ?, alias = ?, modelnumberid = ?, serialnumber = ?, fqdn = ?, logicmonitorurl = ?, machinenotes = ?, mapleft = ?, maptop = ?, isactive = ?, lastupdated = NOW() WHERE machineid = ?"
|
||||
Set cmdDevice = Server.CreateObject("ADODB.Command")
|
||||
cmdDevice.ActiveConnection = objConn
|
||||
cmdDevice.CommandText = strSQL
|
||||
@@ -374,6 +376,7 @@ Else
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@modelnumberid", 3, 1, , modelidValue)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@serialnumber", 200, 1, 100, serialnumber)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@fqdn", 200, 1, 255, fqdn)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@logicmonitorurl", 200, 1, 512, logicmonitorurl)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@machinenotes", 200, 1, 255, description)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@mapleft", 3, 1, , mapleftValue)
|
||||
cmdDevice.Parameters.Append cmdDevice.CreateParameter("@maptop", 3, 1, , maptopValue)
|
||||
@@ -474,6 +477,70 @@ If deviceType = "camera" And idfid <> "" And Not IsNull(idfRelationshipTypeId) T
|
||||
Set cmdInsertRel = Nothing
|
||||
End If
|
||||
|
||||
' Handle server application assignments
|
||||
If deviceType = "server" And deviceId <> "0" Then
|
||||
Dim appsToAdd, appsToRemove, appList, appItem, cmdApp, sqlApp
|
||||
|
||||
' Get apps to add and remove
|
||||
appsToAdd = Trim(Request.Form("apps"))
|
||||
appsToRemove = Trim(Request.Form("removedapps"))
|
||||
|
||||
' Remove applications (set isactive = 0)
|
||||
If appsToRemove <> "" Then
|
||||
appList = Split(appsToRemove, ",")
|
||||
For Each appItem In appList
|
||||
If IsNumeric(Trim(appItem)) Then
|
||||
sqlApp = "UPDATE installedapps SET isactive = 0 WHERE machineid = ? AND appid = ?"
|
||||
Set cmdApp = Server.CreateObject("ADODB.Command")
|
||||
cmdApp.ActiveConnection = objConn
|
||||
cmdApp.CommandText = sqlApp
|
||||
cmdApp.CommandType = 1
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@machineid", 3, 1, , CLng(newMachineId))
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@appid", 3, 1, , CLng(Trim(appItem)))
|
||||
cmdApp.Execute
|
||||
Set cmdApp = Nothing
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
' Add new applications
|
||||
If appsToAdd <> "" Then
|
||||
appList = Split(appsToAdd, ",")
|
||||
For Each appItem In appList
|
||||
If IsNumeric(Trim(appItem)) Then
|
||||
' Check if already exists (but inactive)
|
||||
Dim rsExisting
|
||||
Set rsExisting = objConn.Execute("SELECT installedappid, isactive FROM installedapps WHERE machineid = " & CLng(newMachineId) & " AND appid = " & CLng(Trim(appItem)))
|
||||
If Not rsExisting.EOF Then
|
||||
' Reactivate existing record
|
||||
sqlApp = "UPDATE installedapps SET isactive = 1 WHERE machineid = ? AND appid = ?"
|
||||
Set cmdApp = Server.CreateObject("ADODB.Command")
|
||||
cmdApp.ActiveConnection = objConn
|
||||
cmdApp.CommandText = sqlApp
|
||||
cmdApp.CommandType = 1
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@machineid", 3, 1, , CLng(newMachineId))
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@appid", 3, 1, , CLng(Trim(appItem)))
|
||||
cmdApp.Execute
|
||||
Set cmdApp = Nothing
|
||||
Else
|
||||
' Insert new record
|
||||
sqlApp = "INSERT INTO installedapps (appid, machineid, isactive) VALUES (?, ?, 1)"
|
||||
Set cmdApp = Server.CreateObject("ADODB.Command")
|
||||
cmdApp.ActiveConnection = objConn
|
||||
cmdApp.CommandText = sqlApp
|
||||
cmdApp.CommandType = 1
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@appid", 3, 1, , CLng(Trim(appItem)))
|
||||
cmdApp.Parameters.Append cmdApp.CreateParameter("@machineid", 3, 1, , CLng(newMachineId))
|
||||
cmdApp.Execute
|
||||
Set cmdApp = Nothing
|
||||
End If
|
||||
rsExisting.Close
|
||||
Set rsExisting = Nothing
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
' Success - show success message
|
||||
objConn.Close
|
||||
ShowSuccess deviceDisplayName & " saved successfully.", redirectUrl, deviceDisplayName
|
||||
|
||||
Reference in New Issue
Block a user