<!-- 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">Hosts for {{workspace}} ({{totalHosts}})</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 -->
                        <button id="delete" type="button" class="btn btn-default" title="Delete selected hosts" ng-click="delete()">
                            <span class="glyphicon glyphicon-trash"></span>
                            Delete
                        </button>
                        <button id="merge" type="button" class="btn btn-default" title="Edit selected hosts" ng-disabled="selectedHosts().length > 1" ng-click="edit()">
                            <span class="glyphicon glyphicon-pencil"></span>
                            Edit
                        </button>
                        <a id="merge" href="#/host/ws/{{workspace}}/new" class="btn btn-success" title="New host">
                            <span class="glyphicon glyphicon-plus-sign"></span>
                            New
                        </a>
                    </h2><!-- .ws-label -->
                    <div class="reports col-md-9 col-sm-9 col-xs-12">
                        <div class="col-md-6 col-sm-3 col-xs-11">
                            <form role="form" ng-submit="searchFor(true, searchParams)">
                                <div class="form-group">
                                    <div class="input-group input-group-sm">
                                        <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-change="currentPage = 1" ng-model="searchParams" />
                                        <span class="input-group-addon glyphicon-btn" ng-click="searchFor(true, searchParams)">
                                            <i class="fa fa-search" ng-if="loadedVulns"></i>
                                            <i class="fa fa-refresh fa-spin" ng-if="!loadedVulns"></i>
                                        </span>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <table class="status-report hosts-list table table-responsive">
                            <thead>
                                <tr>
                                    <th><input type="checkbox" ng-model="selectall" ng-click="checkAll()"/></th>
                                    <th>
                                        <a href="" ng-click="toggleSort('name')">Name</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('services')">Open Services</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('vulns')">Vulns</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('credentials')">Credentials</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('os')">OS</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('owned')">Owned</a>
                                    </th>
                                    <th>
                                        <a href="" ng-click="toggleSort('metadata.update_time')">Last modified</a>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat="host in hosts"
                                    selection-model selection-model-type="checkbox"
                                    selection-model-mode="multiple-additive"
                                    selection-model-selected-class="multi-selected"
                                    selection-model-on-change="selectedHosts()">
                                    <td><input type="checkbox" name="{{host._id}}"/></td>
                                    <td>
                                        <a ng-href="#/host/ws/{{workspace}}/hid/{{host._id}}">{{host.name}}</a>
                                        <osint-link query="host.name" osint="osint"></osint-link>
                                    </td>
                                    <td><a ng-href="#/host/ws/{{workspace}}/hid/{{host._id}}" ng-bind="host.services || '-'"></a></td>
                                    <td><a ng-href="#/status/ws/{{workspace}}/search/target={{host.name}}" ng-bind="host.vulns"></a></td>
                                    <td>
                                        <a ng-href="#/credentials/ws/{{workspace}}/hid/{{host._id}}">{{host.credentials}}</a>
                                    </td>
                                    <td>
                                        <a ng-href="#/hosts/ws/{{workspace}}/search/os={{host.os}}">
                                            <img ng-if="host.icon != undefined" ng-src="images/{{host.icon}}.png" uib-tooltip="{{host.os}}"/>
                                            <span ng-if="host.icon == undefined" class="fa fa-laptop" uib-tooltip="{{host.os}}"></span>
                                        </a>
                                    </td>
                                    <td>
                                        <span class="fa fa-exclamation-triangle" aria-hidden="true" ng-if="host.owned"></span>
                                        <span ng-if="host.owned"> owned</span>
                                        <span ng-if="!host.owned">not yet</span>
                                    </td>
                                    <td>
                                        <span am-time-ago="host.metadata.update_time * 1000"></span>
                                        <span ng-if="!host.metadata.update_time" am-time-ago="host.metadata.create_time * 1000"></span>
                                    </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="1" 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 -->
                </div><!-- #reports-main --></div><!-- .right-main -->
            </section><!-- #main -->
