nitweb/angular: display an error message when no doc is found for a full_name
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 21 Jun 2016 16:24:47 +0000 (12:24 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 22 Jun 2016 01:26:49 +0000 (21:26 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/javascripts/entities.js
share/nitweb/views/doc.html

index 16212f8..9333050 100644 (file)
@@ -19,6 +19,8 @@
                .module('entities', ['ngSanitize', 'ui', 'model'])
 
                .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model, $routeParams, $scope, $sce) {
+                       $scope.entityId = $routeParams.id;
+
                        this.loadEntityLinearization = function() {
                                Model.loadEntityLinearization($routeParams.id,
                                        function(data) {
@@ -58,8 +60,8 @@
                        Model.loadEntity($routeParams.id,
                                function(data) {
                                        $scope.mentity = data;
-                               }, function(err) {
-                                       $scope.error = err;
+                               }, function(message, status) {
+                                       $scope.error = {message: message, status: status};
                                });
                }])
 
index 0362502..53f8a2a 100644 (file)
@@ -1,4 +1,14 @@
 <div class='container-fluid'>
+
+       <div ng-if='error' class='alert alert-danger' role='alert'>
+               <span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span>
+               <span class='sr-only'>Error:</span>
+               <span ng-switch='error.status'>
+                       <span ng-switch-when='404'>Entity <code>{{entityId}}</code> not found!</span>
+                       <span ng-switch-default>An error occured<br/>{{error.status}}: {{error.message}}</span>
+               </span>
+       </div>
+
        <div class='page-header'>
                <h2><entity-signature mentity='mentity' /></h2>
                <entity-namespace mentity='mentity' />