diff options
-rw-r--r-- | module/AddonManager.py | 4 | ||||
-rw-r--r-- | module/api/ConfigApi.py | 6 | ||||
-rw-r--r-- | module/plugins/Base.py | 4 | ||||
-rw-r--r-- | module/web/static/css/default/settings.less | 20 | ||||
-rw-r--r-- | module/web/static/js/views/settings/pluginChooserModal.js | 5 | ||||
-rw-r--r-- | module/web/static/js/views/settings/settingsView.js | 14 | ||||
-rw-r--r-- | module/web/templates/default/settings.html | 10 |
7 files changed, 51 insertions, 12 deletions
diff --git a/module/AddonManager.py b/module/AddonManager.py index cc2181767..dc83a553f 100644 --- a/module/AddonManager.py +++ b/module/AddonManager.py @@ -36,6 +36,7 @@ class AddonManager: __builtin__.addonManager = self #needed to let addons register themselves self.log = self.core.log + # TODO: multiuser, addons can store the user itself, probably not needed here self.plugins = {} self.methods = {} # dict of names and list of methods usable by rpc self.events = {} # Contains event that will be registered @@ -237,9 +238,6 @@ class AddonManager: # clean up del self.events[name] - def addConfigHandler(self, plugin, func): - pass #TODO - def addEvent(self, *args): self.core.eventManager.addEvent(*args) diff --git a/module/api/ConfigApi.py b/module/api/ConfigApi.py index d5577f7c3..b2327eb9a 100644 --- a/module/api/ConfigApi.py +++ b/module/api/ConfigApi.py @@ -65,9 +65,13 @@ class ConfigApi(ApiComponent): :rtype: list of PluginInfo """ # TODO: include addons that are activated by default + # TODO: multi user data = [] + active = [x.getName() for x in self.core.addonManager.activePlugins()] for name, config, values in self.core.config.iterSections(self.user): - if not values: continue + # skip unmodified and inactive addons + if not values and name not in active: continue + item = ConfigInfo(name, config.name, config.description, self.core.pluginManager.getCategory(name), self.core.pluginManager.isUserPlugin(name), diff --git a/module/plugins/Base.py b/module/plugins/Base.py index 70805b7f3..b96275db2 100644 --- a/module/plugins/Base.py +++ b/module/plugins/Base.py @@ -140,6 +140,10 @@ class Base(object): getattr(self.log, level)("%s: %s" % (self.__name__, sep.join(strings))) + def getName(self): + """ Name of the plugin class """ + return self.__name__ + def setConfig(self, option, value): """ Set config value for current plugin """ self.core.config.set(self.__name__, option, value) diff --git a/module/web/static/css/default/settings.less b/module/web/static/css/default/settings.less index 44eeddc5f..12cc31e06 100644 --- a/module/web/static/css/default/settings.less +++ b/module/web/static/css/default/settings.less @@ -22,6 +22,26 @@ margin-top: 0;
}
+ .plugin {
+ a {
+ padding-left: 28px;
+ background-position: 4px 2px;
+ background-repeat: no-repeat;
+ background-size: 20px 20px;
+ }
+
+ i {
+ display: none;
+ }
+
+ &:hover {
+ i {
+ display: block;
+ }
+ }
+
+ }
+
border-top-left-radius: 0;
border-top-right-radius: 0;
diff --git a/module/web/static/js/views/settings/pluginChooserModal.js b/module/web/static/js/views/settings/pluginChooserModal.js index c7cdce244..65c412d9c 100644 --- a/module/web/static/js/views/settings/pluginChooserModal.js +++ b/module/web/static/js/views/settings/pluginChooserModal.js @@ -14,10 +14,9 @@ define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/def this.events = _.extend({}, modalView.prototype.events, this.events); var self = this; $.ajax(App.apiRequest('getAvailablePlugins', null, {success: function(data) { - self.plugins = data; + self.plugins = _.sortBy(data, function(item){return item.name;}); self.render(); - } - })); + }})); }, onRender: function() { diff --git a/module/web/static/js/views/settings/settingsView.js b/module/web/static/js/views/settings/settingsView.js index 58507f51a..4e83322e5 100644 --- a/module/web/static/js/views/settings/settingsView.js +++ b/module/web/static/js/views/settings/settingsView.js @@ -9,7 +9,8 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con events: { 'click .settings-menu li > a': 'change_section', - 'click .btn-add': 'choosePlugin' + 'click .btn-add': 'choosePlugin', + 'click .iconf-remove': 'deleteConfig' }, menu: null, @@ -110,7 +111,8 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con }, failure: function() { - + // TODO + this.config = null; }, change_section: function(e) { @@ -134,6 +136,14 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con self.modal.show(); }); + }, + + deleteConfig: function(e){ + e.stopPropagation(); + var el = $(e.target).parent().parent(); + var name = el.data("name"); + + console.log("Delete config " + name); } }); diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index bee583dbf..d8e3430f5 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -23,10 +23,14 @@ <li class="divider"></li>
<li class="nav-header"><i class="icon-th-large icon-white"></i> {{ _("Addons") }}</li>
<%= each plugin %>
- <li data-name="<% name %>"><a href="#"><% label %></a></li>
+ <li class="plugin" data-name="<% name %>">
+ <a href="#" style="background-image: url(icons/<% name %>);">
+ <% label %>
+ <i class="iconf-remove pull-right"></i>
+ </a></li>
<%/each%>
-{# <li class="divider"></li>#}
-{# <li class="nav-header"><i class="icon-th-list icon-white"></i> {{ _("Other") }}</li>#}
+ {# <li class="divider"></li>#}
+ {# <li class="nav-header"><i class="icon-th-list icon-white"></i> {{ _("Other") }}</li>#}
</script>
<script type="text/template" id="template-config">
<legend>
|