From 0fb6c6c40cc9920ce6aec670badb58e38bb381ce Mon Sep 17 00:00:00 2001 From: Athou Date: Sat, 27 Apr 2013 10:44:16 +0200 Subject: [PATCH] refresh button now queues the feed for refresh --- .../frontend/rest/resources/AbstractREST.java | 4 ++++ .../frontend/rest/resources/FeedREST.java | 16 ++++++++++++++++ src/main/webapp/js/controllers.js | 10 ++++++++-- src/main/webapp/js/services.js | 6 ++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java b/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java index 2bf81e6b..0c9e8093 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/AbstractREST.java @@ -35,6 +35,7 @@ import com.commafeed.backend.dao.UserDAO; import com.commafeed.backend.dao.UserRoleDAO; import com.commafeed.backend.dao.UserSettingsDAO; import com.commafeed.backend.feeds.FeedFetcher; +import com.commafeed.backend.feeds.FeedRefreshTaskGiver; import com.commafeed.backend.feeds.OPMLImporter; import com.commafeed.backend.model.User; import com.commafeed.backend.model.UserRole.Role; @@ -105,6 +106,9 @@ public abstract class AbstractREST { @Inject MetricsBean metricsBean; + @Inject + FeedRefreshTaskGiver taskGiver; + @PostConstruct public void init() { CommaFeedApplication app = CommaFeedApplication.get(); diff --git a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java index 2a59cb04..968a3415 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java @@ -103,6 +103,22 @@ public class FeedREST extends AbstractResourceREST { return info; } + @Path("/refresh") + @POST + @ApiOperation(value = "Queue a feed for refresh", notes = "Manually add a feed to the refresh queue") + public Response queueForRefresh(@ApiParam(value = "Feed id") IDRequest req) { + Preconditions.checkNotNull(req); + Preconditions.checkNotNull(req.getId()); + + FeedSubscription sub = feedSubscriptionDAO.findById(getUser(), + req.getId()); + if (sub != null) { + taskGiver.add(sub.getFeed()); + return Response.ok(Status.OK).build(); + } + return Response.ok(Status.NOT_FOUND).build(); + } + @Path("/mark") @POST @ApiOperation(value = "Mark feed entries", notes = "Mark feed entries as read (unread is not supported)") diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index c8aef247..404e65b0 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -165,9 +165,9 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat }]); module.controller('ToolbarCtrl', ['$scope', '$http', '$state', '$stateParams', - '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', 'ServerService', + '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', 'ServerService', 'FeedService', function($scope, $http, $state, $stateParams, $route, $location, - SettingsService, EntryService, ProfileService, AnalyticsService, ServerService) { + SettingsService, EntryService, ProfileService, AnalyticsService, ServerService, FeedService) { function totalActiveAjaxRequests() { return ($http.pendingRequests.length + $.active); @@ -195,7 +195,13 @@ function($scope, $http, $state, $stateParams, $route, $location, } }); $scope.refresh = function() { + if($stateParams._type == 'feed'){ + FeedService.refresh({ + id : $stateParams._id + }); + } $scope.$emit('emitReload'); + }; $scope.markAllAsRead = function() { $scope.$emit('emitMarkAll', { diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index 11096956..243de1f5 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -62,6 +62,12 @@ function($resource, $http) { _method : 'mark' } }, + refresh : { + method : 'POST', + params : { + _method : 'refresh' + } + }, subscribe : { method : 'POST', params : {