2020-01-15 16:38:15 +01:00
|
|
|
import React, { ChangeEvent } from 'react';
|
2020-04-07 08:50:54 +02:00
|
|
|
import { LegacyForms } from '@grafana/ui';
|
|
|
|
|
const { Switch } = LegacyForms;
|
2020-01-15 16:38:15 +01:00
|
|
|
import { PanelData } from '@grafana/data';
|
2021-09-08 16:06:43 +02:00
|
|
|
import { CloudWatchAnnotationQuery } from '../types';
|
2020-04-25 21:48:20 +01:00
|
|
|
import { CloudWatchDatasource } from '../datasource';
|
|
|
|
|
import { QueryField, PanelQueryEditor } from './';
|
2020-01-15 16:38:15 +01:00
|
|
|
|
|
|
|
|
export type Props = {
|
2021-09-08 16:06:43 +02:00
|
|
|
query: CloudWatchAnnotationQuery;
|
2020-01-15 16:38:15 +01:00
|
|
|
datasource: CloudWatchDatasource;
|
2021-09-08 16:06:43 +02:00
|
|
|
onChange: (value: CloudWatchAnnotationQuery) => void;
|
2020-01-15 16:38:15 +01:00
|
|
|
data?: PanelData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function AnnotationQueryEditor(props: React.PropsWithChildren<Props>) {
|
|
|
|
|
const { query, onChange } = props;
|
2021-04-23 14:06:30 +02:00
|
|
|
|
2020-01-15 16:38:15 +01:00
|
|
|
return (
|
|
|
|
|
<>
|
2020-04-25 21:48:20 +01:00
|
|
|
<PanelQueryEditor
|
2020-01-15 16:38:15 +01:00
|
|
|
{...props}
|
2021-09-08 16:06:43 +02:00
|
|
|
onChange={(editorQuery: CloudWatchAnnotationQuery) => onChange({ ...query, ...editorQuery })}
|
2020-04-25 21:48:20 +01:00
|
|
|
onRunQuery={() => {}}
|
|
|
|
|
history={[]}
|
|
|
|
|
></PanelQueryEditor>
|
2020-01-15 16:38:15 +01:00
|
|
|
<div className="gf-form-inline">
|
|
|
|
|
<Switch
|
|
|
|
|
label="Enable Prefix Matching"
|
|
|
|
|
labelClass="query-keyword"
|
|
|
|
|
checked={query.prefixMatching}
|
|
|
|
|
onChange={() => onChange({ ...query, prefixMatching: !query.prefixMatching })}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="gf-form gf-form--grow">
|
|
|
|
|
<QueryField label="Action">
|
|
|
|
|
<input
|
|
|
|
|
disabled={!query.prefixMatching}
|
|
|
|
|
className="gf-form-input width-12"
|
|
|
|
|
value={query.actionPrefix || ''}
|
|
|
|
|
onChange={(event: ChangeEvent<HTMLInputElement>) =>
|
|
|
|
|
onChange({ ...query, actionPrefix: event.target.value })
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</QueryField>
|
|
|
|
|
<QueryField label="Alarm Name">
|
|
|
|
|
<input
|
|
|
|
|
disabled={!query.prefixMatching}
|
|
|
|
|
className="gf-form-input width-12"
|
|
|
|
|
value={query.alarmNamePrefix || ''}
|
|
|
|
|
onChange={(event: ChangeEvent<HTMLInputElement>) =>
|
|
|
|
|
onChange({ ...query, alarmNamePrefix: event.target.value })
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</QueryField>
|
|
|
|
|
<div className="gf-form gf-form--grow">
|
|
|
|
|
<div className="gf-form-label gf-form-label--grow" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|