nitweb/angular: display an error message when no doc is found for a full_name
[nit.git] / share / nitweb / javascripts / entities.js
index 9eefc9f..9333050 100644 (file)
 
 (function() {
        angular
-               .module('entities', ['ui', 'model'])
+               .module('entities', ['ngSanitize', 'ui', 'model'])
+
+               .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model, $routeParams, $scope, $sce) {
+                       $scope.entityId = $routeParams.id;
 
-               .controller('EntityCtrl', ['Model', '$routeParams', '$scope', function(Model, $routeParams, $scope) {
                        this.loadEntityLinearization = function() {
                                Model.loadEntityLinearization($routeParams.id,
                                        function(data) {
                                        });
                        };
 
+                       this.loadEntityGraph = function(e) {
+                               Model.loadEntityGraph($routeParams.id,
+                                       function(data) {
+                                               $scope.graph = $sce.trustAsHtml(data);
+                                       }, function(err) {
+                                               $scope.error = err;
+                                       });
+                       };
+
                        Model.loadEntity($routeParams.id,
                                function(data) {
                                        $scope.mentity = data;
-                               }, function(err) {
-                                       $scope.error = err;
+                               }, function(message, status) {
+                                       $scope.error = {message: message, status: status};
                                });
                }])
 
                        };
                })
 
+               .directive('entityNamespace', function() {
+                       return {
+                               restrict: 'E',
+                               scope: {
+                                       mentity: '='
+                               },
+                               templateUrl: '/directives/entity/namespace.html'
+                       };
+               })
+
                .directive('entityTag', function() {
                        return {
                                restrict: 'E',