mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-06 00:18:39 +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'),
|
text: _('Install'),
|
||||||
handler: this.onInstallPlugin,
|
handler: this.onInstallPlugin,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
|
||||||
cls: 'x-btn-text-icon',
|
|
||||||
text: _('Rescan'),
|
|
||||||
handler: this.onRescanPlugins,
|
|
||||||
scope: this
|
|
||||||
}, '->', {
|
}, '->', {
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Find More'),
|
text: _('Find More'),
|
||||||
|
@ -143,8 +138,11 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
|
this.pluginInfo.on('render', this.onPluginInfoRender, this);
|
||||||
this.grid.on('cellclick', this.onCellClick, this);
|
this.grid.on('cellclick', this.onCellClick, this);
|
||||||
Deluge.Preferences.on('show', this.onPreferencesShow, 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) {
|
disablePlugin: function(plugin) {
|
||||||
|
@ -156,10 +154,30 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
setInfo: function(plugin) {
|
setInfo: function(plugin) {
|
||||||
|
if (!this.pluginInfo.rendered) return;
|
||||||
var values = plugin || this.defaultValues;
|
var values = plugin || this.defaultValues;
|
||||||
this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values);
|
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) {
|
onCellClick: function(grid, rowIndex, colIndex, e) {
|
||||||
if (colIndex != 0) return;
|
if (colIndex != 0) return;
|
||||||
var r = grid.getStore().getAt(rowIndex);
|
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');
|
window.open('http://dev.deluge-torrent.org/wiki/Plugins');
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotAvailablePlugins: function(plugins) {
|
onGotPlugins: function(plugins) {
|
||||||
this.availablePlugins = plugins;
|
this.enabledPlugins = plugins.enabled_plugins;
|
||||||
Deluge.Client.core.get_enabled_plugins({
|
this.availablePlugins = plugins.available_plugins;
|
||||||
success: this.onGotEnabledPlugins,
|
this.setInfo();
|
||||||
scope: this
|
this.updatePluginsGrid();
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onGotEnabledPlugins: function(plugins) {
|
|
||||||
this.enabledPlugins = plugins;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotPluginInfo: function(info) {
|
onGotPluginInfo: function(info) {
|
||||||
|
@ -200,6 +213,20 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
||||||
delete info;
|
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) {
|
onPluginSelect: function(selmodel, rowIndex, r) {
|
||||||
Deluge.Client.web.get_plugin_info(r.get('plugin'), {
|
Deluge.Client.web.get_plugin_info(r.get('plugin'), {
|
||||||
success: this.onGotPluginInfo,
|
success: this.onGotPluginInfo,
|
||||||
|
@ -208,24 +235,11 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onPreferencesShow: function() {
|
onPreferencesShow: function() {
|
||||||
Deluge.Client.core.get_available_plugins({
|
this.updatePlugins();
|
||||||
success: this.onGotAvailablePlugins,
|
|
||||||
scope: this
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onPluginInfoRender: function(ct, position) {
|
||||||
Ext.deluge.preferences.Plugins.superclass.onShow.call(this);
|
|
||||||
this.setInfo();
|
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());
|
Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());
|
Loading…
Add table
Add a link
Reference in a new issue