<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2017  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<form name="form" novalidate>
    <div class="modal-header">
        <h3 class="modal-title">{{title}}</h3>
    </div>
    <div class="modal-body">
        <div class="form-horizontal">
            <div class="form-group" ng-if="showTargets()">
                <div class="col-md-12">
                    <h5>
                        Target
                    </h5>
                    <div class="form-group">
                        <form name="formSearch" role="form">
                            <div class="col-md-8">
                                <div class="form-group input-accordion">
                                    <input type="text" ng-model="targetFilter.ip" class="form-control input-sm"
                                            placeholder="Search targets" ng-change="currentPage = 1">
                                    <span class="btn btn-danger" id="btn_clear_search"
                                            ng-if="!isEmpty(targetFilter) && activeSearch === true"
                                            ng-click="clearFilterTargets()">
                                        <i class="fa fa-times"></i>
                                    </span>
                                </div>
                            </div>
                            <div class="col-md-2">
                                <div class="form-group">
                                    <button type="submit" class="btn btn-success btn-xs background-blue" title="Search targets"
                                            ng-click="filterTargets()" style="height: 30px!important; float: left;"
                                            ng-disabled="isEmpty(targetFilter)">
                                        Search
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <uib-accordion close-others="true">
                        <uib-accordion-group is-open="isopen"
                                             ng-repeat="host in targets"
                                             template-url="scripts/statusReport/partials/accordion-group.html"
                                             is-disabled="host.services.length < 1">
                            <uib-accordion-heading>
                                <a ng-click="assignTarget(host, host.ip)" ng-class="{'multi-selected': credentialData.targetsArray.indexOf(host) >= 0}">{{host.name}} ({{host.hostnames[0]}})</a>
                            </uib-accordion-heading>
                            <div class="panel-body" ng-repeat="service in host.services">
                                <a ng-model="service" ng-click="assignTarget(service, host.ip)" ng-class="{'multi-selected': credentialData.targetsArray.indexOf(service) >= 0}">{{service.name}} {{service.ports}}</a>
                            </div>
                        </uib-accordion-group>
                    </uib-accordion>

                    <div class="showPagination" ng-if="total_rows > pageSize">
                        <div class="form-group">
                            <ul class="pagination">
                                <li>
                                    <a ng-hide="currentPage <= 1"
                                       ng-click="updatePaginator()">
                                        <span aria-hidden="true">&laquo;</span>
                                        <span class="sr-only">Previous</span>
                                    </a>
                                </li>
                                <li><a>{{currentPage}}/{{ ((total_rows / pageSize) | integer) + 1}}</a></li>
                                <li>
                                    <a ng-hide="currentPage > ((total_rows / pageSize) | integer)"
                                       ng-click="updatePaginator(true)">
                                        <span aria-hidden="true">&raquo;</span>
                                        <span class="sr-only">Next</span>
                                    </a>
                                </li>
                            </ul>
                            <ng-form name="goToPage">
                                <div class="col-md-2">
                                    <input type="number" class="form-control" ng-maxlength="((total_rows / pageSize) | integer)"
                                            ng-model="newCurrentPage.value" ng-change="newCurrentPage"placeholder="Go to page"/>
                                </div>
                                <button type="submit" class="btn btn-danger background-blue" ng-click="go()">GO</button>
                            </ng-form>
                        </div>
                    </div>
                    <div class="alert alert-danger target_not_selected" role="alert"
                         ng-hide="credentialData.targetsArray.length > 0">
                        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                        <span class="sr-only">Error:</span>
                        There is no target selected
                    </div>
                </div>
            </div>
            <div class="col-md-12 custom-divider"></div>
            <div class="tab-pane-header">Credential</div>
            <div class="form-group">

                <div class="col-md-3" ng-class="{'has-error': form.nameCredential.$invalid}">
                    <input type="text" class="form-control" id="nameCredential" name="nameCredential" placeholder="Name" ng-model="credentialData.name"/>
                </div>
                <div class="col-md-3" ng-class="{'has-error': form.usernameCredential.$invalid}">
                    <input type="text" class="form-control" id="usernameCredential" name="usernameCredential" placeholder="Username" ng-model="credentialData.username" required/>
                </div>
                <div class="col-md-3" ng-class="{'has-error': form.passwordCredential.$invalid}">
                    <input type="text" class="form-control" id="passwordCredential" name="passwordCredential" placeholder="Password" ng-model="credentialData.password"/>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <div class="modal-button">
            <button class="btn btn-success" ng-disabled="form.$invalid || invalidSubmit()" ng-click="ok()">OK</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
    </div>
</form>
