<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">

    <h1>Partial Import</h1>

    <form class="form-horizontal" name="partialImportForm" novalidate>
        <fieldset class="border-top">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label">File</label>

                <div class="col-md-6" data-ng-hide="importing">
                    <label for="import-file" class="btn btn-default">{{:: 'select-file'| translate}} <i class="pficon pficon-import"></i></label>
                    <input id="import-file" type="file" class="hidden" kc-on-read-file="importFile($fileContent)"/>
                </div>

                <div class="col-md-6" data-ng-show="importing">
                    <button class="btn btn-default" data-ng-click="viewImportDetails()">{{:: 'view-details'| translate}}</button>
                    <button class="btn btn-default" data-ng-click="reset()">{{:: 'clear-import'| translate}}</button>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && isMultiRealm && !hasResults()">
                <label for="fromRealm" class="col-md-2 control-label">Import from realm</label>
                <div class="col-md-2">
                    <div>
                        <select id="fromRealm" ng-model="fileContent" class="form-control" 
                                ng-options="item as item.realm for item in rawContent">
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasArray('users') && !hasResults()">
                <label class="col-md-2 control-label" for="importUsers">Import Users ({{itemCount('users')}})</label>
                <div class="col-sm-6">
                    <input ng-model="importUsers" name="importUsers" id="importUsers" onoffswitch on-text="{{:: 'onText'| translate}}" off-text="{{:: 'offText'| translate}}"/>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasArray('clients') && !hasResults()">
                <label class="col-md-2 control-label" for="importClients">Import Clients ({{itemCount('clients')}})</label>
                <div class="col-sm-6">
                    <input ng-model="importClients" name="importClients" id="importClients" onoffswitch on-text="{{:: 'onText'| translate}}" off-text="{{:: 'offText'| translate}}"/>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasArray('identityProviders') && !hasResults()">
                <label class="col-md-2 control-label" for="importIdentityProviders">Import Identity Providers ({{itemCount('identityProviders')}})</label>
                <div class="col-sm-6">
                    <input ng-model="importIdentityProviders" name="importIdentityProviders" id="importIdentityProviders" onoffswitch on-text="{{:: 'onText'| translate}}" off-text="{{:: 'offText'| translate}}"/>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasRealmRoles() && !hasResults()">
                <label class="col-md-2 control-label" for="importRealmRoles">Import Realm Roles ({{itemCount('roles.realm')}})</label>
                <div class="col-sm-6">
                    <input ng-model="importRealmRoles" name="importRealmRoles" id="importRealmRoles" onoffswitch on-text="{{:: 'onText'| translate}}" off-text="{{:: 'offText'| translate}}"/>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasClientRoles() && !hasResults()">
                <label class="col-md-2 control-label" for="importClientRoles">Import Client Roles ({{itemCount('roles.client')}})</label>
                <div class="col-sm-6">
                    <input ng-model="importClientRoles" name="importClientRoles" id="importClientRoles" onoffswitch on-text="{{:: 'onText'| translate}}" off-text="{{:: 'offText'| translate}}"/>
                </div>
            </div>

            <div class="form-group" data-ng-show="importing && hasResources() && !hasResults()">
                <label for="ifResourceExists" class="col-md-2 control-label">If a resource exists</label>
                <div class="col-md-2">
                    <div>
                        <select id="ifResourceExists" ng-model="ifResourceExists" class="form-control">
                            <option value="FAIL">Fail</option>
                            <option value="SKIP">Skip</option>
                            <option value="OVERWRITE">Overwrite</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>Specify what should be done if you try to import a resource that already exists.</kc-tooltip>
            </div>
        </fieldset>

        <div class="form-group" data-ng-show="importing && hasResources() && !hasResults()">
            <div class="col-md-10 col-md-offset-2">
                <button kc-save data-ng-disabled="!changed">{{:: 'import'| translate}}</button>
            </div>
        </div>

        <div class="form-group" data-ng-show="hasResults()">
            {{successMessage()}}
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>Action</th>
                        <th>Type</th>
                        <th>Name</th>
                        <th>Id</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="result in resultsPage()" >
                        <td ng-show="result.action == 'OVERWRITTEN'"><span class="label label-danger">{{result.action}}</span></td>
                        <td ng-show="result.action == 'SKIPPED'"><span class="label label-warning">{{result.action}}</span></td>
                        <td ng-show="result.action == 'ADDED'"><span class="label label-success">{{result.action}}</span></td>
                        <td>{{result.resourceType}}</td>
                        <td>{{result.resourceName}}</td>
                        <td>{{result.id}}</td>
                    </tr>
                </tbody>
            </table>
            
            <div class="table-nav">
                <button data-ng-click="setFirstPage()" class="first" ng-disabled="">First page</button>
                <button data-ng-click="setPreviousPage()" class="prev" ng-disabled="!hasPrevious()">Previous page</button>
                <button data-ng-click="setNextPage()" class="next" ng-disabled="!hasNext()">Next page</button>
            </div>
        </div>
    </form>
</div>

<kc-menu></kc-menu>