From 1b4669bb2f573cebf9cadfadd47766d0d2046b1a Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Fri, 28 Sep 2012 16:34:38 +0200 Subject: [PATCH 1/3] Stop cherrypy from complaining about a relative favicon path --- headphones/webstart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webstart.py b/headphones/webstart.py index b16d6765..0472a033 100644 --- a/headphones/webstart.py +++ b/headphones/webstart.py @@ -56,7 +56,7 @@ def initialize(options={}): }, '/favicon.ico':{ 'tools.staticfile.on': True, - 'tools.staticfile.filename': "images/favicon.ico" + 'tools.staticfile.filename': os.path.join(os.path.abspath(os.curdir),"images" + os.sep + "favicon.ico") }, '/cache':{ 'tools.staticdir.on': True, From a6c8a756f70e97337d8a77e29c0b0de6322a1301 Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Fri, 28 Sep 2012 18:00:36 +0200 Subject: [PATCH 2/3] Changed Logs page to use ajax for retrieving log messages as needed instead of getting all at the start and freezing the browser --- data/interfaces/default/logs.html | 56 ++++++++++++++++--------------- headphones/webserve.py | 32 ++++++++++++++++++ 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/data/interfaces/default/logs.html b/data/interfaces/default/logs.html index 022be43e..84bdc1f9 100644 --- a/data/interfaces/default/logs.html +++ b/data/interfaces/default/logs.html @@ -16,21 +16,6 @@ lossless<%inherit file="base.html"/> - %for line in lineList: - <% - timestamp, message, level, threadname = line - - if level == 'WARNING' or level == 'ERROR': - grade = 'X' - else: - grade = 'Z' - %> - - ${timestamp} - ${level} - ${message} - - %endfor @@ -42,22 +27,39 @@ lossless<%inherit file="base.html"/> <%def name="javascriptIncludes()"> \ No newline at end of file diff --git a/headphones/webserve.py b/headphones/webserve.py index 799d84f3..59718b9e 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -394,6 +394,38 @@ class WebInterface(object): return serve_template(templatename="logs.html", title="Log", lineList=headphones.LOG_LIST) logs.exposed = True + + def getLog(self,iDisplayStart=0,iDisplayLength=100,iSortCol_0=0,iSortCol_1=0,iSortCol_2=0, + sSortDir_0="desc",sSortDir_1="desc",sSortDir_2="desc", + sSearch="",**kwargs): + + iDisplayStart = int(iDisplayStart) + iDisplayLength = int(iDisplayLength) + + filtered = [] + if sSearch == "": + filtered = headphones.LOG_LIST[::] + else: + filtered = [row for row in headphones.LOG_LIST for column in row if sSearch in column] + + sortcolumn = 0 + if iSortCol_0 == '1': + sortcolumn = 2 + elif iSortCol_0 == '2': + sortcolumn = 1 + filtered.sort(key=lambda x:x[sortcolumn],reverse=sSortDir_0 == "desc") + + rows = filtered[iDisplayStart:(iDisplayStart+iDisplayLength)] + rows = [[row[0],row[2],row[1]] for row in rows] + + dict = {'iTotalDisplayRecords':len(filtered), + 'iTotalRecords':len(headphones.LOG_LIST), + 'aaData':rows, + } + s = simplejson.dumps(dict) + return s + getLog.exposed = True + def clearhistory(self, type=None): myDB = db.DBConnection() if type == 'all': From 18d75db4233df7f38618403b58896fefb302a62e Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Fri, 28 Sep 2012 18:12:01 +0200 Subject: [PATCH 3/3] Removed unnecessary getLog parameters --- headphones/webserve.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 59718b9e..f193cd00 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -395,9 +395,7 @@ class WebInterface(object): logs.exposed = True - def getLog(self,iDisplayStart=0,iDisplayLength=100,iSortCol_0=0,iSortCol_1=0,iSortCol_2=0, - sSortDir_0="desc",sSortDir_1="desc",sSortDir_2="desc", - sSearch="",**kwargs): + def getLog(self,iDisplayStart=0,iDisplayLength=100,iSortCol_0=0,sSortDir_0="desc",sSearch="",**kwargs): iDisplayStart = int(iDisplayStart) iDisplayLength = int(iDisplayLength)