From 56340a91a704e209540e1269a4d6a509469ef81c Mon Sep 17 00:00:00 2001 From: robengel Date: Thu, 9 Jun 2011 16:51:58 -0700 Subject: [PATCH] -nc --- geocamCover/models.py | 33 +++++ geocamCover/static/geocamCover/app.js | 122 ++++++++++++++---- .../static/geocamCover/jquery.ui.map.min.js | 46 +++---- geocamCover/static/geocamCover/layout.css | 47 +++++-- geocamCover/temp.txt | 3 + geocamCover/templates/geocamCover/index.html | 85 ++++++++++-- geocamCover/urls.py | 2 +- geocamCover/views.py | 22 +++- geocamUtilWeb | 1 + 9 files changed, 293 insertions(+), 68 deletions(-) create mode 100644 geocamCover/temp.txt create mode 160000 geocamUtilWeb diff --git a/geocamCover/models.py b/geocamCover/models.py index 1da6869..7500a34 100644 --- a/geocamCover/models.py +++ b/geocamCover/models.py @@ -20,3 +20,36 @@ def __unicode__(self): def get_struct(self): return {"name": self.name, "latitude": self.latitude, "longitude": self.longitude} + + +class Task(models.Model): + place = models.ForeignKey(Place) + title = models.CharField(max_length=200, blank=True) + description = models.CharField(max_length=1000, blank=True) + priority = models.IntegerField(null=True) + created_at = models.DateTimeField(auto_now_add=True) + modified_at = models.DateTimeField(auto_now=True) + created_by = models.ForeignKey(User) + + def __unicode__(self): + return self.name + + def get_struct(self): + return {"place": self.place, "title": self.title, "description": self.description, "priority": self.priority} + + +class Report(models.Model): + task = models.ForeignKey(Task) + title = models.CharField(max_length=200, blank=True) + status = models.CharField(max_length=200, blank=True) + notes = models.CharField(max_length=1000, blank=True) + percent_completed = models.IntegerField(null=True) + created_at = models.DateTimeField(auto_now_add=True) + modified_at = models.DateTimeField(auto_now=True) + created_by = models.ForeignKey(User) + + def __unicode__(self): + return self.name + + def get_struct(self): + return {"task": self.task, "title": self.title, "notes": self.notes, "status": self.status, "percent_completed": self.percent_completed} diff --git a/geocamCover/static/geocamCover/app.js b/geocamCover/static/geocamCover/app.js index 5e66ad5..6d31b31 100644 --- a/geocamCover/static/geocamCover/app.js +++ b/geocamCover/static/geocamCover/app.js @@ -1,3 +1,27 @@ +function Task(){ + this.title = ""; + this.description = ""; + this.priority = 0; +} + +function Report(){ + this.title = ""; + this.status = ""; + this.percent_completed = 0; + this.notes = ""; + this.task = new Task(); +} + +function Place(){ + this.name = ""; + this.position = null; + this.report = new Report(); + this.task = new Task(); +} + +var clicked_position; +var selected_place; + $(document).ready(function () { //MOFFETT FIELD COORDINATES @@ -7,40 +31,94 @@ $(document).ready(function () { 'mapTypeId': google.maps.MapTypeId.ROADMAP, 'zoom': 12, 'callback': function () { - $.getJSON('/geocamCover/hello.json', function(data) { + $.getJSON('/geocamCover/places.json', function(data) { $.each(data.places, function(key, val) { - latlng = new google.maps.LatLng(val.latitude, val.longitude); - $('#map_canvas').gmap('addMarker', {'position': latlng, 'title': val.name}); + $.each(val, function(key, val){ + if (key == "place"){ + latlng = new google.maps.LatLng(val.latitude, val.longitude); + place = new Place(); + place.position = latlng; + place.name = val.name; + addMarker(place); + } + }) }) }); - - } }); //ADDING MARKERS WHEN THE USER CLICKS ON THE MAP $('#map_canvas').gmap({'callback':function(map) { $(map).click(function(event) { - $('div#forms').css("visibility", "visible"); - $('input#name').focus(); - var clicked_position = event.latLng; + $('#place-form').show(); + $('#dim').show(); + clicked_position = event.latLng; + }); + + }}); + + + $("#place-form form").submit(function() { + place = new Place(); + place.position = clicked_position; + place.name = $('#place-form #name').val(); + addMarker(place); + + var new_place = JSON.stringify({"latitude": clicked_position.lat(), + "longitude": clicked_position.lng(), "name": place.name }); + $.post('/geocamCover/place/', new_place, function(data) { + // nothing yet + }); - $("#marker_form").submit(function() { + $('#place-form .name').val(""); + $('#place-form').hide(); + $('#dim').hide(); + return false; + }); + + jQuery("title").html("GeoCam Cover"); - $("#map_canvas").gmap('addMarker', {'position':clicked_position, 'title': $('input#name').val()}); +}); - var new_place = JSON.stringify({"latitude": clicked_position.lat(), - "longitude": clicked_position.lng() , - "name": $('input#name').val() }); +function addMarker(place){ - $.post('/geocamCover/place/', new_place, function(data) { - }); + $("#map_canvas").gmap('addMarker', { + 'position': place.position, + 'title': place.name + }).click(function(){ + showLog(place); + }); +} + + +function showLog(place){ + $('#place-log .name').html(place.name); + $('#place-log').show(); + $('#new-task').hide(); + $('#new-report').hide(); + selectedPlace = place; +} + + +function showNewTask(){ + $("#new-task .name").html(selectedPlace.name); + $('#place-log').hide(); + $('#new-task').show(); +} + + +function showNewReport(){ + $("#new-report .name").html(selectedPlace.name); + $('#place-log').hide(); + $('#new-report').show(); +} - $('input#name').val(""); - $('div#forms').css("visibility", "hidden"); - return false; - }); - }) - }}); -}); \ No newline at end of file +function showMap(){ + $('#dim').hide(); + $('#place-form').hide(); + $('#place-log').hide(); + $('#new-task').hide(); + $('#new-report').hide(); + return false; +} \ No newline at end of file diff --git a/geocamCover/static/geocamCover/jquery.ui.map.min.js b/geocamCover/static/geocamCover/jquery.ui.map.min.js index 5c5ea23..ab4d239 100755 --- a/geocamCover/static/geocamCover/jquery.ui.map.min.js +++ b/geocamCover/static/geocamCover/jquery.ui.map.min.js @@ -1,24 +1,24 @@ - /*! - * jQuery UI Google Map 2.0 - * http://code.google.com/p/jquery-ui-map/ - * Copyright (c) 2010 - 2011 Johan Säll Larsson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ + /*! + * jQuery UI Google Map 2.0 + * http://code.google.com/p/jquery-ui-map/ + * Copyright (c) 2010 - 2011 Johan Säll Larsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(6($){y.1w.x({1k:6(4){f 3.t(\'1k\',4)},1e:6(4){f 3.t(\'1e\',4)},1h:6(4){f 3.t(\'1h\',4)},1d:6(4){f 3.t(\'1d\',4)},1j:6(4){f 3.t(\'1j\',4)},1m:6(4){f 3.t(\'1m\',4)},1n:6(4){f 3.t(\'1n\',4)},1J:6(q){b.c.G.1I(3.P(0),q)},t:6(q,4){g(3.P(0)V b.c.1H){b.c.G.1G(3.P(0),q,4)}A{3.1E(q,4)}f 3}});$.1F("9.8",{K:{1L:h,1R:n b.c.1S(0.0,0.0),1Q:z,1P:z,1C:B,1N:h,1O:h,1T:B,1r:B,1q:h,1p:b.c.1t.1B,1u:B,1x:h,1v:z,1z:z,1y:h,1A:z,1o:B,1K:h,20:5,4:h},2h:6(){$.9.8.e[3.k.l(\'d\')]={p:n b.c.2i(3.k[0],3.K),Y:[],v:h,a:[]}},2g:6(){$.9.8.w(3.K.4,3.o());f $(3.o())},14:6(2f,S){$.1g.U.14.11(3,1a);3.o().2d(3.K)},19:6(16){u e=$.9.8.e[3.k.l(\'d\')];g(!e.v){e.v=n b.c.2e()}e.v.x(16);e.p.2j(e.v)},1U:6(E,15){3.o().2p[15].17($.9.8.T(E))},2q:6(j,4){u s=n b.c.2r(y.x({\'p\':3.o(),\'v\':z},j));3.O().17(s);g(s.v){3.19(s.2l())}$.9.8.w(4,3.o(),s);f $(s)},2m:6(j,4){u R=n b.c.2c(j);$.9.8.w(4,R);f $(R)},2b:6(H,j,4){u 7=$.9.8.e[3.k.l(\'d\')];g(!7.a.M){7.a.M=n b.c.M()}g(!7.a.F){7.a.F=n b.c.F(y.x({\'p\':7.p},j))}7.a.M.21(H,6(C,D){g(D===b.c.13.Q){g(j.E){7.a.F.1Z(C)}}A{7.a.F.X(h)}$.9.8.w(4,(D===b.c.13.Q),C)})},1Y:6(E,j){u 7=$.9.8.e[3.k.l(\'d\')];g(!7.a.L){7.a.L=n b.c.L($.9.8.T(E),j)}7.p.1V(7.a.L)},1X:6(Z,S,4){$.W(3.O(),6(i,s){$.9.8.w(4,(s[Z]===S),s)})},23:6(q,I,4){g(q===\'10\'){$.9.8.10(I,4)}A g(q===\'12\'){$.9.8.12(I,4)}A g(q===\'18\'){$.9.8.18(I,4)}},2a:6(d,j){u 7=$.9.8.e[3.k.l(\'d\')];g(!7.a.N){7.a.N=n b.c.N(d,j)}7.a.N.X(3.o())},27:6(d,1l,j){u 7=$.9.8.e[3.k.l(\'d\')];g(!7.a[d])7.a[d]=n b.c.24(1l,y.x({\'p\':7.p},j))},26:6(H,4){u 7=$.9.8.e[3.k.l(\'d\')];g(!7.a.J){7.a.J=n b.c.J()}7.a.J.28(H,6(C,D){$.9.8.w(4,(D===b.c.2o.Q),C)})},o:6(){f $.9.8.e[3.k.l(\'d\')].p},O:6(){f $.9.8.e[3.k.l(\'d\')].Y},2k:6(d){f $.9.8.e[3.k.l(\'d\')].a[d]},1f:6(){$.W(3.O(),6(i,m){b.c.G.1i(m);m.X(h);m=h});$.9.8.e[3.k.l(\'d\')].Y=[]},1c:6(){3.1f();b.c.G.1i(3.o());$.W($.9.8.e[3.k.l(\'d\')].a,6(i,r){r=h});$.1g.U.1c.1b(3)}});$.x($.9.8,{25:"2.0",e:[],w:6(4){g($.29(4)){4.11(3,22.U.1W.1b(1a,1))}},T:6 2n(r){g(!r){f h}A g(r V y){f r[0]}A g(r V 1s){f r}f 1D.1M(r)}})}(y));',62,152,'|||this|callback||function|instance|gmap|ui|services|google|maps|id|instances|return|if|null||opts|element|attr||new|getMap|map|type|obj|marker|addEventListener|var|bounds|_trigger|extend|jQuery|false|else|true|result|status|panel|DirectionsRenderer|event|request|ns|Geocoder|options|StreetViewPanorama|DirectionsService|FusionTablesLayer|getMarkers|get|OK|iw|value|_unwrap|prototype|instanceof|each|setMap|markers|property|rdfa|apply|microformat|DirectionsStatus|_setOption|position|latLng|push|microdata|addBounds|arguments|call|destroy|mouseover|rightclick|clearMarkers|Widget|dblclick|clearInstanceListeners|mouseout|click|url|drag|dragend|streetViewControl|mapTypeId|mapTypeControlOptions|mapTypeControl|Object|MapTypeId|navigationControl|noClear|fn|navigationControlOptions|scaleControlOptions|scaleControl|scrollwheel|ROADMAP|draggable|document|bind|widget|addListener|MVCObject|trigger|triggerEvent|streetViewControlOptions|backgroundColor|getElementById|draggableCursor|draggingCursor|disableDoubleClickZoom|disableDefaultUI|center|LatLng|keyboardShortcuts|addControl|setStreetView|slice|findMarker|displayStreetView|setDirections|zoom|route|Array|loadMetadata|KmlLayer|version|search|loadKML|geocode|isFunction|loadFusion|displayDirections|InfoWindow|setOptions|LatLngBounds|key|_init|_create|Map|fitBounds|getService|getPosition|addInfoWindow|unwrap|GeocoderStatus|controls|addMarker|Marker'.split('|'),0,{})) \ No newline at end of file diff --git a/geocamCover/static/geocamCover/layout.css b/geocamCover/static/geocamCover/layout.css index 535b0b9..ce3d23a 100644 --- a/geocamCover/static/geocamCover/layout.css +++ b/geocamCover/static/geocamCover/layout.css @@ -8,17 +8,48 @@ html, body { position: absolute; height: 100%; width: 100%; - -} - -.map_size { - width: 320px; - height: 480px; } -div#forms { +#place-form, .form{ background: rgba(0, 0, 0, 0); position: absolute; z-index: 10; - visibility: hidden; + width: 100%; + height: 100%; + display: none; } + +.form{ + background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0,#EEE),color-stop(1,#DDD)); +} + +/* +.form-buttons{ + position:absolute; + bottom:0; + width:100%; +}*/ + + +#place-form form{ + position: absolute; + bottom: 0; + width: 100%; + background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0,#EEE),color-stop(1,#DDD)); + text-align: center; +} + +#place-log{ + height: 100%; +} + + +#dim{ + display: none; + background: black; + opacity: .5; + position: absolute; + z-index: 1; + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/geocamCover/temp.txt b/geocamCover/temp.txt new file mode 100644 index 0000000..ad47c2b --- /dev/null +++ b/geocamCover/temp.txt @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/geocamCover/templates/geocamCover/index.html b/geocamCover/templates/geocamCover/index.html index 28645b3..55735ad 100644 --- a/geocamCover/templates/geocamCover/index.html +++ b/geocamCover/templates/geocamCover/index.html @@ -1,25 +1,92 @@ - + - + -{# #} - + + +
+
+ +
-
-
- - -
+ +
+
+

Do you want to add this as a place?

+ + + +
+
+ +
+
+

+
+
+ + + +
+
+ +
+
+
+

Add Task to ''

+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+

Add Report to ''

+
+ + +
+ +
+ +
+ + + +
+
+
+ + + + +
+
+
\ No newline at end of file diff --git a/geocamCover/urls.py b/geocamCover/urls.py index 2afaeca..97ae866 100644 --- a/geocamCover/urls.py +++ b/geocamCover/urls.py @@ -9,6 +9,6 @@ urlpatterns = patterns('', url(r'^$', views.index, name='index'), - url(r'^hello.json$', views.hello_world_json), + url(r'^places.json$', views.places_json), url(r'^place/$', views.place), ) diff --git a/geocamCover/views.py b/geocamCover/views.py index 41e31d3..9deb48c 100644 --- a/geocamCover/views.py +++ b/geocamCover/views.py @@ -23,11 +23,23 @@ def index(request): return HttpResponse(t.render(c)) -def hello_world_json(request): +def places_json(request): - foo = {"places": [p.get_struct() for p in Place.objects.all()]} - foo_json = json.dumps(foo, sort_keys=True, indent=4) - return HttpResponse(foo_json, mimetype="application/json") + place_hash = {"places": []} + for p in Place.objects.all(): + place_dict = {} + place_dict["place"] = p.get_struct() + place_dict["tasks"] = [] + place_dict["reports"] = [] + + #for t in p.tasks.all(): + # place_dict["tasks"] << t + # for r in p.reports.all(): + # place_dict["reports"] << r + place_hash["places"].append(place_dict) + + places = json.dumps(place_hash, sort_keys=True, indent=4) + return HttpResponse(places, mimetype="application/json") def place(request): @@ -39,4 +51,4 @@ def place(request): struct = json.loads(request.raw_post_data) Place(name=struct['name'], latitude=struct['latitude'], longitude=struct['longitude'] , created_by=user).save() - return HttpResponse("ok") \ No newline at end of file + return HttpResponse("ok") diff --git a/geocamUtilWeb b/geocamUtilWeb new file mode 160000 index 0000000..bea217a --- /dev/null +++ b/geocamUtilWeb @@ -0,0 +1 @@ +Subproject commit bea217ab6d178a70aaf0ed60a3afbd6e0b2a92f0