<div class="main_list" off-click-filter="'.download-js-link, .sidebar-shown, #app-sidebar'">
	<div id="passman-controls" ng-class="{ 'sidebar-shown': selectedCredential }">
		<div class="breadcrumb">
			<div class="breadcrumb">
				<div class="crumb svg ui-droppable" data-dir="/">
					<a ng-click="logout()"><i class="fa fa-home"></i></a>
				</div>
				<div class="crumb svg" ng-click="clearState()">
					<a>{{active_vault.name}}</a>
				</div>

			</div>
			<div class="addCredential" ng-hide="delete_time>0">
				<button ng-click="addCredential()">+</button>
			</div>
		</div>

		<div class="title" credential-counter="filtered_credentials" vault="active_vault" delete-time="delete_time" filters="filterOptions"></div>

		<div class="searchboxContainer" ng-init="filterOptionShown = false;" off-click="filterOptionShown = false;">
			<input type="text" ng-model="filterOptions.filterText" class="searchbox" id="searchBox"
				   placeholder="{{'search.credential' | translate}}" select-on-click clear-btn ng-click="filterOptionShown = true;">
			<div class="searchOptions" ng-show="filterOptionShown">
				<input type="checkbox" ng-model="filterOptions.useRegex"> {{ 'use.regex' | translate }}
			</div>
		</div>

		<div class="viewModes">
			<div class="view-mode" ng-class="{'active': view_mode === 'list' }"
				 ng-click="switchViewMode('list')"><i class="fa fa-list"></i></div>
			<div class="view-mode" ng-class="{'active': view_mode === 'grid' }"
				 ng-click="switchViewMode('grid')"><i class="fa fa-th-large"></i>
			</div>
		</div>
	</div>
	<div class="loaderContainer" ng-if="show_spinner">
		<div class="loader" use-theme type="'border-bottom-color'"></div>
	</div>
	<div ng-init="menuOpen = false;">
		<table class="credential-table"
			   ng-if="view_mode === 'list'">
			<tr ng-repeat="credential in filtered_credentials | orderBy:'label'"
				ng-if="showCredentialRow(credential)"
				ng-click="selectCredential(credential)"  ng-dblclick="editCredential(credential)"
				ng-class="{'selected': selectedCredential.credential_id == credential.credential_id}">
				<td>
					<span class="tags">
					<span class="tag" ng-repeat="tag in credential.tags_raw">{{ ::tag.text}}</span>

					</span>
					<span class="icon" ng-if="credential.url">
						<credential-icon credential="credential"></credential-icon>
					</span>
					<span class="icon" ng-if="!credential.url">
						<i class="fa fa-lock" ng-if="!credential.acl && !credential.shared_key"></i>
						<i class="fa fa-share-alt" ng-if="credential.acl"></i>
						<i class="fa fa-share-alt-square" ng-if="credential.shared_key"> </i>
					</span>
					<a class="label">{{ ::credential.label}}</a>


				</td>
			</tr>
		</table>

		<ul class="grid-view" ng-if="view_mode === 'grid'">
			<li class="credential"
				ng-repeat="credential in filtered_credentials | orderBy:'label'"
				ng-if="credential.hidden == 0 && showCredentialRow(credential)"
				ng-click="selectCredential(credential)"
				use-theme type="'border-color'">
				<div class="credential_content">
					<div>
						<span class="icon" ng-if="credential.url">
							<credential-icon credential="credential"></credential-icon>
						</span>
						<span class="icon" ng-if="!credential.url">
							<i class="fa fa-lock" ng-if="!credential.acl && !credential.shared_key"></i>
							<i class="fa fa-share-alt" ng-if="credential.acl"></i>
							<i class="fa fa-share-alt-square" ng-if="credential.shared_key"> </i>
						</span>
						<div class="label">{{ ::credential.label}}</div>
					</div>
					<div class="tags">
						<div class="tag" ng-repeat="tag in credential.tags_raw">
							{{ ::tag.text}}
						</div>
					</div>
				</div>
			</li>
		</ul>
		<div ng-if="getListSizes().listsize_wout_deleted==0 && no_credentials_label.all && !show_spinner && selectedtags.length==0 && filterOptions.filterText==''" class="nopasswords" ng-hide="delete_time>0">
			<b>{{'vault.hint.hello' | translate}}</b><br>
			<div>{{'vault.hint.hello.add' | translate}}</div>
			<div class="">
				<button ng-click="addCredential()">+</button>
			</div>
		</div>

        <!--nopassword-hint for missing tagresults -->
		<div ng-if="getListSizes().listsize_wout_deleted==0 && no_credentials_label.all && !show_spinner && selectedtags.length>0" class="nopasswords" ng-hide="delete_time>0">
			<div>{{ 'vault.hint.list.notags' | translate}}</div>
		</div>

        <!--nopassword-hint for missing searchresults -->
        <div ng-if="getListSizes().listsize_wout_deleted==0 && no_credentials_label.all && !show_spinner && selectedtags.length==0 && filterOptions.filterText!=''" class="nopasswords" ng-hide="delete_time>0">
            <div>{{ 'vault.hint.list.nosearch' | translate}} <b>'{{filterOptions.filterText}}'</b></div>
        </div>



		<!--nopassword-hint for good strength -->
		<div  class="nopasswords" ng-if="no_credentials_label.s_good" ng-hide="getListSizes().listsize_wout_deleted>0">
			<div>{{ 'vault.hint.list.nogood' | translate}}</div>
		</div>

		<!--nopassword-hint for medium strength -->
		<div  class="nopasswords" ng-if="no_credentials_label.s_medium" ng-hide="getListSizes().listsize_wout_deleted>0">
			<div>{{ 'vault.hint.list.nomedium' | translate}}</div>
		</div>

		<!--nopassword-hint for bad strength -->

		<div  class="nopasswords" ng-if="no_credentials_label.s_low" ng-hide="getListSizes().listsize_wout_deleted>0">
			<div>{{ 'vault.hint.list.nobad' | translate}}</div>
		</div>

		<!--nopassword-hint for expired -->
		<div  class="nopasswords" ng-if="no_credentials_label.expired" ng-hide="getListSizes().listsize_wout_deleted>0">
			<div>{{ 'vault.hint.list.noexpired' | translate}}</div>
		</div>

		<!--nopassword-hint for deleted -->
		<div  class="nopasswords" ng-if="getListSizes().listsize_deleted==0" ng-hide="delete_time==0">
			<div>{{ 'vault.hint.list.nodeleted' | translate}}</div>
		</div>

	</div>
</div>

<div id="app-sidebar" class="app_sidebar" ng-show="selectedCredential" off-click="closeSelected()" >

	<span class="close icon-close" ng-click="closeSelected()" alt="Close"></span>

	<div class="sidebar">
		<span class="icon sidebar-icon" ng-if="selectedCredential.url">
			<credential-icon credential="selectedCredential"></credential-icon>
		</span>
		<span class="icon sidebar-icon" ng-if="!selectedCredential.url">
			<credential-icon credential="selectedCredential"></credential-icon>
		</span>
		<h2 class="sidebar-label">{{selectedCredential.label}}</h2>
	</div>

    <div credential-template="selectedCredential"></div>

    <div ng-show="selectedCredential">
        <div>
            <button class="button"
                    ng-click="editCredential(selectedCredential)"
                    ng-if="selectedCredential.delete_time == 0 && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
                <span class="fa fa-edit"></span> {{ 'edit' | translate}}
            </button>
            <button class="button"
                    ng-click="deleteCredential(selectedCredential)"
                    ng-if="selectedCredential.delete_time == 0 && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
                <span class="fa fa-trash"></span> {{ 'delete' | translate}}
            </button>
            <button class="button"
                    ng-click="shareCredential(selectedCredential)"
                    ng-if="selectedCredential.delete_time == 0 && selectedCredential.acl === undefined &&
						(settings.user_sharing_enabled === 1 || settings.user_sharing_enabled === '1' || settings.link_sharing_enabled === 1 || settings.link_sharing_enabled === '1')">
                <span class="fa fa-share"></span> {{ 'share' | translate}}
            </button>

            <button class="button"
                    ng-click="getRevisions(selectedCredential)"
                    ng-if="selectedCredential.delete_time == 0  && hasPermission(selectedCredential.acl.permissions, permissions.permissions.HISTORY)">
                <span class="fa fa-undo"></span> {{ 'revisions' | translate}}
            </button>

            <button class="button"
                    ng-if="selectedCredential.delete_time > 0"
                    ng-click="recoverCredential(selectedCredential) && hasPermission(selectedCredential.acl.permissions, permissions.permissions.WRITE)">
                <span class="fa fa-recycle"></span> {{'recover' | translate}}
            </button>
            <button class="button"
                    ng-if="selectedCredential.delete_time > 0"
                    ng-click="destroyCredential(selectedCredential)">
                <span class="fa fa-bomb"></span> {{'destroy' | translate}}
            </button>
        </div>
    </div>
</div>

<div class="share_popup" style="display: none">
	{{ 'sharereq.title' | translate}}<br/>
	<p>{{ 'sharereq.line1' | translate}}</p>
	{{active_vault.vault_id}}
	<table class="table">
		<thead>
		<tr>
			<td>{{ 'label' | translate}}</td>
			<td>{{ 'permissions' | translate}}</td>
			<td>{{ 'received.from' | translate}}</td>
			<td>{{ 'date' | translate}}</td>
		</tr>
		</thead>
		<tr ng-repeat="share_request in incoming_share_requests"
			ng-if="share_request.target_vault_id == active_vault.vault_id">
			<td>
				{{share_request.credential_label}}
			</td>
			<td>
				{{share_request.permissions}}
			</td>
			<td>
				{{share_request.from_user_id}}
			</td>
			<td>
				{{share_request.created * 1000 | date:'dd-MM-yyyy @	HH:mm:ss'}}
			</td>
			<td>
				<span class="link" ng-click="acceptShareRequest(share_request)">{{ 'accept' | translate}}</span>
				| <span class="link" ng-click="declineShareRequest(share_request)">{{ 'decline' | translate}}</span>
			</td>
		</tr>
	</table>
</div>
