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
6b5f9d58
Commit
6b5f9d58
authored
Jan 02, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear history
parent
e7d9bbf7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
13 deletions
+42
-13
public/app/features/dashboard/dashgrid/AlertTab.tsx
+7
-5
public/app/features/dashboard/dashgrid/StateHistory.tsx
+35
-8
No files found.
public/app/features/dashboard/dashgrid/AlertTab.tsx
View file @
6b5f9d58
...
...
@@ -19,10 +19,6 @@ export class AlertTab extends PureComponent<Props> {
component
:
AngularComponent
;
panelCtrl
:
any
;
constructor
(
props
)
{
super
(
props
);
}
componentDidMount
()
{
if
(
this
.
shouldLoadAlertTab
())
{
this
.
loadAlertTab
();
...
...
@@ -73,7 +69,13 @@ export class AlertTab extends PureComponent<Props> {
return
{
title
:
'State history'
,
render
:
()
=>
{
return
<
StateHistory
dashboard=
{
this
.
props
.
dashboard
}
panelId=
{
this
.
props
.
panel
.
id
}
/>;
return
(
<
StateHistory
dashboard=
{
this
.
props
.
dashboard
}
panelId=
{
this
.
props
.
panel
.
id
}
onRefresh=
{
this
.
panelCtrl
.
refresh
}
/>
);
},
buttonType
:
ToolbarButtonType
.
View
,
};
...
...
public/app/features/dashboard/dashgrid/StateHistory.tsx
View file @
6b5f9d58
import
React
,
{
PureComponent
}
from
'react'
;
import
alertDef
from
'../../alerting/state/alertDef'
;
import
{
getBackendSrv
}
from
'
../../..
/core/services/backend_srv'
;
import
{
getBackendSrv
}
from
'
app
/core/services/backend_srv'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
appEvents
from
'../../../core/app_events'
;
interface
Props
{
dashboard
:
DashboardModel
;
panelId
:
number
;
onRefresh
:
()
=>
void
;
}
interface
State
{
...
...
@@ -23,14 +25,12 @@ class StateHistory extends PureComponent<Props, State> {
getBackendSrv
()
.
get
(
`/api/annotations?dashboardId=
${
dashboard
.
id
}
&panelId=
${
panelId
}
&limit=50&type=alert`
)
.
then
(
res
=>
{
console
.
log
(
res
);
const
items
=
[];
res
.
map
(
item
=>
{
items
.
push
({
const
items
=
res
.
map
(
item
=>
{
return
{
stateModel
:
alertDef
.
getStateDisplayModel
(
item
.
newState
),
time
:
dashboard
.
formatDate
(
item
.
time
,
'MMM D, YYYY HH:mm:ss'
),
info
:
alertDef
.
getAlertAnnotationInfo
(
item
),
}
)
;
};
});
this
.
setState
({
...
...
@@ -39,20 +39,47 @@ class StateHistory extends PureComponent<Props, State> {
});
}
clearHistory
=
()
=>
{
const
{
dashboard
,
onRefresh
,
panelId
}
=
this
.
props
;
appEvents
.
emit
(
'confirm-modal'
,
{
title
:
'Delete Alert History'
,
text
:
'Are you sure you want to remove all history & annotations for this alert?'
,
icon
:
'fa-trash'
,
yesText
:
'Yes'
,
onConfirm
:
()
=>
{
getBackendSrv
()
.
post
(
'/api/annotations/mass-delete'
,
{
dashboardId
:
dashboard
.
id
,
panelId
:
panelId
,
})
.
then
(()
=>
{
onRefresh
();
});
this
.
setState
({
stateHistoryItems
:
[],
});
},
});
};
render
()
{
const
{
stateHistoryItems
}
=
this
.
state
;
return
(
<
div
>
<
div
style=
{
{
margin
:
'0 auto'
,
maxWidth
:
'720px'
}
}
>
{
stateHistoryItems
.
length
>
0
&&
(
<
div
style=
{
{
marginBottom
:
'15px'
}
}
>
<
span
className=
"muted"
>
Last 50 state changes
</
span
>
<
button
className=
"btn btn-mini btn-danger pull-right"
>
<
button
className=
"btn btn-mini btn-danger pull-right"
onClick=
{
this
.
clearHistory
}
>
<
i
className=
"fa fa-trash"
/>
{
` Clear history`
}
</
button
>
</
div
>
)
}
<
ol
className=
"alert-rule-list"
>
{
stateHistoryItems
?
(
{
stateHistoryItems
.
length
>
0
?
(
stateHistoryItems
.
map
((
item
,
index
)
=>
{
return
(
<
li
className=
"alert-rule-item"
key=
{
`${item.time}-${index}`
}
>
...
...
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