diff --git a/addmachine.asp b/addmachine.asp index 54b3c0b..4dfbb4b 100644 --- a/addmachine.asp +++ b/addmachine.asp @@ -167,13 +167,20 @@ + + + + + +
0; @@ -236,6 +317,14 @@ $('#newvendorname').focus(); return false; } + + // If adding new machine type, make sure name is filled + if ($('#machinetypeid').val() === 'new' && $('#newmachinetypename').val().trim() === '') { + e.preventDefault(); + alert('Please enter a machine type name or select an existing one'); + $('#newmachinetypename').focus(); + return false; + } }); }); diff --git a/deviceaccesspoint.asp b/deviceaccesspoint.asp index 9663976..ca2645d 100644 --- a/deviceaccesspoint.asp +++ b/deviceaccesspoint.asp @@ -236,20 +236,55 @@
- + <% - Dim rsMachineTypes - strSQL3 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" + Dim rsMachineTypes, lastCat + strSQL3 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC" Set rsMachineTypes = objConn.Execute(strSQL3) + lastCat = "" While Not rsMachineTypes.EOF + If rsMachineTypes("category") <> lastCat Then + If lastCat <> "" Then Response.Write("") + Response.Write("") + lastCat = rsMachineTypes("category") + End If Response.Write("") rsMachineTypes.MoveNext Wend + If lastCat <> "" Then Response.Write("") rsMachineTypes.Close Set rsMachineTypes = Nothing %> - + + +
+ +
+
+
+ + +
@@ -487,6 +522,21 @@ $(document).ready(function() { $('#newvendorname').val('').prop('required', false); }); + // Show/hide new machine type section + $('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() { + if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') { + $('#newmodelmachinetypeid').val('new'); + $('#newMachineTypeSection').slideDown(); + $('#newmachinetypename').prop('required', true); + } + }); + + $('#cancelNewMachineType').on('click', function() { + $('#newMachineTypeSection').slideUp(); + $('#newmodelmachinetypeid').val(''); + $('#newmachinetypename').val('').prop('required', false); + }); + // Form validation $('form').on('submit', function(e) { // If adding new model, make sure fields are filled @@ -513,6 +563,15 @@ $(document).ready(function() { return false; } } + // If machine type is 'new', check machine type name + if ($('#newmodelmachinetypeid').val() === 'new') { + if ($('#newmachinetypename').val().trim() === '') { + e.preventDefault(); + alert('Please enter a machine type name or select an existing type'); + $('#newmachinetypename').focus(); + return false; + } + } } }); }); diff --git a/devicecamera.asp b/devicecamera.asp index 2dbf2b5..c4b2d0c 100644 --- a/devicecamera.asp +++ b/devicecamera.asp @@ -327,20 +327,55 @@
- + <% - Dim rsMachineTypes - strSQL2 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" + Dim rsMachineTypes, lastCat + strSQL2 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC" Set rsMachineTypes = objConn.Execute(strSQL2) + lastCat = "" While Not rsMachineTypes.EOF + If rsMachineTypes("category") <> lastCat Then + If lastCat <> "" Then Response.Write("") + Response.Write("") + lastCat = rsMachineTypes("category") + End If Response.Write("") rsMachineTypes.MoveNext Wend + If lastCat <> "" Then Response.Write("") rsMachineTypes.Close Set rsMachineTypes = Nothing %> - + + +
+ +
+
+
+ + +
@@ -594,6 +629,21 @@ $(document).ready(function() { $('#newvendorname').val('').prop('required', false); }); + // Show/hide new machine type section + $('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() { + if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') { + $('#newmodelmachinetypeid').val('new'); + $('#newMachineTypeSection').slideDown(); + $('#newmachinetypename').prop('required', true); + } + }); + + $('#cancelNewMachineType').on('click', function() { + $('#newMachineTypeSection').slideUp(); + $('#newmodelmachinetypeid').val(''); + $('#newmachinetypename').val('').prop('required', false); + }); + // Form validation $('form').on('submit', function(e) { // Validate IDF @@ -635,6 +685,15 @@ $(document).ready(function() { return false; } } + // If machine type is 'new', check machine type name + if ($('#newmodelmachinetypeid').val() === 'new') { + if ($('#newmachinetypename').val().trim() === '') { + e.preventDefault(); + alert('Please enter a machine type name or select an existing type'); + $('#newmachinetypename').focus(); + return false; + } + } } }); }); diff --git a/devicefirewall.asp b/devicefirewall.asp new file mode 100644 index 0000000..6503816 --- /dev/null +++ b/devicefirewall.asp @@ -0,0 +1,586 @@ + + + + + + + + +<% + theme = Request.Cookies("theme") + IF theme = "" THEN + theme="bg-theme1" + END IF + + Dim firewallid, isNewRecord + firewallid = Request.QueryString("id") + If firewallid = "" Or firewallid = "0" Then + isNewRecord = True + firewallid = 0 + Else + isNewRecord = False + End If + + ' If editing, fetch existing data + Dim rs, firewallname, modelid, serialnumber, ipaddress, fqdn, description, maptop, mapleft, isactive + Dim vendorname, modelnumber, logicmonitorurl + If Not isNewRecord Then + Dim strSQL + strSQL = "SELECT mac.machineid, mac.alias AS firewallname, mac.modelnumberid AS modelid, " & _ + "mac.serialnumber, mac.fqdn, mac.logicmonitorurl, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _ + "m.modelnumber, v.vendor, c.address AS ipaddress " & _ + "FROM machines mac " & _ + "LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _ + "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 " & _ + "WHERE mac.machineid = " & firewallid & " AND mac.machinetypeid = 46" + Set rs = objConn.Execute(strSQL) + + If rs.EOF Then + Response.Write("firewall not found") + Response.End + End If + + If Not IsNull(rs("firewallname")) Then firewallname = rs("firewallname") Else firewallname = "" + If Not IsNull(rs("modelid")) Then modelid = rs("modelid") Else modelid = "" + If Not IsNull(rs("serialnumber")) Then serialnumber = rs("serialnumber") Else serialnumber = "" + If Not IsNull(rs("ipaddress")) Then ipaddress = rs("ipaddress") Else ipaddress = "" + If Not IsNull(rs("fqdn")) Then fqdn = rs("fqdn") & "" Else fqdn = "" + If Not IsNull(rs("logicmonitorurl")) Then logicmonitorurl = rs("logicmonitorurl") & "" Else logicmonitorurl = "" + description = rs("description") & "" + If Not IsNull(rs("maptop")) Then maptop = rs("maptop") Else maptop = "" + If Not IsNull(rs("mapleft")) Then mapleft = rs("mapleft") Else mapleft = "" + If Not IsNull(rs("isactive")) Then isactive = rs("isactive") Else isactive = 1 + If Not IsNull(rs("vendor")) Then vendorname = rs("vendor") Else vendorname = "" + If Not IsNull(rs("modelnumber")) Then modelnumber = rs("modelnumber") Else modelnumber = "" + + rs.Close + Set rs = Nothing + Else + ' New record defaults + firewallname = "" + modelid = "" + serialnumber = "" + ipaddress = "" + fqdn = "" + logicmonitorurl = "" + description = "" + maptop = "" + mapleft = "" + isactive = 1 ' Active by default for new records + vendorname = "" + modelnumber = "" + End If +%> + + + + +
+ + +
+ + + + +
+ +
+
+ + +
+
+ +
+
+ +
+
+
+
+
+ + <%If isNewRecord Then Response.Write("Add firewall") Else Response.Write("Edit firewall: " & Server.HTMLEncode(firewallname))%> +
+
+ +
+ + + +
+ +
+ + + Short name to identify this firewall + +
+
+ +
+ +
+
+ +
+ +
+
+ + Select a model or click "New" to add one + +
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ + + IPv4 or IPv6 address + +
+
+ +
+ +
+ + + Fully Qualified Domain Name (optional) + +
+
+ +
+ +
+ + + Link to this device in Logic Monitor (optional) + +
+
+ +
+ +
+ + + Optional: Purpose, rack location, or other notes + +
+
+ +
+ +
+
+ > + +
+ + Inactive devices are hidden from most lists and the network map + +
+
+ + + + + +
+ +
+ +
+ <%If maptop <> "" And mapleft <> "" Then + Response.Write("Current position: X=" & mapleft & ", Y=" & maptop) + Else + Response.Write("No position set - click button to select") + End If%> +
+ + Click to select this firewall's position on the network map + +
+
+ +
+ +
+
+ + + Cancel + + <%If Not isNewRecord Then%> + + <%End If%> +
+
+ +
+ +
+
+
+
+ +
+ +
+ + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + +<% + objConn.Close +%> diff --git a/deviceserver.asp b/deviceserver.asp index 2291a2e..614d620 100644 --- a/deviceserver.asp +++ b/deviceserver.asp @@ -233,20 +233,55 @@
- + <% - Dim rsMachineTypes - strSQL3 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" + Dim rsMachineTypes, lastCat + strSQL3 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC" Set rsMachineTypes = objConn.Execute(strSQL3) + lastCat = "" While Not rsMachineTypes.EOF + If rsMachineTypes("category") <> lastCat Then + If lastCat <> "" Then Response.Write("") + Response.Write("") + lastCat = rsMachineTypes("category") + End If Response.Write("") rsMachineTypes.MoveNext Wend + If lastCat <> "" Then Response.Write("") rsMachineTypes.Close Set rsMachineTypes = Nothing %> - + + +
+ +
+
+
+ + +
@@ -552,6 +587,21 @@ $(document).ready(function() { $('#newvendorname').val('').prop('required', false); }); + // Show/hide new machine type section + $('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() { + if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') { + $('#newmodelmachinetypeid').val('new'); + $('#newMachineTypeSection').slideDown(); + $('#newmachinetypename').prop('required', true); + } + }); + + $('#cancelNewMachineType').on('click', function() { + $('#newMachineTypeSection').slideUp(); + $('#newmodelmachinetypeid').val(''); + $('#newmachinetypename').val('').prop('required', false); + }); + // Form validation $('form').on('submit', function(e) { // If adding new model, make sure fields are filled @@ -578,6 +628,15 @@ $(document).ready(function() { return false; } } + // If machine type is 'new', check machine type name + if ($('#newmodelmachinetypeid').val() === 'new') { + if ($('#newmachinetypename').val().trim() === '') { + e.preventDefault(); + alert('Please enter a machine type name or select an existing type'); + $('#newmachinetypename').focus(); + return false; + } + } } }); diff --git a/deviceswitch.asp b/deviceswitch.asp index 319a941..506d9bf 100644 --- a/deviceswitch.asp +++ b/deviceswitch.asp @@ -232,20 +232,59 @@
- + <% Dim rsMachineTypes - strSQL2 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" + strSQL2 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC" Set rsMachineTypes = objConn.Execute(strSQL2) + Dim lastCat + lastCat = "" While Not rsMachineTypes.EOF + If rsMachineTypes("category") <> lastCat Then + If lastCat <> "" Then Response.Write("") + Response.Write("") + lastCat = rsMachineTypes("category") + End If Response.Write("") rsMachineTypes.MoveNext Wend + If lastCat <> "" Then Response.Write("") rsMachineTypes.Close Set rsMachineTypes = Nothing %> - + + +
+ +
+
+
+ + +
@@ -483,6 +522,21 @@ $(document).ready(function() { $('#newvendorname').val('').prop('required', false); }); + // Show/hide new machine type section + $('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() { + if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') { + $('#newmodelmachinetypeid').val('new'); + $('#newMachineTypeSection').slideDown(); + $('#newmachinetypename').prop('required', true); + } + }); + + $('#cancelNewMachineType').on('click', function() { + $('#newMachineTypeSection').slideUp(); + $('#newmodelmachinetypeid').val(''); + $('#newmachinetypename').val('').prop('required', false); + }); + // Form validation $('form').on('submit', function(e) { // If adding new model, make sure fields are filled @@ -509,6 +563,15 @@ $(document).ready(function() { return false; } } + // If machine type is 'new', check machine type name + if ($('#newmodelmachinetypeid').val() === 'new') { + if ($('#newmachinetypename').val().trim() === '') { + e.preventDefault(); + alert('Please enter a machine type name or select an existing type'); + $('#newmachinetypename').focus(); + return false; + } + } } }); }); diff --git a/includes/data_cache.asp b/includes/data_cache.asp index 4e7707b..a0673b4 100644 --- a/includes/data_cache.asp +++ b/includes/data_cache.asp @@ -152,7 +152,10 @@ Function GetPrinterListCached() ' Fetch from database Dim sql, rs_temp, resultArray(), count, i - sql = "SELECT printers.printerid AS printer, printers.*, vendors.*, models.*, machines.* " & _ + sql = "SELECT printers.printerid AS printer, models.image, printers.installpath, " & _ + "printers.printercsfname, printers.ipaddress, printers.serialnumber AS printerserial, " & _ + "machines.islocationonly, vendors.vendor, models.modelnumber, models.documentationpath, " & _ + "machines.machinenumber, machines.machineid " & _ "FROM printers, vendors, models, machines " & _ "WHERE printers.modelid=models.modelnumberid " & _ "AND models.vendorid=vendors.vendorid " & _ @@ -191,7 +194,7 @@ Function GetPrinterListCached() resultArray(i, 7) = rs_temp("documentationpath") resultArray(i, 8) = rs_temp("printercsfname") resultArray(i, 9) = rs_temp("ipaddress") - resultArray(i, 10) = rs_temp("serialnumber") + resultArray(i, 10) = rs_temp("printerserial") ' Convert islocationonly bit to 1/0 integer (bit fields come as binary) On Error Resume Next @@ -225,7 +228,7 @@ End Function ' Render dropdown options from cached vendor data Function RenderVendorOptions(selectedID) - Dim vendors, output, i + Dim vendors, output, i, safeSelectedID vendors = GetPrinterVendorsCached() output = "" @@ -236,8 +239,14 @@ Function RenderVendorOptions(selectedID) End If On Error Goto 0 + ' Safely handle null/empty selectedID + safeSelectedID = 0 + If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then + safeSelectedID = CLng(selectedID) + End If + For i = 0 To UBound(vendors) - If CLng(vendors(i, 0)) = CLng(selectedID) Then + If CLng(vendors(i, 0)) = safeSelectedID Then output = output & "" Else output = output & "" @@ -249,7 +258,7 @@ End Function ' Render dropdown options from cached model data Function RenderModelOptions(selectedID) - Dim models, output, i + Dim models, output, i, safeSelectedID models = GetPrinterModelsCached() output = "" @@ -260,8 +269,14 @@ Function RenderModelOptions(selectedID) End If On Error Goto 0 + ' Safely handle null/empty selectedID + safeSelectedID = 0 + If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then + safeSelectedID = CLng(selectedID) + End If + For i = 0 To UBound(models) - If CLng(models(i, 0)) = CLng(selectedID) Then + If CLng(models(i, 0)) = safeSelectedID Then output = output & "" Else output = output & "" @@ -331,7 +346,7 @@ End Function ' Render dropdown options from cached support team data Function RenderSupportTeamOptions(selectedID) - Dim teams, output, i + Dim teams, output, i, safeSelectedID teams = GetSupportTeamsCached() output = "" @@ -342,8 +357,14 @@ Function RenderSupportTeamOptions(selectedID) End If On Error Goto 0 + ' Safely handle null/empty selectedID + safeSelectedID = 0 + If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then + safeSelectedID = CLng(selectedID) + End If + For i = 0 To UBound(teams) - If CLng(teams(i, 0)) = CLng(selectedID) Then + If CLng(teams(i, 0)) = safeSelectedID Then output = output & "" Else output = output & "" diff --git a/includes/topbarheader.asp b/includes/topbarheader.asp index e60bd02..b396980 100644 --- a/includes/topbarheader.asp +++ b/includes/topbarheader.asp @@ -9,7 +9,6 @@ function setCookie(value) } -