diff --git a/ocw-ui/frontend/app/scripts/controllers/parameterselect.js b/ocw-ui/frontend/app/scripts/controllers/parameterselect.js index a2554f4c..9b52e538 100644 --- a/ocw-ui/frontend/app/scripts/controllers/parameterselect.js +++ b/ocw-ui/frontend/app/scripts/controllers/parameterselect.js @@ -30,6 +30,7 @@ angular.module('ocwUiApp') .controller('ParameterSelectCtrl', ['$rootScope', '$scope', '$http', '$timeout', '$location', 'selectedDatasetInformation', 'regionSelectParams', 'evaluationSettings', function($rootScope, $scope, $http, $timeout, $location, selectedDatasetInformation, regionSelectParams, evaluationSettings) { + $scope.datasets = selectedDatasetInformation.getDatasets(); // The min/max lat/lon values from the selected datasets @@ -78,6 +79,20 @@ angular.module('ocwUiApp') return res; } + let formatDate = function(oldDate) { + + let newDate = new Date(oldDate); + + let year = newDate.getFullYear(); + + let month = ((newDate.getMonth() + 1) < 10) ? '0' + (newDate.getMonth() + 1).toString: (newDate.getMonth() + 1); + + let day = (newDate.getDate() < 10) ? '0' + newDate.getDate().toString: newDate.getDate(); + + return newDate.getFullYear() + '-' + (newDate.getMonth() + 1) + '-' + newDate.getDate(); + } + + $scope.runEvaluation = function() { $scope.runningEval = true; @@ -159,8 +174,8 @@ angular.module('ocwUiApp') } // Set the bound values for the evaluation - data['start_time'] = $scope.displayParams.start + " 00:00:00", - data['end_time'] = $scope.displayParams.end + " 00:00:00", + data['start_time'] = formatDate($scope.displayParams.start) + " 00:00:00", + data['end_time'] = formatDate($scope.displayParams.end) + " 00:00:00", data['lat_min'] = $scope.displayParams.latMin, data['lat_max'] = $scope.displayParams.latMax, data['lon_min'] = $scope.displayParams.lonMin, @@ -233,8 +248,8 @@ angular.module('ocwUiApp') latMax = (curDataset['latlonVals']['latMax'] < latMax) ? curDataset['latlonVals']['latMax'] : latMax; lonMin = (curDataset['latlonVals']['lonMin'] > lonMin) ? curDataset['latlonVals']['lonMin'] : lonMin; lonMax = (curDataset['latlonVals']['lonMax'] < lonMax) ? curDataset['latlonVals']['lonMax'] : lonMax; - start = (curDataset['timeVals']['start'] > start) ? curDataset['timeVals']['start'] : start; - end = (curDataset['timeVals']['end'] < end) ? curDataset['timeVals']['end'] : end; + start = (curDataset['timeVals']['start'] > start) ? new Date(curDataset['timeVals']['start']) : start; + end = (curDataset['timeVals']['end'] < end) ? new Date(curDataset['timeVals']['end']) : end; datasetRegrid = datasetRegrid || curDataset.regrid; @@ -248,16 +263,16 @@ angular.module('ocwUiApp') $scope.displayParams.latMax = $scope.truncateFloat(latMax); $scope.displayParams.lonMin = $scope.truncateFloat(lonMin); $scope.displayParams.lonMax = $scope.truncateFloat(lonMax); - $scope.displayParams.start = (typeof start == 'undefined') ? "" : start.split(" ")[0]; - $scope.displayParams.end = (typeof end == 'undefined') ? "" : end.split(" ")[0]; + $scope.displayParams.start = (typeof start == 'undefined') ? "" : new Date(start); + $scope.displayParams.end = (typeof end == 'undefined') ? "" : new Date(end); // Update the local store values! $scope.latMin = latMin; $scope.latMax = latMax; $scope.lonMin = lonMin; $scope.lonMax = lonMax; - $scope.start = (typeof start == 'undefined') ? "" : start.split(" ")[0]; - $scope.end = (typeof end == 'undefined') ? "" : end.split(" ")[0]; + $scope.start = (typeof start == 'undefined') ? "" : start; + $scope.end = (typeof end == 'undefined') ? "" : end; $scope.displayParams.areValid = true; $rootScope.$broadcast('redrawOverlays', []); diff --git a/ocw-ui/frontend/app/scripts/controllers/rcmedselection.js b/ocw-ui/frontend/app/scripts/controllers/rcmedselection.js index 81d7d213..484cb7b7 100644 --- a/ocw-ui/frontend/app/scripts/controllers/rcmedselection.js +++ b/ocw-ui/frontend/app/scripts/controllers/rcmedselection.js @@ -81,16 +81,20 @@ angular.module('ocwUiApp') }; $scope.dataSelectUpdated = function() { - var urlString = $rootScope.baseURL + '/rcmed/parameters/dataset/' + - $scope.datasetSelection["shortname"] + - "?callback=JSON_CALLBACK"; - $http.jsonp(urlString) - .success(function(data) { - $scope.retrievedObsParams = data; - if ($scope.retrievedObsParams.length > 1) - $scope.retrievedObsParams.splice(0, 0, {shortname: 'Please select a parameter'}); - $scope.parameterSelection = $scope.retrievedObsParams[0]; - }); + if ($scope.datasetSelection) { + var urlString = $rootScope.baseURL + '/rcmed/parameters/dataset/' + + $scope.datasetSelection["shortname"] + + "?callback=JSON_CALLBACK"; + + $http.jsonp(urlString) + .success(function(data) { + $scope.retrievedObsParams = data; + if ($scope.retrievedObsParams.length > 1) + $scope.retrievedObsParams.splice(0, 0, {longname: 'Please select a parameter'}); + $scope.parameterSelection = $scope.retrievedObsParams[0]; + } + ); + } }; $scope.addObservation = function() { diff --git a/ocw-ui/frontend/app/scripts/controllers/timeline.js b/ocw-ui/frontend/app/scripts/controllers/timeline.js index 2546eded..8d734b65 100644 --- a/ocw-ui/frontend/app/scripts/controllers/timeline.js +++ b/ocw-ui/frontend/app/scripts/controllers/timeline.js @@ -41,7 +41,7 @@ function($rootScope, $scope, selectedDatasetInformation, regionSelectParams) { // Don't process if no datasets have been added if ($scope.datasets.length == 0 || !("timeline" in $rootScope)) return; - + // Create DataTable to add data to timeline var data = new google.visualization.DataTable(); data.addColumn('datetime', 'start'); @@ -66,7 +66,7 @@ function($rootScope, $scope, selectedDatasetInformation, regionSelectParams) { new Date(end.substr(0, 4), end.substr(5, 2) - 1, end.substr(8, 2))); // Add user selected bounds to timeline - if ($scope.regionParams.areValid) { + if ($scope.regionParams.start && $scope.regionParams.end) { var userStart = $scope.regionParams.start; var userEnd = $scope.regionParams.end; @@ -74,22 +74,22 @@ function($rootScope, $scope, selectedDatasetInformation, regionSelectParams) { // Add color to user selected bounds var style = 'background-color: #000000; border: 2px solid;'; var ocwBar = '
'; - + // Add row to DataTable: object with start and end date // note: subtract one from month since indexes from 0 to 11 - data.addRow([new Date(userStart.substr(0,4), userStart.substr(5,2)-1, userStart.substr(8,2)), - new Date(userEnd.substr(0,4), userEnd.substr(5,2)-1, userEnd.substr(8,2)), + data.addRow([new Date(userStart), + new Date(userEnd), ocwBar ]); } - + var options = { "width": "100%", "showCurrentTime": false, "moveable": false, "zoomable": false, }; - - // Draw timeline with data (DataTable) and options (a name-value map) + + // Draw timeline with data (DataTable) and options (a name-value map) $rootScope.timeline.draw(data, options); }; diff --git a/ocw-ui/frontend/app/scripts/controllers/worldmap.js b/ocw-ui/frontend/app/scripts/controllers/worldmap.js index 0d28d6cd..e602ee78 100644 --- a/ocw-ui/frontend/app/scripts/controllers/worldmap.js +++ b/ocw-ui/frontend/app/scripts/controllers/worldmap.js @@ -41,7 +41,7 @@ function($rootScope, $scope, selectedDatasetInformation, regionSelectParams) { // Don't process if we don't have any datasets added or if the map doesn't exist!! if ($scope.datasets.length == 0 || !("map" in $rootScope)) return; - + // Create a group that we'll draw overlays to $rootScope.rectangleGroup = L.layerGroup(); // Add rectangle Group to map @@ -78,7 +78,7 @@ function($rootScope, $scope, selectedDatasetInformation, regionSelectParams) { $rootScope.rectangleGroup.addLayer(overlapBorder); // Draw user selected region - if ($scope.regionParams.areValid) { + if (!isNaN($scope.regionParams.lonMin) && !isNaN($scope.regionParams.lonMax) && !isNaN($scope.regionParams.latMin) && !isNaN($scope.regionParams.latMax)) { var bounds = [[$scope.regionParams.latMax, $scope.regionParams.lonMin], [$scope.regionParams.latMin, $scope.regionParams.lonMax]]; diff --git a/ocw-ui/frontend/app/views/main.html b/ocw-ui/frontend/app/views/main.html index f07875f8..3e94ba5a 100644 --- a/ocw-ui/frontend/app/views/main.html +++ b/ocw-ui/frontend/app/views/main.html @@ -113,10 +113,10 @@