Add PC-machine relationships API and report, fix shopfloor dashboard

- Add getPCMachineRelationships API endpoint for PC-to-machine mappings
- Add pcmachinerelationships.asp report page with copy table/CSV/JSON export
- Fix shopfloor dashboard to immediately hide deactivated notifications
- Add Firewall (machinetypeid 46) support to network device pages
- Add model migration warning banner to networkdevices.asp
- Create SQL script for hybrid model/machine type view

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-01-29 16:06:33 -05:00
parent 603de062e5
commit 8945fe2a0a
10 changed files with 487 additions and 24 deletions

69
api.asp
View File

@@ -61,6 +61,8 @@ Select Case action
GetUDCManualTiming()
Case "getDeployableApps"
GetDeployableApps()
Case "getPCMachineRelationships"
GetPCMachineRelationships()
Case Else
SendError "Invalid action: " & action
End Select
@@ -943,6 +945,73 @@ Sub GetShopfloorPCs()
Response.Write "{""success"":true,""count"":" & pcCount & ",""data"":[" & pcList & "]}"
End Sub
Sub GetPCMachineRelationships()
' Returns PCs that have relationships to machines (equipment) with machine numbers
' Used for identifying which PCs control which shop floor machines
On Error Resume Next
Dim rsRel, strSQL, relList, relCount, relData
strSQL = "SELECT " & _
"pc.machineid AS pc_id, " & _
"pc.machinenumber AS hostname, " & _
"c.address AS ip, " & _
"eq.machineid AS machine_id, " & _
"eq.machinenumber AS machine_number, " & _
"v.vendor AS vendor, " & _
"m.modelnumber AS model " & _
"FROM machinerelationships mr " & _
"JOIN machines eq ON mr.machineid = eq.machineid " & _
"JOIN machines pc ON mr.related_machineid = pc.machineid " & _
"LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _
"LEFT JOIN models m ON eq.modelnumberid = m.modelnumberid " & _
"LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _
"WHERE mr.isactive = 1 " & _
"AND pc.pctypeid IS NOT NULL " & _
"AND eq.machinenumber IS NOT NULL AND eq.machinenumber != '' " & _
"AND eq.machinenumber REGEXP '^[0-9]{4}$' " & _
"AND eq.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _
"AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _
"AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _
"ORDER BY eq.machinenumber"
Set rsRel = objConn.Execute(strSQL)
If Err.Number <> 0 Then
SendError "Database error: " & Err.Description
Exit Sub
End If
' Build JSON array
relList = ""
relCount = 0
Do While Not rsRel.EOF
If relList <> "" Then relList = relList & ","
relData = "{"
relData = relData & """pc_id"":" & rsRel("pc_id") & ","
relData = relData & """hostname"":""" & EscapeJSON(rsRel("hostname") & "") & ""","
relData = relData & """ip"":""" & EscapeJSON(rsRel("ip") & "") & ""","
relData = relData & """machine_id"":" & rsRel("machine_id") & ","
relData = relData & """machine_number"":""" & EscapeJSON(rsRel("machine_number") & "") & ""","
relData = relData & """vendor"":""" & EscapeJSON(rsRel("vendor") & "") & ""","
relData = relData & """model"":""" & EscapeJSON(rsRel("model") & "") & """"
relData = relData & "}"
relList = relList & relData
relCount = relCount + 1
rsRel.MoveNext
Loop
rsRel.Close
Set rsRel = Nothing
' Send response
Response.Write "{""success"":true,""count"":" & relCount & ",""data"":[" & relList & "]}"
End Sub
Sub GetHighUptimePCs()
' Returns list of PCs with uptime >= specified days (for reboot management)
On Error Resume Next