<div class="card mb-2">
	<div class="card-header" ng-class="dir.getBgHighlightClass()" role="tab" id="headingTwo" data-toggle="collapse" data-parent="#accordion-connections" href="#collapseTwo">
		<h5 class="card-title mb-0" ng-class="dir.getTitleHighlightClass()">
			<div class="d-flex align-items-center" role="button">
				<ion-icon class="icon-lg" name="checkmark-outline"></ion-icon>
				<lmsg src="admin.ldap.text.directory_section">2 Directory Settings</lmsg>
			</div>
		</h5>
	</div>
	<div id="collapseTwo" class="panel-collapse collapse">
		<div class="card-body">
			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="directory" lmsg="admin.ldap.text.directory_label">Directory</label>
				<div class="col-md-4">
					<select id="directory" class="form-control" ng-change="dir.changeDirectory()"
							ng-options="k as v for (k, v) in dir.directories" ng-model="dir.properties.directory"></select>
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="user-type" lmsg="admin.ldap.text.usertype_label">User Type Filter</label>
				<div class="col-md-7">
					<input id="user-type" type="text" placeholder="" class="form-control input-md"
						   ng-model="dir.properties.userTypeFilter" ng-readonly="dir.properties.directory != 99">
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="user-enabled" lmsg="admin.ldap.text.userenabled_label">User Enabled Filter</label>
				<div class="col-md-7">
					<input id="user-enabled" type="text" placeholder="" class="form-control input-md"
						   ng-model="dir.properties.userEnabledFilter" ng-readonly="dir.properties.directory != 99">
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="username-field" lmsg="admin.ldap.text.username_label">Username Field</label>
				<div class="col-md-4">
					<input id="username-field" type="text" placeholder="" class="form-control input-md"
						   ng-model="dir.properties.usernameField" ng-readonly="dir.properties.directory != 99">
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="membership-field" lmsg="admin.ldap.text.membership_label">Membership Field</label>
				<div class="col-md-4">
					<input id="membership-field" type="text" placeholder="" class="form-control input-md"
						   ng-model="dir.properties.membershipField" ng-readonly="dir.properties.directory != 99">
				</div>
			</div>

			<div class="form-group row">
				<label class="col-md-3 col-form-label" for="user-guid" lmsg="admin.ldap.text.userguid_label">User Guid Field</label>
				<div class="col-md-4">
					<input id="user-guid" type="text" placeholder="" class="form-control input-md"
						   ng-model="dir.properties.userGuid" ng-readonly="dir.properties.directory != 99">
				</div>
			</div>
			<hr />
			<div class="form-group row">
				<label class="col-md-3 col-form-label pt-0" lmsg="admin.ldap.text.grantaccess_label">Claromentis Access Control - Grant Access By:</label>
				<div class="col-md-4">
					<div class="form-check">
						<input class="form-check-input" type="radio" name="grant-access-by" ng-model="dir.properties.grantAccessBy" id="grant-access-by-0" value="groups" checked="checked">
						<label class="form-check-label" for="grant-access-by-0">
							<lmsg src="admin.ldap.text.securitygroups_label">Security Group(s)</lmsg>
						</label>
					</div>
					<div class="form-check">
						<input class="form-check-input" type="radio" name="grant-access-by" ng-model="dir.properties.grantAccessBy" id="grant-access-by-1" value="ous">
						<label class="form-check-label" for="grant-access-by-1">
							<lmsg src="admin.ldap.text.ous_label">OU(s)</lmsg>
						</label>
					</div>
				</div>
			</div>

			<div class="form-group row align-items-center" ng-repeat="control in dir.accessControlList[dir.properties.grantAccessBy] track by $index">
				<div class="col-9 offset-md-3 col-md-5">
					<input type="text" class="form-control input-md"
						   ng-model="dir.accessControlList[dir.properties.grantAccessBy][$index]">
				</div>
				<div class="col-3 col-md-2 d-inline-flex align-items-baseline">
					<a class="mr-2" ng-if="$index > 0 || dir.accessControlList[dir.properties.grantAccessBy].length > 1" ng-click="dir.removeAccessControlEntry($index)">
						<ion-icon name="trash-outline"></ion-icon>
					</a>
					<ldap-helper msg="admin.ldap.directory.grantaccessby_helper" ng-if="$index == 0"></ldap-helper>
				</div>
				<div class="col-12 col-md-2 ldap-directory-status">
					<small class="text-warning" ng-if="dir.loading">Loading...</small>
					<span ng-if="dir.dictionary[control] && dir.dictionary[control].success">
						<small class="text-success" ng-if="!dir.loading" ng-bind="dir.getSuccessMsg(control)"></small>
					</span>
					<div class="ldap-directory-status-text" ng-if="dir.dictionary[control] && !dir.dictionary[control].success">
						<small class="text-danger" ng-bind="dir.getErrorMsg(control)"></small>
					</div>
				</div>
			</div>
			<div class="form-group row">
				<div class="offset-md-3 col-md-6 ">
					<a class="btn btn-secondary" ng-if="dir.properties.grantAccessBy === 'groups'" ng-click="dir.addGroup()">
						<ion-icon name="add-outline"></ion-icon>
						<lmsg src="admin.ldap.text.addgroup_button">Add another group</lmsg>
					</a>
					<!-- Display each button depending on slection above -->
					<a class="btn btn-secondary" ng-if="dir.properties.grantAccessBy === 'ous'" ng-click="dir.addOU()">
						<ion-icon name="add-outline"></ion-icon>
						<lmsg src="admin.ldap.text.addou_button">Add another OU</lmsg>
					</a>
				</div>
			</div>
			<div class="form-group row">
				<div class="offset-md-3 col-md-6">
					<div class="card card-body bg-light" ng-if="dir.valid !== null" ng-class="dir.valid ? 'alert-success' : 'alert-danger'">
						<div class="card-body">
							<div class="text-center">
								<b ng-if="dir.valid" ng-bind="dir.statusMessage">[20] Intranet Users and [1] OU found</b>
								<b ng-if="!dir.valid" ng-bind="dir.statusMessage">Scanner something error happens</b>
							</div>
						</div>
					</div>
				</div>
			</div>


			<div class="form-group row">
				<div class="offset-md-3 col-md-6 ">
					<button id="validate-settings-button" ng-disabled="dir.loading" ng-click="dir.validate()" class="btn btn-primary" lmsg="admin.ldap.text.validate_button">Validate Settings</button>
					<span class="form-text text-muted"><small lmsg="admin.ldap.text.validate_details">When validating the settings you check the DN syntax is correct as well as confirm each Group / OU contains the expected number of users.</small></span>
				</div>
			</div>

			<div class="form-group row" ng-if="dir.valid || dir.completed">
				<label class="col-md-3 col-form-label" for="user-dir-sync" lmsg="admin.ldap.text.dirsync_label">User Directory Sync</label>
				<div class="col-10 col-md-2">
					<select id="user-dir-sync" ng-model="dir.properties.userDirectorySync" class="form-control">
						<option value="0" lmsg="admin.ldap.text.sync_disabled">Disabled</option>
						<option value="60" lmsg="admin.ldap.text.sync_hourly">Every Hour</option>
						<option value="720" lmsg="admin.ldap.text.sync_twice">Twice a Day</option>
						<option value="1440" lmsg="admin.ldap.text.sync_daily">Daily</option>
						<option value="10080" lmsg="admin.ldap.text.sync_weekly">Weekly</option>
					</select>
				</div>

				<div class="col-2 col-md-1">
					<ldap-helper msg="admin.ldap.directory.userdirectorysync_helper"></ldap-helper>
				</div>


				<label ng-if="dir.showInitialSyncTime()" class="col-md-3 col-form-label" for="initial-sync-time" lmsg="admin.ldap.text.synctime_label">Initial Sync Time</label>
				<div ng-if="dir.showInitialSyncTime()" class="col-md-2">
					<select name="" id="initial-sync-time" ng-model="dir.properties.initialSyncTime" class="form-control">
						<option value="0:00">0:00</option>
						<option value="1:00">1:00</option>
						<option value="2:00">2:00</option>
						<option value="3:00">3:00</option>
						<option value="4:00">4:00</option>
						<option value="5:00">5:00</option>
						<option value="6:00">6:00</option>
						<option value="7:00">7:00</option>
						<option value="8:00">8:00</option>
						<option value="9:00">9:00</option>
						<option value="10:00">10:00</option>
						<option value="11:00">11:00</option>
						<option value="12:00">12:00</option>
						<option value="13:00">13:00</option>
						<option value="14:00">14:00</option>
						<option value="15:00">15:00</option>
						<option value="16:00">16:00</option>
						<option value="17:00">17:00</option>
						<option value="18:00">18:00</option>
						<option value="19:00">19:00</option>
						<option value="20:00">20:00</option>
						<option value="21:00">21:00</option>
						<option value="22:00">22:00</option>
						<option value="23:00">23:00</option>
					</select>
				</div>

			</div>

			<div class="form-group row" ng-if="dir.valid || dir.completed">
				<div class="offset-md-3 col-md-6 ">
					<!--<button id="dir-continue" class="btn btn-primary" ng-disabled="dir.loading || !dir.valid" ng-click="dir.next()" lmsg="admin.ldap.text.continue">Continue</button>-->
					<button id="dir-continue" class="btn btn-primary" ng-click="dir.next()" lmsg="admin.ldap.text.continue">Continue</button>
				</div>
			</div>
		</div>
	</div>
</div>
