Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ input.table-row-value

ul.value-dropdown
{
height : 75px;
height : 200px;
position : absolute;
padding : 0px;
margin : 0px;
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"js/freeboard/freeboard.js",
"js/freeboard/plugins/freeboard.datasources.js",
"js/freeboard/plugins/freeboard.widgets.js",
"examples/plugin_example.js",
"js/freeboard/plugins/wsDataSourcePlugin.js",
// *** Load more plugins here ***
function(){
$(function()
Expand Down
2 changes: 2 additions & 0 deletions js/freeboard/freeboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,8 @@ var freeboard = (function()

if(freeboardLocation != "")
{
theFreeboardModel.allow_edit(allowEdit); // respect the allowEdit flag
theFreeboardModel.setEditing(false); // but always start with editor shut.
$.ajax({
url : freeboardLocation,
success: function(data)
Expand Down
8 changes: 7 additions & 1 deletion js/freeboard/plugins/freeboard.widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Add some styles to our sheet
freeboard.addStyle('.text-widget-unit', 'padding-left: 5px;display:inline;');
freeboard.addStyle('.text-widget-regular-value', valueStyle + "font-size:30px;");
freeboard.addStyle('.text-widget-small-value', valueStyle + "font-size:18px;");
freeboard.addStyle('.text-widget-big-value', valueStyle + "font-size:75px;");

freeboard.addStyle('.gauge-widget-wrapper', "width: 100%;text-align: center;");
Expand Down Expand Up @@ -121,7 +122,8 @@

valueElement
.toggleClass("text-widget-regular-value", (newSettings.size == "regular"))
.toggleClass("text-widget-big-value", (newSettings.size == "big"));
.toggleClass("text-widget-big-value", (newSettings.size == "big"))
.toggleClass("text-widget-small-value", (newSettings.size == "small"));

unitsElement.html((_.isUndefined(newSettings.units) ? "" : newSettings.units));

Expand Down Expand Up @@ -189,6 +191,10 @@
{
name: "Big",
value: "big"
},
{
name: "Small",
value: "small"
}
]
},
Expand Down
72 changes: 72 additions & 0 deletions js/freeboard/plugins/wsDataSourcePlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// ## A Web Socket Datasource Plugin for the Freeboard Dashboard

(function() {

var wsDatasource = function(settings, updateCallback) {
var server = window.location.hostname;
var wsUri, ws;

var self = this;
var currentSettings = settings;

function wsStart(wsUri) {
ws = new WebSocket(wsUri);

ws.onopen = function(evt) {
console.log("ws : connected");
};

ws.onclose = function(evt) {
console.log("ws : disconnected");
setTimeout(function(){wsStart(wsUri)}, 3000); // try to reconnect every 3 secs...
}

ws.onmessage = function (evt) {
try {
var da = JSON.parse(evt.data);
updateCallback(da);
} catch (e) {
console.log("ws : bad parse",evt.data);
}
}

ws.onerror = function(evt) {
console.log("ws : error",evt);
}
}

this.updateNow = function() {
console.log("Update now");
}

this.onDispose = function() {
console.log("Disposed");
}

this.onSettingsChanged = function(newSettings) {
if (ws) ws.close();
currentSettings = newSettings;
wsUri = currentSettings.ws_uri;
wsStart(wsUri);
}

self.onSettingsChanged(settings);
};

freeboard.loadDatasourcePlugin({
type_name : "web_socket",
display_name: "Web Socket",
settings : [
{
name : "ws_uri",
display_name: "WS URI",
description : "Example: ws://server:port/path",
type : "text"
}
],
newInstance : function(settings, newInstanceCallback, updateCallback)
{
newInstanceCallback(new wsDatasource(settings, updateCallback));
}
});
}());