From a27953cf3bc228dd7fe2b28d58bc3ceefd217e91 Mon Sep 17 00:00:00 2001 From: Claudius Weinberger Date: Sun, 19 Apr 2015 23:37:39 -0700 Subject: [PATCH] Design modifications Demo --- .../js/collections/airportCollection.js | 3 +- .../APP/frontend/js/templates/demoView.ejs | 2 +- .../APP/frontend/js/views/demoView.js | 42 ++++++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/collections/airportCollection.js b/js/apps/system/_admin/aardvark/APP/frontend/js/collections/airportCollection.js index 0f85335878..e71e2856c9 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/collections/airportCollection.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/collections/airportCollection.js @@ -41,8 +41,7 @@ type: "POST", url: "/_api/cursor", data: JSON.stringify({ - query: "for f in flights2 filter f.Origin == @airport COLLECT dest = f.Dest WITH COUNT INTO n SORT n RETURN {Dest: dest, count: n}", - // query: "for f in flights2 filter f.Origin == @airport COLLECT dest = f.Dest RETURN dest", + query: "for f in flights12 filter f.Origin == @airport COLLECT dest = f.Dest WITH COUNT INTO n SORT n RETURN {Dest: dest, count: n}", bindVars: {"airport": airport} }), contentType: "application/json", diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/demoView.ejs b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/demoView.ejs index 44b1610277..cd74f93baf 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/demoView.ejs +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/demoView.ejs @@ -10,6 +10,6 @@
-
+
diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/demoView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/demoView.js index d3b0716faf..97965507bf 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/demoView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/demoView.js @@ -133,10 +133,18 @@ loadAirportData: function(airport) { var self = this; + var timer = new Date(); + + var airportData = this.airportCollection.findWhere({_key: airport}); + console.log(airportData); this.airportCollection.getFlightsForAirport(airport, function(list) { + var timeTaken = new Date() - timer; + self.removeFlightLines(false); + var allFlights = 0; + var i = 0; for (i = 0; i < list.length; ++i) { self.addFlightLine( @@ -146,7 +154,30 @@ self.calculateFlightColor(list.length, i), self.calculateFlightWidth(list.length, i) ); + allFlights += list[i].count; } + + if ($("#demo-mapdiv-info").length === 0) { + $("#demo-mapdiv").append("
"); + } + + var tempHTML = ""; + tempHTML = "" + airportData.get("Name") + " - " + airport + "
" + + "Query needed: " + (timeTaken/1000) + "sec" + "
" + + "Number destinations: " + list.length + "
" + + "Number flights: " + allFlights + "
" + + "Top 5:
"; + + for (i = (list.length - 1); i > Math.max(list.length - 6, 0); --i) { + airportData = self.airportCollection.findWhere({_key: list[i].Dest}) + tempHTML += airportData.get("Name") + " - " + airportData.get("_key") + ": " + list[i].count + ""; + if (i > (list.length - 5)) { + tempHTML += "
"; + } + } + + $("#demo-mapdiv-info").html(tempHTML); + self.map.validateData(); }); }, @@ -154,9 +185,9 @@ calculateFlightWidth: function(length, pos) { var intervallWidth = length/2; // return Math.floor(pos/intervallWidth) + 2; - return 1; + return 1.5; }, - + calculateFlightColor: function(length, pos) { var intervallColor = length/this.lineColors.length; return this.lineColors[Math.floor(pos/intervallColor)]; @@ -225,9 +256,10 @@ lines: self.lines, images: imageData, getAreasFromMap: true - }, - clickMapObject: function(mapObject){ + }, + clickMapObject: function(mapObject) { console.log(mapObject); + self.loadAirportData(mapObject.id); }, balloon: { adjustBorderColor: true, @@ -253,7 +285,7 @@ alpha: 0.75, thickness: 2 }, - linesAboveImages: true, + linesAboveImages: false, }); },