<style type="text/css">
a {
cursor: pointer;
}
#columnC_2columns {
width: auto !important;
}
#idx_help {
list-style-type: disc !important;
}
</style>
% if ($c->flash->{error_msg}) {
<pre>
<strong>Error:</strong> <% $c->flash->{error_msg} %>
</pre>
% }
% if ( $c->stash->{view_pager} ) {
<div id="idx_reportlist_pager">
% require DateTime;
% require DateTime::Format::Strptime;
% my $or_dt_now = DateTime->now();
% my $s_dt_now = $or_dt_now->strftime('%F');
% my $or_strp = DateTime::Format::Strptime->new(
% pattern => '%F',
% );
% my $or_dt = $or_strp->parse_datetime( $c->stash->{testrun_date} );
% for my $s_act_pager_value (qw/ year month week day /) {
% if ( $or_dt->clone->add( $s_act_pager_value . 's' => 1 )->strftime('%F') gt $s_dt_now ) {
<div>« <% $s_act_pager_value %></div>
% }
% else {
<div class="clickable" psign="positive" pvalue="<% $s_act_pager_value %>s">« <% $s_act_pager_value %></div>
% }
% }
<div class="pager_date" pager_date="<% $or_dt->strftime('%F') %>">
<% $or_dt->strftime('%a %b %d, %Y') %>
</div>
<div id="idx_pager_interval_div">
<input type="text" size="3" id="idx_pager_interval_input" value="<% $c->stash->{pager_interval} %>" /> day(s)
</div>
<div class="pager_date" pager_date="<% $or_dt->clone->subtract( days => $c->stash->{pager_interval} - 1 )->strftime('%F') %>">
<% $or_dt->clone->subtract( days => $c->stash->{pager_interval} - 1 )->strftime('%a %b %d, %Y') %>
</div>
% for my $s_act_pager_value (qw/ day week month year /) {
<div class="clickable" psign="negative" pvalue="<% $s_act_pager_value %>s"><% $s_act_pager_value %> »</div>
% }
</div>
<br />
<br />
% my $dt_testrun_date = $c->stash->{testrun_date}->strftime('%F');
<input type="hidden" id="idx_report_date" value="<% $dt_testrun_date %>" />
<input type="hidden" id="idx_pager_sign" value="<% $c->req->params->{pager_sign} || '' %>" />
<input type="hidden" id="idx_pager_value" value="<% $c->req->params->{pager_value} || '' %>" />
<input type="hidden" id="idx_pager_interval" value="<% $c->req->params->{pager_interval} || '' %>" />
% }
<input type="hidden" id="idx_path" value="<% $c->req->path %>" />
% if ( $c->stash->{testruns} && @{$c->stash->{testruns}} ) {
<table id="idx_reportlist" class="reportlist">
<thead>
<tr>
<th class="reportid">ID</th>
<th>Updated At (GMT)</th>
<th>Topic</th>
<th>Machine</th>
<th>State</th>
<th>Success</th>
<th>Ratio</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
% my $d_grouping_date = q##;
% foreach my $hr_testrun ( @{$c->stash->{testruns}} ) {
% if ( $c->stash->{pager_interval} != 1 ) {
% if ( $d_grouping_date ne $hr_testrun->{testrun_date} ) {
<tr>
<td colspan="8">
<div class="pager_date" pager_date="<% $hr_testrun->{testrun_date} %>">
% $d_grouping_date = $hr_testrun->{testrun_date};
% my $or_strp = DateTime::Format::Strptime->new(
% pattern => '%F',
% );
% my $or_dt_act = $or_strp->parse_datetime( $hr_testrun->{testrun_date} );
<% $or_dt_act->strftime('%a %b %d, %Y') %>
</div>
</td>
<tr>
% }
% }
<tr>
<td>
<div class="plus idlist"></div>
<a title="Click to show details" href="/tapper/testruns/id/<% $hr_testrun->{testrun_id} %>">tr<% $hr_testrun->{testrun_id} %></a>
</td>
<td><% $hr_testrun->{testrun_date} . ' ' . $hr_testrun->{testrun_time} %></td>
<td>
<div class="plus topic"></div>
<a title="Click to show testruns of topic '<% $hr_testrun->{topic_name} %>'" key="topic">
<% $hr_testrun->{topic_name} %>
</a>
</td>
<td>
% if ( $hr_testrun->{machine_name} ) {
<div class="plus host"></div>
<a title="Click to show testruns on '<% $hr_testrun->{machine_name} %>'" key="host">
<% $hr_testrun->{machine_name} %>
</a>
% }
</td>
<td>
<div class="plus state"></div>
<a title="Click to show testruns in state '<% $hr_testrun->{testrun_state} %>'" key="state">
<% $hr_testrun->{testrun_state} %>
</a>
</td>
<td class="<% lc($hr_testrun->{successgrade} || "") %>">
% if ( $hr_testrun->{successgrade} ) {
<div class="plus success"></div>
<a key="success"><% $hr_testrun->{successgrade} %></a>
% }
</td>
<td class="<% $hr_testrun->{testrun_state} eq 'schedule' || $hr_testrun->{testrun_state} eq 'prepare' ? 'transparent' : $hr_testrun->{testrun_state} eq 'running' ? 'yellow' : '' %>">
% my $i_success_width = int($hr_testrun->{success_ratio} / 2);
<div class="sratio bggreen" style="width:<% $i_success_width %>px"></div>
<div class="sratio bgred" style="width:<% 50 - $i_success_width %>px"></div>
</td>
<td>
<div class="plus owner"></div>
<a title="Click to show testruns of owner '<% $hr_testrun->{testrun_owner} %>'" key="owner">
<% $hr_testrun->{testrun_owner} %>
</a>
</td>
</tr>
% }
</tbody>
</table>
% }
% else {
<div class="no_results">no results found for active filters and date.</div>
% }
<script type="text/javascript">
function get_pager_params () {
var elements = [
['pager_interval','#idx_pager_interval'],
['testrun_date','#idx_report_date'],
['pager_value','#idx_pager_value'],
['pager_sign','#idx_pager_sign'],
];
return $.map( elements, function( a ){
if ( $(a[1]).val() )
return a[0] + '=' + $(a[1]).val();
}).join('&');
}
function get_column_value ( filter, $target ) {
if ( filter == 'idlist' ) {
return $target.next().text().trim().replace(/\D/g,'');
}
else {
return $target.next().text().trim();
}
}
/*
Add a onclick behavior for the reportlist table on dom ready. The
following action depends on the clicked target ( picture ).
*/
$(document).ready(function(){
var selected_elements = [];
$('#idx_reportlist').mousedown(function( e ){
var $target = $(e.target);
var $new_filters = $('#idx_new_filter');
if ( $target.is('a') && !$target.attr('href') ) {
key_dependent_site_call(
e.which,
'/tapper/testruns/'
+ $target.attr('key')
+ '/'
+ $target.text().replace(/^\s*|\s*$/g,'')
+ '?'
+ get_pager_params()
);
}
else if ( $target.is('div') ) {
if ( $target.hasClass('sratio') ) {
key_dependent_site_call(
e.which,
$target.parent().parent().find('a:first').attr('href')
);
}
else if ( $target.hasClass('plus') ) {
var classes = $target.attr('class').split(/\s+/);
if ( classes.length ) {
var filter = '';
$(classes).each(function(){
if ( this != 'plus' ) {
filter = this;
}
});
var exists = false;
var acttext = filter + ': ' + get_column_value( filter, $target );
$('#columnC_2columns li').each(function(){
if ( $(this).text().trim() == acttext.trim() ) {
exists = true;
}
});
if (! exists ) {
$new_filters.append(
'<li>'
+ '<img src="/tapper/static/images/minus.png" onclick="$(this).parent().remove()" />'
+ acttext
+ '</li>'
);
}
if (! e.shiftKey ) {
key_dependent_site_call( e.which,
'/'
+ $('#idx_path').val().replace(/\/\s*$/g,'')
+ '/'
+ $.map( $new_filters.find('li'), function( a ){
return $(a).text().replace(/: /,'/');
}).join('/')
+ '?'
+ get_pager_params()
);
}
}
}
}
});
});
$('#idx_reportlist_pager div.clickable').mousedown(function( e ) {
pager_call( e.which, $(this).attr('psign'), $(this).attr('pvalue') );
});
$('#columnA_2columns div.pager_date').mousedown(function( e ){
key_dependent_site_call( e.which,
'/'
+ $('#idx_path').val().replace(/\/\s*$/g,'')
+ '?testrun_date='
+ $(e.target).attr('pager_date')
);
});
$('#idx_pager_interval_input')
.keydown(function( e ){
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
// home, end, period, and numpad decimal
if ( key == 13 ) {
pager_call( 1 );
}
return (
(
$(this).val().length < 3 && (
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105)
)
) || (
key == 8 ||
key == 9 ||
key == 46 ||
key == 110 ||
key == 190 ||
(key >= 35 && key <= 40)
)
);
})
.focus(function( e ){
$(this).data('value_bak',$(this).val());
})
.blur(function( e ){
if ( $(this).val() != $(this).data('value_bak') ) {
pager_call( 1 );
}
})
;
/*
function for pager requests
*/
function pager_call( key, pager_sign, pager_value ) {
key_dependent_site_call( key, '/'
+ $('#idx_path').val().replace(/\/\s*$/g,'')
+ '?testrun_date=' + $('#idx_report_date').val()
+ ( pager_sign ? '&pager_sign=' + pager_sign : '' )
+ ( pager_value ? '&pager_value=' + pager_value : '' )
+ '&pager_interval=' + $('#idx_pager_interval_input').val()
);
}
function key_dependent_site_call ( key, url ) {
if ( key == 2 ) {
var win = window.open( url, '_blank' );
win.focus();
}
else {
location.href = url;
}
}
</script>
%# Local Variables:
%# buffer-file-coding-system: utf-8
%# End: