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
48114edc
Commit
48114edc
authored
Mar 08, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of new react text panel
parent
90f8179b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
public/app/plugins/panel/text2/TextPanel.tsx
+5
-8
public/app/plugins/panel/text2/TextPanelEditor.tsx
+10
-4
No files found.
public/app/plugins/panel/text2/TextPanel.tsx
View file @
48114edc
// Libraries
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
Remarkable
from
'remarkable'
;
import
Remarkable
from
'remarkable'
;
import
{
debounce
}
from
'lodash'
;
// Utils
import
{
sanitize
}
from
'app/core/utils/text'
;
import
{
sanitize
}
from
'app/core/utils/text'
;
import
config
from
'app/core/config'
;
import
config
from
'app/core/config'
;
import
{
debounce
}
from
'lodash'
;
// Types
// Types
import
{
TextOptions
}
from
'./types'
;
import
{
TextOptions
}
from
'./types'
;
...
@@ -42,13 +44,8 @@ export class TextPanel extends PureComponent<Props, State> {
...
@@ -42,13 +44,8 @@ export class TextPanel extends PureComponent<Props, State> {
const
{
replaceVariables
}
=
this
.
props
;
const
{
replaceVariables
}
=
this
.
props
;
html
=
config
.
disableSanitizeHtml
?
html
:
sanitize
(
html
);
html
=
config
.
disableSanitizeHtml
?
html
:
sanitize
(
html
);
try
{
return
replaceVariables
(
html
);
return
replaceVariables
(
html
);
}
catch
(
e
)
{
// TODO -- put the error in the header window
console
.
log
(
'Text panel error: '
,
e
);
return
html
;
}
}
}
prepareText
(
content
:
string
):
string
{
prepareText
(
content
:
string
):
string
{
...
...
public/app/plugins/panel/text2/TextPanelEditor.tsx
View file @
48114edc
import
React
,
{
PureComponent
}
from
'react'
;
// Libraries
import
React
,
{
PureComponent
,
ChangeEvent
}
from
'react'
;
// Components
import
{
PanelEditorProps
,
PanelOptionsGroup
,
Select
,
SelectOptionItem
}
from
'@grafana/ui'
;
import
{
PanelEditorProps
,
PanelOptionsGroup
,
Select
,
SelectOptionItem
}
from
'@grafana/ui'
;
// Types
import
{
TextOptions
}
from
'./types'
;
import
{
TextOptions
}
from
'./types'
;
export
class
TextPanelEditor
extends
PureComponent
<
PanelEditorProps
<
TextOptions
>>
{
export
class
TextPanelEditor
extends
PureComponent
<
PanelEditorProps
<
TextOptions
>>
{
...
@@ -12,19 +16,21 @@ export class TextPanelEditor extends PureComponent<PanelEditorProps<TextOptions>
...
@@ -12,19 +16,21 @@ export class TextPanelEditor extends PureComponent<PanelEditorProps<TextOptions>
onModeChange
=
(
item
:
SelectOptionItem
)
=>
this
.
props
.
onOptionsChange
({
...
this
.
props
.
options
,
mode
:
item
.
value
});
onModeChange
=
(
item
:
SelectOptionItem
)
=>
this
.
props
.
onOptionsChange
({
...
this
.
props
.
options
,
mode
:
item
.
value
});
onContentChange
=
evt
=>
this
.
props
.
onOptionsChange
({
...
this
.
props
.
options
,
content
:
(
event
.
target
as
any
).
value
});
onContentChange
=
(
evt
:
ChangeEvent
<
HTMLTextAreaElement
>
)
=>
{
this
.
props
.
onOptionsChange
({
...
this
.
props
.
options
,
content
:
(
event
.
target
as
any
).
value
});
};
render
()
{
render
()
{
const
{
mode
,
content
}
=
this
.
props
.
options
;
const
{
mode
,
content
}
=
this
.
props
.
options
;
return
(
return
(
<
PanelOptionsGroup
title=
"Text"
>
<
PanelOptionsGroup
title=
"Text"
>
<
div
className=
"gf-form-inline"
>
<
div
className=
"gf-form"
>
<
div
className=
"gf-form"
>
<
span
className=
"gf-form-label"
>
Mode
</
span
>
<
span
className=
"gf-form-label"
>
Mode
</
span
>
<
Select
onChange=
{
this
.
onModeChange
}
value=
{
this
.
modes
.
find
(
e
=>
mode
===
e
.
value
)
}
options=
{
this
.
modes
}
/>
<
Select
onChange=
{
this
.
onModeChange
}
value=
{
this
.
modes
.
find
(
e
=>
mode
===
e
.
value
)
}
options=
{
this
.
modes
}
/>
</
div
>
</
div
>
</
div
>
{
/* TODO: <code-editor */
}
<
textarea
value=
{
content
}
onChange=
{
this
.
onContentChange
}
className=
"gf-form-input"
rows=
{
10
}
/>
<
textarea
value=
{
content
}
onChange=
{
this
.
onContentChange
}
className=
"gf-form-input"
rows=
{
10
}
/>
</
PanelOptionsGroup
>
</
PanelOptionsGroup
>
);
);
...
...
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