mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-05 16:08:40 +00:00
rewrite the plugins page using the new get_plugins method in the web json api
update the grid when a Plugin{Dis|En}abledEvent occurs
This commit is contained in:
parent
037fbcaaa7
commit
2f49c5cfa7
1 changed files with 68 additions and 54 deletions
|
@ -112,11 +112,6 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
text: _('Install'),
|
||||
handler: this.onInstallPlugin,
|
||||
scope: this
|
||||
}, {
|
||||
cls: 'x-btn-text-icon',
|
||||
text: _('Rescan'),
|
||||
handler: this.onRescanPlugins,
|
||||
scope: this
|
||||
}, '->', {
|
||||
cls: 'x-btn-text-icon',
|
||||
text: _('Find More'),
|
||||
|
@ -143,8 +138,11 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
});
|
||||
|
||||
this.on('show', this.onShow, this);
|
||||
this.pluginInfo.on('render', this.onPluginInfoRender, this);
|
||||
this.grid.on('cellclick', this.onCellClick, this);
|
||||
Deluge.Preferences.on('show', this.onPreferencesShow, this);
|
||||
Deluge.Events.on('PluginDisabledEvent', this.onPluginDisabled, this);
|
||||
Deluge.Events.on('PluginEnabledEvent', this.onPluginsEnabled, this);
|
||||
},
|
||||
|
||||
disablePlugin: function(plugin) {
|
||||
|
@ -156,10 +154,30 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
},
|
||||
|
||||
setInfo: function(plugin) {
|
||||
if (!this.pluginInfo.rendered) return;
|
||||
var values = plugin || this.defaultValues;
|
||||
this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values);
|
||||
},
|
||||
|
||||
updatePlugins: function() {
|
||||
Deluge.Client.web.get_plugins({
|
||||
success: this.onGotPlugins,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
updatePluginsGrid: function() {
|
||||
var plugins = [];
|
||||
Ext.each(this.availablePlugins, function(plugin) {
|
||||
if (this.enabledPlugins.indexOf(plugin) > -1) {
|
||||
plugins.push([true, plugin]);
|
||||
} else {
|
||||
plugins.push([false, plugin]);
|
||||
}
|
||||
}, this);
|
||||
this.grid.getStore().loadData(plugins);
|
||||
},
|
||||
|
||||
onCellClick: function(grid, rowIndex, colIndex, e) {
|
||||
if (colIndex != 0) return;
|
||||
var r = grid.getStore().getAt(rowIndex);
|
||||
|
@ -176,16 +194,11 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
window.open('http://dev.deluge-torrent.org/wiki/Plugins');
|
||||
},
|
||||
|
||||
onGotAvailablePlugins: function(plugins) {
|
||||
this.availablePlugins = plugins;
|
||||
Deluge.Client.core.get_enabled_plugins({
|
||||
success: this.onGotEnabledPlugins,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
onGotEnabledPlugins: function(plugins) {
|
||||
this.enabledPlugins = plugins;
|
||||
onGotPlugins: function(plugins) {
|
||||
this.enabledPlugins = plugins.enabled_plugins;
|
||||
this.availablePlugins = plugins.available_plugins;
|
||||
this.setInfo();
|
||||
this.updatePluginsGrid();
|
||||
},
|
||||
|
||||
onGotPluginInfo: function(info) {
|
||||
|
@ -200,6 +213,20 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
delete info;
|
||||
},
|
||||
|
||||
onPluginEnabled: function(pluginName) {
|
||||
var index = this.grid.getStore().find('plugin', pluginName);
|
||||
var plugin = this.grid.getStore().getAt(index);
|
||||
plugin.set('enabled', true);
|
||||
plugin.commit();
|
||||
},
|
||||
|
||||
onPluginDisabled: function(pluginName) {
|
||||
var index = this.grid.getStore().find('plugin', pluginName);
|
||||
var plugin = this.grid.getStore().getAt(index);
|
||||
plugin.set('enabled', false);
|
||||
plugin.commit();
|
||||
},
|
||||
|
||||
onPluginSelect: function(selmodel, rowIndex, r) {
|
||||
Deluge.Client.web.get_plugin_info(r.get('plugin'), {
|
||||
success: this.onGotPluginInfo,
|
||||
|
@ -208,24 +235,11 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
|||
},
|
||||
|
||||
onPreferencesShow: function() {
|
||||
Deluge.Client.core.get_available_plugins({
|
||||
success: this.onGotAvailablePlugins,
|
||||
scope: this
|
||||
});
|
||||
this.updatePlugins();
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
Ext.deluge.preferences.Plugins.superclass.onShow.call(this);
|
||||
onPluginInfoRender: function(ct, position) {
|
||||
this.setInfo();
|
||||
var plugins = [];
|
||||
Ext.each(this.availablePlugins, function(plugin) {
|
||||
if (this.enabledPlugins.indexOf(plugin) > -1) {
|
||||
plugins.push([true, plugin]);
|
||||
} else {
|
||||
plugins.push([false, plugin]);
|
||||
}
|
||||
}, this);
|
||||
this.grid.getStore().loadData(plugins);
|
||||
}
|
||||
});
|
||||
Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());
|
Loading…
Add table
Add a link
Reference in a new issue