<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <ol class="breadcrumb">
        <li><a href="#/realms/{{realm.realm}}/user-federation">User Federation</a></li>
        <li data-ng-hide="create">{{instance.displayName|capitalize}}</li>
        <li data-ng-show="create">Add User Federation Provider</li>
    </ol>

    <h1 data-ng-hide="create">{{instance.providerName|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create && access.manageUsers" 
    	data-ng-hide="changed" data-ng-click="remove()"></i></h1>
    <h1 data-ng-show="create">Add {{instance.providerName|capitalize}} User Federation Provide</h1>

    <ul class="nav nav-tabs" data-ng-hide="create">
        <li class="active"><a href="#/realms/{{realm.realm}}/user-federation/providers/{{instance.providerName}}/{{instance.id}}">Settings</a></li>
        <li><a href="#/realms/{{realm.realm}}/user-federation/providers/{{instance.providerName}}/{{instance.id}}/mappers">Mappers</a></li>
    </ul>

    <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-md-2 control-label" for="providerId">Provider ID </label>
                <div class="col-md-6">
                    <input class="form-control" id="providerId" type="text" ng-model="instance.id" readonly>
                </div>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="consoleDisplayName">Console display name </label>
                <div class="col-md-6">
                    <input class="form-control" id="consoleDisplayName" type="text" ng-model="instance.displayName" placeholder="defaults to id">
                </div>
                <kc-tooltip>Display name of provider when linked in admin console.</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="priority">Priority </label>
                <div class="col-md-6">
                    <input class="form-control" id="priority" type="text" ng-model="instance.priority">
                </div>
                <kc-tooltip>Priority of provider when doing a user lookup.  Lowest first.</kc-tooltip>
            </div>
            <div data-ng-repeat="option in providerFactory.options" class="form-group">
                <label class="col-md-2 control-label">{{option|capitalize}} </label>

                <div class="col-md-6">
                    <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-md-2 control-label" for="fullSyncEnabled">Periodic full sync</label>
                <div class="col-md-6">
                    <input ng-model="fullSyncEnabled" name="fullSyncEnabled" id="fullSyncEnabled" onoffswitch />
                </div>
                <kc-tooltip>Does periodic full synchronization of provider users to Keycloak should be enabled or not</kc-tooltip>
            </div>
            <div class="form-group clearfix" data-ng-show="fullSyncEnabled">
                <label class="col-md-2 control-label" for="fullSyncPeriod">Full sync period</label>
                <div class="col-md-6">
                    <input class="form-control" type="number" ng-model="instance.fullSyncPeriod" id="fullSyncPeriod" />
                </div>
                <kc-tooltip>Period for full synchronization in seconds</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="changedSyncEnabled">Periodic changed users sync</label>
                <div class="col-md-6">
                    <input ng-model="changedSyncEnabled" name="changedSyncEnabled" id="changedSyncEnabled" onoffswitch />
                </div>
                <kc-tooltip>Does periodic synchronization of changed or newly created provider users to Keycloak should be enabled or not</kc-tooltip>
            </div>
            <div class="form-group clearfix" data-ng-show="changedSyncEnabled">
                <label class="col-md-2 control-label" for="changedSyncPeriod">Changed users sync period</label>
                <div class="col-md-6">
                    <input class="form-control" type="number" ng-model="instance.changedSyncPeriod" id="changedSyncPeriod" />
                </div>
                <kc-tooltip>Period for synchronization of changed or newly created provider users in seconds</kc-tooltip>
            </div>
        </fieldset>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="create && access.manageUsers">
                <button kc-save>Save</button>
                <button kc-cancel data-ng-click="cancel()">Cancel</button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageUsers">
                <button kc-save  data-ng-show="changed">Save</button>
                <button kc-reset data-ng-show="changed">Cancel</button>
                <button class="btn btn-primary" data-ng-click="triggerChangedUsersSync()" data-ng-hide="changed">Synchronize changed users</button>
                <button class="btn btn-primary" data-ng-click="triggerFullSync()" data-ng-hide="changed">Synchronize all users</button>
            </div>
        </div>
    </form>
</div>

<kc-menu></kc-menu>