Skip to content

Commit

Permalink
#1401 Load stats only if the widget is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 22, 2020
1 parent a4e1ede commit b5f75f1
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 121 deletions.
83 changes: 43 additions & 40 deletions frontend/app/scripts/controllers/alert/AlertStatsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,51 @@
this.byStatus = {};
this.byTags = {};

// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'tags',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});
self.$onInit = function() {

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'status',
result: {},
success: function(data){
self.byStatus = self.prepareResult(data);
}
});
// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'tags',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'status',
result: {},
success: function(data){
self.byStatus = self.prepareResult(data);
}
});

// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'type',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byType = self.prepareResult(data);
}
});
// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'alert',
field: 'type',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byType = self.prepareResult(data);
}
});
};

this.prepareResult = function(rawStats) {
var total = rawStats.count;
Expand Down
81 changes: 42 additions & 39 deletions frontend/app/scripts/controllers/case/CaseStatsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,49 @@
this.byStatus = {};
this.byTags = {};

// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'tags',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});
self.$onInit = function() {

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'status',
result: {},
success: function(data){
self.byStatus = self.prepareResult(data);
}
});
// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'tags',
sort: ['-count'],
limit: 5,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'status',
result: {},
success: function(data){
self.byStatus = self.prepareResult(data);
}
});

// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'resolutionStatus',
result: {},
success: function(data){
self.byResolution = self.prepareResult(data);
}
});
// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: 'any',
query: {},
objectType: 'case',
field: 'resolutionStatus',
result: {},
success: function(data){
self.byResolution = self.prepareResult(data);
}
});
};

this.prepareResult = function(rawStats) {
var total = rawStats.count;
Expand All @@ -70,7 +73,7 @@
total: total,
details: columns
};
};
};
}
);
})();
81 changes: 42 additions & 39 deletions frontend/app/scripts/controllers/case/ObservablesStatsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

angular.module('theHiveControllers').controller('ObservablesStatsCtrl',
function($rootScope, $scope, $stateParams, $timeout, StatSrv, StreamStatSrv) {
var self = this;
var self = this;

this.byType = {};
this.byIoc = {};
Expand All @@ -25,46 +25,49 @@
}]
};

// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'tags',
sort: ['_count'],
limit: 10,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});
self.$onInit = function() {

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'dataType',
result: {},
success: function(data){
self.byType = self.prepareResult(data);
}
});
// Get stats by tags
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'tags',
sort: ['_count'],
limit: 10,
result: {},
success: function(data){
self.byTags = self.prepareResult(data);
}
});

// Get stats by type
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'dataType',
result: {},
success: function(data){
self.byType = self.prepareResult(data);
}
});

// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'ioc',
result: {},
success: function(data){
self.byIoc = self.prepareResult(data);
}
});
// Get stats by ioc
StreamStatSrv({
scope: $scope,
rootId: $stateParams.caseId,
query: defaultQuery,
objectType: 'case_artifact',
field: 'ioc',
result: {},
success: function(data){
self.byIoc = self.prepareResult(data);
}
});
};

this.prepareResult = function(rawStats) {
var total = rawStats.count;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/alert/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 class="box-title">List of alerts ({{$vm.list.total || 0}} of {{alertEvents.c
<div class="box-body">
<div ng-include="'views/partials/alert/list/toolbar.html'"></div>

<div class="mv-s filter-panel" ng-include="'views/partials/alert/list/mini-stats.html'" ng-show="$vm.filtering.context.showStats"></div>
<div class="mv-s filter-panel" ng-include="'views/partials/alert/list/mini-stats.html'" ng-if="$vm.filtering.context.showStats"></div>

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

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/case/case.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3 class="box-title">List of cases ({{$vm.list.total || 0}} of {{$vm.caseStats.
<div class="box-body">
<div ng-include="'views/partials/case/list/toolbar.html'"></div>

<div class="mv-s filter-panel" ng-include="'views/partials/case/list/mini-stats.html'" ng-show="$vm.filtering.context.showStats"></div>
<div class="mv-s filter-panel" ng-include="'views/partials/case/list/mini-stats.html'" ng-if="$vm.filtering.context.showStats"></div>

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

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/case/case.observables.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h5 ng-if="selection.artifacts.length > 0 ">

<!-- <pre>{{uiSrv.context | json}}</pre> -->

<div class="filter-panel" ng-include="'views/partials/observables/list/mini-stats.html'" ng-show="filtering.context.showStats"></div>
<div class="filter-panel" ng-include="'views/partials/observables/list/mini-stats.html'" ng-if="filtering.context.showStats"></div>
<br>

<div class="filter-panel" ng-include="'views/partials/observables/list/filters.html'" ng-show="filtering.context.showFilters"></div>
Expand Down

0 comments on commit b5f75f1

Please sign in to comment.