Skip to content

Commit bbcba28

Browse files
committed
Added pull request Freeboard#278
Added pull request Freeboard#227 Added highchart plugin from https://github.com/onlinux/freeboard-dynamic-highcharts-plugin, and added object-support
1 parent 321d573 commit bbcba28

18 files changed

+1095
-76
lines changed

css/freeboard.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ header h1 {
11671167
position: relative;
11681168
-webkit-box-shadow: 0 0 5px #000;
11691169
box-shadow: 0 0 5px #000;
1170+
overflow:scroll;
11701171
}
11711172

11721173
#toggle-header {

css/freeboard.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index-dev.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"plugins/thirdparty/paho.mqtt.plugin.js",
4141
"plugins/thirdparty/randomdatasource.plugin.js",
4242
"plugins/thirdparty/interactive_indicator.js",
43-
"examples/plugin_example.js",
43+
"plugins/thirdparty/plugin_highcharts.js",
44+
"examples/plugin_example.js",
4445

4546
// *** Load more plugins here ***
4647
function(){

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<script type="text/javascript">
1313
head.js("js/freeboard_plugins.min.js",
1414
"plugins/thirdparty/paho.mqtt.plugin.js",
15-
"plugins/thirdparty/interactive_indicator.js",
15+
"plugins/thirdparty/plugin_highcharts.js",
16+
"plugins/thirdparty/interactive_indicator.js",
1617
// *** Load more plugins here ***
1718
function(){
1819
$(function()

js/freeboard.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DatasourceModel = function(theFreeboardModel, datasourcePlugins) {
5757
}
5858

5959
// Do we need to load any external scripts?
60-
if(datasourceType.external_scripts)
60+
if(datasourceType.external_scripts && datasourceType.external_scripts.length>0)
6161
{
6262
head.js(datasourceType.external_scripts.slice(0), finishLoad); // Need to clone the array because head.js adds some weird functions to it
6363
}
@@ -704,14 +704,12 @@ function FreeboardModel(datasourcePlugins, widgetPlugins, freeboardUI)
704704
}
705705
}
706706

707-
function FreeboardUI()
707+
function FreeboardUI(pane_margin, pane_width, min_columns)
708708
{
709-
var PANE_MARGIN = 10;
710-
var PANE_WIDTH = 300;
711-
var MIN_COLUMNS = 3;
712-
var COLUMN_WIDTH = PANE_MARGIN + PANE_WIDTH + PANE_MARGIN;
713709

714-
var userColumns = MIN_COLUMNS;
710+
var column_width = pane_margin + pane_width + pane_margin;
711+
712+
var userColumns = min_columns;
715713

716714
var loadingIndicator = $('<div class="wrapperloading"><div class="loading up" ></div><div class="loading down"></div></div>');
717715
var grid;
@@ -812,9 +810,9 @@ function FreeboardUI()
812810
{
813811
var col_controls = $(".column-tool");
814812
var available_width = $("#board-content").width();
815-
var max_columns = Math.floor(available_width / COLUMN_WIDTH);
813+
var max_columns = Math.floor(available_width / column_width);
816814

817-
if(grid.cols <= MIN_COLUMNS)
815+
if(grid.cols <= min_columns)
818816
{
819817
col_controls.addClass("min");
820818
}
@@ -836,14 +834,14 @@ function FreeboardUI()
836834
function getMaxDisplayableColumnCount()
837835
{
838836
var available_width = $("#board-content").width();
839-
return Math.floor(available_width / COLUMN_WIDTH);
837+
return Math.floor(available_width / column_width);
840838
}
841839

842840
function updateGridWidth(newCols)
843841
{
844-
if(newCols === undefined || newCols < MIN_COLUMNS)
842+
if(newCols === undefined || newCols < min_columns)
845843
{
846-
newCols = MIN_COLUMNS;
844+
newCols = min_columns;
847845
}
848846

849847
var max_columns = getMaxDisplayableColumnCount();
@@ -853,7 +851,7 @@ function FreeboardUI()
853851
}
854852

855853
// +newCols to account for scaling on zoomed browsers
856-
var new_width = (COLUMN_WIDTH * newCols) + newCols;
854+
var new_width = (column_width * newCols) + newCols;
857855
$(".responsive-column-width").css("max-width", new_width);
858856

859857
if(newCols === grid.cols)
@@ -877,7 +875,7 @@ function FreeboardUI()
877875
rootElement.find("> li").each(repositionFunction);
878876

879877
grid.init();
880-
$(".responsive-column-width").css("width", grid.cols * PANE_WIDTH + (grid.cols * PANE_MARGIN * 2));
878+
$(".responsive-column-width").css("width", grid.cols * pane_width + (grid.cols * pane_margin * 2));
881879
}
882880

883881
function getUserColumns()
@@ -887,16 +885,16 @@ function FreeboardUI()
887885

888886
function setUserColumns(numCols)
889887
{
890-
userColumns = Math.max(MIN_COLUMNS, numCols);
888+
userColumns = Math.max(min_columns, numCols);
891889
}
892890

893891
ko.bindingHandlers.grid = {
894892
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)
895893
{
896894
// Initialize our grid
897895
grid = $(element).gridster({
898-
widget_margins : [PANE_MARGIN, PANE_MARGIN],
899-
widget_base_dimensions: [PANE_WIDTH, 10],
896+
widget_margins : [pane_margin, pane_margin],
897+
widget_base_dimensions: [pane_width, 10],
900898
resize: {
901899
enabled : false,
902900
axes : "x"
@@ -1145,6 +1143,7 @@ function FreeboardUI()
11451143
}
11461144
}
11471145

1146+
11481147
JSEditor = function () {
11491148
var assetRoot = ""
11501149

@@ -1257,6 +1256,7 @@ function PaneModel(theFreeboardModel, widgetPlugins) {
12571256

12581257
this.processSizeChange = function()
12591258
{
1259+
console.log("processSizeChange");
12601260
// Give the animation a moment to complete. Really hacky.
12611261
// TODO: Make less hacky. Also, doesn't work when screen resizes.
12621262
setTimeout(function(){
@@ -2306,16 +2306,17 @@ function WidgetModel(theFreeboardModel, widgetPlugins) {
23062306

23072307
this.processDatasourceUpdate = function (datasourceName, newDataNames) {
23082308
var refreshSettingNames = self.datasourceRefreshNotifications[datasourceName];
2309-
23102309
if (_.isArray(refreshSettingNames)) {
23112310
var updates=[];
23122311
_.each(refreshSettingNames, function (setting) {
23132312
_.each(setting.value, function (valuename) {
2314-
if (newDataNames.includes(valuename)) {
2315-
if (updates.findIndex(updates => updates === setting.name)===-1) {
2313+
_.each(newDataNames, function (newdataname) {
2314+
if (newdataname.startsWith(valuename)) {
2315+
if (updates.findIndex(updates => updates === setting.name)===-1) {
23162316
updates.push(setting.name);
2317+
}
23172318
}
2318-
}
2319+
});
23192320
});
23202321
});
23212322
_.each(updates, function (name) {
@@ -2676,7 +2677,7 @@ var freeboard = (function()
26762677
var datasourcePlugins = {};
26772678
var widgetPlugins = {};
26782679

2679-
var freeboardUI = new FreeboardUI();
2680+
var freeboardUI = new FreeboardUI(10, 300, 3);
26802681
var theFreeboardModel = new FreeboardModel(datasourcePlugins, widgetPlugins, freeboardUI);
26812682

26822683
var jsEditor = new JSEditor();

js/freeboard.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/freeboard_plugins.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DatasourceModel = function(theFreeboardModel, datasourcePlugins) {
5757
}
5858

5959
// Do we need to load any external scripts?
60-
if(datasourceType.external_scripts)
60+
if(datasourceType.external_scripts && datasourceType.external_scripts.length>0)
6161
{
6262
head.js(datasourceType.external_scripts.slice(0), finishLoad); // Need to clone the array because head.js adds some weird functions to it
6363
}
@@ -704,14 +704,12 @@ function FreeboardModel(datasourcePlugins, widgetPlugins, freeboardUI)
704704
}
705705
}
706706

707-
function FreeboardUI()
707+
function FreeboardUI(pane_margin, pane_width, min_columns)
708708
{
709-
var PANE_MARGIN = 10;
710-
var PANE_WIDTH = 300;
711-
var MIN_COLUMNS = 3;
712-
var COLUMN_WIDTH = PANE_MARGIN + PANE_WIDTH + PANE_MARGIN;
713709

714-
var userColumns = MIN_COLUMNS;
710+
var column_width = pane_margin + pane_width + pane_margin;
711+
712+
var userColumns = min_columns;
715713

716714
var loadingIndicator = $('<div class="wrapperloading"><div class="loading up" ></div><div class="loading down"></div></div>');
717715
var grid;
@@ -812,9 +810,9 @@ function FreeboardUI()
812810
{
813811
var col_controls = $(".column-tool");
814812
var available_width = $("#board-content").width();
815-
var max_columns = Math.floor(available_width / COLUMN_WIDTH);
813+
var max_columns = Math.floor(available_width / column_width);
816814

817-
if(grid.cols <= MIN_COLUMNS)
815+
if(grid.cols <= min_columns)
818816
{
819817
col_controls.addClass("min");
820818
}
@@ -836,14 +834,14 @@ function FreeboardUI()
836834
function getMaxDisplayableColumnCount()
837835
{
838836
var available_width = $("#board-content").width();
839-
return Math.floor(available_width / COLUMN_WIDTH);
837+
return Math.floor(available_width / column_width);
840838
}
841839

842840
function updateGridWidth(newCols)
843841
{
844-
if(newCols === undefined || newCols < MIN_COLUMNS)
842+
if(newCols === undefined || newCols < min_columns)
845843
{
846-
newCols = MIN_COLUMNS;
844+
newCols = min_columns;
847845
}
848846

849847
var max_columns = getMaxDisplayableColumnCount();
@@ -853,7 +851,7 @@ function FreeboardUI()
853851
}
854852

855853
// +newCols to account for scaling on zoomed browsers
856-
var new_width = (COLUMN_WIDTH * newCols) + newCols;
854+
var new_width = (column_width * newCols) + newCols;
857855
$(".responsive-column-width").css("max-width", new_width);
858856

859857
if(newCols === grid.cols)
@@ -877,7 +875,7 @@ function FreeboardUI()
877875
rootElement.find("> li").each(repositionFunction);
878876

879877
grid.init();
880-
$(".responsive-column-width").css("width", grid.cols * PANE_WIDTH + (grid.cols * PANE_MARGIN * 2));
878+
$(".responsive-column-width").css("width", grid.cols * pane_width + (grid.cols * pane_margin * 2));
881879
}
882880

883881
function getUserColumns()
@@ -887,16 +885,16 @@ function FreeboardUI()
887885

888886
function setUserColumns(numCols)
889887
{
890-
userColumns = Math.max(MIN_COLUMNS, numCols);
888+
userColumns = Math.max(min_columns, numCols);
891889
}
892890

893891
ko.bindingHandlers.grid = {
894892
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext)
895893
{
896894
// Initialize our grid
897895
grid = $(element).gridster({
898-
widget_margins : [PANE_MARGIN, PANE_MARGIN],
899-
widget_base_dimensions: [PANE_WIDTH, 10],
896+
widget_margins : [pane_margin, pane_margin],
897+
widget_base_dimensions: [pane_width, 10],
900898
resize: {
901899
enabled : false,
902900
axes : "x"
@@ -1145,6 +1143,7 @@ function FreeboardUI()
11451143
}
11461144
}
11471145

1146+
11481147
JSEditor = function () {
11491148
var assetRoot = ""
11501149

@@ -1257,6 +1256,7 @@ function PaneModel(theFreeboardModel, widgetPlugins) {
12571256

12581257
this.processSizeChange = function()
12591258
{
1259+
console.log("processSizeChange");
12601260
// Give the animation a moment to complete. Really hacky.
12611261
// TODO: Make less hacky. Also, doesn't work when screen resizes.
12621262
setTimeout(function(){
@@ -2306,16 +2306,17 @@ function WidgetModel(theFreeboardModel, widgetPlugins) {
23062306

23072307
this.processDatasourceUpdate = function (datasourceName, newDataNames) {
23082308
var refreshSettingNames = self.datasourceRefreshNotifications[datasourceName];
2309-
23102309
if (_.isArray(refreshSettingNames)) {
23112310
var updates=[];
23122311
_.each(refreshSettingNames, function (setting) {
23132312
_.each(setting.value, function (valuename) {
2314-
if (newDataNames.includes(valuename)) {
2315-
if (updates.findIndex(updates => updates === setting.name)===-1) {
2313+
_.each(newDataNames, function (newdataname) {
2314+
if (newdataname.startsWith(valuename)) {
2315+
if (updates.findIndex(updates => updates === setting.name)===-1) {
23162316
updates.push(setting.name);
2317+
}
23172318
}
2318-
}
2319+
});
23192320
});
23202321
});
23212322
_.each(updates, function (name) {
@@ -2676,7 +2677,7 @@ var freeboard = (function()
26762677
var datasourcePlugins = {};
26772678
var widgetPlugins = {};
26782679

2679-
var freeboardUI = new FreeboardUI();
2680+
var freeboardUI = new FreeboardUI(10, 300, 3);
26802681
var theFreeboardModel = new FreeboardModel(datasourcePlugins, widgetPlugins, freeboardUI);
26812682

26822683
var jsEditor = new JSEditor();

js/freeboard_plugins.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/css/freeboard/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ header h1 {
817817
position: relative;
818818
-webkit-box-shadow: 0 0 5px #000;
819819
box-shadow: 0 0 5px #000;
820+
overflow:scroll;
820821
}
821822

822823
#toggle-header {

lib/js/freeboard/DatasourceModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DatasourceModel = function(theFreeboardModel, datasourcePlugins) {
5757
}
5858

5959
// Do we need to load any external scripts?
60-
if(datasourceType.external_scripts)
60+
if(datasourceType.external_scripts && datasourceType.external_scripts.length>0)
6161
{
6262
head.js(datasourceType.external_scripts.slice(0), finishLoad); // Need to clone the array because head.js adds some weird functions to it
6363
}

0 commit comments

Comments
 (0)