[%
PROCESS inputs;
PROCESS class_manip;
PROCESS widget_manip;
PROCESS logic_header.ttk;
pagetype = CGI.param('detail');
templates = DBI.tie('reporter.stage2', 'id')
reports = DBI.tie('reporter.stage3', 'id')
outputs = DBI.tie('reporter.output', 'id')
%] [%
SWITCH pagetype;
CASE 'myreports';
INCLUDE header.ttk title="Reporter Dashboard -- Completed Reports";
INCLUDE navbar.ttk + my_scheduled_reports;
CASE 'mycompletereports';
INCLUDE header.ttk title="Reporter Dashboard -- Completed Reports";
INCLUDE navbar.ttk + my_completed_reports;
CASE 'report_template_tree';
INCLUDE header.ttk title="Reporter Dashboard -- Schedule a report";
INCLUDE navbar.ttk + report_template_tree;
CASE;
INCLUDE header.ttk title="Reporter Dashboard";
INCLUDE navbar.ttk + summary;
END;
PROCESS logout.ttk;
BLOCK summary;
WRAPPER html/table border=0 width='100%';
WRAPPER html/row;
INCLUDE html/cell
colspan=2
align='center'
content=link(content='Schedule a new report',href='bradboard?detail=report_template_tree')
style='border-bottom:1px solid black';
END;
WRAPPER html/row;
WRAPPER html/cell colspan=2 valign='top';
INCLUDE report_template_tree;
'
';
END;
END;
WRAPPER html/row;
INCLUDE html/cell
content=link(content='Completed reports',href='bradboard?detail=mycompletereports')
align='center'
style='border-bottom:1px solid black';
END;
WRAPPER html/row;
WRAPPER html/cell valign='top' style='height:200px';
INCLUDE my_completed_reports limit=5;
END;
END;
WRAPPER html/row;
INCLUDE html/cell
content=link(content='Manage scheduled reports',href='bradboard?detail=myreports')
align='center'
style='border-bottom:1px solid black';
END;
WRAPPER html/row;
WRAPPER html/cell valign='top' style='height:200px';
INCLUDE my_scheduled_reports limit=5;
END;
END;
END;
END;
BLOCK my_completed_reports;
q = "SELECT o.* FROM reporter.stage3 s JOIN reporter.output o ON (o.stage3 = s.id) WHERE s.owner = " _ user.id() _
" ORDER BY COALESCE(o.complete_time, o.error_time, o.run_time, o.queue_time) DESC";
IF limit > 0;
q = q _ ' LIMIT ' _ limit;
END;
logme(q);
INCLUDE show_complete_reports;
END;
BLOCK my_scheduled_reports;
q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _
" AND runtime > now() ORDER BY runtime DESC";
IF limit > 0;
q = q _ ' LIMIT ' _ limit;
END;
logme(q);
INCLUDE show_reports;
END;
BLOCK show_complete_reports;
WRAPPER html/table width='100%';
WRAPPER html/row;
INCLUDE html/cell content='Run status' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Report name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Run time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
END;
FOR output = DBI.query(q);
rid = output.stage3;
bg='lightblue';
IF loop.count % 2;
bg='white';
END;
report = reports.$rid;
p = utils.JSON2perl( report.params );
state = 'Waiting in line...';
IF output.state == 'complete';
state = 'Complete';
runtime = output.complete_time;
ELSIF output.state == 'error';
state = 'ERROR';
runtime = output.error_time;
ELSIF output.state == 'running';
state = 'Running';
runtime = output.run_time;
END;
WRAPPER html/row;
INCLUDE html/cell
width='5%'
nowrap='nowrap'
content=state
col=bg
style='padding:5px; border:solid gray 1px;';
INCLUDE html/cell
content=link(content=p.reportname,href="stage3?id=$rid#$output.id")
col=bg
style='border:solid gray 1px;';
INCLUDE html/cell
nowrap='nowrap'
content=runtime.chunk(19).0
col=bg
style='border:solid gray 1px;';
END;
END;
END;
END;
BLOCK show_reports;
WRAPPER html/table width='100%';
WRAPPER html/row;
INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Report name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Create date and time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Scheduled run time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Number of runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
END;
FOR report = DBI.query(q);
rid = report.id;
bg='lightblue';
IF loop.count % 2;
bg='white';
END;
run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
s = DBI.prepare(run_count_q);
run_count = s.execute(rid);
s = DBI.prepare(run_q);
run = s.execute(rid);
WRAPPER html/row;
p = utils.JSON2perl( report.params );
INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(19).0 col=bg style='border:solid gray 1px;';
INCLUDE html/cell
nowrap='nowrap'
content=report.runtime.chunk(19).0
col=bg
style='border:solid gray 1px;';
INCLUDE html/cell content=run_count.get.count col=bg style='border:solid gray 1px;';
END;
END;
END;
END;
BLOCK my_templates;
q = "SELECT * FROM reporter.stage2 WHERE " _
" owner = " _ user.id() _ " ORDER BY create_date DESC";
IF limit > 0;
q = q _ ' LIMIT ' _ limit;
END;
logme(q);
INCLUDE show_templates;
END;
BLOCK public_templates;
q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
" and owner != " _ user.id() _ " ORDER BY create_date DESC";
IF limit > 0;
q = q _ ' LIMIT ' _ limit;
END;
logme(q);
INCLUDE show_templates;
END;
BLOCK show_templates;
WRAPPER html/table width='100%' class='withborder';
WRAPPER html/row;
INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
END;
FOR template = DBI.query(q);
tid = template.id;
bg='lightblue';
IF loop.count % 2;
bg='white';
END;
WRAPPER html/row;
p = utils.JSON2perl( template.params );
INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
END;
END;
END;
END;
BLOCK report_template_tree;
fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
FOR tab = config.findnodes(fact_table_xpath);
counter = loop.count
tid = tab.findvalue('@id');
tname = tab.findvalue('label');
tdesc = tab.findvalue('description');
"