<div class="modal-header">
  <button type="button" class="close" ng-click="cancel()" aria-label="Close"><span aria-hidden="true">&times;</span>
  </button>
  <h3 class="modal-title">Revoke <span class="text-muted"><small>{{ certificate.name }}</small></span></h3>
</div>
<div class="modal-body">
  <form name="revokeForm" novalidate>
    <p><strong>Certificate revocation is final. Once revoked the certificate is no longer valid.</strong></p>
    <div class="form-horizontal">
      <div class="form-group"
           ng-class="{'has-error': revokeForm.confirm.$invalid, 'has-success': !revokeForm.$invalid&&revokeForm.confirm.$dirty}">
        <label class="control-label col-sm-2">
          Confirm Certificate Name
        </label>
        <div class="col-sm-10">
          <input name="confirm" ng-model="confirm" placeholder='{{ certificate.name }}'
                 uib-tooltip="Confirm revocation by entering '{{ certificate.name }}'"
                 class="form-control"
                 compare-to="certificate.name"
                 required/>

          <p ng-show="revokeForm.confirm.$invalid && !revokeForm.confirm.$pristine" class="help-block">
            You must confirm certificate revocation.</p>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2">
          Reason
        </label>
        <div class="col-sm-10">
          <select class="form-control" ng-model="crlReason"
                  ng-options="option.value as option.name for option in [
                      {'name': 'Unspecified', 'value': 'unspecified'},
                      {'name': 'Key Compromise', 'value': 'keyCompromise'},
                      {'name': 'CA Compromise', 'value': 'cACompromise'},
                      {'name': 'Affiliation Changed', 'value': 'affiliationChanged'},
                      {'name': 'Superseded', 'value': 'superseded'},
                      {'name': 'Cessation of Operation', 'value': 'cessationOfOperation'},
                      {'name': 'Certificate Hold', 'value': 'certificateHold'},
                      {'name': 'Remove from CRL', 'value': 'removeFromCRL'},
                      {'name': 'Privilege Withdrawn', 'value': 'privilegeWithdrawn'},
                      {'name': 'Attribute Authority Compromise', 'value': 'aACompromise'}]"

                  ng-init="crlReason = 'unspecified'"></select>
        </div>
      </div>
    </div>
  </form>
  <div ng-if="certificate.endpoints.length">
    <p><strong>Certificate might be associated with the following endpoints. Disassociate this
      certificate before revoking or continue if you've already done so.</strong></p>
    <ul class="list-group">
      <li class="list-group-item" ng-repeat="endpoint in certificate.endpoints">
        <span class="pull-right"><label class="label label-default">{{ endpoint.type }}</label></span>
        <ul class="list-unstyled">
          <li>{{ endpoint.name }}</li>
          <li><span class="text-muted">{{ endpoint.dnsname }}</span></li>
        </ul>
      </li>
    </ul>
  </div>
</div>
<div class="modal-footer">
  <button type="submit" ng-click="revoke(certificate, crlReason)" ng-disabled="revokeForm.confirm.$invalid"
          class="btn btn-danger">Revoke
  </button>
  <button ng-click="cancel()" class="btn">Cancel</button>
</div>
