Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
Should request data when sensors are selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbaddeley committed Dec 4, 2011
1 parent d259524 commit ed99625
Showing 1 changed file with 54 additions and 24 deletions.
78 changes: 54 additions & 24 deletions dashboard/frontend/app/assets/javascripts/dashboard.js
Expand Up @@ -34,12 +34,14 @@ $(function() {
};

$("#select_companies").bind("multiselectclick", function(event, ui){
$.ajax({
url: "companies/" + ui.value + "/facilities.json",
dataType:"json",
context: document.body,
success: facilitiesSuccessHandler
});
if (ui.checked){
$.ajax({
url: "companies/" + ui.value + "/facilities.json",
dataType:"json",
context: document.body,
success: facilitiesSuccessHandler
});
}
}
);

Expand All @@ -52,12 +54,14 @@ $(function() {
};

$("#select_facilities").bind("multiselectclick", function(event, ui){
$.ajax({
url: "facilities/" + ui.value + "/buildings.json",
dataType:"json",
context: document.body,
success: buildingSuccessHandler
});
if (ui.checked){
$.ajax({
url: "facilities/" + ui.value + "/buildings.json",
dataType:"json",
context: document.body,
success: buildingSuccessHandler
});
}
}
);

Expand All @@ -70,12 +74,14 @@ $(function() {
};

$("#select_buildings").bind("multiselectclick", function(event, ui){
$.ajax({
url: "buildings/" + ui.value + "/systems.json",
dataType:"json",
context: document.body,
success: systemSuccessHandler
});
if (ui.checked){
$.ajax({
url: "buildings/" + ui.value + "/systems.json",
dataType:"json",
context: document.body,
success: systemSuccessHandler
});
}
}
);

Expand All @@ -88,16 +94,40 @@ $(function() {
};

$("#select_systems").bind("multiselectclick", function(event, ui){
$.ajax({
url: "systems/" + ui.value + "/sensors.json",
dataType:"json",
context: document.body,
success: sensorSuccessHandler
});
if (ui.checked){
$.ajax({
url: "systems/" + ui.value + "/sensors.json",
dataType:"json",
context: document.body,
success: sensorSuccessHandler
});
}
}
);

var sensorSelectSuccessHandler = function(data){
var output = [];
for(sensor in data){
var sensorOption = new Option(data[sensor].name, data[sensor].id);
$('#select_sensors').append(sensorOption).multiselect('refresh').multiselect('enable');
}
};

$("#select_sensors").bind("multiselectclick", function(event, ui){
if (ui.checked){
var values = $.map(ui.inputs, function(checkbox){
return checkbox.value;
});
$.ajax({
url: "sensors/inputs.json",
dataType:"json",
data:{"ids":values},
context: document.body,
success: sensorSelectSuccessHandler
});
}
}
);

window.chart = new Highcharts.StockChart({
chart : {
Expand Down

0 comments on commit ed99625

Please sign in to comment.