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
e7d9bbf7
Commit
e7d9bbf7
authored
Jan 02, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
state history tab
parent
ce01bd69
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
3 deletions
+90
-3
public/app/features/dashboard/dashgrid/AlertTab.tsx
+4
-2
public/app/features/dashboard/dashgrid/PanelEditor.tsx
+1
-1
public/app/features/dashboard/dashgrid/StateHistory.tsx
+85
-0
No files found.
public/app/features/dashboard/dashgrid/AlertTab.tsx
View file @
e7d9bbf7
...
...
@@ -2,12 +2,15 @@ import React, { PureComponent } from 'react';
import
{
AngularComponent
,
getAngularLoader
}
from
'app/core/services/AngularLoader'
;
import
{
EditorTabBody
,
EditorToolbarView
,
ToolbarButtonType
}
from
'./EditorTabBody'
;
import
EmptyListCTA
from
'app/core/components/EmptyListCTA/EmptyListCTA'
;
import
StateHistory
from
'./StateHistory'
;
import
appEvents
from
'app/core/app_events'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
'app/features/alerting/AlertTabCtrl'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
interface
Props
{
angularPanel
?:
AngularComponent
;
dashboard
:
DashboardModel
;
panel
:
PanelModel
;
}
...
...
@@ -70,7 +73,7 @@ export class AlertTab extends PureComponent<Props> {
return
{
title
:
'State history'
,
render
:
()
=>
{
return
<
div
>
State history
</
div
>;
return
<
StateHistory
dashboard=
{
this
.
props
.
dashboard
}
panelId=
{
this
.
props
.
panel
.
id
}
/
>;
},
buttonType
:
ToolbarButtonType
.
View
,
};
...
...
@@ -119,7 +122,6 @@ export class AlertTab extends PureComponent<Props> {
buttonTitle
:
'Create Alert'
,
};
//TODO move add button react from angular and add condition to render angular view
return
(
<
EditorTabBody
heading=
"Alert"
toolbarItems=
{
toolbarItems
}
>
<>
...
...
public/app/features/dashboard/dashgrid/PanelEditor.tsx
View file @
e7d9bbf7
...
...
@@ -54,7 +54,7 @@ export class PanelEditor extends PureComponent<PanelEditorProps> {
case
'queries'
:
return
<
QueriesTab
panel=
{
panel
}
dashboard=
{
dashboard
}
/>;
case
'alert'
:
return
<
AlertTab
angularPanel=
{
angularPanel
}
panel=
{
panel
}
/>;
return
<
AlertTab
angularPanel=
{
angularPanel
}
dashboard=
{
dashboard
}
panel=
{
panel
}
/>;
case
'visualization'
:
return
(
<
VisualizationTab
...
...
public/app/features/dashboard/dashgrid/StateHistory.tsx
0 → 100644
View file @
e7d9bbf7
import
React
,
{
PureComponent
}
from
'react'
;
import
alertDef
from
'../../alerting/state/alertDef'
;
import
{
getBackendSrv
}
from
'../../../core/services/backend_srv'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
interface
Props
{
dashboard
:
DashboardModel
;
panelId
:
number
;
}
interface
State
{
stateHistoryItems
:
any
[];
}
class
StateHistory
extends
PureComponent
<
Props
,
State
>
{
state
=
{
stateHistoryItems
:
[],
};
componentDidMount
():
void
{
const
{
dashboard
,
panelId
}
=
this
.
props
;
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
({
stateModel
:
alertDef
.
getStateDisplayModel
(
item
.
newState
),
time
:
dashboard
.
formatDate
(
item
.
time
,
'MMM D, YYYY HH:mm:ss'
),
info
:
alertDef
.
getAlertAnnotationInfo
(
item
),
});
});
this
.
setState
({
stateHistoryItems
:
items
,
});
});
}
render
()
{
const
{
stateHistoryItems
}
=
this
.
state
;
return
(
<
div
>
<
div
style=
{
{
margin
:
'0 auto'
,
maxWidth
:
'720px'
}
}
>
<
div
style=
{
{
marginBottom
:
'15px'
}
}
>
<
span
className=
"muted"
>
Last 50 state changes
</
span
>
<
button
className=
"btn btn-mini btn-danger pull-right"
>
<
i
className=
"fa fa-trash"
/>
{
` Clear history`
}
</
button
>
</
div
>
<
ol
className=
"alert-rule-list"
>
{
stateHistoryItems
?
(
stateHistoryItems
.
map
((
item
,
index
)
=>
{
return
(
<
li
className=
"alert-rule-item"
key=
{
`${item.time}-${index}`
}
>
<
div
className=
{
`alert-rule-item__icon ${item.stateModel.stateClass}`
}
>
<
i
className=
{
item
.
stateModel
.
iconClass
}
/>
</
div
>
<
div
className=
"alert-rule-item__body"
>
<
div
className=
"alert-rule-item__header"
>
<
p
className=
"alert-rule-item__name"
>
{
item
.
alertName
}
</
p
>
<
div
className=
"alert-rule-item__text"
>
<
span
className=
{
`${item.stateModel.stateClass}`
}
>
{
item
.
stateModel
.
text
}
</
span
>
</
div
>
</
div
>
{
item
.
info
}
</
div
>
<
div
className=
"alert-rule-item__time"
>
{
item
.
time
}
</
div
>
</
li
>
);
})
)
:
(
<
i
>
No state changes recorded
</
i
>
)
}
</
ol
>
</
div
>
</
div
>
);
}
}
export
default
StateHistory
;
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