diff --git a/ChangeLog b/ChangeLog index 0ba23a608..bf00c80a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,9 @@ Deluge 1.0.4 (31 October 2008) Windows: * Fix starting on non-English versions of Windows +WebUi: + * Javascript auto refresh for both templates. + Deluge 1.0.3 (18 October 2008) Core: * Fix upnp - it should work on more routers now too diff --git a/deluge/ui/webui/config_tabs_webui.py b/deluge/ui/webui/config_tabs_webui.py index e6a99e483..fe25956c6 100644 --- a/deluge/ui/webui/config_tabs_webui.py +++ b/deluge/ui/webui/config_tabs_webui.py @@ -52,6 +52,7 @@ class Template(config_forms.WebCfgForm): template = forms.ChoiceField( label=_("Template"), choices = _templates) button_style = forms.IntChoiceField(_("Button style"),_button_choices) + refresh_secs = forms.IntegerField(label=_("Auto refresh (seconds)"), min_value=2, max_value=60*60) cache_templates = forms.CheckBox(_("Cache templates")) def post_save(self): diff --git a/deluge/ui/webui/page_decorators.py b/deluge/ui/webui/page_decorators.py index a200a02aa..741dec41c 100644 --- a/deluge/ui/webui/page_decorators.py +++ b/deluge/ui/webui/page_decorators.py @@ -20,10 +20,11 @@ def deluge_page_noauth(func): add http headers;print result of func """ def deco(self, name = None): - web.header("Content-Type", "text/html; charset=utf-8") - web.header("Cache-Control", "no-cache, must-revalidate") - res = func(self, name) #deluge_page_noauth - print res + render.set_global("is_auto_refreshed", False); + web.header("Content-Type", "text/html; charset=utf-8") + web.header("Cache-Control", "no-cache, must-revalidate") + res = func(self, name) #deluge_page_noauth + print res deco.__name__ = func.__name__ return deco @@ -112,11 +113,12 @@ def torrent(func): return deco def auto_refreshed(func): - "adds a refresh header" + """" + sets 'is_auto_refreshed' global for templates + note : decorate AFTER deluge_page_* + """ def deco(self, name = None): - if getcookie('auto_refresh') == '1': - web.header("Refresh", "%i ; url=%s" % - (int(getcookie('auto_refresh_secs',10)),self_url())) + render.set_global("is_auto_refreshed", True); return func(self, name) #auto_refreshed deco.__name__ = func.__name__ return deco diff --git a/deluge/ui/webui/render.py b/deluge/ui/webui/render.py index d0ec65a7d..ec2913a09 100644 --- a/deluge/ui/webui/render.py +++ b/deluge/ui/webui/render.py @@ -205,7 +205,8 @@ template.Template.globals.update({ #'env':'0.6', 'forms':web.Storage(), 'enumerate':enumerate, - 'base':'' #updated when running within apache. + 'base':'', #updated when running within apache. + 'is_auto_refreshed':False }) #/template-defs diff --git a/deluge/ui/webui/templates/classic/header.html b/deluge/ui/webui/templates/classic/header.html index eff4c8dd5..78d6e208d 100644 --- a/deluge/ui/webui/templates/classic/header.html +++ b/deluge/ui/webui/templates/classic/header.html @@ -4,8 +4,8 @@ $def with (title, active_tab="NONE") Deluge:$title - - + + diff --git a/deluge/ui/webui/templates/classic/index.html b/deluge/ui/webui/templates/classic/index.html index 92f98e330..237ca0ec9 100644 --- a/deluge/ui/webui/templates/classic/index.html +++ b/deluge/ui/webui/templates/classic/index.html @@ -53,10 +53,20 @@ $for torrent in torrent_list:
+ + +
$:render.part_button('GET', '/torrent/add', _('Add torrent'), 'tango/list-add.png') $:render.part_button('POST', '/pause_all', _('Pause all'), 'tango/pause.png') $:render.part_button('POST', '/resume_all', _('Resume all'), 'tango/start.png') + +$if is_auto_refreshed: +
+ $:render.part_auto_refresh() +
+
+
$:part_stats() diff --git a/deluge/ui/webui/templates/classic/part_auto_refresh.html b/deluge/ui/webui/templates/classic/part_auto_refresh.html new file mode 100644 index 000000000..60a20be86 --- /dev/null +++ b/deluge/ui/webui/templates/classic/part_auto_refresh.html @@ -0,0 +1,24 @@ + +
+ +
+ + +   +
+
+ \ No newline at end of file diff --git a/deluge/ui/webui/templates/classic/part_stats.html b/deluge/ui/webui/templates/classic/part_stats.html index 04be706c6..167aa07a8 100644 --- a/deluge/ui/webui/templates/classic/part_stats.html +++ b/deluge/ui/webui/templates/classic/part_stats.html @@ -1,22 +1,6 @@ $def with (stats) -
- -$_('Auto refresh:') -$if getcookie('auto_refresh') == '1': - ($getcookie('auto_refresh_secs')) $_('seconds')   - $:render.part_button('GET', '/refresh/set', _('Set'), 'tango/preferences-system.png') - $:render.part_button('POST', '/refresh/off', _('Disable'), 'tango/process-stop.png') -$else: - $_('Off')   - $:render.part_button('POST', '/refresh/on', _('Enable'), 'tango/view-refresh.png') -$#end - -$:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png') - -
-
$_('Connections') : $stats.num_connections ($stats.max_num_connections) @@ -27,6 +11,7 @@ $:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png') $:render.part_button('GET', '/config/', _('Settings'), 'tango/preferences-system.png') + $:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png')
diff --git a/deluge/ui/webui/templates/white/header.html b/deluge/ui/webui/templates/white/header.html index 1614ced4a..c014ffd67 100644 --- a/deluge/ui/webui/templates/white/header.html +++ b/deluge/ui/webui/templates/white/header.html @@ -38,8 +38,9 @@ $for id, title, url in admin_pages: Faq - - $#:render.part_auto_refresh() + +$if is_auto_refreshed: + $:render.part_auto_refresh() diff --git a/deluge/ui/webui/templates/white/part_auto_refresh.html b/deluge/ui/webui/templates/white/part_auto_refresh.html deleted file mode 100644 index 7acb24a7c..000000000 --- a/deluge/ui/webui/templates/white/part_auto_refresh.html +++ /dev/null @@ -1,16 +0,0 @@ -
-[ -$_('Auto refresh:') -$if getcookie('auto_refresh') == '1': - ($getcookie('auto_refresh_secs')) $_('seconds')   - $_('Set') - $_('Disable') -$else: - $_('Off')   - $_('Enable') -] - - -$_('Admin')   - -
\ No newline at end of file diff --git a/deluge/ui/webui/webserver_common.py b/deluge/ui/webui/webserver_common.py index f899cef33..3c67a466c 100644 --- a/deluge/ui/webui/webserver_common.py +++ b/deluge/ui/webui/webserver_common.py @@ -60,5 +60,6 @@ CONFIG_DEFAULTS = { "cache_templates":True, "daemon":"http://localhost:58846", "base":"", - "disallow":{} + "disallow":{}, + "refresh_secs":10 }