nitweb/angular: model load metrics
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 4 Jul 2016 23:27:11 +0000 (19:27 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 20 Jul 2016 16:04:49 +0000 (12:04 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/javascripts/entities.js
share/nitweb/javascripts/model.js

index 2438d84..67c68bd 100644 (file)
@@ -18,7 +18,7 @@
        angular
                .module('entities', ['ngSanitize', 'ui', 'model'])
 
-               .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model, $routeParams, $scope, $sce) {
+               .controller('EntityCtrl', ['Model', 'Metrics', '$routeParams', '$scope', '$sce', function(Model, Metrics, $routeParams, $scope, $sce) {
                        $scope.entityId = $routeParams.id;
 
                        this.loadEntityLinearization = function() {
                                        });
                        };
 
+                       this.loadStructuralMetrics = function() {
+                               Metrics.loadStructuralMetrics($routeParams.id,
+                                       function(data) {
+                                               $scope.metrics = data;
+                                       }, function(message, status) {
+                                               $scope.error = {message: message, status: status};
+                                       });
+                       };
+
                        Model.loadEntity($routeParams.id,
                                function(data) {
                                        $scope.mentity = data;
index efcecd5..cd127ed 100644 (file)
                                }
                        }
                }])
+
+               .factory('Metrics', [ '$http', function($http) {
+                       return {
+                               loadStructuralMetrics: function(id, cb, cbErr) {
+                                       $http.get(apiUrl + '/metrics/structural/' + id)
+                                               .success(cb)
+                                               .error(cbErr);
+                               }
+                       }
+               }])
 })();