New way to display global statistics : with links in months names instead of "Details" button
Fix Months name not translated in "By Day" corner
This commit is contained in:
parent
21a21cd68f
commit
cb18cf928e
|
@ -39,6 +39,9 @@ class DisplayHTMLRaw(object):
|
|||
self.iwla = iwla
|
||||
self.html = html
|
||||
|
||||
def resetHTML(self):
|
||||
self.html = ''
|
||||
|
||||
def setRawHTML(self, html):
|
||||
self.html = html
|
||||
|
||||
|
|
36
iwla.py
36
iwla.py
|
@ -458,14 +458,16 @@ class IWLA(object):
|
|||
link = DisplayHTMLRaw(self, '<iframe src="../_stats.html"></iframe>')
|
||||
page.appendBlock(link)
|
||||
|
||||
months_name = ['', self._('Jan'), self._('Feb'), self._('Mar'), self._('Apr'), self._('May'), self._('June'), self._('Jul'), self._('Aug'), self._('Sep'), self._('Oct'), self._('Nov'), self._('Dec')]
|
||||
_, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon)
|
||||
days = self.display.createBlock(DisplayHTMLBlockTableWithGraph, self._('By day'), [self._('Day'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth')], None, nb_month_days, range(1,6), [4, 5])
|
||||
days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
|
||||
nb_visits = 0
|
||||
nb_days = 0
|
||||
for i in range(1, nb_month_days+1):
|
||||
day = '%d<br/>%s' % (i, time.strftime('%b', cur_time))
|
||||
full_day = '%02d %s %d' % (i, time.strftime('%b', cur_time), cur_time.tm_year)
|
||||
month = months_name[int(time.strftime('%m', cur_time), 10)]
|
||||
day = '%d<br/>%s' % (i, month)
|
||||
full_day = '%02d %s %d' % (i, month, 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_visits'], stats['viewed_pages'], stats['viewed_hits'],
|
||||
|
@ -510,52 +512,40 @@ class IWLA(object):
|
|||
cur_time = time.localtime()
|
||||
months_name = ['', self._('Jan'), self._('Feb'), self._('Mar'), self._('Apr'), self._('May'), self._('June'), self._('Jul'), self._('Aug'), self._('Sep'), self._('Oct'), self._('Nov'), self._('Dec')]
|
||||
title = '%s %d' % (self._('Summary'), year)
|
||||
cols = [self._('Month'), self._('Visitors'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth'), self._('Details')]
|
||||
graph_cols=range(1,7)
|
||||
cols = [self._('Month'), self._('Visitors'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth')]
|
||||
graph_cols=range(1,6)
|
||||
months = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols, None, 12, graph_cols, [5, 6])
|
||||
months.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth', ''])
|
||||
months_ = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols[:-1], None, 12, graph_cols[:-1], [5, 6])
|
||||
months_.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
|
||||
months.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
|
||||
total = [0] * len(cols)
|
||||
for i in range(1, 13):
|
||||
month = '%s<br/>%d' % (months_name[i], year)
|
||||
full_month = '%s %d' % (months_name[i], year)
|
||||
link_month = '<a target="_top" href="/%d/%02d/index.html">%s</a>' % (year, i, full_month)
|
||||
if i in month_stats.keys():
|
||||
stats = month_stats[i]
|
||||
link = '<a href="%d/%02d/index.html">%s</a>' % (year, i, self._('Details'))
|
||||
row = [full_month, stats['nb_visitors'], stats['nb_visits'], stats['viewed_pages'], stats['viewed_hits'],
|
||||
stats['viewed_bandwidth'], stats['not_viewed_bandwidth'], link]
|
||||
row = [link_month, stats['nb_visitors'], stats['nb_visits'], stats['viewed_pages'], stats['viewed_hits'],
|
||||
stats['viewed_bandwidth'], stats['not_viewed_bandwidth']]
|
||||
for j in graph_cols:
|
||||
total[j] += row[j]
|
||||
else:
|
||||
row = [full_month, 0, 0, 0, 0, 0, 0, '']
|
||||
row = [full_month, 0, 0, 0, 0, 0, 0]
|
||||
months.appendRow(row)
|
||||
viewed_bandwidth = row[5]
|
||||
not_viewed_bandwidth = row[6]
|
||||
months.setCellValue(i-1, 5, viewed_bandwidth)
|
||||
months.setCellValue(i-1, 6, not_viewed_bandwidth)
|
||||
months.appendShortTitle(month)
|
||||
months_.appendRow(row[:-1])
|
||||
months_.setCellValue(i-1, 5, viewed_bandwidth)
|
||||
months_.setCellValue(i-1, 6, not_viewed_bandwidth)
|
||||
months_.appendShortTitle(month)
|
||||
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)
|
||||
months_.setCellCSSClass(i-1, 0, css)
|
||||
|
||||
total[0] = self._('Total')
|
||||
total[7] = u''
|
||||
months.appendRow(total)
|
||||
page.appendBlock(months)
|
||||
|
||||
months_.appendRow(total[:-1])
|
||||
filename = '%d/_stats.html' % (year)
|
||||
page_ = self.display.createPage(u'', filename, conf.css_path)
|
||||
page_.appendBlock(months_)
|
||||
page_.appendBlock(months)
|
||||
page_.build(conf.DISPLAY_ROOT, False)
|
||||
months.resetHTML()
|
||||
|
||||
def _generateDisplayWholeMonthStats(self):
|
||||
title = '%s %s' % (self._('Statistics for'), conf.domain_name)
|
||||
|
|
|
@ -68,6 +68,7 @@ td:first-child
|
|||
.iwla_search { background : #F4F090; }
|
||||
.iwla_weekend { background : #ECECEC; }
|
||||
.iwla_curday { font-weight: bold; }
|
||||
.iwla_curday > a { font-weight: bold; color:black}
|
||||
.iwla_others { color: #668; }
|
||||
.iwla_update { background : orange; }
|
||||
.iwla_new { background : green }
|
||||
|
|
Loading…
Reference in New Issue
Block a user