Add evaluationSettings service
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/35e8a7ed Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/35e8a7ed Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/35e8a7ed Branch: refs/heads/master Commit: 35e8a7ed3a4dd5ec61260fec53f80dad723629a7 Parents: 8f13d2b Author: Michael Joyce <[email protected]> Authored: Wed Jul 16 10:24:15 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Wed Jul 16 10:24:15 2014 -0700 ---------------------------------------------------------------------- ocw-ui/frontend-new/app/index.html | 1 + .../app/scripts/services/evaluationsettings.js | 37 ++++++++++++++++++++ .../test/spec/services/evaluationsettings.js | 18 ++++++++++ 3 files changed, 56 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/35e8a7ed/ocw-ui/frontend-new/app/index.html ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/app/index.html b/ocw-ui/frontend-new/app/index.html index 5ca9aad..375468a 100644 --- a/ocw-ui/frontend-new/app/index.html +++ b/ocw-ui/frontend-new/app/index.html @@ -105,6 +105,7 @@ <script src="scripts/directives/previewmap.js"></script> <script src="scripts/directives/timeline.js"></script> <script src="scripts/filters/isodatetomiddleendian.js"></script> + <script src="scripts/services/evaluationsettings.js"></script> <!-- endbuild --> </body> </html> http://git-wip-us.apache.org/repos/asf/climate/blob/35e8a7ed/ocw-ui/frontend-new/app/scripts/services/evaluationsettings.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/app/scripts/services/evaluationsettings.js b/ocw-ui/frontend-new/app/scripts/services/evaluationsettings.js new file mode 100644 index 0000000..97e1d75 --- /dev/null +++ b/ocw-ui/frontend-new/app/scripts/services/evaluationsettings.js @@ -0,0 +1,37 @@ +'use strict'; + +/** + * @ngdoc service + * @name ocwUiApp.evaluationSettings + * @description + * # evaluationSettings + * Service in the ocwUiApp. + */ +angular.module('ocwUiApp') +.service('evaluationSettings', function($rootScope, $http) { + $http.get($rootScope.baseURL + '/processing/metrics/').then(function(data) { + metrics_data = data['data']['metrics']; + metrics = []; + + for (var i = 0; i < metrics_data.length; ++i) { + metrics.push({'name': metrics_data[i], 'select': false}); + } + + settings['metrics'] = metrics; + }); + + var settings = { + 'metrics': [], + 'temporal': { + 'options': ['daily', 'monthly', 'yearly'], + 'selected': 'yearly', + }, + 'spatialSelect': null, + }; + + return { + getSettings: function() { + return settings; + } + }; +}); http://git-wip-us.apache.org/repos/asf/climate/blob/35e8a7ed/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js b/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js new file mode 100644 index 0000000..60f6ac3 --- /dev/null +++ b/ocw-ui/frontend-new/test/spec/services/evaluationsettings.js @@ -0,0 +1,18 @@ +'use strict'; + +describe('Service: evaluationSettings', function () { + + // load the service's module + beforeEach(module('ocwUiApp')); + + // instantiate service + var evaluationSettings; + beforeEach(inject(function (_evaluationSettings_) { + evaluationSettings = _evaluationSettings_; + })); + + it('should do something', function () { + expect(!!evaluationSettings).toBe(true); + }); + +});
