grafana/public/app/features/annotations/api.ts
Ashley Harrison cc4d301d50
Annotations: Add typeahead support for tags in builtin annotations (#36377)
* Annotations: create React component, naive attempt at hooking together

* Annotations: Use query object instead of passing annotation

* Annotations: Hook up the new api to get annotation tags

* Annotations: Use InlineFieldRow instead of gf-form-inline

* Annotations: Use InlineSwitch instead of gf-form-switch

* TagFilter: Add support for allowCustomValue

* Annotations: Update to match backend api

* Annotations: Add basic tests, expose inputId on `TagFilter`

* Annotations: Fix test name and reorder tests slightly

* Annotations: Use FieldSet instead of gf-form-group

* Refactor: fixes annotation queries

* Annotations: Everything working, just types to fix...

* Annotations: Fix types?

* Revert "Annotations: Fix types?"

This reverts commit 6df0cae0c9.

* Annotations: Fix types again?

* Annotations: Remove old angular code

* Annotations: Fix unit tests for AnnotationQueryEditor

* Annotations: Check if it's an annotation query immediately

* Annotations: Prevent TagFilter overflowing container when there are a large number of tags

* Change to new form styles

* Annotations: Add id's + fix unit tests

* Updated wording

* Annotations: Allow custom value to preserve being able to use template variables

Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2021-07-06 10:50:46 +01:00

24 lines
792 B
TypeScript

import { AnnotationEvent } from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime';
import { AnnotationTagsResponse } from './types';
export function saveAnnotation(annotation: AnnotationEvent) {
return getBackendSrv().post('/api/annotations', annotation);
}
export function updateAnnotation(annotation: AnnotationEvent) {
return getBackendSrv().put(`/api/annotations/${annotation.id}`, annotation);
}
export function deleteAnnotation(annotation: AnnotationEvent) {
return getBackendSrv().delete(`/api/annotations/${annotation.id}`);
}
export async function getAnnotationTags() {
const response: AnnotationTagsResponse = await getBackendSrv().get('/api/annotations/tags');
return response.result.tags.map(({ tag, count }) => ({
term: tag,
count,
}));
}