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
a24f6998
Commit
a24f6998
authored
Nov 07, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactorings and some clean-up / removal of things not used
parent
08251425
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
149 deletions
+52
-149
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+1
-3
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+0
-2
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
+2
-2
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
+8
-11
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx
+6
-6
public/app/features/dashboard/utils/panel_menu.ts
+31
-65
public/app/plugins/panel/graph2/module.tsx
+0
-1
public/app/plugins/panel/graph2/moduleMenu.tsx
+0
-35
public/app/types/panel.ts
+4
-22
public/app/types/plugins.ts
+0
-2
No files found.
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
a24f6998
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
config
from
'app/core/config'
;
import
config
from
'app/core/config'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
...
@@ -122,10 +122,8 @@ export class DashboardPanel extends PureComponent<Props, State> {
...
@@ -122,10 +122,8 @@ export class DashboardPanel extends PureComponent<Props, State> {
<
div
className=
{
panelWrapperClass
}
>
<
div
className=
{
panelWrapperClass
}
>
<
PanelChrome
<
PanelChrome
component=
{
pluginExports
.
PanelComponent
}
component=
{
pluginExports
.
PanelComponent
}
// withMenuOptions={pluginExports.withMenuOptions}
panel=
{
this
.
props
.
panel
}
panel=
{
this
.
props
.
panel
}
dashboard=
{
this
.
props
.
dashboard
}
dashboard=
{
this
.
props
.
dashboard
}
getMenuAdditional=
{
pluginExports
.
getMenuAdditional
}
/>
/>
</
div
>
</
div
>
{
this
.
props
.
panel
.
isEditing
&&
(
{
this
.
props
.
panel
.
isEditing
&&
(
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
a24f6998
...
@@ -13,13 +13,11 @@ import { PanelHeaderMenu } from './PanelHeader/PanelHeaderMenu';
...
@@ -13,13 +13,11 @@ import { PanelHeaderMenu } from './PanelHeader/PanelHeaderMenu';
import
{
PanelModel
}
from
'../panel_model'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
TimeRange
,
PanelProps
}
from
'app/types'
;
import
{
TimeRange
,
PanelProps
}
from
'app/types'
;
import
{
PanelHeaderGetMenuAdditional
}
from
'app/types/panel'
;
export
interface
Props
{
export
interface
Props
{
panel
:
PanelModel
;
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
component
:
ComponentClass
<
PanelProps
>
;
component
:
ComponentClass
<
PanelProps
>
;
getMenuAdditional
?:
PanelHeaderGetMenuAdditional
;
}
}
export
interface
State
{
export
interface
State
{
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
a24f6998
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
interface
P
anelHeaderP
rops
{
interface
Props
{
title
:
string
;
title
:
string
;
}
}
export
class
PanelHeader
extends
PureComponent
<
P
anelHeaderProps
,
any
>
{
export
class
PanelHeader
extends
PureComponent
<
P
rops
>
{
render
()
{
render
()
{
const
isFullscreen
=
false
;
const
isFullscreen
=
false
;
const
isLoading
=
false
;
const
isLoading
=
false
;
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
View file @
a24f6998
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
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'
;
import
{
PanelHeaderMenuItem
}
from
'./PanelHeaderMenuItem'
;
import
{
PanelHeaderMenuItem
}
from
'./PanelHeaderMenuItem'
;
import
{
PanelHeaderMenuItemProps
}
from
'app/types/panel'
;
import
{
getPanelMenu
}
from
'app/features/dashboard/utils/panel_menu'
;
import
{
getPanelMenu
}
from
'app/features/dashboard/utils/panel_menu'
;
import
{
PanelMenuItem
}
from
'app/types/panel'
;
export
interface
P
anelHeaderMenuP
rops
{
export
interface
Props
{
panel
:
PanelModel
;
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
additionalMenuItems
?:
PanelHeaderMenuItemProps
[];
additionalSubMenuItems
?:
PanelHeaderMenuItemProps
[];
}
}
export
class
PanelHeaderMenu
extends
PureComponent
<
P
anelHeaderMenuProps
,
any
>
{
export
class
PanelHeaderMenu
extends
PureComponent
<
P
rops
>
{
renderItems
=
(
menu
:
Panel
HeaderMenuItemProps
[],
isSubMenu
=
false
)
=>
{
renderItems
=
(
menu
:
Panel
MenuItem
[],
isSubMenu
=
false
)
=>
{
return
(
return
(
<
ul
className=
"dropdown-menu dropdown-menu--menu panel-menu"
role=
{
isSubMenu
?
''
:
'menu'
}
>
<
ul
className=
"dropdown-menu dropdown-menu--menu panel-menu"
role=
{
isSubMenu
?
''
:
'menu'
}
>
{
menu
.
map
((
menuItem
,
idx
:
number
)
=>
{
{
menu
.
map
((
menuItem
,
idx
:
number
)
=>
{
...
@@ -23,7 +21,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
...
@@ -23,7 +21,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
type=
{
menuItem
.
type
}
type=
{
menuItem
.
type
}
text=
{
menuItem
.
text
}
text=
{
menuItem
.
text
}
iconClassName=
{
menuItem
.
iconClassName
}
iconClassName=
{
menuItem
.
iconClassName
}
handleClick=
{
menuItem
.
handle
Click
}
onClick=
{
menuItem
.
on
Click
}
shortcut=
{
menuItem
.
shortcut
}
shortcut=
{
menuItem
.
shortcut
}
>
>
{
menuItem
.
subMenu
&&
this
.
renderItems
(
menuItem
.
subMenu
,
true
)
}
{
menuItem
.
subMenu
&&
this
.
renderItems
(
menuItem
.
subMenu
,
true
)
}
...
@@ -35,9 +33,8 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
...
@@ -35,9 +33,8 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
};
};
render
()
{
render
()
{
console
.
log
(
'PanelHeaderMenu render'
);
const
{
dashboard
,
panel
}
=
this
.
props
;
const
{
dashboard
,
additionalMenuItems
,
additionalSubMenuItems
,
panel
}
=
this
.
props
;
const
menu
=
getPanelMenu
(
dashboard
,
panel
);
const
menu
=
getPanelMenu
(
dashboard
,
panel
,
additionalMenuItems
,
additionalSubMenuItems
);
return
<
div
className=
"panel-menu-container dropdown"
>
{
this
.
renderItems
(
menu
)
}
</
div
>;
return
<
div
className=
"panel-menu-container dropdown"
>
{
this
.
renderItems
(
menu
)
}
</
div
>;
}
}
}
}
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx
View file @
a24f6998
import
React
,
{
SFC
}
from
'react'
;
import
React
,
{
SFC
}
from
'react'
;
import
{
Panel
HeaderMenuItemProps
,
PanelHeaderMenuItemTypes
}
from
'app/types/panel'
;
import
{
Panel
MenuItem
}
from
'app/types/panel'
;
export
const
PanelHeaderMenuItem
:
SFC
<
Panel
HeaderMenuItemProps
>
=
props
=>
{
export
const
PanelHeaderMenuItem
:
SFC
<
Panel
MenuItem
>
=
props
=>
{
const
isSubMenu
=
props
.
type
===
PanelHeaderMenuItemTypes
.
SubMenu
;
const
isSubMenu
=
props
.
type
===
'submenu'
;
const
isDivider
=
props
.
type
===
PanelHeaderMenuItemTypes
.
Divider
;
const
isDivider
=
props
.
type
===
'divider'
;
return
isDivider
?
(
return
isDivider
?
(
<
li
className=
"divider"
/>
<
li
className=
"divider"
/>
)
:
(
)
:
(
<
li
className=
{
isSubMenu
?
'dropdown-submenu'
:
null
}
>
<
li
className=
{
isSubMenu
?
'dropdown-submenu'
:
null
}
>
<
a
onClick=
{
props
.
handle
Click
}
>
<
a
onClick=
{
props
.
on
Click
}
>
{
props
.
iconClassName
&&
<
i
className=
{
props
.
iconClassName
}
/>
}
{
props
.
iconClassName
&&
<
i
className=
{
props
.
iconClassName
}
/>
}
<
span
className=
"dropdown-item-text"
>
{
props
.
text
}
</
span
>
<
span
className=
"dropdown-item-text"
>
{
props
.
text
}
</
span
>
{
props
.
shortcut
&&
<
span
className=
"dropdown-menu-item-shortcut"
>
{
props
.
shortcut
}
</
span
>
}
{
props
.
shortcut
&&
<
span
className=
"dropdown-menu-item-shortcut"
>
{
props
.
shortcut
}
</
span
>
}
...
...
public/app/features/dashboard/utils/panel_menu.ts
View file @
a24f6998
import
{
PanelHeaderMenuItemTypes
,
PanelHeaderMenuItemProps
}
from
'app/types/panel'
;
import
{
store
}
from
'app/store/configureStore'
;
import
{
updateLocation
}
from
'app/core/actions'
;
import
{
updateLocation
}
from
'app/core/actions'
;
import
{
store
}
from
'app/store/configureStore'
;
import
{
removePanel
,
duplicatePanel
,
copyPanel
,
editPanelJson
,
sharePanel
}
from
'app/features/dashboard/utils/panel'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
removePanel
,
duplicatePanel
,
copyPanel
,
editPanelJson
,
sharePanel
}
from
'app/features/dashboard/util
s/panel'
;
import
{
PanelMenuItem
}
from
'app/type
s/panel'
;
export
const
getPanelMenu
=
(
export
const
getPanelMenu
=
(
dashboard
:
DashboardModel
,
panel
:
PanelModel
)
=>
{
dashboard
:
DashboardModel
,
panel
:
PanelModel
,
additionalMenuItems
:
PanelHeaderMenuItemProps
[]
=
[],
additionalSubMenuItems
:
PanelHeaderMenuItemProps
[]
=
[]
)
=>
{
const
onViewPanel
=
()
=>
{
const
onViewPanel
=
()
=>
{
store
.
dispatch
(
store
.
dispatch
(
updateLocation
({
updateLocation
({
...
@@ -19,6 +15,7 @@ export const getPanelMenu = (
...
@@ -19,6 +15,7 @@ export const getPanelMenu = (
edit
:
false
,
edit
:
false
,
fullscreen
:
true
,
fullscreen
:
true
,
},
},
partial
:
true
,
})
})
);
);
};
};
...
@@ -31,6 +28,7 @@ export const getPanelMenu = (
...
@@ -31,6 +28,7 @@ export const getPanelMenu = (
edit
:
true
,
edit
:
true
,
fullscreen
:
true
,
fullscreen
:
true
,
},
},
partial
:
true
,
})
})
);
);
};
};
...
@@ -55,100 +53,68 @@ export const getPanelMenu = (
...
@@ -55,100 +53,68 @@ export const getPanelMenu = (
removePanel
(
dashboard
,
panel
,
true
);
removePanel
(
dashboard
,
panel
,
true
);
};
};
const
getSubMenu
=
()
=>
{
const
menu
:
PanelMenuItem
[]
=
[];
const
menu
:
PanelHeaderMenuItemProps
[]
=
[];
if
(
!
panel
.
fullscreen
&&
dashboard
.
meta
.
canEdit
)
{
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Duplicate'
,
handleClick
:
onDuplicatePanel
,
shortcut
:
'p d'
,
role
:
'Editor'
,
});
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Copy'
,
handleClick
:
onCopyPanel
,
role
:
'Editor'
,
});
}
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Panel JSON'
,
handleClick
:
onEditPanelJson
,
});
if
(
additionalSubMenuItems
)
{
additionalSubMenuItems
.
forEach
(
item
=>
{
menu
.
push
(
item
);
});
}
return
menu
;
};
const
menu
:
PanelHeaderMenuItemProps
[]
=
[];
menu
.
push
({
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'View'
,
text
:
'View'
,
iconClassName
:
'fa fa-fw fa-eye'
,
iconClassName
:
'fa fa-fw fa-eye'
,
handle
Click
:
onViewPanel
,
on
Click
:
onViewPanel
,
shortcut
:
'v'
,
shortcut
:
'v'
,
});
});
if
(
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
meta
.
canEdit
)
{
menu
.
push
({
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Edit'
,
text
:
'Edit'
,
iconClassName
:
'fa fa-fw fa-edit'
,
iconClassName
:
'fa fa-fw fa-edit'
,
handle
Click
:
onEditPanel
,
on
Click
:
onEditPanel
,
shortcut
:
'e'
,
shortcut
:
'e'
,
role
:
'Editor'
,
});
});
}
}
menu
.
push
({
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Share'
,
text
:
'Share'
,
iconClassName
:
'fa fa-fw fa-share'
,
iconClassName
:
'fa fa-fw fa-share'
,
handle
Click
:
onSharePanel
,
on
Click
:
onSharePanel
,
shortcut
:
'p s'
,
shortcut
:
'p s'
,
});
});
if
(
additionalMenuItems
)
{
const
subMenu
:
PanelMenuItem
[]
=
[];
additionalMenuItems
.
forEach
(
item
=>
{
menu
.
push
(
item
);
if
(
!
panel
.
fullscreen
&&
dashboard
.
meta
.
canEdit
)
{
subMenu
.
push
({
text
:
'Duplicate'
,
onClick
:
onDuplicatePanel
,
shortcut
:
'p d'
,
});
subMenu
.
push
({
text
:
'Copy'
,
onClick
:
onCopyPanel
,
});
});
}
}
const
subMenu
:
PanelHeaderMenuItemProps
[]
=
getSubMenu
();
subMenu
.
push
({
text
:
'Panel JSON'
,
onClick
:
onEditPanelJson
,
});
menu
.
push
({
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
SubMenu
,
type
:
'submenu'
,
text
:
'More...'
,
text
:
'More...'
,
iconClassName
:
'fa fa-fw fa-cube'
,
iconClassName
:
'fa fa-fw fa-cube'
,
handleClick
:
null
,
subMenu
:
subMenu
,
subMenu
:
subMenu
,
});
});
if
(
dashboard
.
meta
.
canEdit
)
{
if
(
dashboard
.
meta
.
canEdit
)
{
menu
.
push
({
type
:
'divider'
});
menu
.
push
({
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Divider
,
role
:
'Editor'
,
});
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Remove'
,
text
:
'Remove'
,
iconClassName
:
'fa fa-fw fa-trash'
,
iconClassName
:
'fa fa-fw fa-trash'
,
handle
Click
:
onRemovePanel
,
on
Click
:
onRemovePanel
,
shortcut
:
'p r'
,
shortcut
:
'p r'
,
role
:
'Editor'
,
});
});
}
}
// Additional items from sub-class
// menu.push(...this.getAdditionalMenuItems());
return
menu
;
return
menu
;
};
};
public/app/plugins/panel/graph2/module.tsx
View file @
a24f6998
...
@@ -73,4 +73,3 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
...
@@ -73,4 +73,3 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
}
}
export
{
Graph2
as
PanelComponent
,
GraphOptions
as
PanelOptionsComponent
};
export
{
Graph2
as
PanelComponent
,
GraphOptions
as
PanelOptionsComponent
};
export
{
getMenuAdditional
}
from
'./moduleMenu'
;
public/app/plugins/panel/graph2/moduleMenu.tsx
deleted
100644 → 0
View file @
08251425
import
{
PanelHeaderMenuItemProps
,
PanelHeaderMenuItemTypes
}
from
'app/types/panel'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
export
const
getMenuAdditional
=
(
panel
:
PanelModel
)
=>
{
const
getAdditionalMenuItems
=
()
=>
{
return
[
{
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Hello menu'
,
handleClick
:
()
=>
{
alert
(
'Hello world from menu'
);
},
shortcut
:
'hi'
,
},
]
as
PanelHeaderMenuItemProps
[];
};
const
getAdditionalSubMenuItems
=
()
=>
{
return
[
{
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Hello Sub Menu'
,
handleClick
:
()
=>
{
alert
(
'Hello world from sub menu'
);
},
shortcut
:
'subhi'
,
},
]
as
PanelHeaderMenuItemProps
[];
};
return
{
additionalMenuItems
:
getAdditionalMenuItems
(),
additionalSubMenuItems
:
getAdditionalSubMenuItems
(),
};
};
public/app/types/panel.ts
View file @
a24f6998
import
{
LoadingState
,
TimeSeries
,
TimeRange
}
from
'./series'
;
import
{
LoadingState
,
TimeSeries
,
TimeRange
}
from
'./series'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
export
interface
PanelProps
<
T
=
any
>
{
export
interface
PanelProps
<
T
=
any
>
{
timeSeries
:
TimeSeries
[];
timeSeries
:
TimeSeries
[];
...
@@ -14,29 +13,12 @@ export interface PanelOptionsProps<T = any> {
...
@@ -14,29 +13,12 @@ export interface PanelOptionsProps<T = any> {
onChange
:
(
options
:
T
)
=>
void
;
onChange
:
(
options
:
T
)
=>
void
;
}
}
export
enum
PanelHeaderMenuItemTypes
{
// TODO: Evaluate. Remove?
export
interface
PanelMenuItem
{
Button
=
'Button'
,
// ?
type
?:
'submenu'
|
'divider'
;
Divider
=
'Divider'
,
Link
=
'Link'
,
SubMenu
=
'SubMenu'
,
}
export
interface
PanelHeaderMenuItemProps
{
type
:
PanelHeaderMenuItemTypes
;
text
?:
string
;
text
?:
string
;
iconClassName
?:
string
;
iconClassName
?:
string
;
handle
Click
?:
()
=>
void
;
on
Click
?:
()
=>
void
;
shortcut
?:
string
;
shortcut
?:
string
;
children
?:
any
;
children
?:
any
;
subMenu
?:
PanelHeaderMenuItemProps
[];
subMenu
?:
PanelMenuItem
[];
role
?:
string
;
}
export
interface
PanelHeaderMenuAdditional
{
additionalMenuItems
:
PanelHeaderMenuItemProps
[];
additionalSubMenuItems
:
PanelHeaderMenuItemProps
[];
}
export
interface
PanelHeaderGetMenuAdditional
{
(
panel
:
PanelModel
):
PanelHeaderMenuAdditional
;
}
}
public/app/types/plugins.ts
View file @
a24f6998
import
{
ComponentClass
}
from
'react'
;
import
{
ComponentClass
}
from
'react'
;
import
{
PanelProps
,
PanelOptionsProps
}
from
'./panel'
;
import
{
PanelProps
,
PanelOptionsProps
}
from
'./panel'
;
import
{
PanelHeaderGetMenuAdditional
}
from
'app/types/panel'
;
export
interface
PluginExports
{
export
interface
PluginExports
{
Datasource
?:
any
;
Datasource
?:
any
;
...
@@ -14,7 +13,6 @@ export interface PluginExports {
...
@@ -14,7 +13,6 @@ export interface PluginExports {
PanelCtrl
?;
PanelCtrl
?;
PanelComponent
?:
ComponentClass
<
PanelProps
>
;
PanelComponent
?:
ComponentClass
<
PanelProps
>
;
PanelOptionsComponent
:
ComponentClass
<
PanelOptionsProps
>
;
PanelOptionsComponent
:
ComponentClass
<
PanelOptionsProps
>
;
getMenuAdditional
?:
PanelHeaderGetMenuAdditional
;
}
}
export
interface
PanelPlugin
{
export
interface
PanelPlugin
{
...
...
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