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
8e85295b
Commit
8e85295b
authored
Oct 14, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
react panels query processing
parent
543c67a2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
88 additions
and
34 deletions
+88
-34
public/app/core/core_module.ts
+0
-1
public/app/features/dashboard/dashgrid/DataPanel.tsx
+17
-9
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+2
-2
public/app/features/plugins/datasource_srv.ts
+7
-1
public/app/plugins/panel/graph/module.ts
+1
-0
public/app/plugins/panel/graph2/module.tsx
+22
-10
public/app/plugins/panel/text2/module.tsx
+1
-8
public/app/types/index.ts
+5
-1
public/app/types/panel.ts
+2
-2
public/app/types/series.ts
+31
-0
No files found.
public/app/core/core_module.ts
View file @
8e85295b
import
angular
from
'angular'
;
console
.
log
(
'core module code'
);
const
coreModule
=
angular
.
module
(
'grafana.core'
,
[
'ngRoute'
]);
// legacy modules
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
8e85295b
...
...
@@ -5,11 +5,11 @@ import React, { Component } from 'react';
import
{
getDatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
// Types
import
{
TimeRange
,
LoadingState
}
from
'app/types'
;
import
{
TimeRange
,
LoadingState
,
DataQueryResponse
,
TimeSeries
}
from
'app/types'
;
interface
RenderProps
{
loading
:
LoadingState
;
data
:
any
;
timeSeries
:
TimeSeries
[]
;
}
export
interface
Props
{
...
...
@@ -26,7 +26,7 @@ export interface Props {
export
interface
State
{
isFirstLoad
:
boolean
;
loading
:
LoadingState
;
data
:
any
;
response
:
DataQueryResponse
;
}
export
class
DataPanel
extends
Component
<
Props
,
State
>
{
...
...
@@ -41,7 +41,9 @@ export class DataPanel extends Component<Props, State> {
this
.
state
=
{
loading
:
LoadingState
.
NotStarted
,
data
:
[],
response
:
{
data
:
[],
},
isFirstLoad
:
true
,
};
}
...
...
@@ -70,7 +72,7 @@ export class DataPanel extends Component<Props, State> {
}
if
(
!
queries
.
length
)
{
this
.
setState
({
data
:
[],
loading
:
LoadingState
.
Done
});
this
.
setState
({
loading
:
LoadingState
.
Done
});
return
;
}
...
...
@@ -94,9 +96,14 @@ export class DataPanel extends Component<Props, State> {
cacheTimeout
:
null
,
};
console
.
log
(
'
issueing react
query'
,
queryOptions
);
console
.
log
(
'
Issuing DataPanel
query'
,
queryOptions
);
const
resp
=
await
ds
.
query
(
queryOptions
);
console
.
log
(
resp
);
console
.
log
(
'Issuing DataPanel query Resp'
,
resp
);
this
.
setState
({
loading
:
LoadingState
.
Done
,
response
:
resp
,
});
}
catch
(
err
)
{
console
.
log
(
'Loading error'
,
err
);
this
.
setState
({
loading
:
LoadingState
.
Error
});
...
...
@@ -104,8 +111,9 @@ export class DataPanel extends Component<Props, State> {
};
render
()
{
const
{
data
,
loading
,
isFirstLoad
}
=
this
.
state
;
const
{
response
,
loading
,
isFirstLoad
}
=
this
.
state
;
console
.
log
(
'data panel render'
);
const
timeSeries
=
response
.
data
;
if
(
isFirstLoad
&&
(
loading
===
LoadingState
.
Loading
||
loading
===
LoadingState
.
NotStarted
))
{
return
(
...
...
@@ -119,7 +127,7 @@ export class DataPanel extends Component<Props, State> {
<>
{
this
.
loadingSpinner
}
{
this
.
props
.
children
({
data
,
timeSeries
,
loading
,
})
}
</>
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
8e85295b
...
...
@@ -73,8 +73,8 @@ export class PanelChrome extends PureComponent<Props, State> {
isVisible=
{
this
.
isVisible
}
refreshCounter=
{
refreshCounter
}
>
{
({
loading
,
data
})
=>
{
return
<
PanelComponent
loading=
{
loading
}
data=
{
data
}
/>;
{
({
loading
,
timeSeries
})
=>
{
return
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
/>;
}
}
</
DataPanel
>
</
div
>
...
...
public/app/features/plugins/datasource_srv.ts
View file @
8e85295b
// Libraries
import
_
from
'lodash'
;
import
coreModule
from
'app/core/core_module'
;
// Utils
import
config
from
'app/core/config'
;
import
{
importPluginModule
}
from
'./plugin_loader'
;
// Types
import
{
DataSourceApi
}
from
'app/types/series'
;
export
class
DatasourceSrv
{
datasources
:
any
;
...
...
@@ -15,7 +21,7 @@ export class DatasourceSrv {
this
.
datasources
=
{};
}
get
(
name
?)
{
get
(
name
?)
:
Promise
<
DataSourceApi
>
{
if
(
!
name
)
{
return
this
.
get
(
config
.
defaultDatasource
);
}
...
...
public/app/plugins/panel/graph/module.ts
View file @
8e85295b
...
...
@@ -179,6 +179,7 @@ class GraphCtrl extends MetricsPanelCtrl {
}
onDataReceived
(
dataList
)
{
console
.
log
(
dataList
);
this
.
dataList
=
dataList
;
this
.
seriesList
=
this
.
processor
.
getSeriesList
({
dataList
:
dataList
,
...
...
public/app/plugins/panel/graph2/module.tsx
View file @
8e85295b
// Libraries
import
_
from
'lodash'
;
import
React
,
{
PureComponent
}
from
'react'
;
// Types
import
{
PanelProps
}
from
'app/types'
;
interface
Options
{
...
...
@@ -15,16 +19,24 @@ export class Graph2 extends PureComponent<Props> {
}
render
()
{
const
{
data
}
=
this
.
props
;
let
value
=
0
;
if
(
data
.
length
)
{
value
=
data
[
0
].
value
;
}
console
.
log
(
'graph2 render'
);
return
<
h2
>
Text Panel
{
value
}
</
h2
>;
const
{
timeSeries
}
=
this
.
props
;
let
index
=
0
;
return
(
<
table
className=
"filter-table"
>
<
tbody
>
{
timeSeries
.
map
(
series
=>
{
return
(
<
tr
key=
{
index
++
}
>
<
td
>
{
series
.
target
}
</
td
>
<
td
>
{
series
.
datapoints
[
0
][
0
]
}
</
td
>
<
td
>
{
series
.
datapoints
[
0
][
1
]
}
</
td
>
</
tr
>
);
})
}
</
tbody
>
</
table
>
);
}
}
...
...
public/app/plugins/panel/text2/module.tsx
View file @
8e85295b
...
...
@@ -7,14 +7,7 @@ export class Text2 extends PureComponent<PanelProps> {
}
render
()
{
const
{
data
}
=
this
.
props
;
let
value
=
0
;
if
(
data
.
length
)
{
value
=
data
[
0
].
value
;
}
return
<
h2
>
Text Panel!
{
value
}
</
h2
>;
return
<
h2
>
Text Panel!
</
h2
>;
}
}
...
...
public/app/types/index.ts
View file @
8e85295b
...
...
@@ -9,7 +9,7 @@ import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys';
import
{
Invitee
,
OrgUser
,
User
,
UsersState
}
from
'./user'
;
import
{
DataSource
,
DataSourcesState
}
from
'./datasources'
;
import
{
PluginMeta
,
Plugin
,
PluginsState
}
from
'./plugins'
;
import
{
TimeRange
,
LoadingState
}
from
'./qu
eries'
;
import
{
TimeRange
,
LoadingState
,
TimeSeries
,
DataQuery
,
DataQueryResponse
,
DataQueryOptions
}
from
'./s
eries'
;
import
{
PanelProps
}
from
'./panel'
;
export
{
...
...
@@ -50,6 +50,10 @@ export {
TimeRange
,
LoadingState
,
PanelProps
,
TimeSeries
,
DataQuery
,
DataQueryResponse
,
DataQueryOptions
,
};
export
interface
StoreState
{
...
...
public/app/types/panel.ts
View file @
8e85295b
import
{
LoadingState
}
from
'./qu
eries'
;
import
{
LoadingState
,
TimeSeries
}
from
'./s
eries'
;
export
interface
PanelProps
{
data
:
any
;
timeSeries
:
TimeSeries
[]
;
loading
:
LoadingState
;
}
public/app/types/
qu
eries.ts
→
public/app/types/
s
eries.ts
View file @
8e85295b
...
...
@@ -17,3 +17,34 @@ export interface TimeRange {
to
:
Moment
;
raw
:
RawTimeRange
;
}
export
type
TimeSeriesValue
=
string
|
number
|
null
;
export
type
TimeSeriesPoints
=
TimeSeriesValue
[][];
export
interface
TimeSeries
{
target
:
string
;
datapoints
:
TimeSeriesPoints
;
}
export
interface
DataQueryResponse
{
data
:
TimeSeries
[];
}
export
interface
DataQuery
{
refId
:
string
;
}
export
interface
DataQueryOptions
{
timezone
:
string
;
range
:
TimeRange
;
rangeRaw
:
RawTimeRange
;
targets
:
DataQuery
[];
panelId
:
number
;
dashboardId
:
number
;
cacheTimeout
?:
string
;
}
export
interface
DataSourceApi
{
query
(
options
:
DataQueryOptions
):
Promise
<
DataQueryResponse
>
;
}
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