1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-21 13:41:37 +00:00

Closes #20: Clean error message if document or file does not exist

This commit is contained in:
jendib
2015-08-26 22:11:39 +02:00
parent 5cbdb5d87d
commit 86cae53789
9 changed files with 50 additions and 20 deletions

View File

@@ -7,6 +7,8 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
// Load document data from server
Restangular.one('document', $stateParams.id).get().then(function(data) {
$scope.document = data;
}, function(response) {
$scope.error = response;
});
// Load audit log data from server

View File

@@ -0,0 +1,16 @@
'use strict';
/**
* Image error event directive.
*/
angular.module('docs').directive('imgError', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('error', function() {
//call the function that was passed
scope.$apply(attrs.imgError);
});
}
};
})

View File

@@ -64,6 +64,7 @@
<script src="app/docs/directive/SelectTag.js" type="text/javascript"></script>
<script src="app/docs/directive/AuditLog.js" type="text/javascript"></script>
<script src="app/docs/directive/InlineEdit.js" type="text/javascript"></script>
<script src="app/docs/directive/ImgError.js" type="text/javascript"></script>
<!-- endref -->
</head>
<body>

View File

@@ -1,4 +1,11 @@
<img src="img/loader.gif" ng-show="!document" />
<img src="img/loader.gif" ng-show="!document && !error" />
<div ng-show="error" class="well-lg">
<p class="text-center" ng-show="error.status == 404">
<span class="glyphicon glyphicon-warning-sign"></span>
Document not found
</p>
</div>
<div ng-show="document">
<div class="text-right" ng-show="document.writable">

View File

@@ -22,5 +22,12 @@
<div class="text-center" ng-if="$stateParams.fileId">
<img ng-src="../api/file/{{ $stateParams.fileId }}/data?size=web" />
<img ng-src="../api/file/{{ $stateParams.fileId }}/data?size=web"
ng-init="error = false"
img-error="error = true"
ng-show="!error" />
<p class="well-lg" ng-show="error">
<span class="glyphicon glyphicon-warning-sign"></span>
File not found
</p>
</div>