@@ -27,7 +28,7 @@
-
+
-
- +
-
Unsubscribe
diff --git a/src/main/webapp/directives/toolbar.html b/src/main/webapp/directives/toolbar.html
index d3f43fc2..efd68e83 100644
--- a/src/main/webapp/directives/toolbar.html
+++ b/src/main/webapp/directives/toolbar.html
@@ -1,6 +1,4 @@
-- - Reading Mode +@@ -9,7 +7,7 @@ -+
- Settings diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 1037d702..73db6e49 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -44,9 +44,6 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location, $scope.formatFeedName = function(feed) { var label = feed.name; - if (feed.message) { - label = "!!! " + label; - } if (feed.unread > 0) { label = label + " (" + feed.unread + ")"; } diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index e8490834..20ae851b 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -11,11 +11,11 @@ module.directive('subscribe', function(SubscriptionService) { backdropFade : true, dialogFade : true }; - - $scope.isOpen = false; - $scope.isOpenImport = false; - $scope.sub = {}; - + + $scope.isOpen = false; + $scope.isOpenImport = false; + $scope.sub = {}; + $scope.SubscriptionService = SubscriptionService; $scope.open = function() { @@ -26,13 +26,12 @@ module.directive('subscribe', function(SubscriptionService) { $scope.close = function() { $scope.isOpen = false; }; - + $scope.save = function() { - SubscriptionService.subscribe($scope.sub, function() { - $scope.close(); - }); + SubscriptionService.subscribe($scope.sub); + $scope.close(); }; - + $scope.openImport = function() { $scope.isOpenImport = true; }; @@ -40,7 +39,7 @@ module.directive('subscribe', function(SubscriptionService) { $scope.closeImport = function() { $scope.isOpenImport = false; }; - + $scope.uploadComplete = function(contents, completed) { SubscriptionService.init(); $scope.closeImport(); @@ -51,45 +50,53 @@ module.directive('subscribe', function(SubscriptionService) { module.directive('category', function($compile) { return { - scope: { - node: '=', - selectedType: '=', - selectedId: '=', - feedClick: '&', - categoryClick: '&', - formatCategoryName: '&', - formatFeedName: '&' + scope : { + node : '=', + selectedType : '=', + selectedId : '=', + feedClick : '&', + categoryClick : '&', + formatCategoryName : '&', + formatFeedName : '&' }, restrict : 'E', - replace: true, - templateUrl: 'directives/category.html', - link: function(scope, element) { - var ul = element.find('ul'); + replace : true, + templateUrl : 'directives/category.html', + link : function(scope, element) { + var ul = element.find('ul'); ul.prepend('
\ '); - $compile(ul.contents())(scope); - }, - controller: function($scope, $dialog, SubscriptionService) { - $scope.unsubscribe = function(subscription) { + $compile(ul.contents())(scope); + }, + controller : function($scope, $dialog, SubscriptionService) { + $scope.unsubscribe = function(subscription) { var title = 'Unsubscribe'; - var msg = 'Unsubscribe from ' + subscription.name + ' ?'; - var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; - - $dialog.messageBox(title, msg, btns) - .open() - .then(function(result){ - if(result == 'ok'){ - SubscriptionService.unsubscribe(subscription.id); - } - }); - } - } + var msg = 'Unsubscribe from ' + subscription.name + ' ?'; + var btns = [ { + result : 'cancel', + label : 'Cancel' + }, { + result : 'ok', + label : 'OK', + cssClass : 'btn-primary' + } ]; + + $dialog.messageBox(title, msg, btns).open().then( + function(result) { + if (result == 'ok') { + SubscriptionService + .unsubscribe(subscription.id); + } + }); + } + } }; }); -module.directive('toolbar', function($routeParams, $route, SettingsService, EntryService, SubscriptionService) { +module.directive('toolbar', function($routeParams, $route, SettingsService, + EntryService, SubscriptionService) { return { scope : {}, restrict : 'E', @@ -99,12 +106,12 @@ module.directive('toolbar', function($routeParams, $route, SettingsService, Entr $scope.settings = SettingsService.settings; $scope.refresh = function() { $route.reload(); - }, + }; $scope.markAllAsRead = function() { EntryService.mark({ - type: $routeParams._type, - id: $routeParams._id, - read: true, + type : $routeParams._type, + id : $routeParams._id, + read : true, }, function() { SubscriptionService.init(function() { $route.reload(); diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index 6ede7a5c..ff160e76 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -1,13 +1,17 @@ var module = angular.module('commafeed.services', [ 'ngResource' ]); -module.factory('SubscriptionService', [ '$resource', '$http', +module.factory('SubscriptionService', [ + '$resource', + '$http', function($resource, $http) { - - var flatten = function(category, parentName, array) { - if(!array) array = []; + + var flatten = function(category, parentName, array) { + if (!array) + array = []; array.push({ id : category.id, - name : category.name + (parentName ? (' (in ' + parentName + ')') : '') + name : category.name + + (parentName ? (' (in ' + parentName + ')') : '') }); if (category.children) { for ( var i = 0; i < category.children.length; i++) { @@ -39,32 +43,52 @@ module.factory('SubscriptionService', [ '$resource', '$http', var s = {}; s.subscriptions = {}; s.flatCategories = {}; - + var res = $resource('rest/subscriptions/:_method', {}, actions); s.init = function(callback) { s.subscriptions = res.get(function(data) { s.flatCategories = flatten(s.subscriptions); - if(callback) + if (callback) callback(data); }); }; s.subscribe = function(sub, callback) { - res.subscribe(sub, callback); - s.init(); + res.subscribe(sub, function(data){ + s.init(); + if(callback) callback(data); + }); }; - s.unsubscribe = function(id, callback) { + + var removeSubscription = function(node, subId) { + if (node.children) { + $.each(node.children, function(k, v) { + removeSubscription(v, subId); + }); + } + if (node.feeds) { + var foundAtIndex = -1; + $.each(node.feeds, function(k, v) { + if (v.id == subId) { + foundAtIndex = k; + } + }); + if (foundAtIndex > -1) { + node.feeds.splice(foundAtIndex, 1); + } + } + + } + s.unsubscribe = function(id) { + removeSubscription(s.subscriptions, id); res.unsubscribe({ id : id - }, callback); - s.init(); + }); }; s.init(); return s; } ]); -module.factory('EntryService', [ - '$resource', - '$http', +module.factory('EntryService', [ '$resource', '$http', function($resource, $http) { var actions = { get : { @@ -80,8 +104,7 @@ module.factory('EntryService', [ } } }; - res = $resource('rest/entries/:_method', {}, - actions); + res = $resource('rest/entries/:_method', {}, actions); return res; } ]); diff --git a/src/main/webapp/templates/feeds.html b/src/main/webapp/templates/feeds.html index 6e8886a7..2b0a4f94 100644 --- a/src/main/webapp/templates/feeds.html +++ b/src/main/webapp/templates/feeds.html @@ -1,7 +1,8 @@-{{readType}} - {{entryList.name}} » + ++{{entryList.name}} »
+
-
Unsubscribe
diff --git a/src/main/webapp/directives/toolbar.html b/src/main/webapp/directives/toolbar.html
index d3f43fc2..efd68e83 100644
--- a/src/main/webapp/directives/toolbar.html
+++ b/src/main/webapp/directives/toolbar.html
@@ -1,6 +1,4 @@
-