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
6da2f132
Commit
6da2f132
authored
Mar 22, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep plugin versions
parent
82be27a4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
+29
-10
packages/grafana-ui/src/types/panel.ts
+12
-1
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+5
-3
public/app/features/dashboard/state/PanelModel.ts
+2
-0
public/app/plugins/panel/singlestat2/module.tsx
+10
-6
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
6da2f132
...
...
@@ -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
:
any
)
=>
Partial
<
TOptions
>
;
export
type
PanelMigrationHook
<
TOptions
=
any
>
=
(
exiting
:
any
,
oldVersion
?:
string
)
=>
Partial
<
TOptions
>
;
/**
* Called before a panel is initalized
...
...
@@ -40,7 +40,18 @@ export class ReactPanelPlugin<TOptions = any> {
editor
?:
ComponentClass
<
PanelEditorProps
<
TOptions
>>
;
defaults
?:
TOptions
;
/**
* This function is called before the panel first loads if
* the current version is different than the version that was saved.
*
* This is a good place to support any changes to the options model
*/
onPanelMigration
?:
PanelMigrationHook
<
TOptions
>
;
/**
* This function is called when the visualization was changed. This
* passes in the options that were used in the previous visualization
*/
onPanelTypeChanged
?:
PanelTypeChangedHook
<
TOptions
>
;
constructor
(
panel
:
ComponentClass
<
PanelProps
<
TOptions
>>
,
defaults
?:
TOptions
)
{
...
...
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
6da2f132
import
React
,
{
PureComponent
}
from
'react'
;
import
config
from
'app/core/config'
;
import
classNames
from
'classnames'
;
import
get
from
'lodash/get'
;
import
{
getAngularLoader
,
AngularComponent
}
from
'app/core/services/AngularLoader'
;
import
{
importPluginModule
}
from
'app/features/plugins/plugin_loader'
;
...
...
@@ -99,12 +100,13 @@ export class DashboardPanel extends PureComponent<Props, State> {
panel
.
changeType
(
pluginId
,
hook
);
}
}
else
if
(
plugin
.
exports
&&
plugin
.
exports
.
reactPanel
&&
panel
.
options
)
{
const
pluginVersion
=
get
(
plugin
,
'info.version'
)
||
config
.
buildInfo
.
version
;
const
hook
=
plugin
.
exports
.
reactPanel
.
onPanelMigration
;
if
(
hook
)
{
panel
.
options
=
hook
(
panel
.
options
);
if
(
hook
&&
panel
.
pluginVersion
!==
pluginVersion
)
{
panel
.
options
=
hook
(
panel
.
options
,
panel
.
pluginVersion
);
panel
.
pluginVersion
=
pluginVersion
;
}
}
this
.
setState
({
plugin
,
angularPanel
:
null
});
}
}
...
...
public/app/features/dashboard/state/PanelModel.ts
View file @
6da2f132
...
...
@@ -58,6 +58,7 @@ const mustKeepProps: { [str: string]: boolean } = {
cacheTimeout
:
true
,
cachedPluginOptions
:
true
,
transparent
:
true
,
pluginVersion
:
true
,
};
const
defaults
:
any
=
{
...
...
@@ -87,6 +88,7 @@ export class PanelModel {
targets
:
DataQuery
[];
datasource
:
string
;
thresholds
?:
any
;
pluginVersion
?:
string
;
snapshotData
?:
TimeSeries
[]
|
[
TableData
];
timeFrom
?:
any
;
...
...
public/app/plugins/panel/singlestat2/module.tsx
View file @
6da2f132
...
...
@@ -21,12 +21,16 @@ export const singleStatBaseOptionsCheck = (
return
options
;
};
export
const
singleStatMigrationCheck
=
(
options
:
Partial
<
SingleStatBaseOptions
>
)
=>
{
// 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
];
export
const
singleStatMigrationCheck
=
(
exiting
:
any
,
oldVersion
?:
string
)
=>
{
const
options
=
exiting
as
Partial
<
SingleStatOptions
>
;
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
];
}
}
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