6 PROCESS logic_header.ttk;
8 pagetype = CGI.param('detail');
9 templates = DBI.tie('reporter.stage2', 'id')
10 reports = DBI.tie('reporter.stage3', 'id')
11 outputs = DBI.tie('reporter.output', 'id')
14 %] <style> table {border-collapse:collapse;}</style> [%
18 INCLUDE header.ttk title="Reporter Dashboard -- Completed Reports";
19 INCLUDE navbar.ttk + my_scheduled_reports;
20 CASE 'mycompletereports';
21 INCLUDE header.ttk title="Reporter Dashboard -- Completed Reports";
22 INCLUDE navbar.ttk + my_completed_reports;
23 CASE 'report_template_tree';
24 INCLUDE header.ttk title="Reporter Dashboard -- Schedule a report";
25 INCLUDE navbar.ttk + report_template_tree;
27 INCLUDE header.ttk title="Reporter Dashboard";
28 INCLUDE navbar.ttk + summary;
34 WRAPPER html/table border=0 width='100%';
39 content=link(content='Schedule a new report',href='bradboard?detail=report_template_tree')
40 style='border-bottom:1px solid black';
43 WRAPPER html/cell colspan=2 valign='top';
44 INCLUDE report_template_tree;
50 content=link(content='Completed reports',href='bradboard?detail=mycompletereports')
52 style='border-bottom:1px solid black';
55 WRAPPER html/cell valign='top' style='height:200px';
56 INCLUDE my_completed_reports limit=5;
61 content=link(content='Manage scheduled reports',href='bradboard?detail=myreports')
63 style='border-bottom:1px solid black';
66 WRAPPER html/cell valign='top' style='height:200px';
67 INCLUDE my_scheduled_reports limit=5;
73 BLOCK my_completed_reports;
74 q = "SELECT o.* FROM reporter.stage3 s JOIN reporter.output o ON (o.stage3 = s.id) WHERE s.owner = " _ user.id() _
75 " ORDER BY COALESCE(o.complete_time, o.error_time, o.run_time, o.queue_time) DESC";
77 q = q _ ' LIMIT ' _ limit;
82 INCLUDE show_complete_reports;
86 BLOCK my_scheduled_reports;
87 q = "SELECT * FROM reporter.stage3 WHERE owner = " _ user.id() _
88 " AND runtime > now() ORDER BY runtime DESC";
90 q = q _ ' LIMIT ' _ limit;
99 BLOCK show_complete_reports;
100 WRAPPER html/table width='100%';
102 INCLUDE html/cell content='Run status' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
103 INCLUDE html/cell content='Report name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
104 INCLUDE html/cell content='Run time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
106 FOR output = DBI.query(q);
114 report = reports.$rid;
115 p = utils.JSON2perl( report.params );
117 state = '<span style="font-weight: bold; background-color: lightgray">Waiting in line...</span>';
119 IF output.state == 'complete';
120 state = '<span style="font-weight: bold; background-color: lightgreen">Complete</span>';
121 runtime = output.complete_time;
122 ELSIF output.state == 'error';
123 state = '<span style="font-weight: bold; background-color: lightred">ERROR</span>';
124 runtime = output.error_time;
125 ELSIF output.state == 'running';
126 state = '<span style="font-weight: bold; background-color: lightblue">Running</span>';
127 runtime = output.run_time;
136 style='padding:5px; border:solid gray 1px;';
138 content=link(content=p.reportname,href="stage3?id=$rid#$output.id")
140 style='border:solid gray 1px;';
143 content=runtime.chunk(19).0
145 style='border:solid gray 1px;';
153 WRAPPER html/table width='100%';
155 INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
156 INCLUDE html/cell content='Report name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
157 INCLUDE html/cell content='Create date and time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
158 INCLUDE html/cell content='Scheduled run time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
159 INCLUDE html/cell content='Number of runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
161 FOR report = DBI.query(q);
167 run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
168 run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
170 s = DBI.prepare(run_count_q);
171 run_count = s.execute(rid);
173 s = DBI.prepare(run_q);
174 run = s.execute(rid);
177 p = utils.JSON2perl( report.params );
178 INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
179 INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
180 INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(19).0 col=bg style='border:solid gray 1px;';
183 content=report.runtime.chunk(19).0
185 style='border:solid gray 1px;';
186 INCLUDE html/cell content=run_count.get.count col=bg style='border:solid gray 1px;';
193 q = "SELECT * FROM reporter.stage2 WHERE " _
194 " owner = " _ user.id() _ " ORDER BY create_date DESC";
196 q = q _ ' LIMIT ' _ limit;
201 INCLUDE show_templates;
205 BLOCK public_templates;
206 q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
207 " and owner != " _ user.id() _ " ORDER BY create_date DESC";
209 q = q _ ' LIMIT ' _ limit;
214 INCLUDE show_templates;
218 BLOCK show_templates;
219 WRAPPER html/table width='100%' class='withborder';
221 INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
222 INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
223 INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
225 FOR template = DBI.query(q);
232 p = utils.JSON2perl( template.params );
233 INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
234 INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
235 INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
241 BLOCK report_template_tree;
243 fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
245 FOR tab = config.findnodes(fact_table_xpath);
247 tid = tab.findvalue('@id');
248 tname = tab.findvalue('label');
249 tdesc = tab.findvalue('description');
250 "<div id='fact_tree_$counter'/>";
251 content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
252 "<script language='javascript'>
253 var tree_$counter = new SlimTree(document.getElementById('fact_tree_$counter'),'tree_$counter');
254 tree_" _ counter _ ".addNode($counter,-1,'$tname','stage1?create_stage2=1&id=$tid','$tdesc');
257 q = "SELECT * FROM reporter.stage2 WHERE (pub is true" _
258 " or owner = " _ user.id() _ ") and stage1 = '$tid' ORDER BY create_date DESC";
260 FOR template = DBI.query(q);
261 p = utils.JSON2perl( template.params );
263 "<script language='javascript'>
264 tree_" _ counter _ ".addNode(
268 'stage2?action=run&id=$s2id',