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
bf8703ed
Commit
bf8703ed
authored
Oct 25, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip: panel-header: Move code existing in both angular+react to utility functions
parent
820e47b4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
60 deletions
+31
-60
public/app/features/dashboard/dashboard_ctrl.ts
+2
-29
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
+2
-31
public/app/features/dashboard/utils/panel.ts
+27
-0
No files found.
public/app/features/dashboard/dashboard_ctrl.ts
View file @
bf8703ed
...
...
@@ -2,13 +2,13 @@
import
config
from
'app/core/config'
;
import
appEvents
from
'app/core/app_events'
;
import
coreModule
from
'app/core/core_module'
;
import
{
removePanel
}
from
'app/features/dashboard/utils/panel'
;
// Services
import
{
AnnotationsSrv
}
from
'../annotations/annotations_srv'
;
// Types
import
{
DashboardModel
}
from
'./dashboard_model'
;
import
{
PanelModel
}
from
'./panel_model'
;
export
class
DashboardCtrl
{
dashboard
:
DashboardModel
;
...
...
@@ -136,34 +136,7 @@ export class DashboardCtrl {
}
const
panelInfo
=
this
.
dashboard
.
getPanelInfoById
(
options
.
panelId
);
this
.
removePanel
(
panelInfo
.
panel
,
true
);
}
removePanel
(
panel
:
PanelModel
,
ask
:
boolean
)
{
// confirm deletion
if
(
ask
!==
false
)
{
let
text2
,
confirmText
;
if
(
panel
.
alert
)
{
text2
=
'Panel includes an alert rule, removing panel will also remove alert rule'
;
confirmText
=
'YES'
;
}
this
.
$scope
.
appEvent
(
'confirm-modal'
,
{
title
:
'Remove Panel'
,
text
:
'Are you sure you want to remove this panel?'
,
text2
:
text2
,
icon
:
'fa-trash'
,
confirmText
:
confirmText
,
yesText
:
'Remove'
,
onConfirm
:
()
=>
{
this
.
removePanel
(
panel
,
false
);
},
});
return
;
}
this
.
dashboard
.
removePanel
(
panel
);
removePanel
(
this
.
dashboard
,
panelInfo
.
panel
,
true
);
}
onDestroy
()
{
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx
View file @
bf8703ed
import
React
,
{
PureComponent
}
from
'react'
;
// import { store } from 'app/store/configureStore';
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
import
{
PanelHeaderMenuItem
,
PanelHeaderMenuItemTypes
}
from
'./PanelHeaderMenuItem'
;
import
appEvents
from
'app/core/app_events'
;
import
{
store
}
from
'app/store/configureStore'
;
import
{
updateLocation
}
from
'app/core/actions'
;
import
{
removePanel
}
from
'app/features/dashboard/utils/panel'
;
export
interface
PanelHeaderMenuProps
{
panelId
:
number
;
...
...
@@ -40,30 +38,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
onRemovePanel
=
()
=>
{
const
{
panelId
,
dashboard
}
=
this
.
props
;
const
panelInfo
=
dashboard
.
getPanelInfoById
(
panelId
);
this
.
removePanel
(
panelInfo
.
panel
,
true
);
};
removePanel
=
(
panel
:
PanelModel
,
ask
:
boolean
)
=>
{
const
{
dashboard
}
=
this
.
props
;
// confirm deletion
if
(
ask
!==
false
)
{
const
text2
=
panel
.
alert
?
'Panel includes an alert rule, removing panel will also remove alert rule'
:
null
;
const
confirmText
=
panel
.
alert
?
'YES'
:
null
;
appEvents
.
emit
(
'confirm-modal'
,
{
title
:
'Remove Panel'
,
text
:
'Are you sure you want to remove this panel?'
,
text2
:
text2
,
icon
:
'fa-trash'
,
confirmText
:
confirmText
,
yesText
:
'Remove'
,
onConfirm
:
()
=>
this
.
removePanel
(
panel
,
false
),
});
return
;
}
dashboard
.
removePanel
(
panel
);
removePanel
(
dashboard
,
panelInfo
.
panel
,
true
);
};
render
()
{
...
...
@@ -105,13 +80,9 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
handleClick=
{
()
=>
{}
}
shortcut=
"p d"
/>
<
PanelHeaderMenuItem
type=
{
PanelHeaderMenuItemTypes
.
Link
}
text=
"Copy"
handleClick=
{
()
=>
{}
}
/>
<
PanelHeaderMenuItem
type=
{
PanelHeaderMenuItemTypes
.
Link
}
text=
"Panel JSON"
handleClick=
{
()
=>
{}
}
/>
<
PanelHeaderMenuItem
type=
{
PanelHeaderMenuItemTypes
.
Link
}
text=
"Export CSV"
handleClick=
{
()
=>
{}
}
/>
<
PanelHeaderMenuItem
type=
{
PanelHeaderMenuItemTypes
.
Link
}
text=
"Toggle legend"
...
...
public/app/features/dashboard/utils/panel.ts
0 → 100644
View file @
bf8703ed
import
appEvents
from
'app/core/app_events'
;
import
{
DashboardModel
}
from
'app/features/dashboard/dashboard_model'
;
import
{
PanelModel
}
from
'app/features/dashboard/panel_model'
;
export
const
removePanel
=
(
dashboard
:
DashboardModel
,
panel
:
PanelModel
,
ask
:
boolean
)
=>
{
// confirm deletion
if
(
ask
!==
false
)
{
const
text2
=
panel
.
alert
?
'Panel includes an alert rule, removing panel will also remove alert rule'
:
null
;
const
confirmText
=
panel
.
alert
?
'YES'
:
null
;
appEvents
.
emit
(
'confirm-modal'
,
{
title
:
'Remove Panel'
,
text
:
'Are you sure you want to remove this panel?'
,
text2
:
text2
,
icon
:
'fa-trash'
,
confirmText
:
confirmText
,
yesText
:
'Remove'
,
onConfirm
:
()
=>
removePanel
(
dashboard
,
panel
,
false
),
});
return
;
}
dashboard
.
removePanel
(
panel
);
};
export
default
{
removePanel
,
};
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