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

            <section id="main" class="seccion clearfix">

                <div class="right-main"><div id="reports-main" class="fila clearfix">
                    <h2 class="ws-label">
                        <span id="ws-name" title="Hosts" ng-if="editing && host._id">Editing {{hostName}} in {{workspace}}</span><!-- WS name -->
                        <span id="ws-name" title="Hosts" ng-if="editing && !host._id">Creating host</span><!-- WS name -->
                        <span id="ws-name" title="Hosts" ng-if="!editing">Viewing {{hostName}} in {{workspace}}</span><!-- WS name -->
                        <div id="ws-control" class="btn-group">
                            <button id="refresh" type="button" class="btn btn-danger" title="Refresh current workspace" onclick="location.reload()">
                                <span class="glyphicon glyphicon-refresh"></span>
                            </button>
                            <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" title="Change current workspace">
                                Change workspace <span class="caret"></span>
                            </button>
                            <ul id="nav" class="dropdown-menu dropdown-menu-right" role="menu">
                                <li ng-repeat="ws in workspaces"><a href="#/hosts/ws/{{ws}}" class="ws" >{{ws}}</a></li>
                            </ul><!-- WS navigation -->
                        </div><!-- #ws-control -->
                    </h2>
                    <span ng-hide="!showServices" class="reports col-md-8 col-sm-8 col-xs-8">
                        <h3>Host services</h3>
                        <div>
                            <button type="button" class="btn btn-success btn-sm pull-left" title="New service" ng-click="new()">
                                <span class="glyphicon glyphicon-plus-sign"></span>
                                New service
                            </button>
                            <button type="button" class="btn btn-default btn-sm pull-left" title="Edit selected services" ng-click="edit()" ng-disabled="services.length == 0">
                                <span class="glyphicon glyphicon-pencil"></span>
                                Edit
                            </button>
                            <button type="button" class="btn btn-default btn-sm pull-left" title="Delete selected services" ng-click="delete()" ng-disabled="services.length == 0">
                                <span class="glyphicon glyphicon-trash"></span>
                                Delete
                            </button>
                            <form ng-submit="searchFor(true, searchParams)">
                                <div class="input-group input-group-sm" style="padding-left: 10px">
                                        <span class="input-group-addon glyphicon-btn glyphicon glyphicon-remove" ng-click="searchFor(false, '')" ng-if="search"></span>
                                        <input type="text" class="form-control" id="filter-by"
                                        placeholder="enter keywords" ng-model="searchParams" />
                                        <span class="input-group-addon glyphicon-btn">
                                            <i class="fa fa-search" ng-if="loadedServices"></i>
                                            <i class="fa fa-refresh fa-spin" ng-if="!loadedServices"></i>
                                        </span>
                                </div>
                            </form>
                            <!-- .ws-label -->
                        </div>
                        <div ng-if="loadedServices && services.length == 0">
                            <h4>No services found for {{host.name}}</h4>
                        </div>
                        <div ng-show="loadedServices && services.length > 0">
                            <table class="status-report hosts-list table table-responsive" style="margin-top: 15px">
                                <thead>
                                    <tr>
                                        <th><input type="checkbox" ng-model="selectall" ng-click="checkAllServices()"/></th>
                                        <th>
                                            <a href="" ng-click="toggleSort('name')">Name</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('version')">Version</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('ports')">Ports</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('protocol')">Protocol</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('status')">Status</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('vulns')">Vulns</a>
                                        </th>
                                        <th>
                                            <a href="" ng-click="toggleSort('credentials')">Credentials</a>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr ng-repeat="service in filtered = (services | filter:expression) | orderBy:sortField:reverse | startFrom:(currentPage-1)*pageSize | limitTo:pageSize"
                                        selection-model selection-model-type="checkbox"
                                                        selection-model-mode="multiple-additive"
                                                        selection-model-selected-class="multi-selected">
                                        <td><input type="checkbox" name="{{s._id}}"/></td>
                                        <td>
                                            <a ng-href="#/host/ws/{{workspace}}/hid/{{host._id}}/search/name={{service.name}}">
                                                <span ng-bind="service.name"></span>
                                            </a>
                                            <osint-link query="service.name" osint="osint"></osint-link>
                                        </td>
                                        <td ng-bind="service.version || '-'"></td>
                                        <td>
                                            <span ng-bind="service.ports"></span>
                                            <osint-link query="'port:' + service.ports" osint="osint"></osint-link>
                                        </td>
                                        <td>
                                            <a ng-href="#/host/ws/{{workspace}}/hid/{{host._id}}/search/protocol={{service.protocol}}">
                                                <span ng-bind="service.protocol"></span>
                                            </a>
                                        </td>
                                        <td ng-bind="service.status || '-'"></td>
                                        <td>
                                            <a ng-href="#/status/ws/{{workspace}}/search/service={{service.ports}}&target={{host.name}}">
                                                <span ng-bind="service.vulns"></span>
                                            </a>
                                        </td>
                                        <td>
                                            <a ng-href="#/credentials/ws/{{workspace}}/sid/{{service._id}}">{{service.credentials}}</a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table><!-- #hosts -->
                            <div class="showPagination">
                                <div class="form-group">
                                    <ul class="pagination">
                                        <li><a ng-hide="prevPageDisabled()" ng-click="prevPage()"><span aria-hidden="true">&laquo;</span><span class="sr-only">Previous</span></a></li>
                                        <li><a>{{currentPage}}/{{pageCount()}}</a></li>
                                        <li><a ng-hide="nextPageDisabled()" ng-click="nextPage()"><span aria-hidden="true">&raquo;</span><span class="sr-only">Next</span></a></li>
                                    </ul>
                                    <form name="goToPage" id="goToPageStatus">
                                        <div class="col-md-2">
                                            <input type="number" min="0" max="{{pageCount()}}" class="form-control" ng-model="newCurrentPage" placeholder="Go to page"/>
                                        </div>
                                        <button class="btn btn-default" ng-click="go()">GO</button>
                                        <input type="number" min="1" class="form-control vuln_per_page" ng-model=newPageSize placeholder="Number page" />
                                    </form>
                                </div>
                            </div><!-- .showPagination -->
                        </div><!-- .reports -->
                    </span>
                    <div class="reports col-md-4 col-sm-4 col-xs-4" style="border-left: 1px solid #CCC">
                        <form name="form">
                            <h3>
                                Host details
                                <span style="float:right">
                                    <a class="btn btn-sm btn-default" href="#/host/ws/{{workspace}}/hid/{{host._id}}/edit" ng-if="!editing">
                                        <span class="glyphicon glyphicon-pencil"></span>
                                        Edit
                                    </a>
                                    <button type="button" class="btn btn-sm btn-default" title="Delete host" ng-click="deleteHost()" ng-if="!editing">
                                        <span class="glyphicon glyphicon-trash"></span>
                                        Delete
                                    </button>
                                    <a class="btn btn-danger" href="#/host/ws/{{workspace}}/hid/{{host._id}}" ng-click="loadHosts()" ng-if="editing && !creating">Cancel</a>
                                    <button class="btn btn-success" ng-disabled="form.$invalid" ng-click="ok()" ng-if="editing">OK</button>
                                </span>
                            </h3>
                            <div class="form-horizontal">
                                <div class="form-group" ng-class="{'has-error': !host.name}">
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">Name</strong>
                                        <h5 ng-if="editing">Name</h5>
                                        <label class="sr-only" for="name">Name</label>
                                        <input type="text" class="form-control" id="name" placeholder="Name" ng-model="host.name" ng-if="editing" required/>
                                        <br ng-if="!editing">
                                        <span ng-if="!editing">{{host.name}}</span>
                                        <span class="help-block normal-size" ng-if="editing">
                                            Example: 192.168.0.1
                                        </span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-6" style="margin-bottom: 15px">
                                        <span>Owned:</span>
                                        <input class="form-check-input" type="checkbox" id="owned" ng-model="host.owned" ng-disabled="!editing"></input>
                                    </div>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">Operating System</strong>
                                        <h5 ng-if="editing">Operating System</h5>
                                        <label class="sr-only" for="os">Operating System</label>
                                        <input type="text" class="form-control" id="os" placeholder="Operating System" ng-model="host.os" ng-if="editing"/>
                                        <p ng-if="!editing">
                                        <img ng-if="host.icon && host.icon != 'unknown'" ng-src="images/{{host.icon}}.png" uib-tooltip="{{host.os}}"/>
                                        {{host.os}}
                                        </p>
                                    </div>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">Hostnames</strong>
                                        <h5 ng-if="editing">Hostnames</h5>
                                        <span class="input-group-addon button-radius" ng-click="newHostnames($event)" ng-if="editing">Add Hostname</span>
                                    </div>
                                    <span ng-if="editing">
                                        <div class="col-md-12 input-margin" ng-repeat="hostname in interface.hostnames">
                                            <div class="input-group margin-bottom-sm col-md-12">
                                                <label class="sr-only" for="hostsnames">Hostname</label>
                                                <input type="text" class="form-control" id="hostsnames" placeholder="Hostname" ng-model="hostname.key" />
                                                <span class="input-group-addon" ng-click="interface.hostnames.splice($index, 1)" ng-hide="interface.hostnames.length == 1" ng-if="editing"><i class="fa fa-minus-circle"></i></span>
                                            </div>
                                        </div>
                                    </span>
                                    <span ng-if="!editing">
                                        <div class="col-md-12 input-margin">
                                            <ul>
                                                <li ng-repeat="hostname in interface.hostnames">{{hostname.key}}</li>
                                            </ul>
                                        </div>
                                    </span>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">IPv4</strong>
                                        <h5 ng-if="editing">IPv4</h5>
                                        <input type="text" class="form-control" id="ipv4" placeholder="IPv4" ng-model="interface.ipv4.address" ng-if="editing"/>
                                        <p ng-if="!editing">{{interface.ipv4.address}}</p>
                                    </div>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">IPv6</strong>
                                        <h5 ng-if="editing">IPv6</h5>
                                        <input type="text" class="form-control" id="ipv6" placeholder="IPv6" ng-model="interface.ipv6.address" ng-if="editing"/>
                                        <p ng-if="!editing">{{interface.ipv6.address}}</p>
                                    </div>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">MAC</strong>
                                        <h5 ng-if="editing">MAC</h5>
                                        <input type="text" class="form-control" id="ipv4" placeholder="MAC" ng-model="interface.mac" ng-if="editing"/>
                                        <p ng-if="!editing">{{interface.mac}}</p>
                                    </div>
                                    <div class="col-md-12">
                                        <strong ng-if="!editing">Description</strong>
                                        <h5 ng-if="editing">Description</h5>
                                        <label class="sr-only" for="description">Description</label>
                                        <textarea class="form-control" id="description" placeholder="Description" ng-model="host.description" ng-if="editing"></textarea>
                                        <p ng-if="!editing">{{host.description}}</p>
                                    </div>
                                    <div class="col-md-12">
                                        <i ng-if="!editing">
                                            </br>
                                            <span class="fa fa-clock-o"></span>
                                            <span> Created</span>
                                            <span am-time-ago="host.metadata.create_time * 1000"></span>
                                            <span ng-if="!host.metadata.create_time" am-time-ago="host.metadata.update_time * 1000"></span>
                                        </i>
                                    </div>
                                </div><!-- .form-group -->
                            </div>
                            <div style="float: right">
                                <a class="btn btn-danger" href="#/host/ws/{{workspace}}/hid/{{host._id}}" ng-click="loadHosts()" ng-if="editing && !creating">Cancel</a>
                                <a class="btn btn-danger" href="#/hosts/ws/{{workspace}}" ng-if="editing && creating">Cancel</a>
                                <button class="btn btn-success" ng-disabled="form.$invalid" ng-click="ok()" ng-if="editing">OK</button>
                            </div>
                        </form>
                    </div>
                </div><!-- #reports-main --></div><!-- .right-main -->
            </section><!-- #main -->
