diff --git a/frontend/app/scripts/services/api/TagSrv.js b/frontend/app/scripts/services/api/TagSrv.js index 83a6057a21..9527d15c92 100644 --- a/frontend/app/scripts/services/api/TagSrv.js +++ b/frontend/app/scripts/services/api/TagSrv.js @@ -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 }; })); }); diff --git a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala index f2d0aa0a6a..28973f563e 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala @@ -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] = @@ -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(