Skip to content

Instantly share code, notes, and snippets.

@bacall213
Last active December 23, 2015 08:08
Show Gist options
  • Save bacall213/6605258 to your computer and use it in GitHub Desktop.
Save bacall213/6605258 to your computer and use it in GitHub Desktop.
Ninjablocks Diskspace Dashboard Widget (Designed for use with https://github.com/bacall213/ninja-diskspace) (Author: Brian Call) (License: MIT)
return {
"name": "Ninja Diskspace",
"deviceMap": [
{ "deviceId": 2000, "minimum": 1, "maximum": 1} // Sandbox device until more specific ID is availble
],
"forceDeviceMapGroup": true
}
background: white;
h4 {
color: rgba(0,0,0,0.3);
font-size: 15px;
margin: 10px 10px;
}
.value {
position: absolute;
top: 50px;
width: 100%;
text-align: center;
font-size: 45px;
font-weight: bold;
left: 8px;
.units {
font-size: 14px;
font-weight: normal;
vertical-align: super;
position: relative;
top: -10px;
}
}
.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: 85px;
}
}
.diskspace {
color: hsl(45,100%,45%);
}
<div class="diskspace">
<div class="value">
<span class="text"></span>
<sup class="units">%</sup>
</div>
<div class="sparkline"></div>
</div>
var sparkDisk = element.find(".diskspace .sparkline");
var dataDisk = [];
var sparklineOptions = {
width: '100%',
height: '95px',
chartRangeMin: 0,
chartRangeMax: 100,
chartRangeMinX: 0,
drawNormalOnTop: false,
//fillColor: 'hsla(360,100%,100%,1.0)',
fillColor: null,
tooltipFormat: '<span style="color: {{color}}">&#9679;</span> {{y}}%'
};
function SetDisk(value) {
element.find(".diskspace .value .text").html(value);
dataDisk.push(value);
sparkDisk.sparkline(dataDisk, sparklineOptions);
};
scope.onData = function(data) {
var diskVal = data.DA.split('%');
SetDisk(diskVal[0]);
};
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