Skip to content

Commit

Permalink
#1869 Exclude free tags with default colour from the free tags cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Mar 26, 2021
1 parent 2bf9fce commit 5eb03de
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
50 changes: 28 additions & 22 deletions frontend/app/scripts/services/api/TagSrv.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
(function() {
(function () {
'use strict';
angular.module('theHiveServices')
.service('TagSrv', function(QuerySrv, $q, $http) {
.service('TagSrv', function (QuerySrv, $q, VersionSrv, $http) {

this.getFreeTags = function() {
this.getFreeTags = function () {
var defer = $q.defer();

var operations = [
{ _name: 'listTag'},
{ _name: 'freetags'},
]

QuerySrv.query('v1', operations, {
params: {
name: 'list-tags'
}
}).then(function(response) {
defer.resolve(response.data);
});
VersionSrv.get()
.then(function (appConfig) {
var defaultColour = appConfig.config.freeTagDefaultColour;

return QuerySrv.query('v1', [
{ _name: 'listTag' },
{ _name: 'freetags' },
{ _name: 'filter', _not: { colour: defaultColour } }
], {
params: {
name: 'list-tags'
}
})
})

.then(function (response) {
defer.resolve(response.data);
});

return defer.promise;
};

this.updateTag = function(id, patch) {
this.updateTag = function (id, patch) {
return $http.patch('./api/v1/tag/' + id, patch);
}

this.removeTag = function(id) {
this.removeTag = function (id) {
return $http.delete('./api/v1/tag/' + id);
}

this.autoComplete = function(term) {
this.autoComplete = function (term) {
var defer = $q.defer();

var operations = [
{ _name: 'tagAutoComplete', freeTag: term, limit: 20}
{ _name: 'tagAutoComplete', freeTag: term, limit: 20 }
]

QuerySrv.call('v1', operations, {
name: 'tags-auto-complete'
}).then(function(response) {
defer.resolve(_.map(response, function(tag) {
return {text: tag};
}).then(function (response) {
defer.resolve(_.map(response, function (tag) {
return { text: tag };
}));
});

Expand Down
5 changes: 4 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class StatusCtrl @Inject() (
appConfig.item[FiniteDuration]("stream.longPolling.pollingDuration", "amount of time the UI have to wait before polling the stream")
def streamPollingDuration: FiniteDuration = streamPollingDurationConfig.get

val tagsDefaultColourConfig = appConfig.item[String]("tags.freeTagColour", "Default free tag colour")

private def getVersion(c: Class[_]): String = Option(c.getPackage.getImplementationVersion).getOrElse("SNAPSHOT")

def get: Action[AnyContent] =
Expand All @@ -55,7 +57,8 @@ class StatusCtrl @Inject() (
}),
"capabilities" -> authSrv.capabilities.map(c => JsString(c.toString)),
"ssoAutoLogin" -> authSrv.capabilities.contains(AuthCapability.sso),
"pollingDuration" -> streamPollingDuration.toMillis
"pollingDuration" -> streamPollingDuration.toMillis,
"freeTagDefaultColour" -> tagsDefaultColourConfig.get
),
"schemaStatus" -> schemas.flatMap(_.schemaStatus).map { schemaStatus =>
Json.obj(
Expand Down

0 comments on commit 5eb03de

Please sign in to comment.