Skip to content

Commit

Permalink
#1957 Fix the query that loads taxonomy cache to return just enabled …
Browse files Browse the repository at this point in the history
…taxonomies
  • Loading branch information
nadouani committed Apr 15, 2021
1 parent 6475b86 commit e1e5c89
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 35 deletions.
56 changes: 34 additions & 22 deletions frontend/app/scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,43 @@
.controller('TaxonomyDialogCtrl', TaxonomyDialogCtrl)
.controller('TaxonomyImportCtrl', TaxonomyImportCtrl);

function TaxonomyListCtrl($scope, $uibModal, PaginatedQuerySrv, FilteringSrv, TaxonomySrv, NotificationSrv, ModalSrv, appConfig) {
function TaxonomyListCtrl($scope, $uibModal, PaginatedQuerySrv, FilteringSrv, TaxonomySrv, NotificationSrv, ModalSrv, QuerySrv, appConfig) {
var self = this;

this.appConfig = appConfig;
this.allTaxonomyCount = null;

self.$onInit = function () {
self.filtering = new FilteringSrv('taxonomy', 'taxonomy.list', {
version: 'v1',
defaults: {
showFilters: true,
showStats: false,
pageSize: 15,
sort: ['+namespace']
},
defaultFilter: []
});

self.filtering.initContext('list')
.then(function () {
self.load();

$scope.$watch('$vm.list.pageSize', function (newValue) {
self.filtering.setPageSize(newValue);
});
});

QuerySrv.count(
'v1',
[{ '_name': 'listTaxonomy' }],
{
name: 'all-taxonomy'
})
.then(function (total) {
self.allTaxonomyCount = total;
});
};

self.load = function () {
this.loading = true;
Expand Down Expand Up @@ -152,27 +185,6 @@
this.search();
};

self.$onInit = function () {
self.filtering = new FilteringSrv('taxonomy', 'taxonomy.list', {
version: 'v1',
defaults: {
showFilters: true,
showStats: false,
pageSize: 15,
sort: ['+namespace']
},
defaultFilter: []
});

self.filtering.initContext('list')
.then(function () {
self.load();

$scope.$watch('$vm.list.pageSize', function (newValue) {
self.filtering.setPageSize(newValue);
});
});
};
}

function TaxonomyDialogCtrl($uibModalInstance, TaxonomySrv, NotificationSrv, taxonomy) {
Expand Down
11 changes: 6 additions & 5 deletions frontend/app/scripts/services/api/TaxonomyCacheSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
return QuerySrv.call('v1', [
{ _name: 'listTaxonomy' }
], {
name: 'list-taxonomies'
}, {
name: 'filter',
_field: 'enabled',
_value: true
name: 'list-taxonomies-cache',
filter: {
name: 'filter',
_field: 'enabled',
_value: true
}
});
};

Expand Down
21 changes: 13 additions & 8 deletions frontend/app/views/partials/admin/taxonomy/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
<div class="col-md-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">List of taxonomies</h3>
<!-- <h3 class="box-title">List of taxonomies</h3> -->
<datalist-header title="List of taxonomies" list="$vm.list" total="$vm.allTaxonomyCount">
</datalist-header>
</div>
<div class="box-body">
<div ng-include="'views/partials/admin/taxonomy/list/toolbar.html'"></div>

<div class="mt-xs filter-panel" ng-include="'views/partials/admin/taxonomy/list/filters.html'" ng-show="$vm.filtering.context.showFilters"></div>
<div class="mt-xs filter-panel" ng-include="'views/partials/admin/taxonomy/list/filters.html'"
ng-show="$vm.filtering.context.showFilters"></div>

<div class="row mt-xs">
<div class="col-md-12 clearfix">

<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 Down Expand Up @@ -52,7 +54,8 @@ <h3 class="box-title">List of taxonomies</h3>
<tbody>
<tr ng-repeat="taxonomy in $vm.list.values">
<td>
<span class="clickable" ng-click="$vm.addFilterValue('enabled', !!taxonomy.extraData.enabled)">
<span class="clickable"
ng-click="$vm.addFilterValue('enabled', !!taxonomy.extraData.enabled)">
<i class="fa" ng-class="{
true: 'text-tlp-green fa-circle',
false: 'text-tlp-red fa-circle',
Expand All @@ -75,7 +78,7 @@ <h3 class="box-title">List of taxonomies</h3>
</td>
<td class="clearfix">
<div class="pull-right">
<a class="btn btn-icon btn-clear" href ng-click="$vm.toggleActive(taxonomy)"
<a class="btn btn-icon btn-clear" href ng-click="$vm.toggleActive(taxonomy)"
uib-tooltip="{{!!taxonomy.extraData.enabled ? 'Disable taxonomy' : 'Enable taxonomy'}}">

<i class="fa" ng-class="{
Expand All @@ -84,11 +87,13 @@ <h3 class="box-title">List of taxonomies</h3>
}[!!taxonomy.extraData.enabled]"></i>
</a>

<a class="btn btn-icon btn-clear" href ng-click="$vm.show(taxonomy)" uib-tooltip="Edit taxonomy">
<a class="btn btn-icon btn-clear" href ng-click="$vm.show(taxonomy)"
uib-tooltip="Edit taxonomy">
<i class="text-primary fa fa-search"></i>
</a>

<a class="btn btn-icon btn-clear" href ng-click="$vm.remove(taxonomy)" uib-tooltip="Delete taxonomy">
<a class="btn btn-icon btn-clear" href ng-click="$vm.remove(taxonomy)"
uib-tooltip="Delete taxonomy">
<i class="text-danger fa fa-trash"></i>
</a>
</div>
Expand Down

0 comments on commit e1e5c89

Please sign in to comment.