climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1480758 - in /incubator/climate/trunk/rcmet/src/main/ui/app: js/controllers.js partials/selectObservation.html
Date Thu, 09 May 2013 20:21:39 GMT
Author: joyce
Date: Thu May  9 20:21:38 2013
New Revision: 1480758

URL: http://svn.apache.org/r1480758
Log:
Resolves Climate-13. Use two-way binding and ng-repeat in obs select.

- Adds ng-model values to the parameter select boxes to facilitate
  easier (and correct) grabbing of values in selectObservation.html.
- Removes jQuery from ObservationSelectCtrl that was being used to pull
  down the values of the select boxes in selectObservation.html.
- Switches to using ng-options to correctly generate option tags inside
  of a select tag instead of using ng-repeat.
- Updates uploadLocalFile in the ObservationSelectCtrl to deal with the
  changes to the ng-models in selectObservation.html.

Modified:
    incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js
    incubator/climate/trunk/rcmet/src/main/ui/app/partials/selectObservation.html

Modified: incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js?rev=1480758&r1=1480757&r2=1480758&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/app/js/controllers.js Thu May  9 20:21:38 2013
@@ -311,10 +311,17 @@ function DatasetDisplayCtrl($rootScope, 
 
 // Controller for observation selection in modal
 function ObservationSelectCtrl($rootScope, $scope, $http, selectedDatasetInformation) {
-	$scope.params = ["Please select a file above"];
-	$scope.lats = ["Please select a file above"];
-	$scope.lons = ["Please select a file above"];
-	$scope.times = ["Please select a file above"];
+	// Initalize the option arrays and default to the first element
+	$scope.params      = ["Please select a file above"];
+	$scope.paramSelect = $scope.params[0];
+	$scope.lats        = ["Please select a file above"];
+	$scope.latsSelect  = $scope.lats[0];
+	$scope.lons        = ["Please select a file above"];
+	$scope.lonsSelect  = $scope.lons[0];
+	$scope.times       = ["Please select a file above"];
+	$scope.timeSelect  = $scope.times[0];
+
+	// TODO: We could probably completely remove these variables...
 	$scope.latLonVals = [];
 	$scope.timeVals = [];
 	$scope.localSelectForm = {};
@@ -336,13 +343,16 @@ function ObservationSelectCtrl($rootScop
 			success(function(data) {
 				if ("FAIL" in data) {
 					$scope.params = ["Unable to find variable(s)"];
-					return;
+				} else {
+					$scope.params = data['variables'];
 				}
 
-				$scope.params = data['variables'];
+				// Select the first element so the display isn't empty
+				$scope.paramSelect = $scope.params[0];
 			}).
 			error(function(data) {
 				$scope.params = ["Unable to find variable(s)"];
+				$scope.paramSelect = $scope.params[0];
 			});		
 
 		// Get Lat and Lon variables
@@ -351,17 +361,23 @@ function ObservationSelectCtrl($rootScop
 				if (data["success"] == 0) {
 					$scope.lats = ["Unable to find variable(s)"];
 					$scope.lons = ["Unable to find variable(s)"];
-					return;
+				} else {
+					$scope.lats = [data["latname"]];
+					$scope.lons = [data["lonname"]];
+
+					var tmpMinsMaxs = [data["latMin"], data["latMax"], data["lonMin"], data["lonMax"]];
+					$scope.latLonVals = tmpMinsMaxs.map(parseFloat);
 				}
 
-				$scope.lats = [data["latname"]];
-				$scope.lons = [data["lonname"]];
-				var tmpMinsMaxs = [data["latMin"], data["latMax"], data["lonMin"], data["lonMax"]];
-				$scope.latLonVals = tmpMinsMaxs.map(parseFloat);
+				// Select the first element so the displays aren't empty
+				$scope.latsSelect = $scope.lats[0];
+				$scope.lonsSelect = $scope.lons[0];
 			}).
 			error(function(data) {
 				$scope.lats = ["Unable to find variable(s)"];
 				$scope.lons = ["Unable to find variable(s)"];
+				$scope.latsSelect = $scope.lats[0];
+				$scope.lonsSelect = $scope.lons[0];
 			});		
 
 		// Get Time variables
@@ -369,19 +385,22 @@ function ObservationSelectCtrl($rootScop
 			success(function(data) {
 				if (data["success"] == 0) {
 					$scope.times = ["Unable to find variable(s)"];
-					return;
-				}
-
-				if (data["timename"] instanceof Array) {
-					$scope.times = data["timename"];
 				} else {
-					$scope.times = [data["timename"]];
+					if (data["timename"] instanceof Array) {
+						$scope.times = data["timename"];
+					} else {
+						$scope.times = [data["timename"]];
+					}
+
+					$scope.timeVals = [data["start_time"], data["end_time"]];
 				}
 
-				$scope.timeVals = [data["start_time"], data["end_time"]];
+				// Select the first element so the display isn't empty
+				$scope.timeSelect = $scope.times[0];
 			}).
 			error(function(data) {
 				$scope.times = ["Unable to find variable(s)"];
+				$scope.timeSelect = $scope.times[0];
 			});		
 	};
 
@@ -399,24 +418,29 @@ function ObservationSelectCtrl($rootScop
 		var splitFilePath = input.split('/');
 		newDataset['name'] = splitFilePath[splitFilePath.length - 1];
 		// Save the model parameter variable. We save it twice for consistency and display convenience.
-		newDataset['param'] = $('#paramSelect').val();
+		newDataset['param'] = $scope.paramSelect;
 		newDataset['paramName'] = newDataset['param'];
 		// Save the lat/lon information
-		newDataset['lat'] = $('#latsSelect').val();
-		newDataset['lon'] = $('#lonsSelect').val();
+		newDataset['lat'] = $scope.latsSelect;
+		newDataset['lon'] = $scope.lonsSelect;
+
 		newDataset['latlonVals'] = {"latMin": $scope.latLonVals[0], "latMax": $scope.latLonVals[1],
 									"lonMin": $scope.latLonVals[2], "lonMax": $scope.latLonVals[3]};
 		// Get the time information
-		newDataset['time'] = $('#timesSelect').val();
+		newDataset['time'] = $scope.timeSelect;
 		newDataset['timeVals'] = {"start": $scope.timeVals[0], "end": $scope.timeVals[1]};
 
 		selectedDatasetInformation.addDataset(newDataset);
 
 		// Reset all the fields!!
 		$scope.params = ["Please select a file above"];
+		$scope.paramSelect = $scope.params[0];
 		$scope.lats = ["Please select a file above"];
+		$scope.latsSelect = $scope.lats[0];
 		$scope.lons = ["Please select a file above"];
+		$scope.lonsSelect = $scope.lons[0];
 		$scope.times = ["Please select a file above"];
+		$scope.timeSelect = $scope.times[0];
 		$scope.latLonVals = [];
 		$scope.timeVals = [];
 

Modified: incubator/climate/trunk/rcmet/src/main/ui/app/partials/selectObservation.html
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/ui/app/partials/selectObservation.html?rev=1480758&r1=1480757&r2=1480758&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/ui/app/partials/selectObservation.html (original)
+++ incubator/climate/trunk/rcmet/src/main/ui/app/partials/selectObservation.html Thu May
 9 20:21:38 2013
@@ -14,38 +14,25 @@
 		Parameter Option
 	</div>
 	<div class="span3">
-		<!--
-			This is not really the correct way to handle this. The commented code should be used,
but
-			it's not working. So...
-		-->
-		<!--<select ng-model="paramSelect" ng-options="val for val in params"></select>-->
-		<select id="paramSelect">
-			<option ng-repeat="param in params">{{param}}</option>
-		</select>
+    <select ng-model="paramSelect" ng-options="param for param in params"></select>
 	</div>
 	<div class="span2 text-center">
 		Latitude Variable
 	</div>
 	<div class="span3">
-		<select id="latsSelect">
-			<option ng-repeat="lat in lats">{{lat}}</option>
-		</select>
+    <select ng-model="latsSelect" ng-options="lat for lat in lats"></select>
 	</div>
 	<div class="span2 text-center">
 		Longitude Variable
 	</div>
 	<div class="span3">
-		<select id="lonsSelect">
-			<option ng-repeat="lon in lons">{{lon}}</option>
-		</select>
+    <select ng-model="lonsSelect" ng-options="lon for lon in lons"></select>
 	</div>
 	<div class="span2 text-center">
 		Date/Time Variable
 	</div>
 	<div class="span3">
-		<select id="timesSelect">
-			<option ng-repeat="time in times">{{time}}</option>
-		</select>
+    <select ng-model="timeSelect" ng-options="time for time in times"></select>
 	</div>
 </div>
 



Mime
View raw message