blob: 6a128c7c5fc0b64155504c408f5fb93daf6e84d1 [file] [log] [blame]
<!--
Copyright 2017-present Open Networking Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div ng-show="vm.data.length > 0 && vm.loader == false">
<div class="row" ng-if="vm.config.filter == 'fulltext'">
<div class="col-xs-12">
<input
class="form-control"
placeholder="Type to search.."
type="text"
ng-model="vm.query"/>
</div>
</div>
<div class="table-responsive">
<table ng-class="vm.classes">
<thead>
<tr>
<th ng-repeat="col in ::vm.config.columns">
{{col.label}}
<div ng-if="vm.config.order">
<a href="" ng-click="vm.orderBy = col.prop; vm.reverse = false">
<i class="fa fa-chevron-up"></i>
</a>
<a href="" ng-click="vm.orderBy = col.prop; vm.reverse = true">
<i class="fa fa-chevron-down"></i>
</a>
</div>
</th>
<th ng-if="vm.config.actions">Actions:</th>
</tr>
</thead>
<tbody ng-if="vm.config.filter == 'field'">
<tr>
<td ng-repeat="col in vm.config.columns">
<input
ng-if="col.type !== 'boolean' && col.type !== 'array' && col.type !== 'object' && col.type !== 'custom'"
class="form-control"
placeholder="Type to search by {{col.label}}"
type="text"
ng-model="vm.query[col.prop]"/>
<select
ng-if="col.type === 'boolean'"
class="form-control"
ng-model="vm.query[col.prop]">
<option value="">-</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
</td>
<td ng-if="vm.config.actions"></td>
</tr>
</tbody>
<tbody>
<tr ng-class="{active: vm.config.selectedRow == $index}" ng-repeat="item in (vm.config.filteredData = (vm.data | filter:vm.query | orderBy:vm.orderBy:vm.reverse | pagination:vm.currentPage * vm.config.pagination.pageSize | limitTo: (vm.config.pagination.pageSize || vm.data.length))) track by $index">
<td ng-repeat="col in vm.config.columns" xos-link-wrapper>
<span ng-if="!col.type || col.type === 'text'">{{item[col.prop]}}</span>
<span ng-if="col.type === 'boolean'">
<i class="fa"
ng-class="{'fa-ok': item[col.prop], 'fa-remove': !item[col.prop]}">
</i>
</span>
<span ng-if="col.type === 'date'">
{{item[col.prop] | date:'H:mm MMM d, yyyy'}}
</span>
<span ng-if="col.type === 'array'">
{{item[col.prop] | arrayToList}}
</span>
<span ng-if="col.type === 'object'">
<dl class="dl-horizontal">
<span ng-repeat="(k,v) in item[col.prop]">
<dt>{{k}}</dt>
<dd>{{v}}</dd>
</span>
</dl>
</span>
<span ng-if="col.type === 'custom'">
{{item[col.prop + '-formatted']}}
<i class="ng-hide">{{col.formatter(item)}}</i>
</span>
<span ng-if="col.type === 'icon'">
<i class="fa fa-{{col.formatter(item)}}">
</i>
</span>
<div class="xos-table-hover" ng-if="col.hover">
<div class="alert alert-info">
{{col.hover(item)}}
</div>
</div>
</td>
<td class="xos-table-actions" ng-if="vm.config.actions">
<a href=""
ng-repeat="action in vm.config.actions"
ng-click="action.cb(item)"
title="{{action.label}}">
<i
class="fa fa-{{action.icon}}"
style="color: {{action.color}};"></i>
</a>
</td>
</tr>
</tbody>
</table>
<xos-pagination
ng-if="vm.config.pagination"
page-size="vm.config.pagination.pageSize"
total-elements="vm.data.length"
change="vm.goToPage">
</xos-pagination>
</div>
</div>
<div ng-show="(vm.data.length == 0 || !vm.data) && vm.loader == false">
<xos-alert config="{type: 'info'}" show="true">
No data to show.
</xos-alert>
</div>
<div ng-show="vm.loader == true">
<div class="loader"></div>
</div>