diff options
4 files changed, 81 insertions, 11 deletions
diff --git a/pyload/web/app/scripts/models/CollectorPackage.js b/pyload/web/app/scripts/models/CollectorPackage.js index 17a3a1551..216e6be9d 100644 --- a/pyload/web/app/scripts/models/CollectorPackage.js +++ b/pyload/web/app/scripts/models/CollectorPackage.js @@ -9,11 +9,13 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection password: null, new_name: null, links: null, - pid: null + pid: null, + ignored: null // list of ignored plugins }, initialize: function() { this.set('links', new LinkList()); + this.set('ignored', {}); }, destroy: function() { @@ -39,7 +41,13 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection // Add the package to pyload add: function() { var self = this; - var links = this.get('links').pluck('url'); + // Filter the ignored links and retrieve urls + var links = _.map(this.get('links').filter(function(link) { + return !_.has(self.get('ignored'), link.get('plugin')); + }), function(link) { + return link.get('url'); + }); + var pid = this.get('pid'); if (pid !== null && _.isNumber(pid)) { @@ -87,24 +95,41 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection name: this.getName(), links: this.get('links').toJSON() }; - var links = this.get('links'); - data.length = links.length; + // Summary + data.length = data.links.length; data.size = 0; data.online = 0; data.offline = 0; data.unknown = 0; + data.plugins = {}; - // Summary - links.each(function(link) { - if (link.get('status') === Api.DownloadStatus.Online) + // map of ignored plugins + var ignored = this.get('ignored'); + + _.each(data.links, function(link) { + + link.ignored = _.has(ignored, link.plugin); + + if (link.status === Api.DownloadStatus.Online) data.online++; - else if (link.get('status') === Api.DownloadStatus.Offline) + else if (link.status === Api.DownloadStatus.Offline) data.offline++; else data.unknown++; - if (link.get('size') > 0) - data.size += link.get('size'); + if (link.size > 0) + data.size += link.size; + + if (_.has(data.plugins, link.plugin)) + data.plugins[link.plugin].count++; + else { + data.plugins[link.plugin] = { + count: 1, + ignored: link.ignored + }; + + } + }); return data; diff --git a/pyload/web/app/scripts/views/linkgrabber/packageView.js b/pyload/web/app/scripts/views/linkgrabber/packageView.js index a9d04ced6..00b784844 100644 --- a/pyload/web/app/scripts/views/linkgrabber/packageView.js +++ b/pyload/web/app/scripts/views/linkgrabber/packageView.js @@ -24,7 +24,8 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package' 'click .btn-add': 'addPackage', 'click .btn-password': 'togglePassword', 'click .btn-delete': 'deletePackage', - 'click .btn-mini': 'deleteLink' + 'click .btn-mini': 'deleteLink', + 'click .plugin-item': 'togglePlugin' }, expanded: false, @@ -89,6 +90,18 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package' var el = $(e.target); el.find('i').toggleClass('icon-lock icon-unlock'); this.ui.password.toggle(); + }, + + togglePlugin: function(e) { + var el = $(e.target); + var plugin = el.data('plugin'); + var ignored = this.model.get('ignored'); + if (_.has(ignored, plugin)) + delete ignored[plugin]; + else + ignored[plugin] = true; + + this.render(); } }); diff --git a/pyload/web/app/styles/default/linkgrabber.less b/pyload/web/app/styles/default/linkgrabber.less index 010dbadec..630491975 100644 --- a/pyload/web/app/styles/default/linkgrabber.less +++ b/pyload/web/app/styles/default/linkgrabber.less @@ -62,4 +62,24 @@ margin-bottom: 0; } +} + +.plugin-list { + + img { + height: 20px; + width: 20px; + } + + .plugin-item { + cursor: pointer; + font-size: small; + font-weight: bold; + + &.ignored { + opacity: 0.5; + } + + } + }
\ No newline at end of file diff --git a/pyload/web/app/templates/default/linkgrabber/package.html b/pyload/web/app/templates/default/linkgrabber/package.html index 2efdc2b35..882db30e6 100644 --- a/pyload/web/app/templates/default/linkgrabber/package.html +++ b/pyload/web/app/templates/default/linkgrabber/package.html @@ -12,6 +12,7 @@ <table class="table table-condensed" {{#unless expanded}}style="display: none"{{/unless}}> <tbody> {{#each links}} + {{#unless ignored}} <tr> <td class="link-name">{{ name }}</td> <td><img src="{{ pluginIcon plugin }}"> {{ plugin }}</td> @@ -19,6 +20,7 @@ <td>{{ linkStatus status }}</td> <td><button class="btn btn-danger btn-mini" data-index={{@index}}><i class="icon-trash"></i></button></td> </tr> + {{/unless}} {{/each}} </tbody> </table> @@ -41,4 +43,14 @@ <span class="text-info"> {{ unknown }} {{_ "unknown" }} </span> + +<div class="plugin-list pull-right"> + {{#each plugins}} + <span class="plugin-item{{#if ignored}} ignored{{/if}}" data-plugin="{{@key}}"> + <img src="{{ pluginIcon @key}}"> + {{@key}}: {{count}} + </span> + {{/each}} +</div> + {{/if}} |