forked from Archives/Athou_commafeed
rename feeds
This commit is contained in:
@@ -25,6 +25,7 @@ import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.frontend.model.Category;
|
||||
import com.commafeed.frontend.model.Subscription;
|
||||
import com.commafeed.frontend.model.SubscriptionRequest;
|
||||
import com.commafeed.frontend.rest.resources.EntriesREST.Type;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
|
||||
@@ -78,12 +79,29 @@ public class SubscriptionsREST extends AbstractREST {
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("rename")
|
||||
public Response rename(@QueryParam("type") Type type,
|
||||
@QueryParam("id") Long id, @QueryParam("name") String name) {
|
||||
if (type == Type.feed) {
|
||||
FeedSubscription subscription = feedSubscriptionService.findById(
|
||||
getUser(), id);
|
||||
subscription.setTitle(name);
|
||||
feedSubscriptionService.update(subscription);
|
||||
} else if (type == Type.category) {
|
||||
FeedCategory category = feedCategoryService.findById(getUser(), id);
|
||||
category.setName(name);
|
||||
feedCategoryService.update(category);
|
||||
}
|
||||
return Response.ok(Status.OK).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("collapse")
|
||||
public Response collapse(@QueryParam("id") String id,
|
||||
@QueryParam("collapse") boolean collapse) {
|
||||
Preconditions.checkNotNull(id);
|
||||
if (!"all".equals(id)) {
|
||||
if (EntriesREST.ALL.equals(id)) {
|
||||
FeedCategory category = feedCategoryService.findById(getUser(),
|
||||
Long.valueOf(id));
|
||||
category.setCollapsed(collapse);
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
top: -4px;
|
||||
}
|
||||
|
||||
.main .dropdown-menu a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
<ul>
|
||||
<li ng-repeat="feed in node.feeds" ng-mouseenter="hovered=feed" ng-mouseleave="hovered=null" ng-class="{error: feed.message}">
|
||||
<div class="dropdown pull-right">
|
||||
<a dropdown-toggle class="pull-right feed-menu-icon"><i ng-show="hovered==feed" class="icon icon-chevron-down"></i> </a>
|
||||
<a dropdown-toggle class="pull-right"><i ng-show="hovered==feed" class="icon icon-chevron-down"></i> </a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a ng-click="edit(feed)">Edit</a>
|
||||
<a ng-click="rename(feed)">Rename</a>
|
||||
</li>
|
||||
<li>
|
||||
<a ng-click="unsubscribe(feed)">Unsubscribe</a>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
var module = angular.module('commafeed.directives', []);
|
||||
|
||||
app.directive('ngBlur', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, elm, attrs) {
|
||||
elm.bind('blur', function() {
|
||||
scope.$apply(attrs.ngBlur);
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
restrict : 'A',
|
||||
link : function(scope, elm, attrs) {
|
||||
elm.bind('blur', function() {
|
||||
scope.$apply(attrs.ngBlur);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('scrollTo', function() {
|
||||
@@ -57,7 +57,6 @@ module.directive('subscribe', function(SubscriptionService) {
|
||||
$scope.close = function() {
|
||||
$scope.isOpen = false;
|
||||
};
|
||||
|
||||
|
||||
$scope.urlChanged = function() {
|
||||
if ($scope.sub.url && !$scope.sub.title) {
|
||||
@@ -87,18 +86,18 @@ module.directive('subscribe', function(SubscriptionService) {
|
||||
SubscriptionService.init();
|
||||
$scope.closeImport();
|
||||
};
|
||||
|
||||
|
||||
$scope.cat = {};
|
||||
|
||||
$scope.openCategory= function(){
|
||||
|
||||
$scope.openCategory = function() {
|
||||
$scope.isOpenCategory = true;
|
||||
$scope.cat = {};
|
||||
};
|
||||
|
||||
$scope.closeCategory= function(){
|
||||
|
||||
$scope.closeCategory = function() {
|
||||
$scope.isOpenCategory = false;
|
||||
};
|
||||
|
||||
|
||||
$scope.saveCategory = function() {
|
||||
SubscriptionService.addCategory($scope.cat);
|
||||
$scope.closeCategory();
|
||||
@@ -152,6 +151,18 @@ module.directive('category', function($compile) {
|
||||
});
|
||||
};
|
||||
|
||||
$scope.rename = function(feed) {
|
||||
var name = window.prompt("Rename feed : ", feed.name);
|
||||
if (name && name != feed.name) {
|
||||
feed.name = name;
|
||||
SubscriptionService.rename({
|
||||
type : 'feed',
|
||||
id : feed.id,
|
||||
name : name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$scope.toggleCategory = function(category) {
|
||||
SubscriptionService.collapse({
|
||||
id : category.id,
|
||||
@@ -162,7 +173,7 @@ module.directive('category', function($compile) {
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('toolbar', function($stateParams, $route, $location,
|
||||
module.directive('toolbar', function($stateParams, $route, $location,
|
||||
SettingsService, EntryService, SubscriptionService, SessionService) {
|
||||
return {
|
||||
scope : {},
|
||||
@@ -174,7 +185,7 @@ module.directive('toolbar', function($stateParams, $route, $location,
|
||||
function totalActiveAjaxRequests() {
|
||||
return ($http.pendingRequests.length + $.active);
|
||||
}
|
||||
|
||||
|
||||
$scope.session = SessionService.get();
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
@@ -49,6 +49,12 @@ module.factory('SubscriptionService', function($resource, $http) {
|
||||
_method : 'unsubscribe'
|
||||
}
|
||||
},
|
||||
rename : {
|
||||
method : 'GET',
|
||||
params : {
|
||||
_method : 'rename'
|
||||
}
|
||||
},
|
||||
collapse : {
|
||||
method : 'GET',
|
||||
params : {
|
||||
@@ -81,6 +87,7 @@ module.factory('SubscriptionService', function($resource, $http) {
|
||||
});
|
||||
};
|
||||
s.fetch = res.fetch;
|
||||
s.rename = res.rename;
|
||||
s.subscribe = function(sub, callback) {
|
||||
res.subscribe(sub, function(data) {
|
||||
s.init();
|
||||
|
||||
Reference in New Issue
Block a user