mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
3c6e0e8ef8
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
88 lines
2.9 KiB
TypeScript
88 lines
2.9 KiB
TypeScript
import { cloneDeep } from 'lodash';
|
|
|
|
import { AnnotationEvent, deprecationWarning } from '@grafana/data';
|
|
import { deleteAnnotation, saveAnnotation, updateAnnotation } from 'app/features/annotations/api';
|
|
import { AnnotationQueryOptions } from 'app/features/annotations/types';
|
|
|
|
/**
|
|
* @deprecated AnnotationsSrv is deprecated in favor of DashboardQueryRunner
|
|
*/
|
|
export class AnnotationsSrv {
|
|
/**
|
|
* @deprecated clearPromiseCaches is deprecated
|
|
*/
|
|
clearPromiseCaches() {
|
|
deprecationWarning('annotations_srv.ts', 'clearPromiseCaches', 'DashboardQueryRunner');
|
|
}
|
|
|
|
/**
|
|
* @deprecated getAnnotations is deprecated in favor of DashboardQueryRunner.getResult
|
|
*/
|
|
getAnnotations(options: AnnotationQueryOptions) {
|
|
deprecationWarning('annotations_srv.ts', 'getAnnotations', 'DashboardQueryRunner.getResult');
|
|
return Promise.resolve({ annotations: [], alertState: undefined });
|
|
}
|
|
|
|
/**
|
|
* @deprecated getAlertStates is deprecated in favor of DashboardQueryRunner.getResult
|
|
*/
|
|
getAlertStates(options: any) {
|
|
deprecationWarning('annotations_srv.ts', 'getAlertStates', 'DashboardQueryRunner.getResult');
|
|
return Promise.resolve(undefined);
|
|
}
|
|
|
|
/**
|
|
* @deprecated getGlobalAnnotations is deprecated in favor of DashboardQueryRunner.getResult
|
|
*/
|
|
getGlobalAnnotations(options: AnnotationQueryOptions) {
|
|
deprecationWarning('annotations_srv.ts', 'getGlobalAnnotations', 'DashboardQueryRunner.getResult');
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
/**
|
|
* @deprecated saveAnnotationEvent is deprecated
|
|
*/
|
|
saveAnnotationEvent(annotation: AnnotationEvent) {
|
|
deprecationWarning('annotations_srv.ts', 'saveAnnotationEvent', 'api/saveAnnotation');
|
|
return saveAnnotation(annotation);
|
|
}
|
|
|
|
/**
|
|
* @deprecated updateAnnotationEvent is deprecated
|
|
*/
|
|
updateAnnotationEvent(annotation: AnnotationEvent) {
|
|
deprecationWarning('annotations_srv.ts', 'updateAnnotationEvent', 'api/updateAnnotation');
|
|
return updateAnnotation(annotation);
|
|
}
|
|
|
|
/**
|
|
* @deprecated deleteAnnotationEvent is deprecated
|
|
*/
|
|
deleteAnnotationEvent(annotation: AnnotationEvent) {
|
|
deprecationWarning('annotations_srv.ts', 'deleteAnnotationEvent', 'api/deleteAnnotation');
|
|
return deleteAnnotation(annotation);
|
|
}
|
|
|
|
/**
|
|
* @deprecated translateQueryResult is deprecated in favor of DashboardQueryRunner/utils/translateQueryResult
|
|
*/
|
|
translateQueryResult(annotation: any, results: any) {
|
|
deprecationWarning('annotations_srv.ts', 'translateQueryResult', 'DashboardQueryRunner/utils/translateQueryResult');
|
|
// if annotation has snapshotData
|
|
// make clone and remove it
|
|
if (annotation.snapshotData) {
|
|
annotation = cloneDeep(annotation);
|
|
delete annotation.snapshotData;
|
|
}
|
|
|
|
for (const item of results) {
|
|
item.source = annotation;
|
|
item.color = annotation.iconColor;
|
|
item.type = annotation.name;
|
|
item.isRegion = item.timeEnd && item.time !== item.timeEnd;
|
|
}
|
|
|
|
return results;
|
|
}
|
|
}
|