<!--

    Copyright (C) 2015-2016 Jeeva Kandasamy (jkandasa@gmail.com)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div>

  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"  ng-click="cancel()">
      <span class="pficon pficon-close"></span>
    </button>
    <div class="modal-title"><b>{{header}}</b></div>
  </div>

  <div class="modal-body modal-body-text-only">
    <form class="form-horizontal" name="mcForm">
      <div class="form-group">
        <label class="col-sm-2 control-label">{{ 'TEMPLATE' | translate }}</label>
        <div class="col-sm-10">
           <label>{{request.template}}</label>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{{ 'SCRIPT' | translate }}</label>
        <div class="col-sm-10">
          <select class="form-control" pf-select data-live-search="true" ng-options="script for script in scripts"  ng-model="request.script" >
            <option value="" ng-hide="false">{{ 'NOTHING_SELECTED' | translate }}</option>
          </select>
        </div>
      </div>
      <div class="form-group" ng-if="request.script">
        <label class="col-sm-2 control-label">{{ 'SCRIPT_BINDINGS' | translate }}</label>
        <div class="col-sm-10">
          <input class="form-control" placeholder="{{ 'SCRIPT_BINDINGS' | translate }}" ng-model="request.bindings" pf-validation="cs.isJsonString(input)" required />
          <span class="help-block">{{ 'SYNTAX_ERROR' | translate }}</span>
        </div>
      </div>
    </form>
    <div ng-if="templateResult">
      <legend><small>{{ 'RESULT' | translate }}</small></legend>
      <mc-dynamic ng-bind-html="templateResult"></mc-dynamic>
    </div>
  </div>

  <div class="modal-footer">
    <button class="btn btn-default" ng-click="cancel()"><i class="fa fa-close"></i> {{ 'CANCEL' | translate }}</button>
    <button class="btn btn-primary" ng-click="runNow()" ng-disabled="runningInProgress || mcForm.$invalid">
      <div ng-if="runningInProgress" class="spinner spinner-xs"></div>
      <i class="fa fa-play"></i> {{runningInProgress ? ('RUNNING' | translate):('RUN' | translate)}}</button>
  </div>

</div>
