mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: Improve code formatting and readability in SNMP monitor components
This commit is contained in:
@@ -32,7 +32,8 @@ const SnmpMonitorStepForm: FunctionComponent<ComponentProps> = (
|
||||
const snmpVersionOptions: Array<DropdownOption> =
|
||||
DropdownUtil.getDropdownOptionsFromEnum(SnmpVersion);
|
||||
|
||||
const isV3: boolean = props.monitorStepSnmpMonitor.snmpVersion === SnmpVersion.V3;
|
||||
const isV3: boolean =
|
||||
props.monitorStepSnmpMonitor.snmpVersion === SnmpVersion.V3;
|
||||
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
@@ -133,7 +134,9 @@ const SnmpMonitorStepForm: FunctionComponent<ComponentProps> = (
|
||||
required={true}
|
||||
/>
|
||||
<Input
|
||||
initialValue={props.monitorStepSnmpMonitor.communityString || "public"}
|
||||
initialValue={
|
||||
props.monitorStepSnmpMonitor.communityString || "public"
|
||||
}
|
||||
placeholder="public"
|
||||
onChange={(value: string) => {
|
||||
props.onChange({
|
||||
|
||||
@@ -155,9 +155,7 @@ const SnmpOidEditor: FunctionComponent<ComponentProps> = (
|
||||
<Dropdown
|
||||
options={templateOptions}
|
||||
placeholder="Select a common OID template..."
|
||||
onChange={(
|
||||
value: DropdownValue | Array<DropdownValue> | null,
|
||||
) => {
|
||||
onChange={(value: DropdownValue | Array<DropdownValue> | null) => {
|
||||
if (value) {
|
||||
const template: SnmpOid | undefined =
|
||||
SnmpOidTemplates.getCommonOids().find((t: SnmpOid) => {
|
||||
|
||||
@@ -90,7 +90,9 @@ const SnmpV3AuthForm: FunctionComponent<ComponentProps> = (
|
||||
return option.value === props.value.authProtocol;
|
||||
},
|
||||
)}
|
||||
onChange={(value: DropdownValue | Array<DropdownValue> | null) => {
|
||||
onChange={(
|
||||
value: DropdownValue | Array<DropdownValue> | null,
|
||||
) => {
|
||||
props.onChange({
|
||||
...props.value,
|
||||
authProtocol: value as SnmpAuthProtocol,
|
||||
@@ -134,7 +136,9 @@ const SnmpV3AuthForm: FunctionComponent<ComponentProps> = (
|
||||
return option.value === props.value.privProtocol;
|
||||
},
|
||||
)}
|
||||
onChange={(value: DropdownValue | Array<DropdownValue> | null) => {
|
||||
onChange={(
|
||||
value: DropdownValue | Array<DropdownValue> | null,
|
||||
) => {
|
||||
props.onChange({
|
||||
...props.value,
|
||||
privProtocol: value as SnmpPrivProtocol,
|
||||
|
||||
@@ -295,7 +295,10 @@ export default class SnmpMonitor {
|
||||
}
|
||||
|
||||
// Handle numeric values
|
||||
if (typeof varbind.value === "number" || typeof varbind.value === "bigint") {
|
||||
if (
|
||||
typeof varbind.value === "number" ||
|
||||
typeof varbind.value === "bigint"
|
||||
) {
|
||||
return Number(varbind.value);
|
||||
}
|
||||
|
||||
@@ -303,7 +306,9 @@ export default class SnmpMonitor {
|
||||
return String(varbind.value);
|
||||
}
|
||||
|
||||
private static mapSnmpDataType(type: snmp.ObjectType | undefined): SnmpDataType {
|
||||
private static mapSnmpDataType(
|
||||
type: snmp.ObjectType | undefined,
|
||||
): SnmpDataType {
|
||||
switch (type) {
|
||||
case snmp.ObjectType.Integer:
|
||||
return SnmpDataType.Integer;
|
||||
@@ -336,7 +341,9 @@ export default class SnmpMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
private static mapSnmpErrorType(type: snmp.ObjectType | undefined): SnmpDataType {
|
||||
private static mapSnmpErrorType(
|
||||
type: snmp.ObjectType | undefined,
|
||||
): SnmpDataType {
|
||||
switch (type) {
|
||||
case snmp.ObjectType.NoSuchObject:
|
||||
return SnmpDataType.NoSuchObject;
|
||||
|
||||
@@ -169,7 +169,8 @@ export default class MonitorUtil {
|
||||
monitorStep.data.snmpMonitor.snmpV3Auth.authKey =
|
||||
(await MonitorUtil.fillSecretsInStringOrJSON({
|
||||
secrets: monitorSecrets,
|
||||
populateSecretsIn: monitorStep.data.snmpMonitor.snmpV3Auth.authKey,
|
||||
populateSecretsIn:
|
||||
monitorStep.data.snmpMonitor.snmpV3Auth.authKey,
|
||||
})) as string;
|
||||
}
|
||||
|
||||
@@ -185,7 +186,8 @@ export default class MonitorUtil {
|
||||
monitorStep.data.snmpMonitor.snmpV3Auth.privKey =
|
||||
(await MonitorUtil.fillSecretsInStringOrJSON({
|
||||
secrets: monitorSecrets,
|
||||
populateSecretsIn: monitorStep.data.snmpMonitor.snmpV3Auth.privKey,
|
||||
populateSecretsIn:
|
||||
monitorStep.data.snmpMonitor.snmpV3Auth.privKey,
|
||||
})) as string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user