<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}}">General</a></li>
        <li class="active" data-ng-show="realm.social"><a href="#/realms/{{realm.realm}}/social-settings">Social</a></li>
        <li><a href="#/realms/{{realm.realm}}/roles">Roles</a></li>
        <li><a href="#/realms/{{realm.realm}}/default-roles">Default Roles</a></li>
        <li><a href="#/realms/{{realm.realm}}/required-credentials">Credentials</a></li>
        <li><a href="#/realms/{{realm.realm}}/token-settings">Token</a></li>
        <li><a href="#/realms/{{realm.realm}}/keys-settings">Keys</a></li>
        <li><a href="#/realms/{{realm.realm}}/smtp-settings">Email</a></li>
    </ul>
    <div id="content">
        <ol class="breadcrumb">
            <li><a href="#/realms/{{realm.realm}}">{{realm.realm}}</a></li>
            <li><a href="#/realms/{{realm.realm}}">Settings</a></li>
            <li class="active">Social</li>
        </ol>
        <h2><span>{{realm.realm}}</span> Social Providers Settings</h2>


        <div class="feedback info inline">
            <p><strong>Social Callback URL:</strong> {{callbackUrl}}</p>
        </div>

        <form name="realmForm" novalidate>
            <fieldset>
                <div>
                    <table>
                        <caption class="hidden">Table of social providers</caption>
                        <thead>
                        <tr>
                            <th colspan="5" class="rcue-table-actions">
                                <div class="actions">
                                    <div class="select-rcue">
                                        <select ng-model="newProviderId"
                                                ng-options="(p|capitalize) for p in (allProviders|remove:configuredProviders)"
                                                data-ng-change="addProvider(newProviderId); newProviderId = null">
                                            <option value="" disabled selected>Add provider...</option>
                                        </select>
                                    </div>
                                </div>
                            </th>
                        </tr>
                        <tr ng-show="configuredProviders.length > 0">
                            <th>Provider</th>
                            <th>Key <span class="required">*</span></th>
                            <th>Secret <span class="required">*</span></th>
                            <th colspan="1">Actions</th>
                        </tr>
                        </thead>
                        <tbody ng-show="configuredProviders.length > 0">
                        <tr ng-repeat="pId in configuredProviders">
                            <td>
                                <div class="clearfix">
                                    <input class="input-small disabled" type="text" value="{{pId|capitalize}}" readonly>
                                </div>
                            </td>
                            <td>
                                <input class="input-small" type="text" placeholder="Key" ng-model="realm.socialProviders[pId+'.key']"
                                       ng-class="{'dirty': postSaveProviders.indexOf(pId) > -1}" required>
                            </td>
                            <td>
                                <input class="input-small" type="text" placeholder="Secret" ng-model="realm.socialProviders[pId+'.secret']"
                                       ng-class="{'dirty': postSaveProviders.indexOf(pId) > -1}" required>
                            </td>
                            <td>
                                <div class="action-div"><i class="icon-remove" ng-click="removeProvider(pId)"></i></div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>

            <div class="form-actions">
                <button type="submit" kc-save class="primary" data-ng-show="changed">Save
                    changes
                </button>
                <button type="submit" kc-reset data-ng-show="changed">Clear changes
                </button>
            </div>
        </form>
    </div>
</div>
</div>

<!-- TODO remove once this page is properly styled -->
<style type="text/css">
    .social-provider input.ng-invalid.dirty,
    .social-provider input.ng-invalid.ng-dirty {
        background-color: #FFEEEE;
    }

    .social-provider .actions > div {
        display: inline-block;
        overflow: hidden;
    }

    .social-provider td {
        font-size: 10px;
    }

    .social-provider .action-div {
        display: inline-block;
        margin: 5px;
    }

    .social-provider .icon-remove, .social-provider .icon-question {
        cursor: pointer;
    }
</style>