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
e03c7bf1
Commit
e03c7bf1
authored
Mar 24, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Panels: Support angular -> react migration via PanelMigrationHandler
parent
20fec4d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
packages/grafana-ui/src/types/panel.ts
+8
-2
public/app/features/dashboard/state/PanelModel.ts
+1
-1
public/app/plugins/panel/singlestat2/module.tsx
+3
-4
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
e03c7bf1
...
...
@@ -21,10 +21,16 @@ export interface PanelEditorProps<T = any> {
onOptionsChange
:
(
options
:
T
)
=>
void
;
}
export
interface
PanelModel
<
TOptions
=
any
>
{
id
:
number
;
options
:
TOptions
;
pluginVersion
?:
string
;
}
/**
* Called when a panel is first loaded with
existing options
* Called when a panel is first loaded with
current panel model
*/
export
type
PanelMigrationHandler
<
TOptions
=
any
>
=
(
exiting
:
any
,
oldVersion
?:
string
)
=>
Partial
<
TOptions
>
;
export
type
PanelMigrationHandler
<
TOptions
=
any
>
=
(
panel
:
PanelModel
<
TOptions
>
)
=>
Partial
<
TOptions
>
;
/**
* Called before a panel is initalized
...
...
public/app/features/dashboard/state/PanelModel.ts
View file @
e03c7bf1
...
...
@@ -250,7 +250,7 @@ export class PanelModel {
const
{
reactPanel
}
=
plugin
.
exports
;
if
(
reactPanel
&&
reactPanel
.
onPanelMigration
)
{
this
.
options
=
reactPanel
.
onPanelMigration
(
this
.
options
,
this
.
pluginVersion
);
this
.
options
=
reactPanel
.
onPanelMigration
(
this
);
this
.
pluginVersion
=
plugin
.
info
?
plugin
.
info
.
version
:
'1.0.0'
;
}
}
...
...
public/app/plugins/panel/singlestat2/module.tsx
View file @
e03c7bf1
import
{
ReactPanelPlugin
,
getStatsCalculators
}
from
'@grafana/ui'
;
import
{
ReactPanelPlugin
,
getStatsCalculators
,
PanelModel
}
from
'@grafana/ui'
;
import
{
SingleStatOptions
,
defaults
,
SingleStatBaseOptions
}
from
'./types'
;
import
{
SingleStatPanel
}
from
'./SingleStatPanel'
;
import
cloneDeep
from
'lodash/cloneDeep'
;
...
...
@@ -21,12 +21,11 @@ export const singleStatBaseOptionsCheck = (
return
options
;
};
export
const
singleStatMigrationCheck
=
(
exiting
:
any
,
oldVersion
?:
string
)
=>
{
const
options
=
exiting
as
Partial
<
SingleStatOptions
>
;
export
const
singleStatMigrationCheck
=
(
panel
:
PanelModel
<
SingleStatOptions
>
)
=>
{
const
options
=
panel
.
options
;
if
(
options
.
valueOptions
)
{
// 6.1 renamed some stats, This makes sure they are up to date
// avg -> mean, current -> last, total -> sum
const
{
valueOptions
}
=
options
;
if
(
valueOptions
&&
valueOptions
.
stat
)
{
valueOptions
.
stat
=
getStatsCalculators
([
valueOptions
.
stat
]).
map
(
s
=>
s
.
id
)[
0
];
...
...
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