Created
August 18, 2017 05:24
-
-
Save bodsch/941357c0879b087c67e5059616a1b73d to your computer and use it in GitHub Desktop.
dasching widget for icinga2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dashing.Icinga2 extends Dashing.Widget | |
@accessor 'current', Dashing.AnimatedValue | |
onData: (data) -> | |
if data.color | |
# clear existing "color-*" classes | |
$(@get('node')).attr 'class', (i,c) -> | |
c.replace /\bcolor-\S+/g, '' | |
# add new class | |
$(@get('node')).addClass "color-#{data.color}" | |
checkUpdate: => | |
if updatedAt = @get('updatedAt') | |
timestamp = new Date(updatedAt * 1000) | |
now = new Date() | |
diff = now.getTime() - timestamp.getTime() | |
if diff > 30000 | |
@onData({color:'grey'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 class="title" data-bind="title"></h1> | |
<ul class="list-nostyle"> | |
<li data-foreach-item="items"> | |
<div data-bind-class="item.color"> | |
<span class="label" data-bind="item.label"></span> | |
<span class="value" data-bind="item.value"></span> | |
</div> | |
</li> | |
</ul> | |
<p class="updated-at" data-bind="updatedAtMessage"></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------------------- | |
// Sass declarations | |
// ---------------------------------------------------------------------------- | |
$background-color: #165aa8; | |
$value-color: #fff; | |
$label-color: rgba(255, 255, 255, 0.7); | |
$background-color-green: green; | |
$background-color-green-1: lighten($background-color-green, 60%); | |
$background-color-green-2: darken($background-color-green, 30%); | |
$value-color-green: #fff; | |
$background-color-red: red; | |
$background-color-red-1: lighten($background-color-red, 60%); | |
$background-color-red-2: darken($background-color-red, 30%); | |
$value-color-red: #fff; | |
$background-color-yellow: yellow; | |
$background-color-yellow-1: lighten($background-color-yellow, 60%); | |
$background-color-yellow-2: darken($background-color-yellow, 30%); | |
$value-color-yellow: #fff; | |
$background-color-purple: #aa44ff; | |
$background-color-purple-1: #aa44ff; | |
$background-color-purple-2: #aa44ff; | |
$value-color-purple: #fff; | |
$background-color-grey: #999999; | |
$value-color-grey: #fff; | |
$title-color: rgba(255, 255, 255, 0.7); | |
// $title-color-uns: rgba(0, 0, 0, 0.7); | |
$moreinfo-color: rgba(255, 255, 255, 0.7); | |
@-webkit-keyframes icinga-yellow-background { | |
0% { background-color: $background-color-yellow-1; } | |
50% { background-color: $background-color-yellow-2; } | |
100% { background-color: $background-color-yellow-1; } | |
} | |
@-webkit-keyframes icinga-red-background { | |
0% { background-color: $background-color-red-1; } | |
50% { background-color: $background-color-red-2; } | |
100% { background-color: $background-color-red-1; } | |
} | |
@-webkit-keyframes icinga-green-background { | |
0% { background-color: $background-color-green-1; } | |
50% { background-color: $background-color-green-2; } | |
100% { background-color: $background-color-green-1; } | |
} | |
@-webkit-keyframes icinga-purple-background { | |
0% { background-color: $background-color-purple-1; } | |
50% { background-color: $background-color-purple-2; } | |
100% { background-color: $background-color-purple-1; } | |
} | |
@mixin animation($animation-name, $duration, $function, $animation-iteration-count:"infinite"){ | |
-webkit-animation: $animation-name $duration $function #{$animation-iteration-count}; | |
-moz-animation: $animation-name $duration $function #{$animation-iteration-count}; | |
-ms-animation: $animation-name $duration $function #{$animation-iteration-count}; | |
} | |
// ---------------------------------------------------------------------------- | |
// Widget-number styles | |
// ---------------------------------------------------------------------------- | |
.widget-icinga2 { | |
/* background-color: $background-color; */ | |
.title { | |
color: $title-color; | |
font-size: 25px; | |
text-align: center; | |
margin-top: -3em; | |
} | |
.list-nostyle { | |
list-style: none; | |
text-align: left; | |
} | |
.list-nostyle div { | |
padding: 0 4px 2px 4px; | |
border-radius: 3px | |
} | |
.list-nostyle div.green { | |
background-color: $background-color-green; | |
.value { color: $value-color-green; } | |
} | |
.list-nostyle div.green-blink { | |
background-color: $background-color-green; | |
@include animation(icinga-green-background, 4s, ease); | |
.value { color: $value-color-green; } | |
} | |
.list-nostyle div.red { | |
background-color: $background-color-red; | |
.value { color: $value-color-red; } | |
} | |
.list-nostyle div.red-blink { | |
background-color: $background-color-red; | |
@include animation(icinga-red-background, 4s, ease); | |
.value { color: $value-color-red; } | |
} | |
.list-nostyle div.yellow { | |
background-color: $background-color-yellow; | |
.value { color: $value-color-yellow; } | |
} | |
.list-nostyle div.yellow-blink { | |
@include animation(icinga-yellow-background, 4s, ease); | |
background-color: $background-color-yellow; | |
.value { color: $value-color-yellow; } | |
} | |
.list-nostyle div.purple { | |
background-color: $background-color-purple; | |
.value { color: $value-color-purple; } | |
} | |
.list-nostyle div.purple-blink { | |
@include animation(icinga-purple-background, 4s, ease); | |
background-color: $background-color-purple; | |
.value { color: $value-color-purple; } | |
} | |
.list-nostyle div.grey { | |
background-color: $background-color-grey; | |
.value { color: $value-color-grey; } | |
} | |
.label { | |
color: $label-color; | |
font-size: 15px; | |
} | |
.value { | |
float: right; | |
margin-left: 50px; | |
margin-top: 5px; | |
font-weight: 500; | |
font-size: 15px; | |
color: $value-color; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to use them, include this into the dashing dashboard:
and this into the dashing job: