<!-- Template for listing tests for rig -->
<div style="margin:auto;padding:20px;">
<h1>Avaliable tests for rig [% nav.rig %]</h1>



<div class="search_nav_header" id=search_nav>
[% UNLESS data.page %][% data.page = 1 %][% END -%]
[% UNLESS data.pages %][% data.pages = 1 %][% END -%]
[% UNLESS data.entries %][% data.entries = 15 %][% END -%]

<div class="search_nav_container" id=search_list>
<div style="display:inline;"> 

<select name=entries onchange="set_entries[% nav.pid %](this.value)" autocomplete="off" class="search_nav_select" style="direction: rtl;">
[% entries = [10,15,20,30,50,100,150] -%]
[% IF nav.debug -%]
   [% entries.push(500) -%]
   [% entries.push(1000) -%]
   [% entries.push(10000) -%]
   [% entries.push(100000) -%]
[% END -%]
[% FOREACH i IN entries -%]
   [% IF i == data.entries -%]
<option selected="selected" value="[% i %]" style="direction: rtl;">[% i %]</option>
   [% ELSE -%]
<option value="[% i %]" style="direction: rtl;">[% i %]</option>
   [% END -%]
[% END -%]
</select> results per page
</div>
<div style="display:inline;">
[% offset = 5 -%]
[% min = data.page - offset -%]
[% IF min < 1 %][% min = 1 %][% END -%]
[% max = data.page + offset -%]
[% IF max > data.pages %][% max = data.pages %][% END -%]
[% UNLESS data.no_enteies_select -%]
[% IF data.page > 1 -%]
<button class="search_nav_btn" onclick="set_offset[% nav.pid %](1)">&lt;&lt;</button>
<button class="search_nav_btn" onclick="set_offset[% nav.pid %]([% data.page - 1 %])">PREV</button>
[% ELSE -%]
<button class="search_nav_btn"">&lt;&lt;</button>
<button class="search_nav_btn">PREV</button>
[% END -%]
 [% i = min %]
  [% WHILE i <= max %]
     [% IF i == data.page %]
<button class="search_nav_btn_select">[% i %]</button>
     [% ELSE %]
<button class="search_nav_btn" onclick="set_offset[% nav.pid %]([% i %])">[% i %]</button>
     [% END %]
     [% i = i + 1 %]
  [% END %]
[% IF data.page < data.pages %]
<button class="search_nav_btn" onclick="set_offset[% nav.pid%]([% data.page + 1 %])">NEXT</button>
<button class="search_nav_btn" onclick="set_offset[% nav.pid %]([% data.pages %])">&gt;&gt;</button>
[% ELSE %]
<button class="search_nav_btn">NEXT</button>
<button class="search_nav_btn">&gt;&gt;</button>
[% END %]
<select class="search_nav_select" onchange="set_offset[% nav.pid %](this.value)">
[% i = 1 -%]
[% WHILE i <= data.pages -%]
  [% IF i == data.page -%]
<option value="[% i %]" selected=selected>Page [% i %] of [% data.pages %]</option>
  [% ELSE -%]
<option value="[% i %]">Page [% i %] of [% data.pages %]</option>
  [% END -%]
  [% i = i + 1 -%]
[% END -%]
</select>
[% END -%]
</div>


</div>



<form method="post" name="search_nav_[% nav.pid %]">
[% INCLUDE print_hidden.tt -%]
<input type=hidden name=entries value="[% data.entries %]">
<input type=hidden name=offset value="[% nav.offset %]">
<input type=hidden name=page value="[% data.page %]">
<input type=hidden name=action value="[% nav.action %]"> 
<input type=hidden name=order value="[% nav.order %]">
</form>


<table class="content-container fit-content list-view test-list">
<tr><th>Test</th><th>Started</th><th>User</th><th>Sample</th><th>Project</th></tr>
[% FOR i IN list %]
<tr><td>
[% IF i.is_read %]
<button class="rfcbutton testbtn" onclick="openInNewTab('http[% IF i.ssl %]s[% END %]://[% i.hostname %]/cgi-bin/show_data.cgi?name=[% user_info.name %]&pass=[% user_info.pass %]&url=http[% IF i.ssl %]s[% END %]://[% i.hostname %]/rig[% i.rig %]/[% i.rig %]test[% i.test %]/')">[% i.rig %]test[% i.test %]</button>
[% ELSE %]
[% i.rig %]test[% i.test %]
[% END %]
</td><td>[% i.start %]</td><td>[% i.start_by %]</td><td>[% i.sample %]</td><td>[% i.project %]</td><td><button class="rfcbutton testbtn" onclick="create_zip([% nav.rig %],[% i.test %])" title="Update zip archive"><i class="fa fa-redo"></i></button></td></tr>
[% END %]
</table>

</div>

<style>
.testbtn {
   width:100%;
}

.test-list {
    border-spacing: 5px;
    border-collapse: separate;
}


</style>




<script>

function create_zip(rig,test)
{
   var query = '&action=create_zip&rig='+rig+'&test='+test;
   run_ajax('rig_ajax_run.cgi',query,function(){alert('Creating zip archive, email will be sent when it is ready for download')});
}

function set_offset[% nav.pid %](of)
{
   var f = document.search_nav_[% nav.pid %];
   f.offset.value = (of -1) * [% data.entries %];
[% IF nav.jquery_load_callback -%]
   [% nav.jquery_load_callback %]("search_nav_[% nav.pid %]",f.order.value);
[% ELSE -%]
   f.submit();
[% END -%]
}

function set_entries[% nav.pid %](nr)
{
   var f = document.search_nav_[% nav.pid %];
   f.entries.value = nr;
   f.offset.value = 0;
[% IF nav.jquery_load_callback -%]
   [% nav.jquery_load_callback %]("search_nav_[% nav.pid %]",f.order.value);
[% ELSE -%]
   f.submit();
[% END -%]
}


function order_by[% nav.pid %](form,val)
{
   var f = document.forms.namedItem(form);
   f.offset.value = 0;
   f.order.value = val;
[% IF nav.jquery_load_callback -%]
   [% nav.jquery_load_callback %]("search_nav_[% nav.pid %]",f.order.value);
[% ELSE -%]
   f.submit();
[% END -%]
}


</script>




<!-- End list rig template -->