javascript auto-refresh

This commit is contained in:
Martijn Voncken 2008-11-05 21:53:11 +00:00
parent 040337982f
commit 80318855f9
11 changed files with 58 additions and 46 deletions

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -4,8 +4,8 @@ $def with (title, active_tab="NONE")
<title>Deluge:$title</title>
<link rel="icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
<link rel="shortcut icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
<link rel="stylesheet" type="text/css" href="$base/static/simple_site_style.css" />
<script language="javascript" src="$base/static/deluge.js"></script>
<link rel="stylesheet" type="text/css" href="$base/static/simple_site_style.css" />
</head>
<body>

View file

@ -53,10 +53,20 @@ $for torrent in torrent_list:
<div class="panel">
<table><tr><td>
$: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')
<!--$:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png')-->
</td>
<td>
$if is_auto_refreshed:
<div style="width:120px;height:20px;overflow:hidden;align:left;text-align:left;padding-left:20px;">
$:render.part_auto_refresh()
</div>
</td>
</tr></table>
</div>
$:part_stats()

View file

@ -0,0 +1,24 @@
<script language="javascript" src="$base/static/refresh.js"></script>
<div class="progress_bar_outer"
id = "timer_outer"
style="width:100px;background-color:#EEE;margin-top:3px;"
title="$_('Auto Refresh')"
onclick="toggle_timer()"
>
<div id="timer_bar" class="progress_bar" style="width:0%" style="text-align:left">
<img src="$base/static/images/tango/pause.png" id="timer_pause" >
<img src="$base/static/images/tango/view-refresh.png" id="timer_start" style="display:none">
&nbsp;
</div>
</div>
<script language="javascript">
refresh_secs = $get_config("refresh_secs")
if (getCookie('auto_refresh') == "1") {
start_timer();
}
else {
stop_timer();
}
</script>

View file

@ -1,22 +1,6 @@
$def with (stats)
<div class="panel" id='refresh_panel'>
$_('Auto refresh:')
$if getcookie('auto_refresh') == '1':
($getcookie('auto_refresh_secs')) $_('seconds') &nbsp;
$:render.part_button('GET', '/refresh/set', _('Set'), 'tango/preferences-system.png')
$:render.part_button('POST', '/refresh/off', _('Disable'), 'tango/process-stop.png')
$else:
$_('Off') &nbsp;
$:render.part_button('POST', '/refresh/on', _('Enable'), 'tango/view-refresh.png')
$#end
$:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png')
</div>
<div class="panel" id='stats_panel'>
$_('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')
</div>

View file

@ -38,8 +38,9 @@ $for id, title, url in admin_pages:
<a href="http://dev.deluge-torrent.org/wiki/Faq">Faq</a>
</div>
</td><td align="right">
$#:render.part_auto_refresh()
</td><td align="left">
$if is_auto_refreshed:
$:render.part_auto_refresh()
</td><td>

View file

@ -1,16 +0,0 @@
<div class="panel" id='refresh_panel'>
[
$_('Auto refresh:')
$if getcookie('auto_refresh') == '1':
($getcookie('auto_refresh_secs')) $_('seconds') &nbsp;
<a href="$base/refresh/set">$_('Set')</a>
<a href="$base/refresh/off">$_('Disable')</a><!--WRONG, setting things on a GET-->
$else:
$_('Off') &nbsp;
<a href="$base/refresh/on">$_('Enable')</a><!--WRONG, setting things on a GET-->
]
<a href="$base/config/">$_('Admin') </a>&nbsp;
</div>

View file

@ -60,5 +60,6 @@ CONFIG_DEFAULTS = {
"cache_templates":True,
"daemon":"http://localhost:58846",
"base":"",
"disallow":{}
"disallow":{},
"refresh_secs":10
}