Skip to content

Commit

Permalink
#174 Add select all feature to analyzers selection in observables lis…
Browse files Browse the repository at this point in the history
…t page
  • Loading branch information
nadouani committed Apr 12, 2017
1 parent e08e184 commit b6b5d6d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion thehive-misp/app/connectors/misp/JsonFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.Date
import org.elastic4play.models.JsonFormat.enumFormat
import play.api.libs.json.JsLookupResult.jsLookupResultToJsLookup
import play.api.libs.json.JsValue.jsValueToJsLookup
import play.api.libs.json.{JsSuccess, JsValue, Json, Reads}
import play.api.libs.json.{ JsSuccess, JsValue, Json, Reads }

object JsonFormat {
implicit val eventStatusFormat = enumFormat(EventStatus)
Expand Down
1 change: 1 addition & 0 deletions ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<script src="scripts/filters/filter-value.js"></script>
<script src="scripts/filters/getField.js"></script>
<script src="scripts/filters/hash-type.js"></script>
<script src="scripts/filters/order-object-by.js"></script>
<script src="scripts/filters/sha256.js"></script>
<script src="scripts/filters/shortDate.js"></script>
<script src="scripts/filters/showDate.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions ui/app/scripts/controllers/case/CaseObservablesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@
});
};

$scope.selectAllAnalyzers = function(selected) {
$scope.analyzersList.selected = _.mapObject($scope.analyzersList.selected, function(/*val, key*/) {
return selected;
});
};


// run an Analyzer on an artifact
$scope.runAnalyzer = function (analyzerId, artifact) {
var artifactName = artifact.data || artifact.attachment.name;
Expand Down
19 changes: 19 additions & 0 deletions ui/app/scripts/filters/order-object-by.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(function() {
'use strict';
angular.module('theHiveFilters')
.filter('orderObjectBy', function() {
return function(items, field, reverse) {
var filtered = [];
angular.forEach(items, function(item) {
filtered.push(item);
});
filtered.sort(function(a, b) {
return (a[field] > b[field] ? 1 : -1);
});
if (reverse) {
filtered.reverse();
}
return filtered;
};
});
})();
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
</div>
</div>

<div class="text-center" ng-switch-default>
<div class="vpad10 text-warning" ng-if="analyzersList.countDataTypes > 1">
<div class="p-xxs" ng-switch-default>
<div class="mb-xxs text-center text-warning" ng-if="analyzersList.countDataTypes > 1">
Only a subset of the selected observables can be analyzed <strong>({{analyzersList.activeDataTypes.join(', ')}})</strong> and the remaining observables will be ignored
</div>
<div class="vpad10">
<ul class="list-inline">
<li ng-repeat="analyzer in analyzersList.analyzers" ng-show="analyzersList.active[analyzer.id]">
<input id="{{analyzer.id}}" value="{{analyzer.description}}" type="checkbox" ng-model="analyzersList.selected[analyzer.id]"> {{analyzer.name}}
</li>
</ul>
<div class="mb-xxs">
<a href class="mr-xxs" ng-click="selectAllAnalyzers(true)">Select All</a><a href class="ml-xxs" ng-click="selectAllAnalyzers(false)">Deselect All</a>
</div>
<div class="vpad10">
<ul class="list-unstyled mb-xxs">
<li ng-repeat="analyzer in analyzersList.analyzers | orderObjectBy:'id'" ng-show="analyzersList.active[analyzer.id]">
<input id="select_{{analyzer.id}}" value="{{analyzer.description}}" type="checkbox" ng-model="analyzersList.selected[analyzer.id]">
<label for="select_{{analyzer.id}}">{{analyzer.name}}</label>
</li>
</ul>
<div class="text-center mt-xxs">
<span class="btn btn-sm btn-primary" ng-click="runAnalyzerOnSelection();"><i class="glyphicon glyphicon-fire"></i> Run selected analyzers</span>
<span class="btn btn-sm btn-default" ng-click="selection.Action='main';">Cancel</span>
</div>
Expand Down

0 comments on commit b6b5d6d

Please sign in to comment.