Menu="IPMI:1"
Title="Settings"
---
<?php require_once '/usr/local/emhttp/plugins/ipmitool-plugin/include/ipmitool_helpers.php'; ?>
<script type="text/javascript" src="/plugins/ipmitool-plugin/js/jquery.mask.js"></script>

<form markdown="1" name="ipmitool_settings" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="ipmitool-plugin/ipmitool-plugin.cfg" />
<input type="hidden" id="COMMAND" name="#command" value="" />

Enable Event Notifications:
: <select id="IPMIEVD" name="IPMIEVD" size="1" onChange="checkIPMIEVD(this.form);">
  <?=mk_option($ipmievd, "disable", "No");?>
  <?=mk_option($ipmievd, "enable", "Yes");?>
  </select>

Enable Network Connection:
: <select id="REMOTE" class="ipmievd-run" name="REMOTE" title="" size="1" onChange="checkREMOTE(this.form);">
  <?=mk_option($ipmi_remote, "disable", "No");?>
  <?=mk_option($ipmi_remote, "enable", "Yes");?>
  </select>

<label class="ipmitool-lan">IPMI IP Address:</label>
: <input id="IPADDR" type="text" class="ipmitool-lan ipmitool-ipaddr" name="IPADDR" maxlength="40" value="<?=$ipmi_ipaddr;?>" title="IPMI IP address" placeholder="" ><label class='ipmitool-lan'><?=$ipmi_conn_check;?></label>

<label class="ipmitool-lan">IPMI User Name:</label>
: <input id="USER" type="text" class="ipmitool-lan" name="USER" maxlength="40" value="<?=$ipmi_user;?>" title="username for remote access IPMI" placeholder="username for remote access" >

<label class="ipmitool-lan">IPMI Password:</label>
: <input id="PASSWORD" type="password" class="ipmitool-lan" name="PASSWORD" maxlength="40" value="<?=$ipmi_password;?>" title="password for remote access IPMI" placeholder="password for remote access" >

Display CPU temperature:
: <select name="CPU_TEMP">
		<option value='false'>None</option>
		<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_cpu_temp);?>
  </select>

Display Motherboard temperature:
: <select name="MB_TEMP">
		<option value='false'>None</option>	
		<?=ipmi_get_options($ipmi_sensors, 'Temperature', $ipmi_mb_temp);?>
	</select>

Display Fan speed:
: <select name="FAN_DISP">
		<option value='false'>None</option>
		<?=ipmi_get_options($ipmi_sensors, 'Fan', $ipmi_fan_disp);?>
	</select>

<input id="DEFAULT" class="ipmievd-run" type="button" value="Default" onClick="resetDATA(this.form);">
: <input id="btnApply" type="submit" value="Apply" onClick="verifyDATA(this.form)"><input type="button" value="Done" onClick="done()">
</form>

<script type="text/javascript">
$(function(){
	$('.tabs')
		.append("<span class='status'>Fan Control: <?=$ipmifan_status;?> </span>")
		.append("<span class='status'>Event Notification: <?=$ipmievd_status;?> </span>");
	checkIPMIEVD(document.ipmitool_settings);
	//checkIPMIFAN(document.ipmifan_settings);
	checkREMOTE(document.ipmitool_settings);
	decData(document.ipmitool_settings);
	//ip address input mask
	$('.ipmitool-ipaddr').mask('0ZZ.0ZZ.0ZZ.0ZZ', {translation:  {'Z': {pattern: /[0-9]/, optional: true}}});
});

function resetDATA(form) {
	form.REMOTE.selectedIndex = 0;
	form.IPADDR.value = "";
	form.USER.value = "";
	form.PASSWORD.value = "";
	form.CPU_TEMP.selectedIndex = 0;
	form.MB_TEMP.selectedIndex = 0;
	form.FAN_DISP.selectedIndex = 0;
	form.submit();
}

function checkIPMIEVD(form) {
	if ("<?=$ipmievd_running;?>" == true)
	{
		$(".ipmievd-run").prop("disabled", true);
		form.btnApply.disabled = "disabled";
   }else{
   	$(".ipmievd-run").prop("disabled", false);
		$("#btnApply").prop("disabled", false);
	}
	if (form.IPMIEVD.value == "enable")
		form.COMMAND.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/start";
	else {
		form.COMMAND.value = "/usr/local/emhttp/plugins/ipmitool-plugin/scripts/stop";
	}
}

function decData(form) {
 form.PASSWORD.value = atob(form.PASSWORD.value);
}

function checkREMOTE(form) {
	if (form.REMOTE.selectedIndex < 1 )
		$(".ipmitool-lan").hide();
	else
   	$(".ipmitool-lan").show();
   	$(".ipmitool-lan").prop("disabled", (form.IPMIEVD.value == "enable"));
}

function verifyDATA(form) {
	form.IPMIEVD.value = form.IPMIEVD.value.replace(/ /g,"_");
	form.REMOTE.value = form.REMOTE.value.replace(/ /g,"_");
	form.USER.value = form.USER.value.replace(/ /g,"_");
	form.PASSWORD.value = btoa(form.PASSWORD.value);
}

</script>