Skip to content

Commit

Permalink
Merge pull request #15 from rdmorganiser/pending_indicator
Browse files Browse the repository at this point in the history
Pending indicator
  • Loading branch information
jochenklar committed Sep 21, 2016
2 parents 11e44fc + 372fad5 commit ba85ccb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
27 changes: 26 additions & 1 deletion apps/core/static/core/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,29 @@ angular.module('core', ['ngResource'])
}
}
};
});
})

.directive('pending', ['$http', '$timeout', function ($http, $timeout) {
return {
restrict: 'E',
template: '<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>',
link: function (scope, element, attrs) {
scope.isPending = function () {
return $http.pendingRequests.length > 0;
};
scope.$watch(scope.isPending, function (value) {
if (value) {
if (angular.isUndefined(scope.promise) || scope.pending === null) {
scope.promise = $timeout(function(){
element.removeClass('ng-hide');
}, 300);
}
} else {
$timeout.cancel(scope.promise);
scope.pending = null;
element.addClass('ng-hide');
}
});
}
};
}]);
6 changes: 6 additions & 0 deletions apps/core/templates/core/base_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
</ul>

<ul class="nav navbar-nav navbar-right">
<li>
<p class="navbar-text">
<pending></pending>
</p>
</li>

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% trans 'Language' %}<span class="caret"></span></a>
<ul class="dropdown-menu">
Expand Down
2 changes: 1 addition & 1 deletion apps/domain/templates/domain/domain.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h2>{% trans 'Export' %}</h2>

<h1>{% trans 'Domain' %}</h1>

<div ng-repeat="entity in service.domain | orderBy: 'label' | filter: service.filter"
<div ng-repeat="entity in service.domain | orderBy: 'label' | filter: service.filter"
ng-include src="'nested_entity.html'">
</div>

Expand Down

0 comments on commit ba85ccb

Please sign in to comment.