import styles from './ConfigurationForm.module.css'; import Block from '../../../GBlock/Block'; import Text from '../../../Text/Text'; import PluginState from '../../../../plugin_state'; import { Button, Field, Form, Input } from '@grafana/ui'; import cn from 'classnames/bind'; import { SubmitHandler } from 'react-hook-form'; import React, { FC, useCallback, useState } from 'react'; import { isEmpty } from 'lodash-es'; const cx = cn.bind(styles); type Props = { onSuccessfulSetup: () => void; defaultDataExporterApiUrl: string; }; type FormProps = { dataExporterApiUrl: string; }; /** * https://stackoverflow.com/a/43467144 */ const isValidUrl = (url: string): boolean => { try { new URL(url); return true; } catch (_) { return false; } }; const FormErrorMessage: FC<{ errorMsg: string }> = ({ errorMsg }) => ( <>
      {errorMsg}
    
Need help?
- file bugs on our GitHub Issues page{' '} here
); const ConfigurationForm: FC = ({ onSuccessfulSetup, defaultDataExporterApiUrl }) => { const [setupErrorMsg, setSetupErrorMsg] = useState(null); const [formLoading, setFormLoading] = useState(false); const setupPlugin: SubmitHandler = useCallback( async ({ dataExporterApiUrl }) => { setFormLoading(true); const errorMsg = await PluginState.installPlugin(dataExporterApiUrl); if (!errorMsg) { onSuccessfulSetup(); } else { setSetupErrorMsg(errorMsg); setFormLoading(false); } }, [onSuccessfulSetup] ); return ( defaultValues={{ dataExporterApiUrl: defaultDataExporterApiUrl }} onSubmit={setupPlugin}> {({ register, errors }) => ( <>

1. Launch the DataExporter backend

Run hobby, dev or production backend. See{' '} here {' '} on how to get started.

2. Let us know the base URL of your DataExporter API

The DataExporter backend must be reachable from your Grafana installation. Some examples are:
- http://host.docker.internal:8080
- http://localhost:8080
{setupErrorMsg && } )} ); }; export default ConfigurationForm;