<div class="bs-sidebar col-sm-3 " data-ng-include data-src="'partials/realm-menu.html'"></div>
<div id="content-area" class="col-sm-9" role="main">
    <ul class="nav nav-tabs nav-tabs-pf">
        <li><a href="#/realms/{{realm.realm}}/users">User List</a></li>
        <li><a href="#/realms/{{realm.realm}}/user-federation">Federation</a></li>
    </ul>
    <div id="content">
        <ol class="breadcrumb" data-ng-hide="create">
            <li><a href="#/realms/{{realm.realm}}/user-federation">Federation Providers</a></li>
            <li><a href="#/realms/{{realm.realm}}/user-federation/providers/{{instance.providerName}}/{{instance.id}}">{{instance.displayName}}</a></li>
            <li class="active">Provider Settings</li>
        </ol>
        <ol class="breadcrumb" data-ng-show="create">
            <li><a href="#/realms/{{realm.realm}}/user-federation">Federation Providers</a></li>
            <li class="active">Add Federation Provider</li>
        </ol>
        <h2 class="pull-left" data-ng-hide="create">Provider Settings</h2>
        <h2 class="pull-left" data-ng-show="create">Add Federation Provider</h2>
        <p class="subtitle"><span class="required">*</span> Required fields</p>
        <form class="form-horizontal" name="realmForm" novalidate kc-read-only="!access.manageRealm">

            <fieldset>
                <legend><span class="text">Required Settings</span></legend>
                <div class="form-group clearfix" data-ng-show="!create">
                    <label class="col-sm-2 control-label" for="providerId">Provider ID </label>
                    <div class="col-sm-4">
                        <input class="form-control" id="providerId" type="text" ng-model="instance.id" readonly>
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="consoleDisplayName">Console display name </label>
                    <div class="col-sm-4">
                        <input class="form-control" id="consoleDisplayName" type="text" ng-model="instance.displayName" placeholder="defaults to id">
                    </div>
                    <span tooltip-placement="right" tooltip="Display name of provider when linked in admin console." class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="priority">Priority </label>
                    <div class="col-sm-4">
                        <input class="form-control" id="priority" type="text" ng-model="instance.priority">
                    </div>
                    <span tooltip-placement="right" tooltip="Priority of provider when doing a user lookup.  Lowest first." class="fa fa-info-circle"></span>
                </div>
                <div data-ng-repeat="option in providerFactory.options" class="form-group">
                    <label class="col-sm-2 control-label">{{option|capitalize}} </label>

                    <div class="col-sm-4">
                        <input class="form-control" type="text" data-ng-model="instance.config[ option ]" >
                    </div>
                </div>

            </fieldset>

            <fieldset>
                <legend><span class="text">Sync settings</span></legend>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="fullSyncEnabled">Periodic full sync</label>
                    <div class="col-sm-4">
                        <input ng-model="fullSyncEnabled" name="fullSyncEnabled" id="fullSyncEnabled" onoffswitch />
                    </div>
                    <span tooltip-placement="right" tooltip="Does periodic full synchronization of provider users to Keycloak should be enabled or not" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix" data-ng-show="fullSyncEnabled">
                    <label class="col-sm-2 control-label" for="fullSyncPeriod">Full sync period</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="number" ng-model="instance.fullSyncPeriod" id="fullSyncPeriod" />
                    </div>
                    <span tooltip-placement="right" tooltip="Period for full synchronization in seconds" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="changedSyncEnabled">Periodic changed users sync</label>
                    <div class="col-sm-4">
                        <input ng-model="changedSyncEnabled" name="changedSyncEnabled" id="changedSyncEnabled" onoffswitch />
                    </div>
                    <span tooltip-placement="right" tooltip="Does periodic synchronization of changed or newly created provider users to Keycloak should be enabled or not" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix" data-ng-show="changedSyncEnabled">
                    <label class="col-sm-2 control-label" for="changedSyncPeriod">Changed users sync period</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="number" ng-model="instance.changedSyncPeriod" id="changedSyncPeriod" />
                    </div>
                    <span tooltip-placement="right" tooltip="Period for synchronization of changed or newly created provider users in seconds" class="fa fa-info-circle"></span>
                </div>
            </fieldset>

            <div class="pull-right form-actions" data-ng-show="create && access.manageUsers">
                <button kc-cancel data-ng-click="cancel()">Cancel</button>
                <button kc-save>Save</button>
            </div>

            <div class="pull-right form-actions" data-ng-show="!create && access.manageUsers">
                <button kc-reset data-ng-show="changed">Clear changes</button>
                <button kc-save  data-ng-show="changed">Save</button>
                <button kc-delete data-ng-click="remove()" data-ng-hide="changed">Delete</button>
                <button kc-delete data-ng-click="triggerFullSync()" data-ng-hide="changed">Synchronize all users</button>
                <button kc-delete data-ng-click="triggerChangedUsersSync()" data-ng-hide="changed">Synchronize changed users</button>
            </div>
        </form>
    </div>
</div>