From aa4c783601996f0c2eae6dba64e9c166fc1a549f Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 10 Jun 2009 16:37:21 +0000 Subject: [PATCH] tweak the setup script so the web plugin has the correct entry point implement the webui server side plugin add a page to the preferences window in the javascript --- .../scheduler/scheduler/data/scheduler.js | 92 +++++++++++++++++++ deluge/plugins/scheduler/scheduler/webui.py | 18 +++- deluge/plugins/scheduler/setup.py | 2 +- 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 deluge/plugins/scheduler/scheduler/data/scheduler.js diff --git a/deluge/plugins/scheduler/scheduler/data/scheduler.js b/deluge/plugins/scheduler/scheduler/data/scheduler.js new file mode 100644 index 000000000..6a9d9790a --- /dev/null +++ b/deluge/plugins/scheduler/scheduler/data/scheduler.js @@ -0,0 +1,92 @@ +(function() { + function createEl(parent, type) { + var el = document.createElement(type); + parent.appendChild(el); + return el; + } + + var DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']; + + ScheduleSelectPanel = Ext.extend(Ext.form.FieldSet, { + constructor: function(config) { + config = Ext.apply({ + title: _('Schedule'), + autoHeight: true + }, config); + ScheduleSelectPanel.superclass.constructor.call(this, config); + }, + + onRender: function(ct, position) { + ScheduleSelectPanel.superclass.onRender.call(this, ct, position); + + var dom = this.body.dom; + var table = createEl(dom, 'table'); + + Ext.each(DAYS, function(day) { + var row = createEl(table, 'tr'); + var label = createEl(row, 'th'); + label.setAttribute('style', 'font-weight: bold; padding-right: 5px;'); + label.innerHTML = day; + for (var hour = 0; hour < 24; hour++) { + var cell = createEl(row, 'td'); + cell.setAttribute('style', 'border: 1px solid Green; width: 16px; height: 20px; background: LightGreen;'); + } + }); + } + }); + + SchedulerPreferences = Ext.extend(Ext.Panel, { + constructor: function(config) { + config = Ext.apply({ + border: false, + title: _('Scheduler') + }, config); + SchedulerPreferences.superclass.constructor.call(this, config); + }, + + initComponent: function() { + SchedulerPreferences.superclass.initComponent.call(this); + + this.form = this.add({ + xtype: 'form', + layout: 'form', + border: false, + autoHeight: true + }); + + this.schedule = this.form.add(new ScheduleSelectPanel()); + + this.slowSettings = this.form.add({ + xtype: 'fieldset', + title: _('Slow Settings'), + autoHeight: true, + defaultType: 'uxspinner' + }); + + this.downloadLimit = this.slowSettings.add({ + fieldLabel: _('Download Limit'), + name: 'download_limit' + }); + this.uploadLimit = this.slowSettings.add({ + fieldLabel: _('Upload Limit'), + name: 'upload_limit' + }); + this.activeTorrents = this.slowSettings.add({ + fieldLabel: _('Active Torrents'), + name: 'active_torrents' + }); + }, + + onRender: function(ct, position) { + SchedulerPreferences.superclass.onRender.call(this, ct, position); + this.form.layout = new Ext.layout.FormLayout(); + this.form.layout.setContainer(this); + this.form.doLayout(); + }, + + onShow: function() { + SchedulerPreferences.superclass.onShow.call(this); + } + }); + Deluge.Preferences.addPage(new SchedulerPreferences()); +})(); \ No newline at end of file diff --git a/deluge/plugins/scheduler/scheduler/webui.py b/deluge/plugins/scheduler/scheduler/webui.py index de1b5fdff..9f28d582f 100644 --- a/deluge/plugins/scheduler/scheduler/webui.py +++ b/deluge/plugins/scheduler/scheduler/webui.py @@ -36,14 +36,26 @@ # statement from all source files in the program, then also delete it here. # +import pkg_resources + from deluge.log import LOG as log from deluge.ui.client import client from deluge import component from deluge.plugins.pluginbase import WebPluginBase +from common import get_resource + class WebUI(WebPluginBase): def enable(self): - pass + deluge_web = component.get("DelugeWeb").top_level + deluge_web.add_script("/js/scheduler.js") + + javascript = component.get("Javascript").directories + javascript.append(get_resource("")) - def disable(self): - pass + def disable(self): + deluge_web = component.get("DelugeWeb").top_level + deluge_web.remove_script("/js/scheduler.js") + + javascript = component.get("Javascript").directories + javascript.remove(get_resource("")) diff --git a/deluge/plugins/scheduler/setup.py b/deluge/plugins/scheduler/setup.py index b5abee686..0746e4681 100644 --- a/deluge/plugins/scheduler/setup.py +++ b/deluge/plugins/scheduler/setup.py @@ -66,7 +66,7 @@ setup( %s = %s:CorePlugin [deluge.plugin.gtkui] %s = %s:GtkUIPlugin - [deluge.plugin.webui] + [deluge.plugin.web] %s = %s:WebUIPlugin """ % ((__plugin_name__, __plugin_name__.lower())*3) )