Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
1e4846d4
Unverified
Commit
1e4846d4
authored
Sep 15, 2020
by
Ryan McKinley
Committed by
GitHub
Sep 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotation: use DataFrame[] rather than a single DataFrame (#27587)
parent
e04e3e7d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
25 deletions
+21
-25
packages/grafana-data/src/types/annotations.ts
+1
-1
public/app/features/annotations/annotations_srv.ts
+3
-4
public/app/features/annotations/components/AnnotationResultMapper.tsx
+1
-1
public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx
+3
-1
public/app/features/annotations/standardAnnotationSupport.test.ts
+3
-3
public/app/features/annotations/standardAnnotationSupport.ts
+9
-9
public/app/features/annotations/types.ts
+1
-6
No files found.
packages/grafana-data/src/types/annotations.ts
View file @
1e4846d4
...
...
@@ -78,7 +78,7 @@ export interface AnnotationSupport<TQuery extends DataQuery = DataQuery, TAnno =
/**
* When the standard frame > event processing is insufficient, this allows explicit control of the mappings
*/
processEvents
?(
anno
:
TAnno
,
data
:
DataFrame
):
AnnotationEvent
[]
|
undefined
;
processEvents
?(
anno
:
TAnno
,
data
:
DataFrame
[]
):
AnnotationEvent
[]
|
undefined
;
/**
* Specify a custom QueryEditor for the annotation page. If not specified, the standard one will be used
...
...
public/app/features/annotations/annotations_srv.ts
View file @
1e4846d4
...
...
@@ -24,7 +24,7 @@ import { getTimeSrv } from '../dashboard/services/TimeSrv';
import
{
Observable
,
of
}
from
'rxjs'
;
import
{
map
}
from
'rxjs/operators'
;
import
{
AnnotationQueryResponse
,
AnnotationQueryOptions
}
from
'./types'
;
import
{
standardAnnotationSupport
,
singleFrameFromPanelData
}
from
'./standardAnnotationSupport'
;
import
{
standardAnnotationSupport
}
from
'./standardAnnotationSupport'
;
import
{
runRequest
}
from
'../dashboard/state/runRequest'
;
let
counter
=
100
;
...
...
@@ -263,9 +263,8 @@ export function executeAnnotationQuery(
return
runRequest
(
datasource
,
queryRequest
).
pipe
(
map
(
panelData
=>
{
const
frame
=
singleFrameFromPanelData
(
panelData
);
const
events
=
frame
?
processor
.
processEvents
!
(
annotation
,
frame
)
:
[];
return
{
panelData
,
frame
,
events
};
const
events
=
panelData
.
series
?
processor
.
processEvents
!
(
annotation
,
panelData
.
series
)
:
[];
return
{
panelData
,
events
};
})
);
}
...
...
public/app/features/annotations/components/AnnotationResultMapper.tsx
View file @
1e4846d4
...
...
@@ -42,7 +42,7 @@ export class AnnotationFieldMapper extends PureComponent<Props, State> {
}
updateFields
=
()
=>
{
const
frame
=
this
.
props
.
response
?.
frame
;
const
frame
=
this
.
props
.
response
?.
panelData
?.
series
[
0
]
;
if
(
frame
&&
frame
.
fields
)
{
const
fieldNames
=
frame
.
fields
.
map
(
f
=>
{
const
name
=
getFieldDisplayName
(
f
,
frame
);
...
...
public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx
View file @
1e4846d4
...
...
@@ -97,7 +97,7 @@ export default class StandardAnnotationQueryEditor extends PureComponent<Props,
if
(
running
||
response
?.
panelData
?.
state
===
LoadingState
.
Loading
||
!
response
)
{
text
=
'loading...'
;
}
else
{
const
{
events
,
panelData
,
frame
}
=
response
;
const
{
events
,
panelData
}
=
response
;
if
(
panelData
?.
error
)
{
rowStyle
=
'alert-error'
;
...
...
@@ -108,6 +108,8 @@ export default class StandardAnnotationQueryEditor extends PureComponent<Props,
icon
=
'exclamation-triangle'
;
text
=
'No events found'
;
}
else
{
const
frame
=
panelData
?.
series
[
0
];
text
=
`
${
events
.
length
}
events (from
${
frame
?.
fields
.
length
}
fields
)
`;
}
}
...
...
public/app/features/annotations/standardAnnotationSupport.test.ts
View file @
1e4846d4
import
{
toDataFrame
,
FieldType
}
from
'@grafana/data'
;
import
{
getAnnotationsFrom
Frame
}
from
'./standardAnnotationSupport'
;
import
{
getAnnotationsFrom
Data
}
from
'./standardAnnotationSupport'
;
describe
(
'DataFrame to annotations'
,
()
=>
{
test
(
'simple conversion'
,
()
=>
{
...
...
@@ -11,7 +11,7 @@ describe('DataFrame to annotations', () => {
],
});
const
events
=
getAnnotationsFrom
Frame
(
frame
);
const
events
=
getAnnotationsFrom
Data
([
frame
]
);
expect
(
events
).
toMatchInlineSnapshot
(
`
Array [
Object {
...
...
@@ -51,7 +51,7 @@ describe('DataFrame to annotations', () => {
],
});
const
events
=
getAnnotationsFrom
Frame
(
frame
,
{
const
events
=
getAnnotationsFrom
Data
([
frame
]
,
{
text
:
{
value
:
'bbbbb'
},
time
:
{
value
:
'time2'
},
timeEnd
:
{
value
:
'time1'
},
...
...
public/app/features/annotations/standardAnnotationSupport.ts
View file @
1e4846d4
...
...
@@ -2,7 +2,6 @@ import {
DataFrame
,
AnnotationQuery
,
AnnotationSupport
,
PanelData
,
transformDataFrame
,
FieldType
,
Field
,
...
...
@@ -43,20 +42,20 @@ export const standardAnnotationSupport: AnnotationSupport = {
/**
* When the standard frame > event processing is insufficient, this allows explicit control of the mappings
*/
processEvents
:
(
anno
:
AnnotationQuery
,
data
:
DataFrame
)
=>
{
return
getAnnotationsFrom
Frame
(
data
,
anno
.
mappings
);
processEvents
:
(
anno
:
AnnotationQuery
,
data
:
DataFrame
[]
)
=>
{
return
getAnnotationsFrom
Data
(
data
,
anno
.
mappings
);
},
};
/**
* Flatten all panel data into a single frame
*/
export
function
singleFrameFromPanelData
(
rsp
:
PanelData
):
DataFrame
|
undefined
{
if
(
!
rsp
?.
series
?.
length
)
{
export
function
singleFrameFromPanelData
(
data
:
DataFrame
[]
):
DataFrame
|
undefined
{
if
(
!
data
?.
length
)
{
return
undefined
;
}
if
(
rsp
.
series
.
length
===
1
)
{
return
rsp
.
series
[
0
];
if
(
data
.
length
===
1
)
{
return
data
[
0
];
}
return
transformDataFrame
(
...
...
@@ -66,7 +65,7 @@ export function singleFrameFromPanelData(rsp: PanelData): DataFrame | undefined
options
:
{
byField
:
'Time'
},
},
],
rsp
.
series
data
)[
0
];
}
...
...
@@ -108,7 +107,8 @@ export const annotationEventNames: AnnotationFieldInfo[] = [
// { key: 'email' },
];
export
function
getAnnotationsFromFrame
(
frame
:
DataFrame
,
options
?:
AnnotationEventMappings
):
AnnotationEvent
[]
{
export
function
getAnnotationsFromData
(
data
:
DataFrame
[],
options
?:
AnnotationEventMappings
):
AnnotationEvent
[]
{
const
frame
=
singleFrameFromPanelData
(
data
);
if
(
!
frame
?.
length
)
{
return
[];
}
...
...
public/app/features/annotations/types.ts
View file @
1e4846d4
import
{
PanelData
,
DataFrame
,
AnnotationEvent
,
TimeRange
}
from
'@grafana/data'
;
import
{
PanelData
,
AnnotationEvent
,
TimeRange
}
from
'@grafana/data'
;
import
{
DashboardModel
,
PanelModel
}
from
'../dashboard/state'
;
export
interface
AnnotationQueryOptions
{
...
...
@@ -9,11 +9,6 @@ export interface AnnotationQueryOptions {
export
interface
AnnotationQueryResponse
{
/**
* All the data flattened to a single frame
*/
frame
?:
DataFrame
;
/**
* The processed annotation events
*/
events
?:
AnnotationEvent
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment