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
e69fe93e
Unverified
Commit
e69fe93e
authored
Oct 08, 2020
by
Ryan McKinley
Committed by
GitHub
Oct 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Live: improve dashboard editing notifications (#28094)
parent
b55a51e2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
public/app/features/live/dashboard/DashboardChangedModal.tsx
+10
-4
public/app/features/live/dashboard/dashboardWatcher.ts
+19
-2
public/app/features/live/dashboard/types.ts
+1
-0
No files found.
public/app/features/live/dashboard/DashboardChangedModal.tsx
View file @
e69fe93e
import
React
,
{
PureComponent
}
from
'react'
;
import
{
Modal
,
stylesFactory
,
VerticalGroup
}
from
'@grafana/ui'
;
import
{
Modal
,
stylesFactory
}
from
'@grafana/ui'
;
import
{
css
}
from
'emotion'
;
import
{
dashboardWatcher
}
from
'./dashboardWatcher'
;
import
{
config
}
from
'@grafana/runtime'
;
...
...
@@ -71,6 +71,7 @@ export class DashboardChangedModal extends PureComponent<Props, State> {
title=
"Dashboard Changed"
icon=
"copy"
onDismiss=
{
this
.
onDismiss
}
onClickBackdrop=
{
()
=>
{}
}
className=
{
styles
.
modal
}
>
<
div
>
...
...
@@ -80,7 +81,6 @@ export class DashboardChangedModal extends PureComponent<Props, State> {
<
div
>
This dashboard has been modifed by another session
</
div
>
)
}
<
br
/>
<
VerticalGroup
>
{
options
.
map
(
opt
=>
{
return
(
<
div
key=
{
opt
.
label
}
onClick=
{
opt
.
action
}
className=
{
styles
.
radioItem
}
>
...
...
@@ -89,7 +89,6 @@ export class DashboardChangedModal extends PureComponent<Props, State> {
</
div
>
);
})
}
</
VerticalGroup
>
<
br
/>
</
div
>
</
Modal
>
...
...
@@ -104,9 +103,16 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
`
,
radioItem
:
css
`
margin: 0;
margin-left:
${
theme
.
spacing
.
md
}
;
font-size:
${
theme
.
typography
.
size
.
sm
}
;
color:
${
theme
.
colors
.
textWeak
}
;
padding: 10px;
cursor: pointer;
width: 100%;
&:hover {
background:
${
theme
.
colors
.
formCheckboxBgCheckedHover
}
;
color:
${
theme
.
colors
.
text
}
;
}
`
,
};
});
public/app/features/live/dashboard/dashboardWatcher.ts
View file @
e69fe93e
...
...
@@ -23,6 +23,7 @@ class DashboardWatcher {
uid
?:
string
;
ignoreSave
?:
boolean
;
editing
=
false
;
lastEditing
?:
DashboardEvent
;
setEditingState
(
state
:
boolean
)
{
const
changed
=
(
this
.
editing
=
state
);
...
...
@@ -42,7 +43,8 @@ class DashboardWatcher {
sessionId
,
uid
:
this
.
uid
!
,
action
:
this
.
editing
?
DashboardEventAction
.
EditingStarted
:
DashboardEventAction
.
EditingCanceled
,
message
:
'user (name)'
,
message
:
(
window
as
any
).
grafanaBootData
?.
user
?.
name
,
timestamp
:
Date
.
now
(),
};
this
.
channel
!
.
publish
!
(
msg
);
}
...
...
@@ -79,6 +81,16 @@ class DashboardWatcher {
this
.
ignoreSave
=
true
;
}
getRecentEditingEvent
()
{
if
(
this
.
lastEditing
&&
this
.
lastEditing
.
timestamp
)
{
const
elapsed
=
Date
.
now
()
-
this
.
lastEditing
.
timestamp
;
if
(
elapsed
>
5000
)
{
this
.
lastEditing
=
undefined
;
}
}
return
this
.
lastEditing
;
}
observer
=
{
next
:
(
event
:
LiveChannelEvent
<
DashboardEvent
>
)
=>
{
// Send the editing state when connection starts
...
...
@@ -121,11 +133,16 @@ class DashboardWatcher {
}
}
else
if
(
showPopup
)
{
if
(
action
===
DashboardEventAction
.
EditingStarted
)
{
const
editingEvent
=
event
.
message
;
const
recent
=
this
.
getRecentEditingEvent
();
if
(
!
recent
||
recent
.
message
!==
editingEvent
.
message
)
{
appEvents
.
emit
(
AppEvents
.
alertWarning
,
[
'Another session is editing this dashboard'
,
event
.
message
.
message
,
editingEvent
.
message
,
]);
}
this
.
lastEditing
=
editingEvent
;
}
}
return
;
}
...
...
public/app/features/live/dashboard/types.ts
View file @
e69fe93e
...
...
@@ -11,4 +11,5 @@ export interface DashboardEvent {
userId
?:
number
;
message
?:
string
;
sessionId
?:
string
;
timestamp
?:
number
;
}
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