Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OSS
Meerkat
Commits
ff832ccc
Commit
ff832ccc
authored
May 03, 2021
by
MaxSol1
Browse files
popup global red indicator when meerkat frontend isn't getting updates
parent
75d84ca9
Changes
7
Show whitespace changes
Inline
Side-by-side
frontend/src/elements/card.jsx
View file @
ff832ccc
...
...
@@ -101,12 +101,16 @@ export function CheckCard({options, slug, dashboard}) {
}
if
(
options
.
objectType
!==
null
&&
options
.
filter
!==
null
)
{
try
{
const
res
=
await
meerkat
.
getIcingaObjectState
(
options
.
objectType
,
options
.
filter
,
dashboard
);
const
state
=
icingaResultCodeToCheckState
(
options
.
objectType
,
res
.
MaxState
);
res
.
Acknowledged
?
setAcknowledged
(
'
ack
'
)
:
setAcknowledged
(
""
);
setCheckState
(
state
);
muteAlerts
();
alertSound
(
state
);
}
catch
(
error
)
{
window
.
flash
(
`This dashboard isn't updating:
${
error
}
`
,
'
error
'
)
}
}
});
}
...
...
frontend/src/elements/image.jsx
View file @
ff832ccc
...
...
@@ -246,12 +246,16 @@ export function CheckImage({options, dashboard, slug}) {
}
}
if
(
options
.
objectType
!==
null
&&
options
.
filter
!==
null
)
{
try
{
const
res
=
await
meerkat
.
getIcingaObjectState
(
options
.
objectType
,
options
.
filter
,
dashboard
);
const
state
=
icingaResultCodeToCheckState
(
options
.
objectType
,
res
.
MaxState
);
res
.
Acknowledged
?
setAcknowledged
(
'
ack
'
)
:
setAcknowledged
(
""
);
setCheckState
(
state
);
muteAlerts
();
alertSound
(
state
);
}
catch
(
error
)
{
window
.
flash
(
"
This dashboard isn't updating
"
,
'
error
'
)
}
}
});
}
...
...
frontend/src/elements/line.jsx
View file @
ff832ccc
...
...
@@ -205,12 +205,16 @@ export function CheckLine({options, dashboard, slug}) {
}
if
(
options
.
objectType
!==
null
&&
options
.
filter
!==
null
)
{
try
{
const
res
=
await
meerkat
.
getIcingaObjectState
(
options
.
objectType
,
options
.
filter
,
dashboard
);
const
state
=
icingaResultCodeToCheckState
(
options
.
objectType
,
res
.
MaxState
);
res
.
Acknowledged
?
setAcknowledged
(
"
ack
"
)
:
setAcknowledged
(
""
);
res
.
Acknowledged
?
setAcknowledged
(
'
ack
'
)
:
setAcknowledged
(
""
);
setCheckState
(
state
);
muteAlerts
();
alertSound
(
state
);
}
catch
(
error
)
{
window
.
flash
(
"
This dashboard isn't updating
"
,
'
error
'
)
}
}
});
}
...
...
frontend/src/elements/svg.jsx
View file @
ff832ccc
...
...
@@ -178,12 +178,16 @@ export function CheckSVG({options, dashboard, slug}) {
}
}
if
(
options
.
objectType
!==
null
&&
options
.
filter
!==
null
)
{
try
{
const
res
=
await
meerkat
.
getIcingaObjectState
(
options
.
objectType
,
options
.
filter
,
dashboard
);
const
state
=
icingaResultCodeToCheckState
(
options
.
objectType
,
res
.
MaxState
);
res
.
Acknowledged
?
setAcknowledged
(
"
ack
"
)
:
setAcknowledged
(
""
);
res
.
Acknowledged
?
setAcknowledged
(
'
ack
'
)
:
setAcknowledged
(
""
);
setCheckState
(
state
);
muteAlerts
();
alertSound
(
state
);
}
catch
(
error
)
{
window
.
flash
(
"
This dashboard isn't updating
"
,
'
error
'
)
}
}
});
}
...
...
frontend/src/flash.js
0 → 100644
View file @
ff832ccc
import
{
h
,
Fragment
}
from
'
preact
'
;
import
{
useState
,
useEffect
}
from
'
preact/hooks
'
;
import
bus
from
'
../utils/bus
'
;
export
const
Flash
=
()
=>
{
let
[
visibility
,
setVisibility
]
=
useState
(
false
);
let
[
message
,
setMessage
]
=
useState
(
''
);
let
[
type
,
setType
]
=
useState
(
''
);
useEffect
(()
=>
{
bus
.
addListener
(
'
flash
'
,
({
message
,
type
})
=>
{
setVisibility
(
true
);
setMessage
(
message
);
setType
(
type
);
setTimeout
(()
=>
{
setVisibility
(
false
);
},
4000
);
});
},
[]);
const
alert
=
{
color
:
'
white
'
,
background
:
'
#ff4a4a
'
,
borderRadius
:
'
5px
'
,
position
:
'
absolute
'
,
top
:
'
40px
'
,
right
:
'
30px
'
,
paddingTop
:
'
38px
'
,
paddingBottom
:
'
25px
'
,
paddingTop
:
'
38px
'
,
paddingLeft
:
'
40px
'
,
paddingRight
:
'
40px
'
,
display
:
'
flex
'
,
alignItems
:
'
center
'
,
marginTop
:
'
20px
'
,
zIndex
:
2
,
margin
:
0
,
fontSize
:
'
20px
'
,
}
const
close
=
{
color
:
'
white
'
,
cursor
:
'
pointer
'
,
marginLeft
:
'
30px
'
,
marginRight
:
'
5px
'
,
marginBottom
:
'
14px
'
,
}
// const error = {
// background: 'red',
// }
// const success = {
// background: 'lightgreen',
// }
useEffect
(()
=>
{
if
(
document
.
getElementById
(
'
close
'
)
!==
null
)
{
document
.
getElementById
(
'
close
'
).
addEventListener
(
'
click
'
,
()
=>
setVisibility
(
false
));
}
})
return
(
visibility
&&
<
div
style
=
{
alert
}
>
<
p
>
{
message
}
<
/p
>
<
span
style
=
{
close
}
id
=
"
close
"
><
strong
>
X
<
/strong></
span
>
<
/div
>
)
}
\ No newline at end of file
frontend/src/index.jsx
View file @
ff832ccc
...
...
@@ -4,9 +4,12 @@ import { Router } from 'preact-router';
import
{
Home
}
from
'
./home
'
;
import
{
Editor
}
from
'
./editor
'
;
import
{
Viewer
}
from
'
./viewer
'
;
import
{
Flash
}
from
'
./flash
'
;
import
bus
from
'
../utils/bus
'
;
function
Main
()
{
return
<
Fragment
>
<
Flash
/>
<
Router
>
<
Home
path
=
"/"
/>
<
Editor
path
=
"/edit/:slug"
/>
...
...
@@ -17,6 +20,8 @@ function Main() {
</
Fragment
>
}
window
.
flash
=
(
message
,
type
=
"
success
"
)
=>
bus
.
emit
(
'
flash
'
,
({
message
,
type
}));
function
NotFound
()
{
return
<
div
>
404
</
div
>
}
...
...
frontend/utils/bus.js
0 → 100644
View file @
ff832ccc
import
EventEmitter
from
'
events
'
;
export
default
new
EventEmitter
();
\ No newline at end of file
Max Reeves
@max1
mentioned in issue
#38 (closed)
·
May 03, 2021
mentioned in issue
#38 (closed)
mentioned in issue #38
Toggle commit list
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