<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' | translate}}</a></li>
        <li data-ng-hide="create">{{instance.name|capitalize}}</li>
        <li data-ng-show="create">{{:: 'add-user-storage-provider' | translate}}</li>
    </ol>

    <kc-tabs-user-storage></kc-tabs-user-storage>

    <form class="form-horizontal" name="realmForm" novalidate kc-read-only="!access.manageRealm">
        <fieldset>
            <legend><span class="text">{{:: 'required-settings' | translate}}</span></legend>
            <div class="form-group clearfix" data-ng-show="!create">
                <label class="col-md-2 control-label" for="providerId">{{:: 'provider-id' | translate}} </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' | translate}} </label>
                <div class="col-md-6">
                    <input class="form-control" id="consoleDisplayName" type="text" ng-model="instance.name" placeholder="{{:: 'defaults-to-id' | translate}}">
                </div>
                <kc-tooltip>{{:: 'console-display-name.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="priority">{{:: 'priority' | translate}} </label>
                <div class="col-md-6">
                    <input class="form-control" id="priority" type="text" ng-model="instance.config['priority'][0]">
                </div>
                <kc-tooltip>{{:: 'priority.tooltip' | translate}}</kc-tooltip>
            </div>

            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="kerberosRealm"><span class="required">*</span> {{:: 'kerberos-realm' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="kerberosRealm" type="text" ng-model="instance.config['kerberosRealm'][0]" required>
                </div>
                <kc-tooltip>{{:: 'kerberos-realm.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="serverPrincipal"><span class="required">*</span> {{:: 'server-principal' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="serverPrincipal" type="text" ng-model="instance.config['serverPrincipal'][0]" required>
                </div>
                <kc-tooltip>{{:: 'server-principal.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="keyTab"><span class="required">*</span> {{:: 'keytab' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="keyTab" type="text" ng-model="instance.config['keyTab'][0]" required>
                </div>
                <kc-tooltip>{{:: 'keytab.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="debug">{{:: 'debug' | translate}} </label>
                <div class="col-md-6">
                    <input ng-model="instance.config['debug'][0]" id="debug" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'debug.tooltip' | translate}}</kc-tooltip>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="allowPasswordAuthentication">{{:: 'allow-password-authentication' | translate}} </label>
                <div class="col-md-6">
                    <input ng-model="instance.config['allowPasswordAuthentication'][0]" id="allowPasswordAuthentication" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'allow-password-authentication.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group" data-ng-show="instance.config['allowPasswordAuthentication'][0] == 'true'">
                <label class="col-md-2 control-label" for="editMode">{{:: 'edit-mode' | translate}}</label>
                <div class="col-md-6">
                    <div>
                        <select class="form-control" id="editMode"
                                ng-model="instance.config['editMode'][0]">
                            <option>READ_ONLY</option>
                            <option>UNSYNCED</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'edit-mode.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="updateProfileFirstLogin">{{:: 'update-profile-first-login' | translate}} </label>
                <div class="col-md-6">
                    <input ng-model="instance.config['updateProfileFirstLogin'][0]" id="updateProfileFirstLogin" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'update-profile-first-login.tooltip' | translate}}</kc-tooltip>
            </div>

        </fieldset>

        <fieldset>
            <legend><span class="text">{{:: 'user-storage-cache-policy' | translate}}</span></legend>
            <div class="form-group">
                <label for="cachePolicy" class="col-md-2 control-label">{{:: 'userStorage.cachePolicy' | translate}}</label>
                <div class="col-md-2">
                    <div>
                        <select id="cachePolicy" ng-model="instance.config['cachePolicy'][0]" class="form-control">
                            <option value="DEFAULT">{{:: 'userStorage.cachePolicy.option.DEFAULT' | translate}}</option>
                            <option value="EVICT_DAILY">{{:: 'userStorage.cachePolicy.option.EVICT_DAILY' | translate}}</option>
                            <option value="EVICT_WEEKLY">{{:: 'userStorage.cachePolicy.option.EVICT_WEEKLY' | translate}}</option>
                            <option value="MAX_LIFESPAN">{{:: 'userStorage.cachePolicy.option.MAX_LIFESPAN' | translate}}</option>
                            <option value="NO_CACHE">{{:: 'userStorage.cachePolicy.option.NO_CACHE' | translate}}</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'userStorage.cachePolicy.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group" data-ng-show="instance.config['cachePolicy'][0] == 'EVICT_WEEKLY'">
                <label for="evictionDay" class="col-md-2 control-label">{{:: 'userStorage.evictionDay' | translate}}</label>
                <div class="col-md-2">
                    <div>
                        <select id="evictionDay" ng-model="instance.config['evictionDay'][0]" class="form-control">
                            <option value="1">{{:: 'Sunday' | translate}}</option>
                            <option value="2">{{:: 'Monday' | translate}}</option>
                            <option value="3">{{:: 'Tuesday' | translate}}</option>
                            <option value="4">{{:: 'Wednesday' | translate}}</option>
                            <option value="5">{{:: 'Thursday' | translate}}</option>
                            <option value="6">{{:: 'Friday' | translate}}</option>
                            <option value="7">{{:: 'Saturday' | translate}}</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'userStorage.cachePolicy.evictionDay.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix" data-ng-show="instance.config['cachePolicy'][0] == 'EVICT_WEEKLY' || instance.config['cachePolicy'][0] == 'EVICT_DAILY'">
                <label class="col-md-2 control-label" for="evictionHour">{{:: 'userStorage.cachePolicy.evictionHour' | translate}}</label>
                <div class="col-md-2">
                    <div>
                        <select id="evictionHour" ng-model="instance.config['evictionHour'][0]" class="form-control">
                            <option value="0">00</option>
                            <option value="1">01</option>
                            <option value="2">02</option>
                            <option value="3">03</option>
                            <option value="4">04</option>
                            <option value="5">05</option>
                            <option value="6">06</option>
                            <option value="7">07</option>
                            <option value="8">08</option>
                            <option value="9">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'userStorage.cachePolicy.evictionHour.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix" data-ng-show="instance.config['cachePolicy'][0] == 'EVICT_WEEKLY' || instance.config['cachePolicy'][0] == 'EVICT_DAILY'">
                <label class="col-md-2 control-label" for="evictionMinute">{{:: 'userStorage.cachePolicy.evictionMinute' | translate}}</label>
                <div class="col-md-2">
                    <div>
                        <select id="evictionMinute" ng-model="instance.config['evictionMinute'][0]" class="form-control">
                            <option value="0">00</option>
                            <option value="1">01</option>
                            <option value="2">02</option>
                            <option value="3">03</option>
                            <option value="4">04</option>
                            <option value="5">05</option>
                            <option value="6">06</option>
                            <option value="7">07</option>
                            <option value="8">08</option>
                            <option value="9">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                            <option value="25">25</option>
                            <option value="26">26</option>
                            <option value="27">27</option>
                            <option value="28">28</option>
                            <option value="29">29</option>
                            <option value="30">30</option>
                            <option value="31">31</option>
                            <option value="32">32</option>
                            <option value="33">33</option>
                            <option value="34">34</option>
                            <option value="35">35</option>
                            <option value="36">36</option>
                            <option value="37">37</option>
                            <option value="38">38</option>
                            <option value="39">39</option>
                            <option value="40">40</option>
                            <option value="41">41</option>
                            <option value="42">42</option>
                            <option value="43">43</option>
                            <option value="44">44</option>
                            <option value="45">45</option>
                            <option value="46">46</option>
                            <option value="47">47</option>
                            <option value="48">48</option>
                            <option value="49">49</option>
                            <option value="50">50</option>
                            <option value="51">51</option>
                            <option value="52">52</option>
                            <option value="53">53</option>
                            <option value="54">54</option>
                            <option value="55">55</option>
                            <option value="56">56</option>
                            <option value="57">57</option>
                            <option value="58">58</option>
                            <option value="59">59</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'userStorage.cachePolicy.evictionMinute.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix" data-ng-show="instance.config['cachePolicy'][0] == 'MAX_LIFESPAN'">
                <label class="col-md-2 control-label" for="maxLifespan">{{:: 'userStorage.cachePolicy.maxLifespan' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" type="text"  ng-model="instance.config['maxLifespan'][0]" id="maxLifespan" />
                </div>
                <kc-tooltip>{{:: 'userStorage.cachePolicy.maxLifespan.tooltip' | translate}}</kc-tooltip>
            </div>
        </fieldset>


        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="create && access.manageRealm">
                <button kc-save>{{:: 'save' | translate}}</button>
                <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageRealm">
                <button kc-save  data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
                <button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
            </div>
        </div>
    </form>
</div>

<kc-menu></kc-menu>