<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}}/clients">{{:: 'clients' | translate}}</a></li>
        <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
        <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
        <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
        <li data-ng-show="create">{{:: 'authz-add-drools-policy' | translate}}</li>
        <li data-ng-hide="create">Rules</li>
        <li data-ng-hide="create">{{originalPolicy.name}}</li>
    </ol>

    <h1 data-ng-show="create">{{:: 'authz-add-drools-policy' | translate}}</h1>
    <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
                                                         data-ng-click="remove()"></i></h1>

    <form class="form-horizontal" name="clientForm" novalidate>
        <fieldset class="border-top">
            <div class="form-group">
                <label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
                <div class="col-sm-6">
                    <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
                </div>
                <kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="description">{{:: 'description' | translate}} </label>
                <div class="col-sm-6">
                    <input class="form-control" type="text" id="description" name="description" data-ng-model="policy.description">
                </div>
                <kc-tooltip>{{:: 'authz-policy-description.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="artifactGroupId">{{:: 'authz-policy-drools-maven-artifact' | translate}} <span class="required" data-ng-show="create">*</span></label>
                <button data-ng-click="resolveModules()" id="resolveModule" class="btn btn-primary">{{:: 'authz-policy-drools-maven-artifact-resolve' | translate}}</button>
                <div class="col-sm-3">
                    <input class="form-control" type="text" id="artifactGroupId" name="artifactGroupId" data-ng-model="policy.artifactGroupId" placeholder="Group Identifier" required>
                </div>
                <kc-tooltip>{{:: 'authz-policy-drools-maven-artifact.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="artifactId"></label>
                <div class="col-sm-3">
                    <input class="form-control" type="text" id="artifactId" name="artifactId" data-ng-model="policy.artifactId" autofocus placeholder="Artifact Identifier" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="artifactVersion"></label>
                <div class="col-sm-3">
                    <input class="form-control" type="text" id="artifactVersion" name="artifactVersion" data-ng-model="policy.artifactVersion" autofocus placeholder="Version" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="moduleName">{{:: 'authz-policy-drools-module' | translate}} <span class="required" data-ng-show="create">*</span></label>
                <div class="col-sm-3">
                    <div>
                        <select class="form-control" id="moduleName"
                                ng-model="policy.moduleName"
                                ng-options="moduleName as moduleName for moduleName in drools.moduleNames"
                                ng-change="resolveSessions()"
                                ng-disabled="!drools.moduleNames.length"
                                required>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'authz-policy-drools-module.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="sessionName">{{:: 'authz-policy-drools-session' | translate}} <span class="required" data-ng-show="create">*</span></label>
                <div class="col-sm-3">
                    <div>
                        <select class="form-control" id="sessionName"
                                ng-model="policy.sessionName"
                                ng-options="sessionName as sessionName for sessionName in drools.moduleSessions"
                                ng-disabled="!drools.moduleSessions.length"
                                required>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'authz-policy-drools-session.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="scannerPeriod">{{:: 'authz-policy-drools-update-period' | translate}}</label>
                <div class="col-md-6 time-selector">
                    <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="policy.scannerPeriod" id="scannerPeriod"
                           name="scannerPeriod"
                           ng-disabled="!policy.sessionName"/>
                    <select class="form-control" id="scannerPeriodUnit" name="scannerPeriodUnit"
                            data-ng-model="policy.scannerPeriodUnit"
                            ng-disabled="!policy.sessionName">
                        <option value="Seconds">{{:: 'seconds' | translate}}</option>
                        <option value="Minutes">{{:: 'minutes' | translate}}</option>
                        <option value="Hours">{{:: 'hours' | translate}}</option>
                        <option value="Days">{{:: 'days' | translate}}</option>
                    </select>
                </div>
                <kc-tooltip>{{:: 'authz-policy-drools-update-period.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="logic">{{:: 'authz-policy-logic' | translate}}</label>

                <div class="col-sm-1">
                    <select class="form-control" id="logic"
                            data-ng-model="policy.logic">
                        <option value="POSITIVE">{{:: 'authz-policy-logic-positive' | translate}}</option>
                        <option value="NEGATIVE">{{:: 'authz-policy-logic-negative' | translate}}</option>
                    </select>
                </div>

                <kc-tooltip>{{:: 'authz-policy-logic.tooltip' | translate}}</kc-tooltip>
            </div>
            <input type="hidden" data-ng-model="policy.type"/>
        </fieldset>

        <div class="form-group" data-ng-show="access.manageAuthorization">
            <div class="col-md-10 col-md-offset-2">
                <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>