<!-- Default setup template -->
[% INCLUDE device_setup/common.tt %]

<div class="content-container fit-content">
<h2>[% data.type %] '[% data.UIname.replace('_',' ') %]'</h2>
<br>
<table class="device_setup">
[% FOR i IN data.tags -%]
[% IF i.hide %][% NEXT %][% END -%]
[% IF i.id == 'type' %][% NEXT %][% END %]
[% IF i.id == 'controler' %]
<tr><th title="[% i.description %]">[% i.id.replace('_',' ').ucfirst %]</th>
<td>
[% IF data.controler_id %]
<form method="post" action="/cgi-bin/celltest/device_config.cgi" enctype="multipart/form-data">
[% INCLUDE print_hidden.tt %]
<input type="hidden" name="type" value="MFC">
<input type=hidden name=device value="[% data.controler_id %]">
<button class=textfield>[% data.controler_id %]</button>
</form>
[% ELSIF data.mode == 'Automatic' %]
<div style="color:red;">Error: No controler could be<br> found with gas [% data.name %] although<br> gas is defined as automatic!</div>
[% ELSIF data.controlers.size == 1 && data.controler_id %]
[% data.controler_id %], (Multiplexed)
[% END %]
</td></tr>
[% NEXT %]
[% END %]
<tr><th title="[% i.description %]">[% i.id.replace('_',' ').ucfirst %]</th>
<th>
[% IF i.values.size > 0 -%]
[% IF i.id == 'mode' %]
<select name="[% i.id %]" id="[% i.id %]" autocomplete=off onchange="confirm_mode(this)" class=textfield>
[% ELSE %]
<select name="[% i.id %]" id="[% i.id %]" autocomplete=off onchange="[% IF i.change_reload %]change_type(this)[% ELSE %]change_val(this)[% END %]" class=textfield>
[% END %]
[% FOR j IN i.values -%]
<option value="[% j %]" [% IF i.value.upper == j.upper %]selected=selected[% END %]>[% j %]</option>
[% END -%]
</select>
[% ELSE -%]
[% IF i.readonly == 'Read-write' %]
[% IF i.id == 'comments' %]
<textarea  name="[% i.id %]" id="[% i.id %]" class=textfield onchange="[% IF i.change_reload %]change_type(this)[% ELSE %]change_spline(this)[% END %]" autocomplete=off>[% i.value.replace(',',"\n") %]</textarea>
[% ELSE %]
<input name="[% i.id %]" id="[% i.id %]" class=textfield [% IF i.id == 'tty' %]style="width:80%;"[% END %] type=text value="[% i.value %]" onchange="[% IF i.change_reload %]change_type(this)[% ELSE %]change_val(this)[% END %]" autocomplete=off>
[% IF i.id == 'tty' %]<button type=button style="float:right;" title="Find avaliable serial ports" onclick="find_tty()">?</button>[% END %]
[% END %]
[% ELSE %]
[% i.readonly_value %]
[% END %]
[% END -%]
</th>
</tr>
[% END -%]
<tr><td></td><td>
<button style="float:right;"><i class="fa fa-save"></i> Save</button>
</td></tr>
<tr><th></th><td><button class=textfield onclick="run_test()"><i class="fa fa-check"></i> Test '[% data.UIname.replace('_',' ') %]'</button></td></tr>
<tr><th></th><td><button class=textfield onclick="run_monitor()"><i class="fa fa-eye"></i> Monitor '[% data.UIname.replace('_',' ') %]'</button></td></tr>
[% FOR i IN data.ui_fn_names %]
<tr><th title="[% i.description %]">[% i.name.replace('_',' ').ucfirst %]</th><td><button class=textfield onclick="[% IF i.args %]run_args('[% data.class %]','[% data.name %]','[% i.name %]',[% i.args %])[% ELSE %]run_no_args('[% data.class %]','[% data.name %]','[% i.name %]')[% END %]"><i class="fa fa-play"></i> Run function</button></td></tr>
[% END %]
<tr><th colspan=2>Include '[% data.UIname.replace('_',' ') %]' in data logging:
<input type=checkbox [% IF data.enabled %]checked=checked[% END%] onchange="change_include(this)" id=include autocomplete=off>
</td></tr>
</table>

<script>

function confirm_mode(element)
{
    if (!confirm("Warning: Changing 'automatic'/'manual' status for a gas may result in incorrect gas configuration! Continue?"))
    {
        return false;
    }
    var n = element.name;
    var val = element.value;
    var sec = '[% data.section %]';
    element.disabled = true;
    run_ajax('change_config.cgi','&action=change_config_value&section='+sec+'&key='+n+'&value='+val,set_type);
}

</script>

</div>
<!-- End default template -->
