diff --git a/display.py b/display.py index c3dc4e4..febb705 100644 --- a/display.py +++ b/display.py @@ -146,7 +146,7 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock): class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable): - def __init__(self, title, cols, short_titles=None, nb_valid_rows=0): + def __init__(self, title, cols, short_titles=None, nb_valid_rows=0, graph_cols=None): super(DisplayHTMLBlockTableWithGraph, self).__init__(title=title, cols=cols) self.short_titles = short_titles or [] self.nb_valid_rows = nb_valid_rows @@ -156,6 +156,8 @@ class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable): self.raw_rows = [] self.maxes = [0] * len(cols) self.table_graph_css = 'iwla_graph_table' + self.td_img_css = 'iwla_td_img' + self.graph_cols = graph_cols or [] def appendRow(self, row): self.raw_rows.append(row) @@ -196,8 +198,10 @@ class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable): html += '' for i in range(0, self.nb_valid_rows): row = self.rows[i] - html += '' - for j in range(1, len(row)): + css = '' + if self.td_img_css: css=' class="%s"' % (self.td_img_css) + html += '' % (css) + for j in self.graph_cols: style = self.getColCSSClass(j) icon = self._getIconFromStyle(style) if not icon: continue diff --git a/iwla.py b/iwla.py index 8fa6f0c..66acaf2 100755 --- a/iwla.py +++ b/iwla.py @@ -245,13 +245,13 @@ class IWLA(object): page = DisplayHTMLPage(title, filename, conf.css_path) _, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon) - days = DisplayHTMLBlockTableWithGraph('By day', ['Day', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'], nb_valid_rows=nb_month_days) + days = DisplayHTMLBlockTableWithGraph('By day', ['Day', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'], nb_valid_rows=nb_month_days, graph_cols=range(1,6)) days.setColsCSSClass(['', 'iwla_visitor', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth']) nb_visits = 0 nb_days = 0 - for i in range(0, nb_month_days): - day = '%d
%s' % (i+1, time.strftime('%b', cur_time)) - full_day = '%d %s %d' % (i+1, time.strftime('%b', cur_time), cur_time.tm_year) + for i in range(1, nb_month_days+1): + day = '%d
%s' % (i, time.strftime('%b', cur_time)) + full_day = '%d %s %d' % (i, time.strftime('%b', cur_time), cur_time.tm_year) if i in self.current_analysis['days_stats'].keys(): stats = self.current_analysis['days_stats'][i] row = [full_day, stats['nb_visitors'], stats['viewed_pages'], stats['viewed_hits'], @@ -261,18 +261,18 @@ class IWLA(object): else: row = [full_day, 0, 0, 0, 0, 0] days.appendRow(row) - days.setCellValue(i, 4, bytesToStr(row[4])) - days.setCellValue(i, 5, bytesToStr(row[5])) + days.setCellValue(i-1, 4, bytesToStr(row[4])) + days.setCellValue(i-1, 5, bytesToStr(row[5])) days.appendShortTitle(day) - adate = date(cur_time.tm_year, cur_time.tm_mon, i+1) + adate = date(cur_time.tm_year, cur_time.tm_mon, i) week_day = adate.weekday() if week_day == 5 or week_day == 6: - days.setRowCSSClass(i, 'iwla_weekend') + days.setRowCSSClass(i-1, 'iwla_weekend') if adate == date.today(): css = days.getCellCSSClass(i, 0) if css: css = '%s %s' % (css, 'iwla_curday') else: css = 'iwla_curday' - days.setCellCSSClass(i, 0, css) + days.setCellCSSClass(i-1, 0, css) stats = self.current_analysis['month_stats'] @@ -295,36 +295,35 @@ class IWLA(object): self.display.addPage(page) def _generateDisplayMonthStats(self, page, year, month_stats): - + cur_time = time.localtime() + months_name = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] title = 'Summary %d' % (year) - cols = ['Month', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'] - months = DisplayHTMLBlockTableWithGraph(title, cols, nb_valid_rows=12) - months.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth']) + cols = ['Month', 'Visitors', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth', 'Details'] + graph_cols=range(1,6) + months = DisplayHTMLBlockTableWithGraph(title, cols, nb_valid_rows=12, graph_cols=graph_cols) + months.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth', '']) total = [0] * len(cols) - for i in range(0, 12): - month = '%s
%d' % ('Jan', year) - full_month = '%s %d' % ('Jan', year) + for i in range(1, 13): + month = '%s
%d' % (months_name[i], year) + full_month = '%s %d' % (months_name[i], year) if i in month_stats.keys(): stats = month_stats[i] + link = 'Details' % (year, i) row = [full_month, stats['nb_visitors'], stats['viewed_pages'], stats['viewed_hits'], - stats['viewed_bandwidth'], stats['not_viewed_bandwidth']] - for i in range(1, len(row[1:])): - total[i] += row[i] + stats['viewed_bandwidth'], stats['not_viewed_bandwidth'], link] + for j in graph_cols: + total[j] += row[j] else: - row = [full_month, 0, 0, 0, 0, 0] + row = [full_month, 0, 0, 0, 0, 0, ''] months.appendRow(row) - months.setCellValue(i, 4, bytesToStr(row[4])) - months.setCellValue(i, 5, bytesToStr(row[5])) + months.setCellValue(i-1, 4, bytesToStr(row[4])) + months.setCellValue(i-1, 5, bytesToStr(row[5])) months.appendShortTitle(month) - # adate = date(cur_time.tm_year, cur_time.tm_mon, i+1) - # week_day = adate.weekday() - # if week_day == 5 or week_day == 6: - # months.setRowCSSClass(i, 'iwla_weekend') - # if adate == date.today(): - # css = months.getCellCSSClass(i, 0) - # if css: css = '%s %s' % (css, 'iwla_curday') - # else: css = 'iwla_curday' - # months.setCellCSSClass(i, 0, css) + if year == cur_time.tm_year and i == cur_time.tm_mon: + css = months.getCellCSSClass(i-1, 0) + if css: css = '%s %s' % (css, 'iwla_curday') + else: css = 'iwla_curday' + months.setCellCSSClass(i-1, 0, css) total[0] = 'Total' total[4] = bytesToStr(total[4]) diff --git a/resources/css/iwla.css b/resources/css/iwla.css index 6caeee3..5371769 100644 --- a/resources/css/iwla.css +++ b/resources/css/iwla.css @@ -20,7 +20,7 @@ body width: 60%; } -.iwla_block_title > a +a { font: 11px verdana, arial, helvetica, sans-serif; font-weight: normal; @@ -49,7 +49,7 @@ td vertical-align:middle; } -td img +.iwla_td_img { vertical-align:bottom; }