diff --git a/src/datasource/components/ConfigEditor.tsx b/src/datasource/components/ConfigEditor.tsx index 494c330..7443487 100644 --- a/src/datasource/components/ConfigEditor.tsx +++ b/src/datasource/components/ConfigEditor.tsx @@ -1,11 +1,32 @@ import React, { useEffect, useState } from 'react'; import { getDataSourceSrv, config } from '@grafana/runtime'; -import { DataSourcePluginOptionsEditorProps, DataSourceSettings, SelectableValue } from '@grafana/data'; -import { Button, DataSourceHttpSettings, InlineFormLabel, LegacyForms, Select } from '@grafana/ui'; +import { DataSourcePluginOptionsEditorProps, DataSourceSettings, GrafanaTheme2, SelectableValue } from '@grafana/data'; +import { + Field, + Icon, + Input, + Label, + SecretInput, + SecureSocksProxySettings, + Select, + Switch, + Tooltip, + useStyles2, +} from '@grafana/ui'; import { ZabbixAuthType, ZabbixDSOptions, ZabbixSecureJSONData } from '../types'; import { gte } from 'semver'; - -const { FormField, Switch } = LegacyForms; +import { + Auth, + ConfigSection, + ConfigSubSection, + Stack, + convertLegacyAuthProps, + ConnectionSettings, + DataSourceDescription, + AdvancedHttpSettings, +} from '@grafana/experimental'; +import { Divider } from './Divider'; +import { css } from '@emotion/css'; const SUPPORTED_SQL_DS = ['mysql', 'postgres', 'influxdb']; @@ -16,6 +37,7 @@ const authOptions: Array> = [ export type Props = DataSourcePluginOptionsEditorProps; export const ConfigEditor = (props: Props) => { + const styles = useStyles2(getStyles); const { options, onOptionsChange } = props; const [selectedDBDatasource, setSelectedDBDatasource] = useState(null); @@ -79,233 +101,300 @@ export const ConfigEditor = (props: Props) => { return ( <> - -
-

Zabbix API details

-
- - Auth type - + + + + + + + + + + + + -
-
- {options.secureJsonFields?.password ? ( - <> - + + resetSecureJsonField('password', options, onOptionsChange)} + onBlur={secureJsonDataChangeHandler('password', options, onOptionsChange)} + /> + + + )} + + {options.jsonData?.authType === ZabbixAuthType.Token && ( + <> + + resetSecureJsonField('apiToken', options, onOptionsChange)} + onBlur={secureJsonDataChangeHandler('apiToken', options, onOptionsChange)} + /> + + + )} + + + + + + + +
+ + + + + Cache TTL + + Zabbix data source caches metric names in memory. Specify how often data will be updated. + + } + > + + + + + } + > + + + + + + Timeout + Zabbix API connection timeout in seconds. Default is 30.}> + + + + + } + > + { + onOptionsChange({ + ...options, + jsonData: { ...options.jsonData, timeout: parseInt(event.currentTarget.value, 10) }, + }); + }} + /> + + + + + + + + + {options.jsonData.trends && ( + <> + + + After + + Time after which trends will be used. Best practice is to set this value to your history + storage period (7d, 30d, etc). + + } + > + + + + + } + > + + + + + Range + + Time range width after which trends will be used instead of history. It&aposs better to set + this value in range of 4 to 7 days to prevent loading large amount of history data. + + } + > + + + + + } + > + + + + )} + + + + + + + + {options.jsonData.dbConnectionEnable && ( + <> + + - - - ) : ( - + )} -
- - )} - - {options.jsonData.trends && ( - <> -
- -
-
- -
- - )} -
- -
-
- { - onOptionsChange({ - ...options, - jsonData: { ...options.jsonData, timeout: parseInt(event.currentTarget.value, 10) }, - }); - }} - tooltip="Zabbix API connection timeout in seconds. Default is 30." - /> -
-
+ + )} + -
-

Direct DB Connection

- - {options.jsonData.dbConnectionEnable && ( - <> -
- Data Source -