diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/web/media/default/css/log.css | 5 | ||||
-rw-r--r-- | module/web/pyload/views.py | 44 | ||||
-rw-r--r-- | module/web/templates/default/logs.html | 9 |
3 files changed, 42 insertions, 16 deletions
diff --git a/module/web/media/default/css/log.css b/module/web/media/default/css/log.css index bf410d45a..73786bfb4 100644 --- a/module/web/media/default/css/log.css +++ b/module/web/media/default/css/log.css @@ -64,4 +64,9 @@ td.loglevel .logpaginator a { padding: 0px 8px 0px 8px; +} +.logwarn +{ + text-align: center; + color: red; }
\ No newline at end of file diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 4d247246a..2c58f021a 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -174,8 +174,15 @@ def download(request, path): @check_server def logs(request, item=-1): - perpage = request.session.get('perpage', 40); - perpage_p = {20:20, 40: 40, 100: 100, 0:'all'} + perpage = request.session.get('perpage', 34); + reversed = request.session.get('reversed', False); + + warning = "" + conf = settings.PYLOAD.get_config() + if not conf['log']['file_log']['value']: + warning = "Warning: File log is disabled, see settings page." + + perpage_p = ((20,20), (34, 34), (40, 40), (100, 100), (0,'all')) fro = None; if request.method == 'POST': @@ -186,8 +193,12 @@ def logs(request, item=-1): try: perpage = int(request.POST['perpage']) request.session['perpage'] = perpage + + reversed = bool(request.POST.get('reversed', False)) + request.session['reversed'] = reversed except: pass + try: item = int(item) except: @@ -197,28 +208,35 @@ def logs(request, item=-1): if perpage == 0: item = 0 - if item < 0 or type(item) is not int: - item = len(log) - perpage + if item < 1 or type(item) is not int: + item = len(log) - perpage + 1 + + if type(fro) is datetime: # we will search for datetime + item = -1 + data = [] counter = 0 perpagecheck = 0 for l in log: counter = counter+1; - try: - date,time,level,message = l.split(" ", 3) - except: - continue + if counter >= item: + date,time,level,message = l.split(" ", 3) dtime = datetime.strptime(date+' '+time, '%d.%m.%Y %H:%M:%S') - if fro == None: - fro = dtime - if fro <= dtime: + + if item == -1 and fro <= dtime: + item = counter #found our datetime + if item >= 0: data.append({'line': counter, 'date': date+" "+time, 'level':level, 'message': message}) perpagecheck = perpagecheck +1; + if fro == None: #if fro not set set it to first showed line + fro = dtime; if perpagecheck >= perpage and perpage > 0: break - - return render_to_response(join(settings.TEMPLATE, 'logs.html'), RequestContext(request, {'log': data, 'from': fro.strftime('%d.%m.%Y %H:%M:%S'), 'perpage':perpage, 'perpage_p':perpage_p, 'iprev': 0 if item - perpage < 0 else item - perpage, 'inext': (item + perpage) if item+perpage < len(log) else len(log)-perpage}, [status_proc])) + + if reversed: + data.reverse() + return render_to_response(join(settings.TEMPLATE, 'logs.html'), RequestContext(request, {'warning': warning, 'log': data, 'from': fro.strftime('%d.%m.%Y %H:%M:%S'), 'reversed': reversed, 'perpage':perpage, 'perpage_p':sorted(perpage_p), 'iprev': 1 if item - perpage < 1 else item - perpage, 'inext': (item + perpage) if item+perpage < len(log) else item}, [status_proc])) @login_required @permission('pyload.can_add_dl') diff --git a/module/web/templates/default/logs.html b/module/web/templates/default/logs.html index 2bf626769..5da99912f 100644 --- a/module/web/templates/default/logs.html +++ b/module/web/templates/default/logs.html @@ -30,17 +30,20 @@ {% block content %} <div style="clear: both;"></div> -<div class="logpaginator"><a href="{% url logs 0%}"><< {% trans "Start" %}</a> <a href="{% url logs iprev %}">< {% trans "prev" %}</a> <a href="{% url logs inext %}">{% trans "next" %} ></a> <a href="{% url logs %}">{% trans "End" %} >></a></div> +<div class="logpaginator"><a href="{% url logs 1%}"><< {% trans "Start" %}</a> <a href="{% url logs iprev %}">< {% trans "prev" %}</a> <a href="{% url logs inext %}">{% trans "next" %} ></a> <a href="{% url logs %}">{% trans "End" %} >></a></div> <div class="logperpage"> <form id="logform1" action="" method="POST"> + <label for="reversed">Reversed:</label> + <input type="checkbox" name="reversed" onchange="this.form.submit();" {% if reversed %} checked="checked" {% endif %} /> <label for="perpage">Lines per page:</label> <select name="perpage" onchange="this.form.submit();"> - {% for value,text in perpage_p.iteritems %} - <option value="{{value}}"{% ifequal value perpage %} selected="selected" {% endifequal %}>{{text}}</option> + {% for value in perpage_p %} + <option value="{{value.0}}"{% ifequal value.0 perpage %} selected="selected" {% endifequal %}>{{value.1}}</option> {% endfor %} </select> </form> </div> +<div class="logwarn">{{warning}}</div> <div style="clear: both;"></div> <div class="logdiv"> <table class="logtable" cellpadding="0" cellspacing="0"> |