Matteo Scandolo | 500e4c4 | 2017-08-08 13:05:24 -0700 | [diff] [blame] | 1 | |
| 2 | <!-- |
| 3 | Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | --> |
Matteo Scandolo | e9cdf9a | 2017-11-21 10:41:28 -0800 | [diff] [blame] | 17 | |
Matteo Scandolo | 710dc15 | 2017-04-11 13:54:23 -0700 | [diff] [blame] | 18 | <div ng-show="vm.data.length > 0 && vm.loader == false"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 19 | <div class="row" ng-if="vm.config.filter == 'fulltext'"> |
| 20 | <div class="col-xs-12"> |
| 21 | <input |
| 22 | class="form-control" |
| 23 | placeholder="Type to search.." |
| 24 | type="text" |
| 25 | ng-model="vm.query"/> |
| 26 | </div> |
| 27 | </div> |
Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame] | 28 | <div class="table-responsive"> |
| 29 | <table ng-class="vm.classes"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 30 | <thead> |
| 31 | <tr> |
Matteo Scandolo | b53dd4b | 2018-06-25 15:09:57 -0700 | [diff] [blame^] | 32 | <th ng-if="vm.config.actions">Actions:</th> |
Matteo Scandolo | 04f487c | 2017-09-12 10:37:48 -0700 | [diff] [blame] | 33 | <th ng-repeat="col in ::vm.config.columns"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 34 | {{col.label}} |
Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame] | 35 | <div ng-if="vm.config.order"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 36 | <a href="" ng-click="vm.orderBy = col.prop; vm.reverse = false"> |
Matteo Scandolo | d58d504 | 2016-12-16 16:59:21 -0800 | [diff] [blame] | 37 | <i class="fa fa-chevron-up"></i> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 38 | </a> |
| 39 | <a href="" ng-click="vm.orderBy = col.prop; vm.reverse = true"> |
Matteo Scandolo | d58d504 | 2016-12-16 16:59:21 -0800 | [diff] [blame] | 40 | <i class="fa fa-chevron-down"></i> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 41 | </a> |
Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame] | 42 | </div> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 43 | </th> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 44 | </tr> |
| 45 | </thead> |
| 46 | <tbody ng-if="vm.config.filter == 'field'"> |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 47 | <tr> |
Matteo Scandolo | 5d962a3 | 2017-08-01 18:16:14 -0700 | [diff] [blame] | 48 | <td ng-repeat="col in vm.config.columns"> |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 49 | <input |
| 50 | ng-if="col.type !== 'boolean' && col.type !== 'array' && col.type !== 'object' && col.type !== 'custom'" |
| 51 | class="form-control" |
| 52 | placeholder="Type to search by {{col.label}}" |
| 53 | type="text" |
| 54 | ng-model="vm.query[col.prop]"/> |
| 55 | <select |
| 56 | ng-if="col.type === 'boolean'" |
| 57 | class="form-control" |
| 58 | ng-model="vm.query[col.prop]"> |
| 59 | <option value="">-</option> |
| 60 | <option value="true">True</option> |
| 61 | <option value="false">False</option> |
| 62 | </select> |
| 63 | </td> |
| 64 | <td ng-if="vm.config.actions"></td> |
| 65 | </tr> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 66 | </tbody> |
| 67 | <tbody> |
Matteo Scandolo | e9cdf9a | 2017-11-21 10:41:28 -0800 | [diff] [blame] | 68 | <tr ng-class="{active: vm.config.selectedRow == $index, deleted: item.deleted}" 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"> |
Matteo Scandolo | b53dd4b | 2018-06-25 15:09:57 -0700 | [diff] [blame^] | 69 | <td class="xos-table-actions" ng-if="vm.config.actions"> |
| 70 | <a href="" |
| 71 | ng-repeat="action in vm.config.actions" |
| 72 | ng-click="action.cb(item)" |
| 73 | title="{{action.label}}"> |
| 74 | <i |
| 75 | class="fa fa-{{action.icon}}" |
| 76 | style="color: {{action.color}};"></i> |
| 77 | </a> |
| 78 | </td> |
Matteo Scandolo | 5d962a3 | 2017-08-01 18:16:14 -0700 | [diff] [blame] | 79 | <td ng-repeat="col in vm.config.columns" xos-link-wrapper> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 80 | <span ng-if="!col.type || col.type === 'text'">{{item[col.prop]}}</span> |
| 81 | <span ng-if="col.type === 'boolean'"> |
Matteo Scandolo | d58d504 | 2016-12-16 16:59:21 -0800 | [diff] [blame] | 82 | <i class="fa" |
| 83 | ng-class="{'fa-ok': item[col.prop], 'fa-remove': !item[col.prop]}"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 84 | </i> |
| 85 | </span> |
| 86 | <span ng-if="col.type === 'date'"> |
| 87 | {{item[col.prop] | date:'H:mm MMM d, yyyy'}} |
| 88 | </span> |
| 89 | <span ng-if="col.type === 'array'"> |
| 90 | {{item[col.prop] | arrayToList}} |
| 91 | </span> |
| 92 | <span ng-if="col.type === 'object'"> |
| 93 | <dl class="dl-horizontal"> |
| 94 | <span ng-repeat="(k,v) in item[col.prop]"> |
| 95 | <dt>{{k}}</dt> |
| 96 | <dd>{{v}}</dd> |
| 97 | </span> |
| 98 | </dl> |
| 99 | </span> |
| 100 | <span ng-if="col.type === 'custom'"> |
Matteo Scandolo | 0496423 | 2017-01-07 12:53:46 -0800 | [diff] [blame] | 101 | {{item[col.prop + '-formatted']}} |
| 102 | <i class="ng-hide">{{col.formatter(item)}}</i> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 103 | </span> |
| 104 | <span ng-if="col.type === 'icon'"> |
Matteo Scandolo | d58d504 | 2016-12-16 16:59:21 -0800 | [diff] [blame] | 105 | <i class="fa fa-{{col.formatter(item)}}"> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 106 | </i> |
Matteo Scandolo | 8b2370c | 2017-02-02 17:19:07 -0800 | [diff] [blame] | 107 | </span> |
| 108 | <div class="xos-table-hover" ng-if="col.hover"> |
| 109 | <div class="alert alert-info"> |
| 110 | {{col.hover(item)}} |
| 111 | </div> |
| 112 | </div> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 113 | </td> |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 114 | </tr> |
| 115 | </tbody> |
| 116 | </table> |
Matteo Scandolo | 8b2370c | 2017-02-02 17:19:07 -0800 | [diff] [blame] | 117 | <xos-pagination |
| 118 | ng-if="vm.config.pagination" |
| 119 | page-size="vm.config.pagination.pageSize" |
| 120 | total-elements="vm.data.length" |
| 121 | change="vm.goToPage"> |
| 122 | </xos-pagination> |
Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame] | 123 | </div> |
Matteo Scandolo | 710dc15 | 2017-04-11 13:54:23 -0700 | [diff] [blame] | 124 | </div> |
| 125 | <div ng-show="(vm.data.length == 0 || !vm.data) && vm.loader == false"> |
| 126 | <xos-alert config="{type: 'info'}" show="true"> |
| 127 | No data to show. |
| 128 | </xos-alert> |
| 129 | </div> |
| 130 | <div ng-show="vm.loader == true"> |
| 131 | <div class="loader"></div> |
| 132 | </div> |