forked from Archives/Athou_commafeed
fix #24
This commit is contained in:
@@ -8,6 +8,7 @@ public class Subscription implements Serializable {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String message;
|
||||
private int errorCount;
|
||||
private String feedUrl;
|
||||
private long unread;
|
||||
|
||||
@@ -51,4 +52,12 @@ public class Subscription implements Serializable {
|
||||
this.feedUrl = feedUrl;
|
||||
}
|
||||
|
||||
public int getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
public void setErrorCount(int errorCount) {
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -213,6 +213,7 @@ public class SubscriptionsREST extends AbstractREST {
|
||||
sub.setId(subscription.getId());
|
||||
sub.setName(subscription.getTitle());
|
||||
sub.setMessage(subscription.getFeed().getMessage());
|
||||
sub.setErrorCount(subscription.getFeed().getErrorCount());
|
||||
sub.setFeedUrl(subscription.getFeed().getLink());
|
||||
Long size = unreadCount.get(subscription.getId());
|
||||
sub.setUnread(size == null ? 0 : size);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<li> <input type="checkbox" ng-model="node.expanded" ng-click="toggleCategory(node)" />
|
||||
<label ng-click="categoryClick({id: node.id})"
|
||||
ng-class="{selected: (node.id == selectedId && selectedType == 'category')}">{{formatCategoryName({category:node})}}
|
||||
ng-class="{selected: (node.id == selectedId && selectedType == 'category'), unread: unreadCount({category:node})}">{{formatCategoryName({category:node})}}
|
||||
</label>
|
||||
<ul>
|
||||
<li ng-repeat="feed in node.feeds" ng-mouseenter="hovered=feed" ng-mouseleave="hovered=null" ng-class="{error: feed.message && feed.errorCount > 10}">
|
||||
|
||||
@@ -95,12 +95,12 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
|
||||
|
||||
$scope.SubscriptionService = SubscriptionService;
|
||||
|
||||
var unreadCount = function(category) {
|
||||
$scope.unreadCount = function(category) {
|
||||
var count = 0;
|
||||
var i;
|
||||
if (category.children) {
|
||||
for (i = 0; i < category.children.length; i++) {
|
||||
count = count + unreadCount(category.children[i]);
|
||||
count = count + $scope.unreadCount(category.children[i]);
|
||||
}
|
||||
}
|
||||
if (category.feeds) {
|
||||
@@ -113,7 +113,7 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
|
||||
};
|
||||
|
||||
var rootUnreadCount = function() {
|
||||
return unreadCount($scope.SubscriptionService.subscriptions);
|
||||
return $scope.unreadCount($scope.SubscriptionService.subscriptions);
|
||||
};
|
||||
|
||||
$scope.$watch(rootUnreadCount, function(value) {
|
||||
@@ -125,7 +125,7 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
|
||||
});
|
||||
|
||||
$scope.formatCategoryName = function(category) {
|
||||
var count = unreadCount(category);
|
||||
var count = $scope.unreadCount(category);
|
||||
var label = category.name;
|
||||
if (count > 0) {
|
||||
label = label + ' (' + count + ')';
|
||||
|
||||
@@ -49,6 +49,7 @@ module.directive('category', function($compile) {
|
||||
selectedId : '=',
|
||||
feedClick : '&',
|
||||
categoryClick : '&',
|
||||
unreadCount : '&',
|
||||
formatCategoryName : '&',
|
||||
formatFeedName : '&'
|
||||
},
|
||||
@@ -59,7 +60,8 @@ module.directive('category', function($compile) {
|
||||
var ul = element.find('ul');
|
||||
var html = '<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" ';
|
||||
html = html + 'category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId" ';
|
||||
html = html + 'format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})"> ';
|
||||
html = html + 'format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})" ';
|
||||
html = html + 'unread-count="unreadCount({category:category})">';
|
||||
html = html + '</category>';
|
||||
ul.prepend(html);
|
||||
$compile(ul.contents())(scope);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
feed-click="feedClicked(id)" category-click="categoryClicked(id)"
|
||||
selected-type="selectedType" selected-id="selectedId"
|
||||
format-category-name="formatCategoryName(category)"
|
||||
format-feed-name="formatFeedName(feed)"> </category>
|
||||
format-feed-name="formatFeedName(feed)"
|
||||
unread-count="unreadCount(category)"> </category>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in New Issue
Block a user