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
83073dea
Commit
83073dea
authored
Nov 15, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
panel-header: Move the corner information in the panel header to its own component
parent
0fa8ae4f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
17 deletions
+102
-17
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
+7
-17
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderCorner.tsx
+94
-0
public/app/features/dashboard/panel_model.ts
+1
-0
No files found.
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
83073dea
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
PanelHeaderCorner
from
'./PanelHeaderCorner'
;
import
{
PanelHeaderMenu
}
from
'./PanelHeaderMenu'
;
import
{
PanelHeaderMenu
}
from
'./PanelHeaderMenu'
;
import
Tooltip
from
'app/core/components/Tooltip/Tooltip'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
...
@@ -44,23 +44,13 @@ export class PanelHeader extends PureComponent<Props, State> {
...
@@ -44,23 +44,13 @@ export class PanelHeader extends PureComponent<Props, State> {
const
{
panel
,
dashboard
,
timeInfo
}
=
this
.
props
;
const
{
panel
,
dashboard
,
timeInfo
}
=
this
.
props
;
return
(
return
(
<>
<>
{
panel
.
description
&&
(
<
PanelHeaderCorner
panel=
{
panel
}
/>
<
Tooltip
content=
{
panel
.
description
}
className=
"absolute"
refClassName=
"panel-info-corner panel-info-corner--info"
>
<
i
className=
"fa"
/>
<
span
className=
"panel-info-corner-inner"
/>
</
Tooltip
>
)
}
{
isLoading
&&
(
<
span
className=
"panel-loading"
>
<
i
className=
"fa fa-spinner fa-spin"
/>
</
span
>
)
}
<
div
className=
{
panelHeaderClass
}
>
<
div
className=
{
panelHeaderClass
}
>
{
isLoading
&&
(
<
span
className=
"panel-loading"
>
<
i
className=
"fa fa-spinner fa-spin"
/>
</
span
>
)
}
<
div
className=
"panel-title-container"
onClick=
{
this
.
onMenuToggle
}
>
<
div
className=
"panel-title-container"
onClick=
{
this
.
onMenuToggle
}
>
<
div
className=
"panel-title"
>
<
div
className=
"panel-title"
>
<
span
className=
"icon-gf panel-alert-icon"
/>
<
span
className=
"icon-gf panel-alert-icon"
/>
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderCorner.tsx
0 → 100644
View file @
83073dea
import
React
,
{
PureComponent
}
from
'react'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
Tooltip
from
'app/core/components/Tooltip/Tooltip'
;
import
templateSrv
from
'app/features/templating/template_srv'
;
import
{
LinkSrv
}
from
'app/features/dashboard/panellinks/link_srv'
;
import
{
getTimeSrv
,
TimeSrv
}
from
'app/features/dashboard/time_srv'
;
import
Remarkable
from
'remarkable'
;
enum
InfoModes
{
Error
=
'Error'
,
Info
=
'Info'
,
Links
=
'Links'
,
}
interface
Props
{
panel
:
PanelModel
;
}
export
class
PanelHeaderCorner
extends
PureComponent
<
Props
>
{
timeSrv
:
TimeSrv
=
getTimeSrv
();
getInfoMode
=
()
=>
{
const
{
panel
}
=
this
.
props
;
// TODO
// if (error) {
// return InfoModes.Error;
// }
if
(
!!
panel
.
description
)
{
return
InfoModes
.
Info
;
}
if
(
panel
.
links
&&
panel
.
links
.
length
)
{
return
InfoModes
.
Links
;
}
return
undefined
;
};
getInfoContent
=
()
=>
{
const
{
panel
}
=
this
.
props
;
const
markdown
=
panel
.
description
;
const
linkSrv
=
new
LinkSrv
(
templateSrv
,
this
.
timeSrv
);
const
sanitize
=
str
=>
str
;
// TODO
const
interpolatedMarkdown
=
templateSrv
.
replace
(
markdown
,
panel
.
scopedVars
);
const
remarkableInterpolatedMarkdown
=
new
Remarkable
().
render
(
interpolatedMarkdown
);
const
html
=
(
<
div
className=
"markdown-html"
>
<
div
dangerouslySetInnerHTML=
{
{
__html
:
remarkableInterpolatedMarkdown
}
}
/>
{
panel
.
links
&&
panel
.
links
.
length
>
0
&&
(
<
ul
>
{
panel
.
links
.
map
((
link
,
idx
)
=>
{
const
info
=
linkSrv
.
getPanelLinkAnchorInfo
(
link
,
panel
.
scopedVars
);
return
(
<
li
key=
{
idx
}
>
<
a
className=
"panel-menu-link"
href=
{
info
.
href
}
target=
{
info
.
target
}
>
{
info
.
title
}
</
a
>
</
li
>
);
})
}
</
ul
>
)
}
</
div
>
);
return
sanitize
(
html
);
};
render
()
{
const
infoMode
:
InfoModes
|
undefined
=
this
.
getInfoMode
();
if
(
!
infoMode
)
{
return
null
;
}
const
infoContent
=
this
.
getInfoContent
();
return
(
<>
{
infoMode
===
InfoModes
.
Info
||
infoMode
===
InfoModes
.
Links
?
(
<
Tooltip
content=
{
infoContent
}
className=
"absolute"
refClassName=
{
`panel-info-corner panel-info-corner--${infoMode.toLowerCase()}`
}
>
<
i
className=
"fa"
/>
<
span
className=
"panel-info-corner-inner"
/>
</
Tooltip
>
)
:
null
}
</>
);
}
}
export
default
PanelHeaderCorner
;
public/app/features/dashboard/panel_model.ts
View file @
83073dea
...
@@ -50,6 +50,7 @@ export class PanelModel {
...
@@ -50,6 +50,7 @@ export class PanelModel {
maxDataPoints
?:
number
;
maxDataPoints
?:
number
;
interval
?:
string
;
interval
?:
string
;
description
?:
string
;
description
?:
string
;
links
?:
[];
// non persisted
// non persisted
fullscreen
:
boolean
;
fullscreen
:
boolean
;
...
...
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