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 -- Scheduled 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;
117 template = templates.$tid;
119 p = utils.JSON2perl( report.params );
120 t = utils.JSON2perl( template.params );
122 state = '<span style="font-weight: bold; background-color: lightgray">Waiting in line...</span>';
124 IF output.state == 'complete';
125 state = '<span style="font-weight: bold; background-color: lightgreen">Complete</span>';
126 runtime = output.complete_time;
127 ELSIF output.state == 'error';
128 state = '<span style="font-weight: bold; background-color: lightred">ERROR</span>';
129 runtime = output.error_time;
130 ELSIF output.state == 'running';
131 state = '<span style="font-weight: bold; background-color: lightblue">Running</span>';
132 runtime = output.run_time;
135 name_link = link(content=p.reportname,href="stage3?id=$rid#$output.id");
136 name_link = t.templatename _ ' :: ' _ name_link;
144 style='padding:5px; border:solid gray 1px;';
148 style='border:solid gray 1px;';
151 content=runtime.chunk(19).0
153 style='border:solid gray 1px;';
161 WRAPPER html/table width='100%';
163 INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
164 INCLUDE html/cell content='Report name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
165 INCLUDE html/cell content='Create date and time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
166 INCLUDE html/cell content='Scheduled run time' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
167 INCLUDE html/cell content='Number of runs' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
169 FOR report = DBI.query(q);
175 run_q = 'SELECT * FROM reporter.output WHERE stage3 = ? ORDER BY queue_time LIMIT 1';
176 run_count_q = 'SELECT count(*) as count FROM reporter.output WHERE stage3 = ?';
178 s = DBI.prepare(run_count_q);
179 run_count = s.execute(rid);
181 s = DBI.prepare(run_q);
182 run = s.execute(rid);
185 p = utils.JSON2perl( report.params );
186 INCLUDE html/cell content=(report.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
187 INCLUDE html/cell content=link(content=p.reportname,href="stage3?id=$rid") col=bg style='border:solid gray 1px;';
188 INCLUDE html/cell nowrap='nowrap' content=report.create_date.chunk(19).0 col=bg style='border:solid gray 1px;';
191 content=report.runtime.chunk(19).0
193 style='border:solid gray 1px;';
194 INCLUDE html/cell content=run_count.get.count col=bg style='border:solid gray 1px;';
201 q = "SELECT * FROM reporter.stage2 WHERE " _
202 " owner = " _ user.id() _ " ORDER BY create_date DESC";
204 q = q _ ' LIMIT ' _ limit;
209 INCLUDE show_templates;
213 BLOCK public_templates;
214 q = "SELECT * FROM reporter.stage2 WHERE pub is true" _
215 " and owner != " _ user.id() _ " ORDER BY create_date DESC";
217 q = q _ ' LIMIT ' _ limit;
222 INCLUDE show_templates;
226 BLOCK show_templates;
227 WRAPPER html/table width='100%' class='withborder';
229 INCLUDE html/cell content='Public' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
230 INCLUDE html/cell content='Template Name' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
231 INCLUDE html/cell content='Created at' nowrap='nowrap' col='lightgray' style='border:solid gray 1px;';
233 FOR template = DBI.query(q);
240 p = utils.JSON2perl( template.params );
241 INCLUDE html/cell content=(template.pub ? 'Y' : 'N') col=bg style='border:solid gray 1px;' align='center';
242 INCLUDE html/cell content=link(content=p.templatename,href="stage2?id=$tid") col=bg style='border:solid gray 1px;';
243 INCLUDE html/cell content=template.create_date.chunk(10).0 col=bg style='border:solid gray 1px;';
249 BLOCK report_template_tree;
251 fact_table_xpath = "/reporter/tables/table[@fact-table='true']";
253 FOR tab = config.findnodes(fact_table_xpath);
255 tid = tab.findvalue('@id');
256 tname = tab.findvalue('label');
257 tdesc = tab.findvalue('description');
258 "<div id='fact_tree_$counter'/>";
259 content=link(content=tab.findvalue('label'),href="stage1?id=$tid") style='border:solid gray 1px;';
260 "<script language='javascript'>
261 var tree_$counter = new SlimTree(document.getElementById('fact_tree_$counter'),'tree_$counter');
262 tree_" _ counter _ ".addNode($counter,-1,'$tname','stage1?create_stage2=1&id=$tid','$tdesc');
265 q = "SELECT * FROM reporter.stage2 WHERE (pub is true" _
266 " or owner = " _ user.id() _ ") and stage1 = '$tid' ORDER BY create_date DESC";
268 FOR template = DBI.query(q);
269 p = utils.JSON2perl( template.params );
271 "<script language='javascript'>
272 tree_" _ counter _ ".addNode(
276 'stage2?action=run&id=$s2id',