-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate angular annotation editor (#196)
- Loading branch information
Showing
11 changed files
with
70 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AnnotationEventFieldSource } from '@grafana/data'; | ||
|
||
const isNewAnnotation = (json: any) => { | ||
return !('annotation' in json); | ||
}; | ||
|
||
export const prepareAnnotation = (json: any) => { | ||
if (isNewAnnotation(json)) { | ||
return json; | ||
} | ||
|
||
const { annotation, ...annotationRest } = json; | ||
const { field, timeField, ...targetRest } = annotation; | ||
|
||
const migratedAnnotation = { | ||
...annotationRest, | ||
target: targetRest, | ||
mappings: { | ||
text: field | ||
? { | ||
source: AnnotationEventFieldSource.Field, | ||
value: field, | ||
} | ||
: undefined, | ||
time: timeField | ||
? { | ||
source: AnnotationEventFieldSource.Field, | ||
value: timeField, | ||
} | ||
: undefined, | ||
...annotationRest.mappings, | ||
}, | ||
}; | ||
|
||
return migratedAnnotation; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import { DataSourcePlugin } from '@grafana/data'; | ||
import { DataSource } from './DataSource'; | ||
import { GithubDataSource } from './DataSource'; | ||
import ConfigEditor from './views/ConfigEditor'; | ||
import QueryEditor from './views/QueryEditor'; | ||
import VariableQueryEditor from './views/VariableQueryEditor'; | ||
import AnnotationCtrl from './annotations'; | ||
import { GitHubQuery, GithubDataSourceOptions, GithubSecureJsonData } from './types'; | ||
|
||
export const plugin = new DataSourcePlugin<DataSource, GitHubQuery, GithubDataSourceOptions, GithubSecureJsonData>( | ||
DataSource | ||
) | ||
export const plugin = new DataSourcePlugin< | ||
GithubDataSource, | ||
GitHubQuery, | ||
GithubDataSourceOptions, | ||
GithubSecureJsonData | ||
>(GithubDataSource) | ||
.setConfigEditor(ConfigEditor) | ||
.setVariableQueryEditor(VariableQueryEditor) | ||
.setQueryEditor(QueryEditor) | ||
.setAnnotationQueryCtrl(AnnotationCtrl); | ||
.setQueryEditor(QueryEditor); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters