From 58b2b9b1d95b53d5539a35e2669e31ce11c3313c Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Wed, 21 Oct 2020 11:24:56 +0200 Subject: [PATCH] #1579 WIP: Add client side pagination in case similarity in alert dialog --- .../alert/AlertSimilarCaseListCmp.js | 22 +++++- .../alert/similar-case-list.component.html | 67 +++++++++++++------ .../components/alert/similarity/toolbar.html | 8 ++- 3 files changed, 75 insertions(+), 22 deletions(-) diff --git a/frontend/app/scripts/components/alert/AlertSimilarCaseListCmp.js b/frontend/app/scripts/components/alert/AlertSimilarCaseListCmp.js index 0b5dc6fb81..12805b6df4 100644 --- a/frontend/app/scripts/components/alert/AlertSimilarCaseListCmp.js +++ b/frontend/app/scripts/components/alert/AlertSimilarCaseListCmp.js @@ -11,7 +11,6 @@ self.similarityFilters = { fTitle: undefined, fMatches: undefined - }; self.rateFilters = { @@ -19,8 +18,14 @@ fIoc: undefined }; + self.sortField = '-sCreatedAt'; self.matches = []; + self.pagination = { + pageSize: 10, + currentPage: 1 + }; + self.$onInit = function() { this.filtering = new FilteringSrv('case', 'alert.dialog.similar-cases', { version: 'v1', @@ -53,7 +58,7 @@ skipStream: true, version: 'v1', loadAll: true, - pageSize: self.filtering.context.pageSize, + //pageSize: self.filtering.context.pageSize, operations: [ {'_name': 'getAlert', 'idOrName': this.alertId}, {'_name': 'similarCases', 'caseFilter': this.filtering.buildQuery()} @@ -64,6 +69,7 @@ item.fMatches = _.keys(item.observableTypes); item.fObservables = Math.floor((item.similarObservableCount / item.observableCount) * 100); item.fIocs = Math.floor((item.similarIocCount / item.iocCount) * 100); + item.sCreatedAt = item.case._createdAt; }); self.matches = _.uniq(_.flatten(_.map(data, function(item){ @@ -136,6 +142,18 @@ return data; }; + this.sortByField = function(field) { + var sort = null; + + if(this.sortField.substr(1) !== field) { + sort = '+' + field; + } else { + sort = (this.sortField === '+' + field) ? '-'+field : '+'+field; + } + + this.sortField = sort; + }; + }, controllerAs: '$cmp', diff --git a/frontend/app/views/components/alert/similar-case-list.component.html b/frontend/app/views/components/alert/similar-case-list.component.html index 9a9ee89b99..0bad641daf 100644 --- a/frontend/app/views/components/alert/similar-case-list.component.html +++ b/frontend/app/views/components/alert/similar-case-list.component.html @@ -20,23 +20,53 @@
- - - + +
+
    +
    +
    -
    Title
    -
    Date
    -
    Observables
    -
    IOCs
    + + + +
    Matches
    Action
    +
    @@ -72,12 +102,11 @@
    - - -
    + +
    - -
    + +
    @@ -87,7 +116,7 @@
    None - {{tag}} + {{tag}}
    @@ -103,13 +132,13 @@
    -
    +
    - {{item.case.startDate | shortDate}} + {{item.case._createdAt | shortDate}}
    diff --git a/frontend/app/views/components/alert/similarity/toolbar.html b/frontend/app/views/components/alert/similarity/toolbar.html index 3e1b0db377..85713bdb94 100644 --- a/frontend/app/views/components/alert/similarity/toolbar.html +++ b/frontend/app/views/components/alert/similarity/toolbar.html @@ -26,7 +26,13 @@
    - + +
    + + per page +