<h4 class="bg-primary" ng-if="device.targetType === 1">Device IR Control Settings</h4>
<h4 class="bg-primary" ng-if="device.targetType === 2">Device Network Control Settings</h4>


<form name="deviceSettingsForm" role="form" submit-and-disable="doNext()" enter-press="deviceSettingsForm.$valid && doNext()" novalidate>

	<div class="form-group" ng-if="device.targetType === 1">
		<label>Base station infrared (IR) output setting:</label>


		<div class="radio">
			<label>
			        <input type="radio" name="rear"  ng-model="ir.target"  ng-value="1"> Wired IR emitters attached to my device
					&nbsp&nbsp&nbspIR Port: <select class="btn btn-default" name="irPort" ng-model="ir.port" ng-disabled="1 != ir.target" ng-options="value.value as value.name for value in irPortOptions"> </select>
			</label>
		</div>

		<div class="radio">
			<label>
				<input type="radio" name="front" ng-model="ir.target" ng-value="2" ng-disabled="!wireless_ir_port"> Wireless IR
				(requires line of sight from the base station to the device)
			</label>
		</div>

		<div ng-if="room.bstations.length > 1">
			<p>There are multiple control extenders available in this room. Select which one will control this device.</p>
			<select name="baseStation" ng-model="device.targetAddr" ng-options="baseStation.mac as baseStation.name +' (' + baseStation.type + ')' for baseStation in room.bstations" required>  </select>
		</div>
	</div>


	<div class="form-group" ng-if="device.targetType === 2">
		<div class="form-group">
			<label for="ipAddress">IP address</label>
			<input class="form-control" type="text" name="ipAddress" placeholder="Enter IP address" ng-model="device.targetAddr" ng-pattern="/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" required>
			<p class="help-block" ng-show="deviceSettingsForm.ipAddress.$error.required && deviceSettingsForm.ipAddress.$dirty">An IP address is required.</p>
			<p class="help-block" ng-show="deviceSettingsForm.ipAddress.$error.pattern && deviceSettingsForm.ipAddress.$dirty">Please enter a valid IP address.</p>
		</div>

		<div class="form-group">
			<label for="port">Port</label>
			<input class="form-control" type="number" name="port" placeholder="Enter port number" ng-model="device.targetPort" min="0" max="65535" ng-maxlength="5" required>
			<p class="help-block" ng-show="deviceSettingsForm.port.$error.required && deviceSettingsForm.port.$dirty">A port number is required.</p>
			<p class="help-block" ng-show="deviceSettingsForm.port.$error.min || deviceSettingsForm.port.$error.max && deviceSettingsForm.port.$dirty">Please enter a number between 0 and 65535.</p>
		</div>
	</div>

	<div class="left-and-right">
		<go-back state="menu.programming.add-device.device-brand"></go-back>
		<button class="btn btn-primary" type="submit" ng-disabled="deviceSettingsForm.$invalid">
			<span ng-if="isEntDevice"> Next <i class="fa fa-caret-right"></i></span>
			<span ng-if="!isEntDevice"> Finish </span>
		</button>
	</div>
</form>
