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
82be27a4
Commit
82be27a4
authored
Mar 22, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove panel plugin setters
parent
0f0f76b6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
58 deletions
+37
-58
packages/grafana-ui/src/types/panel.ts
+4
-26
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+2
-2
public/app/plugins/panel/bargauge/module.tsx
+3
-4
public/app/plugins/panel/gauge/module.tsx
+5
-5
public/app/plugins/panel/graph2/module.tsx
+4
-3
public/app/plugins/panel/graph2/types.ts
+6
-0
public/app/plugins/panel/piechart/module.tsx
+2
-3
public/app/plugins/panel/singlestat2/module.tsx
+5
-6
public/app/plugins/panel/table2/module.tsx
+2
-3
public/app/plugins/panel/text2/module.tsx
+4
-6
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
82be27a4
...
...
@@ -24,7 +24,7 @@ export interface PanelEditorProps<T = any> {
/**
* Called when a panel is first loaded with existing options
*/
export
type
PanelMigrationHook
<
TOptions
=
any
>
=
(
options
:
Partial
<
TOptions
>
)
=>
Partial
<
TOptions
>
;
export
type
PanelMigrationHook
<
TOptions
=
any
>
=
(
options
:
any
)
=>
Partial
<
TOptions
>
;
/**
* Called before a panel is initalized
...
...
@@ -40,35 +40,13 @@ export class ReactPanelPlugin<TOptions = any> {
editor
?:
ComponentClass
<
PanelEditorProps
<
TOptions
>>
;
defaults
?:
TOptions
;
panelMigrationHook
?:
PanelMigrationHook
<
TOptions
>
;
panelTypeChangedHook
?:
PanelTypeChangedHook
<
TOptions
>
;
onPanelMigration
?:
PanelMigrationHook
<
TOptions
>
;
onPanelTypeChanged
?:
PanelTypeChangedHook
<
TOptions
>
;
constructor
(
panel
:
ComponentClass
<
PanelProps
<
TOptions
>>
)
{
constructor
(
panel
:
ComponentClass
<
PanelProps
<
TOptions
>>
,
defaults
?:
TOptions
)
{
this
.
panel
=
panel
;
}
setEditor
(
editor
:
ComponentClass
<
PanelEditorProps
<
TOptions
>>
)
{
this
.
editor
=
editor
;
}
setDefaults
(
defaults
:
TOptions
)
{
this
.
defaults
=
defaults
;
}
/**
* Called when the panel first loaded with
*/
setPanelMigrationHook
(
v
:
PanelMigrationHook
<
TOptions
>
)
{
this
.
panelMigrationHook
=
v
;
}
/**
* Called when the visualization changes.
* Lets you keep whatever settings made sense in the previous panel
*/
setPanelTypeChangedHook
(
v
:
PanelTypeChangedHook
<
TOptions
>
)
{
this
.
panelTypeChangedHook
=
v
;
}
}
export
interface
PanelSize
{
...
...
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
82be27a4
...
...
@@ -94,12 +94,12 @@ export class DashboardPanel extends PureComponent<Props, State> {
}
else
{
let
hook
:
PanelTypeChangedHook
|
null
=
null
;
if
(
plugin
.
exports
.
reactPanel
)
{
hook
=
plugin
.
exports
.
reactPanel
.
panelTypeChangedHook
;
hook
=
plugin
.
exports
.
reactPanel
.
onPanelTypeChanged
;
}
panel
.
changeType
(
pluginId
,
hook
);
}
}
else
if
(
plugin
.
exports
&&
plugin
.
exports
.
reactPanel
&&
panel
.
options
)
{
const
hook
=
plugin
.
exports
.
reactPanel
.
panelMigrationHook
;
const
hook
=
plugin
.
exports
.
reactPanel
.
onPanelMigration
;
if
(
hook
)
{
panel
.
options
=
hook
(
panel
.
options
);
}
...
...
public/app/plugins/panel/bargauge/module.tsx
View file @
82be27a4
...
...
@@ -5,8 +5,7 @@ import { BarGaugePanelEditor } from './BarGaugePanelEditor';
import
{
BarGaugeOptions
,
defaults
}
from
'./types'
;
import
{
singleStatBaseOptionsCheck
}
from
'../singlestat2/module'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
BarGaugeOptions
>
(
BarGaugePanel
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
BarGaugeOptions
>
(
BarGaugePanel
,
defaults
);
reactPanel
.
setEditor
(
BarGaugePanelEditor
);
reactPanel
.
setDefaults
(
defaults
);
reactPanel
.
setPanelTypeChangedHook
(
singleStatBaseOptionsCheck
);
reactPanel
.
editor
=
BarGaugePanelEditor
;
reactPanel
.
onPanelTypeChanged
=
singleStatBaseOptionsCheck
;
public/app/plugins/panel/gauge/module.tsx
View file @
82be27a4
...
...
@@ -3,10 +3,10 @@ import { ReactPanelPlugin } from '@grafana/ui';
import
{
GaugePanelEditor
}
from
'./GaugePanelEditor'
;
import
{
GaugePanel
}
from
'./GaugePanel'
;
import
{
GaugeOptions
,
defaults
}
from
'./types'
;
import
{
singleStatBaseOptionsCheck
}
from
'../singlestat2/module'
;
import
{
singleStatBaseOptionsCheck
,
singleStatMigrationCheck
}
from
'../singlestat2/module'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
GaugeOptions
>
(
GaugePanel
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
GaugeOptions
>
(
GaugePanel
,
defaults
);
reactPanel
.
setEditor
(
GaugePanelEditor
)
;
reactPanel
.
setDefaults
(
defaults
)
;
reactPanel
.
setPanelTypeChangedHook
(
singleStatBaseOptionsCheck
)
;
reactPanel
.
editor
=
GaugePanelEditor
;
reactPanel
.
onPanelTypeChanged
=
singleStatBaseOptionsCheck
;
reactPanel
.
onPanelMigration
=
singleStatMigrationCheck
;
public/app/plugins/panel/graph2/module.tsx
View file @
82be27a4
...
...
@@ -2,7 +2,8 @@ import { ReactPanelPlugin } from '@grafana/ui';
import
{
GraphPanelEditor
}
from
'./GraphPanelEditor'
;
import
{
GraphPanel
}
from
'./GraphPanel'
;
import
{
Options
}
from
'./types'
;
import
{
Options
,
defaults
}
from
'./types'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
Options
>
(
GraphPanel
);
reactPanel
.
setEditor
(
GraphPanelEditor
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
Options
>
(
GraphPanel
,
defaults
);
reactPanel
.
editor
=
GraphPanelEditor
;
public/app/plugins/panel/graph2/types.ts
View file @
82be27a4
...
...
@@ -3,3 +3,9 @@ export interface Options {
showLines
:
boolean
;
showPoints
:
boolean
;
}
export
const
defaults
:
Options
=
{
showBars
:
false
,
showLines
:
true
,
showPoints
:
false
,
};
public/app/plugins/panel/piechart/module.tsx
View file @
82be27a4
...
...
@@ -4,7 +4,6 @@ import PieChartPanelEditor from './PieChartPanelEditor';
import
{
PieChartPanel
}
from
'./PieChartPanel'
;
import
{
PieChartOptions
,
defaults
}
from
'./types'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
PieChartOptions
>
(
PieChartPanel
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
PieChartOptions
>
(
PieChartPanel
,
defaults
);
reactPanel
.
setEditor
(
PieChartPanelEditor
);
reactPanel
.
setDefaults
(
defaults
);
reactPanel
.
editor
=
PieChartPanelEditor
;
public/app/plugins/panel/singlestat2/module.tsx
View file @
82be27a4
...
...
@@ -4,8 +4,6 @@ import { SingleStatPanel } from './SingleStatPanel';
import
cloneDeep
from
'lodash/cloneDeep'
;
import
{
SingleStatEditor
}
from
'./SingleStatEditor'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
SingleStatOptions
>
(
SingleStatPanel
);
const
optionsToKeep
=
[
'valueOptions'
,
'stat'
,
'maxValue'
,
'maxValue'
,
'thresholds'
,
'valueMappings'
];
export
const
singleStatBaseOptionsCheck
=
(
...
...
@@ -33,7 +31,8 @@ export const singleStatMigrationCheck = (options: Partial<SingleStatBaseOptions>
return
options
;
};
reactPanel
.
setEditor
(
SingleStatEditor
);
reactPanel
.
setDefaults
(
defaults
);
reactPanel
.
setPanelTypeChangedHook
(
singleStatBaseOptionsCheck
);
reactPanel
.
setPanelMigrationHook
(
singleStatMigrationCheck
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
SingleStatOptions
>
(
SingleStatPanel
,
defaults
);
reactPanel
.
editor
=
SingleStatEditor
;
reactPanel
.
onPanelTypeChanged
=
singleStatBaseOptionsCheck
;
reactPanel
.
onPanelMigration
=
singleStatMigrationCheck
;
public/app/plugins/panel/table2/module.tsx
View file @
82be27a4
...
...
@@ -4,6 +4,5 @@ import { TablePanelEditor } from './TablePanelEditor';
import
{
TablePanel
}
from
'./TablePanel'
;
import
{
Options
,
defaults
}
from
'./types'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
Options
>
(
TablePanel
);
reactPanel
.
setEditor
(
TablePanelEditor
);
reactPanel
.
setDefaults
(
defaults
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
Options
>
(
TablePanel
,
defaults
);
reactPanel
.
editor
=
TablePanelEditor
;
public/app/plugins/panel/text2/module.tsx
View file @
82be27a4
...
...
@@ -4,14 +4,12 @@ import { TextPanelEditor } from './TextPanelEditor';
import
{
TextPanel
}
from
'./TextPanel'
;
import
{
TextOptions
,
defaults
}
from
'./types'
;
export
const
reactPanel
=
new
ReactPanelPlugin
<
TextOptions
>
(
TextPanel
);
export
const
reactPanel
=
new
ReactPanelPlugin
<
TextOptions
>
(
TextPanel
,
defaults
);
reactPanel
.
setEditor
(
TextPanelEditor
);
reactPanel
.
setDefaults
(
defaults
);
reactPanel
.
setPanelTypeChangedHook
((
options
:
TextOptions
,
prevPluginId
:
string
,
prevOptions
:
any
)
=>
{
reactPanel
.
editor
=
TextPanelEditor
;
reactPanel
.
onPanelTypeChanged
=
(
options
:
TextOptions
,
prevPluginId
:
string
,
prevOptions
:
any
)
=>
{
if
(
prevPluginId
===
'text'
)
{
return
prevOptions
as
TextOptions
;
}
return
options
;
}
)
;
};
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