Add machine map editor and fix machine map display
- Create machine_map_editor.asp for bulk position editing - Draggable Leaflet markers for repositioning machines - Sidebar with filterable machine list - Pending changes tracking with save/reset functionality - Proper Y-axis coordinate conversion (2550 - top) - Update machine_map.asp - Reduce marker size from 20px to 12px to reduce overlap - Filter out network devices (16-20) and PCs (33+) from display - Show equipment only (machinetypeid 2-15) - Add updateMachinePositions API endpoint in api.asp - Accepts JSON array of position changes - Updates mapleft/maptop for multiple machines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
67
api.asp
67
api.asp
@@ -55,6 +55,8 @@ Select Case action
|
||||
GetShopfloorPCs()
|
||||
Case "getRecordedIP"
|
||||
GetRecordedIP()
|
||||
Case "updateMachinePositions"
|
||||
UpdateMachinePositions()
|
||||
Case Else
|
||||
SendError "Invalid action: " & action
|
||||
End Select
|
||||
@@ -2412,4 +2414,69 @@ Sub UpdateWinRMStatus()
|
||||
Response.Write "{""success"":true,""message"":""WinRM status updated"",""hostname"":""" & hostname & """,""iswinrm"":" & winrmValue & "}"
|
||||
End Sub
|
||||
|
||||
' ============================================================================
|
||||
' UPDATE MACHINE POSITIONS - Bulk update mapleft/maptop for machines
|
||||
' ============================================================================
|
||||
Sub UpdateMachinePositions()
|
||||
On Error Resume Next
|
||||
|
||||
Dim changesJson, changes, i, updateCount, errorCount
|
||||
changesJson = Request.Form("changes")
|
||||
|
||||
If changesJson = "" Then
|
||||
SendError "Missing changes parameter"
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
LogToFile "UpdateMachinePositions: Received " & Len(changesJson) & " bytes"
|
||||
|
||||
' Parse JSON array
|
||||
changes = ParseJSONArray(changesJson)
|
||||
|
||||
If Not IsArray(changes) Then
|
||||
SendError "Invalid changes format"
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
updateCount = 0
|
||||
errorCount = 0
|
||||
|
||||
' Update each machine position
|
||||
For i = 0 To UBound(changes)
|
||||
Dim machineId, newLeft, newTop, updateSQL
|
||||
|
||||
machineId = GetJSONValue(changes(i), "id")
|
||||
newLeft = GetJSONValue(changes(i), "newLeft")
|
||||
newTop = GetJSONValue(changes(i), "newTop")
|
||||
|
||||
If machineId <> "" And IsNumeric(machineId) And IsNumeric(newLeft) And IsNumeric(newTop) Then
|
||||
updateSQL = "UPDATE machines SET mapleft = " & CLng(newLeft) & ", maptop = " & CLng(newTop) & _
|
||||
" WHERE machineid = " & CLng(machineId)
|
||||
objConn.Execute updateSQL
|
||||
|
||||
If Err.Number = 0 Then
|
||||
updateCount = updateCount + 1
|
||||
LogToFile " Updated machineid " & machineId & " to (" & newLeft & ", " & newTop & ")"
|
||||
Else
|
||||
errorCount = errorCount + 1
|
||||
LogToFile " Error updating machineid " & machineId & ": " & Err.Description
|
||||
Err.Clear
|
||||
End If
|
||||
Else
|
||||
errorCount = errorCount + 1
|
||||
LogToFile " Invalid data for change " & i
|
||||
End If
|
||||
Next
|
||||
|
||||
LogToFile "UpdateMachinePositions: Updated " & updateCount & ", Errors " & errorCount
|
||||
|
||||
' Send response
|
||||
Response.ContentType = "application/json"
|
||||
If errorCount = 0 Then
|
||||
Response.Write "{""success"":true,""message"":""Updated " & updateCount & " position(s)"",""updated"":" & updateCount & "}"
|
||||
Else
|
||||
Response.Write "{""success"":true,""message"":""Updated " & updateCount & ", " & errorCount & " error(s)"",""updated"":" & updateCount & ",""errors"":" & errorCount & "}"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
%>
|
||||
|
||||
Reference in New Issue
Block a user