UI fixes and map JS changes
10 files changed, 71 lines added, 8 lines removed
Changes
--- app/controllers/displays_controller.rb 9eb44c473bbd0f810248fff6d83c39bf930a8d61
+++ app/controllers/displays_controller.rb 1b0ef73c9561909231d4b2dac64d19687106bbf1
@@ -44,6 +44,44 @@
+ ))
+ end
+ render :json => data
+ }
+ end
+ end
+
+ # Generate the current state of the ETAs and vehicle positions.
+ # routes and stops. The vehicles will be loaded another way.
+ def current
+ @stops = Stop.enabled
+ @vehicles = Vehicle.active
+ respond_to do |format|
+
+ format.js { # Manually build some objects to jsonify+ data = {:stops => [], :vehicles => []}+ @stops.each do |s|
+ data[:stops].push(s.serializable_hash(
+ :only => [:short_name, :name],
+ :include => {+ :etas => {+ :only => [:timestamp]
+ }
+ }
+ ))
+ end
+ @vehicles.each do |r|
+ data[:vehicles].push(r.serializable_hash(
+ :only => [:id, :name],
+ :include => {+ :latest_position => {+ :only => [:latitude, :longitude, :speed, :heading, :timestamp],
+ :methods => [:public_status_msg, :cardinal_point]
+ },
+ :icon => {+ :only => [:id]
+ }
+ }
--- app/views/displays/index.html.erb 9eb44c473bbd0f810248fff6d83c39bf930a8d61
+++ app/views/displays/index.html.erb 1b0ef73c9561909231d4b2dac64d19687106bbf1
@@ -1,5 +1,8 @@
+ var mapHeight = $(window).height() - $('.ui-header').height();+ $('#map_canvas').css('height', mapHeight);+
@@ -68,7 +71,7 @@
- $('#map').css('margin-left', columnWidth + 'px');+ $('#map').css('margin-left', (columnWidth + 30) + 'px');@@ -83,7 +86,7 @@
- var current_data_path = '<%= current_vehicles_path(:format => 'js') %>';
+ var current_data_path = '<%= displays_current_path(:format => 'js') %>';
--- config/routes.rb 9eb44c473bbd0f810248fff6d83c39bf930a8d61
+++ config/routes.rb 1b0ef73c9561909231d4b2dac64d19687106bbf1
@@ -23,6 +23,7 @@
+ match '/displays/current', :to => 'displays#current'
--- public/javascripts/map.js 9eb44c473bbd0f810248fff6d83c39bf930a8d61
+++ public/javascripts/map.js 1b0ef73c9561909231d4b2dac64d19687106bbf1
@@ -1,5 +1,7 @@
+// Hold the Shuttles and Stops in arrays
+var stops = new Object();
@@ -8,10 +10,7 @@
- $.each(data.stops, function(i, stop){- stop['description'] = stop_description(stop);
- var stop_marker = add_point_to_map(stop, map, {icon: stop_icon_path});- });
+
@@ -22,6 +21,13 @@
+ $.each(data.stops, function(i, stop){+ stop['description'] = stop_description(stop);
+ var stop_marker_info = add_point_to_map(stop, map, {icon: stop_icon_path}, true);+ var stop_marker = stop_marker_info[0];
+ stop_marker.info_window = stop_marker_info[1];
+ stops[stop.short_name] = stop_marker;
+ });
@@ -31,8 +37,7 @@
- $.each(data, function(i, obj){- var vehicle = obj.vehicle;
+ $.each(data.vehicles, function(i, vehicle){@@ -63,6 +68,14 @@
+ });
+
+ // Update the stops with their new ETA
+ $.each(data.stops, function(i, stop) {+
+ var stop_marker = stops[stop.short_name];
+ stop_marker.info_window.setContent(stop_description(stop) + "<br>" + stop.etas[0].timestamp);
+
--- public/stylesheets/new.css 9eb44c473bbd0f810248fff6d83c39bf930a8d61
+++ public/stylesheets/new.css 1b0ef73c9561909231d4b2dac64d19687106bbf1
@@ -1,3 +1,7 @@
+.ui-content {+ padding: 0px;
+}
+
@@ -23,6 +27,10 @@
+ }
+ #eta
+ {+ padding: 15px;