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

    <h1>
        <span>{{:: 'partial-import' | translate}}</span>
        <kc-tooltip>{{:: 'partial-import.tooltip' | translate}}</kc-tooltip>
    </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">{{:: 'exported-json-file' | translate}}</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' | translate}}</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' | translate}} ({{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' | translate}} ({{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' | translate}} ({{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' | translate}} ({{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' | translate}} ({{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-resource-exists' | translate}}</label>
                <div class="col-md-2">
                    <div>
                        <select id="ifResourceExists" ng-model="ifResourceExists" class="form-control">
                            <option value="FAIL">{{:: 'fail' | translate}}</option>
                            <option value="SKIP">{{:: 'skip' | translate}}</option>
                            <option value="OVERWRITE">{{:: 'overwrite' | translate}}</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'if-resource-exists.tooltip' | translate}}</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' | translate}}</th>
                        <th>{{:: 'type' | translate}}</th>
                        <th>{{:: 'name' | translate}}</th>
                        <th>{{:: 'id' | translate}}</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' | translate}}</button>
                <button data-ng-click="setPreviousPage()" class="prev" ng-disabled="!hasPrevious()">{{:: 'previous-page' | translate}}</button>
                <button data-ng-click="setNextPage()" class="next" ng-disabled="!hasNext()">{{:: 'next-page' | translate}}</button>
            </div>
        </div>
    </form>
</div>

<kc-menu></kc-menu>