Skip to content

Commit

Permalink
#1948 WIP: Use limited count in custom tags admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 10, 2021
1 parent aaed111 commit 2b081da
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

angular.module('theHiveComponents')
.component('orgCustomTagsList', {
controller: function ($scope, PaginatedQuerySrv, FilteringSrv, TaxonomyCacheSrv, TagSrv, UserSrv, ModalUtilsSrv, NotificationSrv) {
controller: function ($scope, PaginatedQuerySrv, QuerySrv, FilteringSrv, TaxonomyCacheSrv, TagSrv, UserSrv, ModalUtilsSrv, NotificationSrv) {
var self = this;

self.tags = [];
Expand All @@ -30,6 +30,18 @@
self.filtering.setPageSize(newValue);
});
});

QuerySrv.query(
'v1',
[{ '_name': 'countFreetags' }],
{
params: {
name: 'all-custom-tags.count'
}
})
.then(function (response) {
self.freetagsCount = response.data;
});
};

this.load = function () {
Expand All @@ -40,6 +52,7 @@
skipStream: true,
sort: self.filtering.context.sort,
loadAll: false,
limitedCount: true,
pageSize: self.filtering.context.pageSize,
filter: this.filtering.buildQuery(),
operations: [
Expand Down
75 changes: 46 additions & 29 deletions frontend/app/views/components/org/custom-tags/tag-list.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div ng-include="'views/components/org/custom-tags/toolbar.html'"></div>

<div class="mt-xs filter-panel" ng-include="'views/components/org/custom-tags/filters.html'" ng-show="$vm.filtering.context.showFilters"></div>
<div class="mt-xs filter-panel" ng-include="'views/components/org/custom-tags/filters.html'"
ng-show="$vm.filtering.context.showFilters"></div>

<!-- Filters preview -->
<div class="row mt-xs">
<div class="col-md-12 clearfix">
<div class="pull-left">
<h4>
Custom tags List ({{$vm.list.values.length || 0}} of {{$vm.list.total}})
List of custom tags ({{$vm.list.total | limitedCount}} of {{$vm.freetagsCount}})
</h4>
</div>

<filters-preview filters="$vm.filtering.context.filters"
on-clear-item="$vm.removeFilter(field)"
<filters-preview filters="$vm.filtering.context.filters" on-clear-item="$vm.removeFilter(field)"
on-clear-all="$vm.clearFilters()"></filters-preview>
</div>
</div>
Expand All @@ -23,19 +23,22 @@ <h4>
<div class="empty-message">No records</div>
</div>

<div class="col-md-12" ng-show="$vm.list.total > 0">
<div class="col-md-12" ng-show="$vm.list.total != 0">
<psearch control="$vm.list"></psearch>

<table class="table table-striped case-tags">
<thead>
<tr>
<th>
<a href class="text-default" ng-click="$vm.sortByField('predicate')">
Name
<i ng-show="$vm.filtering.context.sort.indexOf('+predicate') === -1 && $vm.filtering.context.sort.indexOf('-predicate') === -1" class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+predicate') !== -1" class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-predicate') !== -1" class="fa fa-caret-down"></i>
</a>
<a href class="text-default" ng-click="$vm.sortByField('predicate')">
Name
<i ng-show="$vm.filtering.context.sort.indexOf('+predicate') === -1 && $vm.filtering.context.sort.indexOf('-predicate') === -1"
class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+predicate') !== -1"
class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-predicate') !== -1"
class="fa fa-caret-down"></i>
</a>
</th>
<th width="250px">
Colour
Expand All @@ -48,17 +51,25 @@ <h4>
<th style="width: 150px">
Dates

<a href class="text-default ml-xxxs" ng-click="$vm.sortByField('_createdAt')" uib-tooltip="Sort by creation date">
<a href class="text-default ml-xxxs" ng-click="$vm.sortByField('_createdAt')"
uib-tooltip="Sort by creation date">
C.
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdAt') === -1 && $vm.filtering.context.sort.indexOf('-_createdAt') === -1" class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdAt') !== -1" class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-_createdAt') !== -1" class="fa fa-caret-down"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdAt') === -1 && $vm.filtering.context.sort.indexOf('-_createdAt') === -1"
class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_createdAt') !== -1"
class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-_createdAt') !== -1"
class="fa fa-caret-down"></i>
</a>
<a href class="text-default ml-xxxs" ng-click="$vm.sortByField('_updatedAt')" uib-tooltip="Sort by last update date">
<a href class="text-default ml-xxxs" ng-click="$vm.sortByField('_updatedAt')"
uib-tooltip="Sort by last update date">
U.
<i ng-show="$vm.filtering.context.sort.indexOf('+_updatedAt') === -1 && $vm.filtering.context.sort.indexOf('-_updatedAt') === -1" class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_updatedAt') !== -1" class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-_updatedAt') !== -1" class="fa fa-caret-down"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_updatedAt') === -1 && $vm.filtering.context.sort.indexOf('-_updatedAt') === -1"
class="fa fa-sort"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('+_updatedAt') !== -1"
class="fa fa-caret-up"></i>
<i ng-show="$vm.filtering.context.sort.indexOf('-_updatedAt') !== -1"
class="fa fa-caret-down"></i>
</a>
</th>
<th style="width: 60px">Actions</th>
Expand All @@ -69,24 +80,30 @@ <h4>
<tr ng-repeat="tag in $vm.list.values">
<td>
<!-- <tag-item class="label-lg" value="tag.predicate" colour="tag.colour"></tag-item> -->
<updatable-tag value="tag.predicate" colour="tag.colour" on-update="$vm.updateTag(tag._id, newValue)"></updatable-tag>
<updatable-tag value="tag.predicate" colour="tag.colour"
on-update="$vm.updateTag(tag._id, newValue)"></updatable-tag>
</td>
<td>
<updatable-colour value="tag.colour" on-update="$vm.updateColour(tag._id, newValue)"></updatable-colour>
<updatable-colour value="tag.colour" on-update="$vm.updateColour(tag._id, newValue)">
</updatable-colour>
</td>
<td>{{tag.extraData.usage.case}}</td>
<td>{{tag.extraData.usage.alert}}</td>
<td>{{tag.extraData.usage.observable}}</td>
<td>{{tag.extraData.usage.caseTemplate}}</td>
<td>{{tag.extraData.usage.case | limitedCount}}</td>
<td>{{tag.extraData.usage.alert | limitedCount}}</td>
<td>{{tag.extraData.usage.observable | limitedCount}}</td>
<td>{{tag.extraData.usage.caseTemplate | limitedCount}}</td>
<td class="nowrap">
<user user-id="tag._createdBy" icon-only="true" icon-size="m"></user>
</td>
<td>
<div ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+_createdAt') !== -1 || $vm.filtering.context.sort.indexOf('-_createdAt') !== -1}">
C. <a href ng-click="$vm.addFilterValue('_createdAt', tag._createdAt)">{{tag._createdAt | shortDate}}</a>
<div
ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+_createdAt') !== -1 || $vm.filtering.context.sort.indexOf('-_createdAt') !== -1}">
C. <a href ng-click="$vm.addFilterValue('_createdAt', tag._createdAt)">{{tag._createdAt |
shortDate}}</a>
</div>
<div ng-if="tag._updatedAt > 0" ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+_updatedAt') !== -1 || $vm.filtering.context.sort.indexOf('-_updatedAt') !== -1}">
U. <a href ng-click="$vm.addFilterValue('_updatedAt', tag._updatedAt)">{{tag._updatedAt | shortDate}}</a>
<div ng-if="tag._updatedAt > 0"
ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+_updatedAt') !== -1 || $vm.filtering.context.sort.indexOf('-_updatedAt') !== -1}">
U. <a href ng-click="$vm.addFilterValue('_updatedAt', tag._updatedAt)">{{tag._updatedAt |
shortDate}}</a>
</div>
</td>
<td class="text-center">
Expand Down

0 comments on commit 2b081da

Please sign in to comment.