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
90c41bb0
Commit
90c41bb0
authored
Nov 14, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed how size is calcualted and propagated and added proper interval calc to DataPanel
parent
dedeaf54
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
31 deletions
+41
-31
public/app/core/components/Switch/Switch.tsx
+1
-0
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
+1
-0
public/app/features/dashboard/dashgrid/DataPanel.tsx
+19
-17
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+12
-14
public/app/types/series.ts
+2
-0
public/app/viz/Graph.tsx
+1
-0
public/sass/pages/_dashboard.scss
+5
-0
No files found.
public/app/core/components/Switch/Switch.tsx
View file @
90c41bb0
...
...
@@ -26,6 +26,7 @@ export class Switch extends PureComponent<Props, State> {
render
()
{
const
{
labelClass
=
''
,
switchClass
=
''
,
label
,
checked
,
small
}
=
this
.
props
;
const
labelId
=
`check-
${
this
.
state
.
id
}
`
;
let
labelClassName
=
`gf-form-label
${
labelClass
}
pointer`
;
let
switchClassName
=
`gf-form-switch
${
switchClass
}
`
;
...
...
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
View file @
90c41bb0
...
...
@@ -176,6 +176,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
renderPanels
()
{
const
panelElements
=
[];
console
.
log
(
'render panels'
);
for
(
const
panel
of
this
.
props
.
dashboard
.
panels
)
{
const
panelClasses
=
classNames
({
panel
:
true
,
'panel--fullscreen'
:
panel
.
fullscreen
});
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
90c41bb0
...
...
@@ -4,6 +4,9 @@ import React, { Component } from 'react';
// Services
import
{
getDatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
// Utils
import
kbn
from
'app/core/utils/kbn'
;
// Types
import
{
TimeRange
,
LoadingState
,
DataQueryOptions
,
DataQueryResponse
,
TimeSeries
}
from
'app/types'
;
...
...
@@ -21,6 +24,8 @@ export interface Props {
timeRange
?:
TimeRange
;
widthPixels
:
number
;
refreshCounter
:
number
;
minInterval
?:
string
;
maxDataPoints
?:
number
;
children
:
(
r
:
RenderProps
)
=>
JSX
.
Element
;
}
...
...
@@ -52,7 +57,7 @@ export class DataPanel extends Component<Props, State> {
}
componentDidMount
()
{
console
.
log
(
'DataPanel mount'
);
this
.
issueQueries
(
);
}
async
componentDidUpdate
(
prevProps
:
Props
)
{
...
...
@@ -64,12 +69,11 @@ export class DataPanel extends Component<Props, State> {
}
hasPropsChanged
(
prevProps
:
Props
)
{
return
this
.
props
.
refreshCounter
!==
prevProps
.
refreshCounter
||
this
.
props
.
isVisible
!==
prevProps
.
isVisible
;
return
this
.
props
.
refreshCounter
!==
prevProps
.
refreshCounter
;
}
issueQueries
=
async
()
=>
{
const
{
isVisible
,
queries
,
datasource
,
panelId
,
dashboardId
,
timeRange
}
=
this
.
props
;
console
.
log
(
'issueQueries'
,
this
.
props
);
const
{
isVisible
,
queries
,
datasource
,
panelId
,
dashboardId
,
timeRange
,
widthPixels
,
maxDataPoints
}
=
this
.
props
;
if
(
!
isVisible
)
{
return
;
...
...
@@ -84,16 +88,21 @@ export class DataPanel extends Component<Props, State> {
try
{
const
ds
=
await
this
.
dataSourceSrv
.
get
(
datasource
);
// TODO interpolate variables
const
minInterval
=
this
.
props
.
minInterval
||
ds
.
interval
;
const
intervalRes
=
kbn
.
calculateInterval
(
timeRange
,
widthPixels
,
minInterval
);
const
queryOptions
:
DataQueryOptions
=
{
timezone
:
'browser'
,
panelId
:
panelId
,
dashboardId
:
dashboardId
,
range
:
timeRange
,
rangeRaw
:
timeRange
.
raw
,
interval
:
'1s'
,
intervalMs
:
60000
,
interval
:
intervalRes
.
interval
,
intervalMs
:
intervalRes
.
intervalMs
,
targets
:
queries
,
maxDataPoints
:
500
,
maxDataPoints
:
maxDataPoints
||
widthPixels
,
scopedVars
:
{},
cacheTimeout
:
null
,
};
...
...
@@ -114,17 +123,10 @@ export class DataPanel extends Component<Props, State> {
};
render
()
{
const
{
response
,
loading
,
isFirstLoad
}
=
this
.
state
;
console
.
log
(
'data panel render'
);
const
{
response
,
loading
}
=
this
.
state
;
const
timeSeries
=
response
.
data
;
// if (isFirstLoad && (loading === LoadingState.Loading || loading === LoadingState.NotStarted)) {
// return (
// <div className="loading">
// <p>Loading</p>
// </div>
// );
// }
console
.
log
(
'data panel render'
);
return
(
<>
...
...
@@ -142,7 +144,7 @@ export class DataPanel extends Component<Props, State> {
if
(
loading
===
LoadingState
.
Loading
)
{
return
(
<
div
className=
"panel
__
loading"
>
<
div
className=
"panel
-
loading"
>
<
i
className=
"fa fa-spinner fa-spin"
/>
</
div
>
);
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
90c41bb0
...
...
@@ -88,16 +88,14 @@ export class PanelChrome extends PureComponent<Props, State> {
console
.
log
(
'panelChrome render'
);
return
(
<
div
className=
"panel-container"
>
<
AutoSizer
>
{
({
width
,
height
})
=>
{
// console.log('SizeMe', size);
console
.
log
(
'autosizer width'
,
width
);
if
(
width
===
0
)
{
return
null
;
}
return
(
<
AutoSizer
>
{
({
width
,
height
})
=>
{
if
(
width
===
0
)
{
return
null
;
}
return
(
<
div
className=
"panel-container panel-container--absolute"
>
<
DataPanel
datasource=
{
datasource
}
queries=
{
targets
}
...
...
@@ -125,10 +123,10 @@ export class PanelChrome extends PureComponent<Props, State> {
);
}
}
</
DataPanel
>
);
}
}
</
AutoSizer
>
</
div
>
</
div
>
);
}
}
</
AutoSizer
>
);
}
}
public/app/types/series.ts
View file @
90c41bb0
...
...
@@ -89,4 +89,6 @@ export interface DataQueryOptions {
export
interface
DataSourceApi
{
query
(
options
:
DataQueryOptions
):
Promise
<
DataQueryResponse
>
;
testDatasource
():
Promise
<
any
>
;
interval
?:
string
;
}
public/app/viz/Graph.tsx
View file @
90c41bb0
...
...
@@ -92,6 +92,7 @@ export class Graph extends PureComponent<GraphProps> {
};
try
{
console
.
log
(
'Graph render'
);
$
.
plot
(
this
.
element
,
timeSeries
,
flotOptions
);
}
catch
(
err
)
{
console
.
log
(
'Graph rendering error'
,
err
,
flotOptions
,
timeSeries
);
...
...
public/sass/pages/_dashboard.scss
View file @
90c41bb0
...
...
@@ -43,6 +43,7 @@ div.flot-text {
position
:
relative
;
border-radius
:
3px
;
height
:
100%
;
width
:
100%
;
&
.panel-transparent
{
background-color
:
transparent
;
...
...
@@ -60,6 +61,10 @@ div.flot-text {
&
--is-editing
{
height
:
auto
;
}
&
--absolute
{
position
:
absolute
;
}
}
.panel-content
{
...
...
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