Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrega2 LSWC : Felipe Echanique, Oscar González #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
74 changes: 38 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.3)
actionpack (= 3.1.3)
actionmailer (3.1.1)
actionpack (= 3.1.1)
mail (~> 2.3.0)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
actionpack (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.5)
rack (~> 1.3.2)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
sprockets (~> 2.0.2)
activemodel (3.1.1)
activesupport (= 3.1.1)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activerecord (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
activeresource (3.1.1)
activemodel (= 3.1.1)
activesupport (= 3.1.1)
activesupport (3.1.1)
multi_json (~> 1.0)
ansi (1.4.1)
arel (2.2.1)
Expand All @@ -39,22 +39,22 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.3)
coffee-script-source (1.2.0)
erubis (2.7.0)
execjs (1.2.9)
execjs (1.2.13)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.18)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
json (1.6.3)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.3)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
Expand All @@ -65,25 +65,25 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
rails (3.1.1)
actionmailer (= 3.1.1)
actionpack (= 3.1.1)
activerecord (= 3.1.1)
activeresource (= 3.1.1)
activesupport (= 3.1.1)
bundler (~> 1.0)
railties (= 3.1.3)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
railties (= 3.1.1)
railties (3.1.1)
actionpack (= 3.1.1)
activesupport (= 3.1.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.11)
rdoc (3.12)
json (~> 1.4)
sass (3.1.10)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
Expand All @@ -93,7 +93,8 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
sqlite3 (1.3.5)
sqlite3 (1.3.5-x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -102,18 +103,19 @@ GEM
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.31)
uglifier (1.1.0)
uglifier (1.2.0)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
cleditor_rails
coffee-rails (~> 3.1.1)
jquery-rails
rails (= 3.1.3)
rails (= 3.1.1)
sass-rails (~> 3.1.5)
sqlite3
turn (= 0.8.2)
Expand Down
Binary file added app/assets/images/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 138 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,141 @@
//= require cleditor
//= require jquery_ujs
//= require_tree .

var map;
var markersArray = [];
var def_image = '/assets/default.png';

function sitesmap() {
var latlng = new google.maps.LatLng(40.420088, '-3.688810');
var site_name = document.getElementById( 'site_name' ).value;
var site_lat = document.getElementById( 'site_latitude' ).value;
var site_lon = document.getElementById( 'site_longitude' ).value;
var site_zoom = document.getElementById( 'site_zoom' ).value;
var site_image = document.getElementById( 'site_image_url' ).value;
if(site_lat != ''){
latlng = new google.maps.LatLng(site_lat, site_lon);
}
if(site_image == ''){
site_image = def_image;
}
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("sitesmap_canvas"), myOptions);

if(site_zoom != ''){
map.setZoom(parseInt(site_zoom));
}

google.maps.event.addListener(map, 'click', function(event) {

var myLatLng = event.latLng;

document.getElementById( 'site_latitude' ).value = myLatLng.lat();
document.getElementById( 'site_longitude' ).value = myLatLng.lng();
document.getElementById( 'site_zoom' ).value = map.getZoom();
setOneMarker(myLatLng, site_name, site_image);

});

setOneMarker(latlng, site_name, site_image);
}

function setOneMarker(myLatLng, site_name, site_image){

var image = new google.maps.MarkerImage(site_image, null, null,
new google.maps.Point(20, 20), new google.maps.Size(40, 40));
var shadow = new google.maps.MarkerImage('/assets/shadow.png',
new google.maps.Size(80, 80),
new google.maps.Point(0,0),
new google.maps.Point(30,30));


clearOverlays();
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: site_name,
icon: image,
shadow: shadow
});

markersArray.push(marker);

}

function travelmap() {
var latlng = new google.maps.LatLng(40.420088, -3.688810);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("travelmap_canvas"), myOptions);

}

function setMultipleMarker(site_lat, site_lon, site_name, site_image){

var latlng = new google.maps.LatLng(site_lat, site_lon);

if(site_image == ''){
site_image = def_image;
}

var image = new google.maps.MarkerImage(site_image, null, null,
new google.maps.Point(20, 20), new google.maps.Size(40, 40));

var shadow = new google.maps.MarkerImage('/assets/shadow.png',
new google.maps.Size(80, 80),
new google.maps.Point(0,0),
new google.maps.Point(30,30));

var marker = new google.maps.Marker({
position: latlng,
map: map,
title: site_name,
icon: image,
shadow: shadow
});

markersArray.push(marker);
fitBounds();

}

function clearOverlays() {
if (markersArray) {
for (i in markersArray) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
}
}

function fitBounds() {
if (markersArray) {
var bounds = new google.maps.LatLngBounds();
for(var i in markersArray) {
bounds.extend(markersArray[i].getPosition());
}
map.fitBounds(bounds);
}
}

function setMarkers(sitesArray){

if (sitesArray) {

for(var i in sitesArray) {
var site_lat = sitesArray[i][0];
var site_lon = sitesArray[i][1];
var site_name = sitesArray[i][2];
var site_image = sitesArray[i][3];
setMultipleMarker(site_lat, site_lon, site_name, site_image)
}
}
}
3 changes: 3 additions & 0 deletions app/assets/javascripts/viajes.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/viajes.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Viajes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
10 changes: 7 additions & 3 deletions app/controllers/selecteds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def edit
# POST /selecteds.json
def create
@selected = Selected.new(params[:selected])
@site = Site.find(@selected.site_id)
@site.increment!(:visits)


respond_to do |format|
if @selected.save
format.html { redirect_to @selected.trip, notice: 'Selected was successfully created.' }
Expand Down Expand Up @@ -74,12 +77,13 @@ def update
# DELETE /selecteds/1.json
def destroy
@selected = Selected.find(params[:id])
@site = Site.find(@selected.site_id)
@site.decrement!(:visits)
@selected.destroy

respond_to do |format|
format.html { redirect_to @selected.trip }
# format.html { redirect_to selecteds_url }
format.json { head :ok }
format.html { redirect_to @selected.trip, notice: 'Selected was successfully destroyed.' }
format.json { render json: @selected, status: :created, location: @selected }
end
end
end
6 changes: 6 additions & 0 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def update
# DELETE /sites/1.json
def destroy
@site = Site.find(params[:id])

@selecteds = Selected.find_all_by_site_id(params[:id]) #buscamos todos los selected con site id igual al par�metro id y los eliminamos.
@selecteds.each do |selected|
selected.destroy
end

@site.destroy

respond_to do |format|
Expand Down
1 change: 1 addition & 0 deletions app/controllers/trips_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def index
def show
@trip = Trip.find(params[:id])
@selected = Selected.new


respond_to do |format|
format.html # show.html.erb
Expand Down
Loading