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
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
...
...
@@ -122,10 +122,8 @@ export class DashboardPanel extends PureComponent<Props, State> {
<
div
className=
{
panelWrapperClass
}
>
<
PanelChrome
component=
{
pluginExports
.
PanelComponent
}
// withMenuOptions={pluginExports.withMenuOptions}
panel=
{
this
.
props
.
panel
}
dashboard=
{
this
.
props
.
dashboard
}
getMenuAdditional=
{
pluginExports
.
getMenuAdditional
}
/>
</
div
>
{
this
.
props
.
panel
.
isEditing
&&
(
...
...
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
a24f6998
...
...
@@ -13,13 +13,11 @@ import { PanelHeaderMenu } from './PanelHeader/PanelHeaderMenu';
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
TimeRange
,
PanelProps
}
from
'app/types'
;
import
{
PanelHeaderGetMenuAdditional
}
from
'app/types/panel'
;
export
interface
Props
{
panel
:
PanelModel
;
dashboard
:
DashboardModel
;
component
:
ComponentClass
<
PanelProps
>
;
getMenuAdditional
?:
PanelHeaderGetMenuAdditional
;
}
export
interface
State
{
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
a24f6998
import
React
,
{
PureComponent
}
from
'react'
;
import
classNames
from
'classnames'
;
interface
P
anelHeaderP
rops
{
interface
Props
{
title
:
string
;
}
export
class
PanelHeader
extends
PureComponent
<
P
anelHeaderProps
,
any
>
{
export
class
PanelHeader
extends
PureComponent
<
P
rops
>
{
render
()
{
const
isFullscreen
=
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
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
PanelHeaderMenuItem
}
from
'./PanelHeaderMenuItem'
;
import
{
PanelHeaderMenuItemProps
}
from
'app/types/panel'
;
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
;
dashboard
:
DashboardModel
;
additionalMenuItems
?:
PanelHeaderMenuItemProps
[];
additionalSubMenuItems
?:
PanelHeaderMenuItemProps
[];
}
export
class
PanelHeaderMenu
extends
PureComponent
<
P
anelHeaderMenuProps
,
any
>
{
renderItems
=
(
menu
:
Panel
HeaderMenuItemProps
[],
isSubMenu
=
false
)
=>
{
export
class
PanelHeaderMenu
extends
PureComponent
<
P
rops
>
{
renderItems
=
(
menu
:
Panel
MenuItem
[],
isSubMenu
=
false
)
=>
{
return
(
<
ul
className=
"dropdown-menu dropdown-menu--menu panel-menu"
role=
{
isSubMenu
?
''
:
'menu'
}
>
{
menu
.
map
((
menuItem
,
idx
:
number
)
=>
{
...
...
@@ -23,7 +21,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
type=
{
menuItem
.
type
}
text=
{
menuItem
.
text
}
iconClassName=
{
menuItem
.
iconClassName
}
handleClick=
{
menuItem
.
handle
Click
}
onClick=
{
menuItem
.
on
Click
}
shortcut=
{
menuItem
.
shortcut
}
>
{
menuItem
.
subMenu
&&
this
.
renderItems
(
menuItem
.
subMenu
,
true
)
}
...
...
@@ -35,9 +33,8 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
};
render
()
{
console
.
log
(
'PanelHeaderMenu render'
);
const
{
dashboard
,
additionalMenuItems
,
additionalSubMenuItems
,
panel
}
=
this
.
props
;
const
menu
=
getPanelMenu
(
dashboard
,
panel
,
additionalMenuItems
,
additionalSubMenuItems
);
const
{
dashboard
,
panel
}
=
this
.
props
;
const
menu
=
getPanelMenu
(
dashboard
,
panel
);
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
{
Panel
HeaderMenuItemProps
,
PanelHeaderMenuItemTypes
}
from
'app/types/panel'
;
import
React
,
{
SFC
}
from
'react'
;
import
{
Panel
MenuItem
}
from
'app/types/panel'
;
export
const
PanelHeaderMenuItem
:
SFC
<
Panel
HeaderMenuItemProps
>
=
props
=>
{
const
isSubMenu
=
props
.
type
===
PanelHeaderMenuItemTypes
.
SubMenu
;
const
isDivider
=
props
.
type
===
PanelHeaderMenuItemTypes
.
Divider
;
export
const
PanelHeaderMenuItem
:
SFC
<
Panel
MenuItem
>
=
props
=>
{
const
isSubMenu
=
props
.
type
===
'submenu'
;
const
isDivider
=
props
.
type
===
'divider'
;
return
isDivider
?
(
<
li
className=
"divider"
/>
)
:
(
<
li
className=
{
isSubMenu
?
'dropdown-submenu'
:
null
}
>
<
a
onClick=
{
props
.
handle
Click
}
>
<
a
onClick=
{
props
.
on
Click
}
>
{
props
.
iconClassName
&&
<
i
className=
{
props
.
iconClassName
}
/>
}
<
span
className=
"dropdown-item-text"
>
{
props
.
text
}
</
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
{
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
{
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
=
(
dashboard
:
DashboardModel
,
panel
:
PanelModel
,
additionalMenuItems
:
PanelHeaderMenuItemProps
[]
=
[],
additionalSubMenuItems
:
PanelHeaderMenuItemProps
[]
=
[]
)
=>
{
export
const
getPanelMenu
=
(
dashboard
:
DashboardModel
,
panel
:
PanelModel
)
=>
{
const
onViewPanel
=
()
=>
{
store
.
dispatch
(
updateLocation
({
...
...
@@ -19,6 +15,7 @@ export const getPanelMenu = (
edit
:
false
,
fullscreen
:
true
,
},
partial
:
true
,
})
);
};
...
...
@@ -31,6 +28,7 @@ export const getPanelMenu = (
edit
:
true
,
fullscreen
:
true
,
},
partial
:
true
,
})
);
};
...
...
@@ -55,100 +53,68 @@ export const getPanelMenu = (
removePanel
(
dashboard
,
panel
,
true
);
};
const
getSubMenu
=
()
=>
{
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
[]
=
[];
const
menu
:
PanelMenuItem
[]
=
[];
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'View'
,
iconClassName
:
'fa fa-fw fa-eye'
,
handle
Click
:
onViewPanel
,
on
Click
:
onViewPanel
,
shortcut
:
'v'
,
});
if
(
dashboard
.
meta
.
canEdit
)
{
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Edit'
,
iconClassName
:
'fa fa-fw fa-edit'
,
handle
Click
:
onEditPanel
,
on
Click
:
onEditPanel
,
shortcut
:
'e'
,
role
:
'Editor'
,
});
}
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Share'
,
iconClassName
:
'fa fa-fw fa-share'
,
handle
Click
:
onSharePanel
,
on
Click
:
onSharePanel
,
shortcut
:
'p s'
,
});
if
(
additionalMenuItems
)
{
additionalMenuItems
.
forEach
(
item
=>
{
menu
.
push
(
item
);
const
subMenu
:
PanelMenuItem
[]
=
[];
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
({
type
:
PanelHeaderMenuItemTypes
.
SubMenu
,
type
:
'submenu'
,
text
:
'More...'
,
iconClassName
:
'fa fa-fw fa-cube'
,
handleClick
:
null
,
subMenu
:
subMenu
,
});
if
(
dashboard
.
meta
.
canEdit
)
{
menu
.
push
({
type
:
'divider'
});
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Divider
,
role
:
'Editor'
,
});
menu
.
push
({
type
:
PanelHeaderMenuItemTypes
.
Link
,
text
:
'Remove'
,
iconClassName
:
'fa fa-fw fa-trash'
,
handle
Click
:
onRemovePanel
,
on
Click
:
onRemovePanel
,
shortcut
:
'p r'
,
role
:
'Editor'
,
});
}
// Additional items from sub-class
// menu.push(...this.getAdditionalMenuItems());
return
menu
;
};
public/app/plugins/panel/graph2/module.tsx
View file @
a24f6998
...
...
@@ -73,4 +73,3 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
}
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
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
export
interface
PanelProps
<
T
=
any
>
{
timeSeries
:
TimeSeries
[];
...
...
@@ -14,29 +13,12 @@ export interface PanelOptionsProps<T = any> {
onChange
:
(
options
:
T
)
=>
void
;
}
export
enum
PanelHeaderMenuItemTypes
{
// TODO: Evaluate. Remove?
Button
=
'Button'
,
// ?
Divider
=
'Divider'
,
Link
=
'Link'
,
SubMenu
=
'SubMenu'
,
}
export
interface
PanelHeaderMenuItemProps
{
type
:
PanelHeaderMenuItemTypes
;
export
interface
PanelMenuItem
{
type
?:
'submenu'
|
'divider'
;
text
?:
string
;
iconClassName
?:
string
;
handle
Click
?:
()
=>
void
;
on
Click
?:
()
=>
void
;
shortcut
?:
string
;
children
?:
any
;
subMenu
?:
PanelHeaderMenuItemProps
[];
role
?:
string
;
}
export
interface
PanelHeaderMenuAdditional
{
additionalMenuItems
:
PanelHeaderMenuItemProps
[];
additionalSubMenuItems
:
PanelHeaderMenuItemProps
[];
}
export
interface
PanelHeaderGetMenuAdditional
{
(
panel
:
PanelModel
):
PanelHeaderMenuAdditional
;
subMenu
?:
PanelMenuItem
[];
}
public/app/types/plugins.ts
View file @
a24f6998
import
{
ComponentClass
}
from
'react'
;
import
{
PanelProps
,
PanelOptionsProps
}
from
'./panel'
;
import
{
PanelHeaderGetMenuAdditional
}
from
'app/types/panel'
;
export
interface
PluginExports
{
Datasource
?:
any
;
...
...
@@ -14,7 +13,6 @@ export interface PluginExports {
PanelCtrl
?;
PanelComponent
?:
ComponentClass
<
PanelProps
>
;
PanelOptionsComponent
:
ComponentClass
<
PanelOptionsProps
>
;
getMenuAdditional
?:
PanelHeaderGetMenuAdditional
;
}
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