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

<section id="main" class="seccion clearfix">
    <div class="faraday-header-border-fix"></div>
    <div class="left-main-without-pagination">
        <div ng-controller="headerCtrl" ng-include="'scripts/commons/partials/header.html'"></div>
        <div id="reports-main" class="fila clearfix">
            <div class="reports col-md-12 col-sm-12 col-xs-12">
                <div class="button-control justify-flex-start  col-md-12 col-sm-12 col-xs-12">
                    <div class="control-wrapper control-new">
                        <button id="new" type="button" class="btn btn-success btn-new" ng-title="{{workspaceData.readonly == false? 'New credential' : 'Read-only. Workspace disabled'}}" ng-click="new()" ng-disabled="workspaceData.readonly == true">
                            New
                        </button>
                    </div>
                    <table>
                    <thead>
                        <tr>
                            <th class="col-s-1" style="border-left: 1px solid rgb(221, 221, 221); padding-left: 12px;">
                                    <a href="#/status/ws/{{workspace}}" class="status-report" ng-class="{'navigation-active' : component == 'status'}" style="color: black !important; font-weight: bold; font-size: 15px;" uib-tooltip="Vulns" tooltip-placement="right">
                                        Vulns
                                    </a>
                                </th>
                            <th class="col-s-1">
                                <a href="#/hosts/ws/{{workspace}}" class="workspaces" ng-class="{'navigation-active' : component == 'hosts'}" style="color: black !important; font-weight: bold; font-size: 15px;" uib-tooltip="Hosts" tooltip-placement="right">
                                    Hosts
                                </a>
                                <div class="flex-spacer"></div>
                            </th>
                            <th class="col-s-1">
                                <a href="#/credentials/ws/{{workspace}}" class="workspaces" ng-class="{'navigation-active' : component == 'credentials'}" style="color: black !important; font-weight: bold; font-size: 15px;" uib-tooltip="Credentials" tooltip-placement="right">
                                    Credentials
                                </a>
                                <div class="flex-spacer"></div>
                            </th>
                            <th class="col-md-1" style = "border-right: 1px solid rgb(221, 221, 221); padding-right: 12px">
                                <a href="#/taskgroup" class="executive-report" ng-class="{'navigation-active' : component == 'taskgroup'}" style="color: black !important; font-weight: bold; font-size: 15px;">
                                    Tasks
                                </a>
                                <div class="flex-spacer"></div>
                            </th>
                        </tr>
                    </thead>
                </table>
                    <div class="control-wrapper control-edit">
                        <button type="button" class="btn edit" title="{{workspaceData.readonly == false ? 'Edit selected credentials' : 'Read-only. Workspace disabled'}}" ng-disabled="selectedCredentials().length != 1 || workspaceData.readonly == true" ng-click="edit()">
                            <img src="images/icon-toolbar-edit.svg" class="edit-icon" />
                        </button>
                    </div>
                    <div class="control-wrapper">
                        <button  id="delete" type="button" class="btn" title="{{workspaceData.readonly == false ? 'Delete selected credentials' : 'Read-only. Workspace disabled'}}" ng-disabled="selectedCredentials().length == 0 || workspaceData.readonly == true" ng-click="delete()">
                            <img src="images/icon-toolbar-delete.svg" class="delete-icon" />
                        </button>
                    </div>
                    <div class="control-wrapper search-wrapper">
                        <form role="form">
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon glyphicon-btn glyphicon glyphicon-remove" ng-if="search && search != 'confirmed=true'" style="cursor: pointer" ng-click="clearSearch()"></span>
                                    <input type="text" class="form-control" placeholder="Enter keywords" ng-model="search" />
                                    <span class="input-group-addon glyphicon-btn">
                                        <img src="images/icon-toolbar-searchbar-loupe.svg" class="search-icon" />
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="reports col-md-12 col-sm-12 col-xs-12">
            <table ng-if="credentials.length > 0" class="table-v3 licenses-list table table-responsive">
                <thead>
                    <tr class="ui-grid-header">
                        <th class="ui-grid-cell-contents checkbox-select ui-grid-header-cell">
                            <input type="checkbox" ng-model="selectall" ng-click="checkAll()"/>
                        </th>
                        <th ng-if="!parentObject.parent_type" class="ui-grid-cell-contents ui-grid-header-cell">
                            <span ng-click="toggleSort('target')">Target</span>
                        </th>
                        <th class="ui-grid-cell-contents ui-grid-header-cell">
                            <span ng-click="toggleSort('name')">Name</span>
                        </th>
                        <th class="ui-grid-cell-contents ui-grid-header-cell">
                            <span ng-click="toggleSort('username')">Username</span>
                        </th>
                        <th class="ui-grid-cell-contents ui-grid-header-cell">
                            <span ng-click="toggleSort('password')">Password</span>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="credential in credentials | filter:search | orderBy:sort_field:reverse"
                        selection-model selection-model-type="checkbox"
                        selection-model-mode="multiple-additive"
                        selection-model-selected-class="multi-selected"
                        selection-model-on-change="selectedCredentials()">
                        <td class="ui-grid-cell-contents checkbox-select">
                            <input type="checkbox" name="{{credential._id}}"/>
                        </td>
                        <td class="ui-grid-cell-contents" ng-if="!parentObject.parent_type"> {{credential.target}} </td>
                        <td class="ui-grid-cell-contents">{{credential.name}}</td>
                        <td class="ui-grid-cell-contents">{{credential.username}}</td>
                        <td class="ui-grid-cell-contents">{{credential.password}}</td>
                    </tr>
                </tbody>
            </table>
            <h3 ng-if="credentials.length == 0">
                No credentials found in this workspace
            </h3>
        </div>
    </div>
</section>
