Skip to content

Commit

Permalink
#1625 Use observable ignoreSimilarity flag in observable details page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani authored and To-om committed Nov 13, 2020
1 parent 7125db1 commit 2f9fc62
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 26 deletions.
60 changes: 35 additions & 25 deletions frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@
mode: 'vb'
};

// Add tab
CaseTabsSrv.addTab(observableName, {
name: observableName,
label: artifact.data || artifact.attachment.name,
closable: true,
state: 'app.case.observables-item',
params: {
itemId: artifact.id
}
});

// Select tab
$timeout(function() {
CaseTabsSrv.activateTab(observableName);
$('html,body').animate({scrollTop: $('body').offset().top}, 'fast');
}, 0);

$scope.initScope = function (artifact) {

var promise = $scope.analysisEnabled ? AnalyzerSrv.forDataType(artifact.dataType) : $q.resolve([]);
Expand Down Expand Up @@ -171,14 +154,6 @@
});
};

CaseArtifactSrv.similar(observableId, {
range: 'all',
sort: ['-startDate']
}).then(function(response) {
$scope.similarArtifacts = response;
});


$scope.openArtifact = function (a) {
$state.go('app.case.observables-item', {
caseId: a.stats['case']._id,
Expand Down Expand Up @@ -214,6 +189,10 @@
})
.then(function(response) {
$scope.artifact = response.toJSON();

if(fieldName === 'ignoreSimilarity' && !!!newValue) {
$scope.getSimilarity();
}
})
.catch(function (response) {
NotificationSrv.error('ObservableDetails', response.data, response.status);
Expand Down Expand Up @@ -367,8 +346,39 @@
});
};

$scope.getSimilarity = function() {
CaseArtifactSrv.similar(observableId, {
range: 'all',
sort: ['-startDate']
}).then(function(response) {
$scope.similarArtifacts = response;
});
};

this.$onInit = function () {

// Add tab
CaseTabsSrv.addTab(observableName, {
name: observableName,
label: artifact.data || artifact.attachment.name,
closable: true,
state: 'app.case.observables-item',
params: {
itemId: artifact.id
}
});

// Select tab
$timeout(function() {
CaseTabsSrv.activateTab(observableName);
$('html,body').animate({scrollTop: $('body').offset().top}, 'fast');
}, 0);

// Fetch similar cases
if(!$scope.artifact.ignoreSimilarity) {
$scope.getSimilarity();
}

if(SecuritySrv.checkPermissions(['manageShare'], $scope.userPermissions)) {
$scope.loadShares();
}
Expand Down
17 changes: 16 additions & 1 deletion frontend/app/views/partials/observables/details/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ <h4 class="vpad10 text-primary">
</dd>
</dl>

<dl class="dl-horizontal clear">
<dt class="pull-left">Ignored for similarity</dt>
<dd ng-if="canEdit">
<span class="clickable" ng-click="updateField('ignoreSimilarity', !artifact.ignoreSimilarity)">
<i class="text-primary fa" ng-class="{'true': 'fa-chain-broken', 'false': 'fa-chain'}[artifact.ignoreSimilarity]"></i>
</span>
</dd>
<dd ng-if="!canEdit">
<span>
<i class="text-primary fa" ng-class="{'true': 'fa-chain-broken', 'false': 'fa-chain'}[artifact.ignoreSimilarity]"></i>
</span>
</dd>
</dl>

<dl class="dl-horizontal">
<dt class="pull-left">Tags</dt>
<dd ng-if="canEdit">
Expand All @@ -101,8 +115,9 @@ <h4 class="vpad10 text-primary">
</dl>
</div>
<!-- Observable links -->
<div class="col-md-6">
<div class="col-md-6" ng-if="!!!artifact.ignoreSimilarity">
<h4 class="vpad10 text-primary">Links</h4>

<div class="empty-message" ng-if="similarArtifacts.length === 0">
This observable has not been seen in any other case
</div>
Expand Down

0 comments on commit 2f9fc62

Please sign in to comment.