Last active
December 21, 2015 17:39
-
-
Save bacall213/6341813 to your computer and use it in GitHub Desktop.
Ninja RAM BETA Dashboard Widget
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
return { | |
"name": "Ninja RAM", | |
"deviceMap": [ | |
{ "deviceId": [520,521,522,523], "minimum": 1, "maximum": 1} | |
], | |
"forceDeviceMapGroup": true | |
} |
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
background: white; | |
h4 { | |
color: rgba(0,0,0,0.3); | |
font-size: 15px; | |
margin: 10px 10px; | |
} | |
.sensor { | |
color: hsl(45,100%,45%); | |
} | |
.value { | |
position: absolute; | |
top: 50px; | |
width: 100%; | |
text-align: center; | |
font-size: 45px; | |
font-weight: bold; | |
left: 55px; | |
.units { | |
font-size: 14px; | |
font-weight: normal; | |
vertical-align: super; | |
position: relative; | |
top: -10px; | |
} | |
.hiText { | |
position: relative; | |
display: inline-block; | |
color: hsl(20,75%,65%); | |
font-weight: bold; | |
font-size: 10px; | |
width: 50px; | |
top: -15px; | |
left: -25px; | |
text-align: left; | |
} | |
.loText { | |
position: relative; | |
display: inline-block; | |
color: hsl(203,60%,56%); | |
font-weight: bold; | |
font-size: 10px; | |
width: 50px; | |
top: -4px; | |
left: -88px; | |
text-align: left; | |
} | |
} | |
.sparkline { | |
position: relative; | |
top: 100px; | |
width: 90%; | |
height: 95px; | |
margin-left: auto; | |
margin-right: auto; | |
line-height: 30px; | |
border: 1px solid hsl(0,0%,90%); | |
background: hsl(0,0%,95%); | |
canvas { | |
width: 100%; | |
height: 30px; | |
} | |
} |
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
<div class="sensor"> | |
<div class="value"> | |
<span class="text"></span> | |
<sup class="units">%</sup> | |
<span class="hiText"></span> | |
<span class="loText"></span> | |
</div> | |
<div class="sparkline"></div> | |
</div> |
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
var sparkCPU = element.find(".sensor .sparkline"); | |
var dataCPU = []; | |
var sparklineOptions = { | |
width: '100%', | |
height: '95px', | |
chartRangeMin: 0, | |
chartRangeMax: 100, | |
chartRangeMinX: 0, | |
chartRangeMaxX: 100, | |
drawNormalOnTop: false, | |
fillColor: 'hsla(360,100%,100%,1.0)', | |
tooltipFormat: '<span style="color: {{color}}">●</span> {{y}}%' | |
} | |
function SetCPU(value) { | |
element.find(".sensor .value .text").html(value); | |
dataCPU.push(value); | |
sparkCPU.sparkline(dataCPU, sparklineOptions); | |
element.find(".sensor .value .hiText").html("HI: " + Math.max.apply(null, dataCPU)); | |
element.find(".sensor .value .loText").html("LO: " + Math.min.apply(null, dataCPU)); | |
}; | |
scope.onData = function(data) { | |
if (data.D >= 520 || data.D <= 523) { | |
SetCPU(data.DA); | |
} | |
} | |
scope.Widget.settings.name = _.find(scope.Widget.devices, function(device) { return true; }).shortName; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment